#include <c4d_objectdata.h>
Class holding the information for object handles.
The handle system has been changed in such a way that handles must travel with the mouse.
The system tries to help automate the placement of the handles. It calculates the correct handle positions and constrains the handle.
The values of
HandleInfo
are typically set in
ObjectData::GetHandle
by the user.
Here is the internal code of the
ObjectData::DetectHandle
and
ObjectData::MoveHandle
methods:
Here is code from the DoubleCircle SDK example that shows the implementation of the automated handle interface functions:
Int32 DoubleCircleData::GetHandleCount( BaseObject *op) { return 1; } void DoubleCircleData::GetHandle( BaseObject *op, Int32 i, HandleInfo &info) { BaseContainer *data = op-> GetDataInstance (); if (!data) return ; Float rad = data-> GetFloat (CIRCLEOBJECT_RAD); Int32 plane = data-> GetInt32 ( PRIM_PLANE ); info. position = SwapPoint( 向量 (rad, 0.0, 0.0),plane); info. direction = !SwapPoint( 向量 (1.0, 0.0, 0.0),plane); info. type = HANDLECONSTRAINTTYPE::LINEAR ; } void DoubleCircleData::SetHandle( BaseObject *op, Int32 i, 向量 p, const HandleInfo &info) { BaseContainer *data = op-> GetDataInstance (); if (!data) return ; Float val = Dot(p, info. direction ); data-> SetFloat (CIRCLEOBJECT_RAD, ClampValue (val, 0.0_f, ( Float ) MAXRANGE )); }
公共成员函数 |
|
HandleInfo () | |
~HandleInfo (void) | |
向量 | CalculateNewPosition ( BaseDraw *bd, const 矩阵 &mg, const 向量 &mouse_pos) const |
Public Attributes |
|
向量 | position |
向量 | direction |
向量 | center |
Float | radius |
HANDLECONSTRAINTTYPE | type |
HandleInfo | ( | ) |
Constructor.
~ HandleInfo | ( | void | ) |
Destructor.
向量 CalculateNewPosition | ( | BaseDraw * | bd , |
const 矩阵 & | mg , | ||
const 向量 & | mouse_pos | ||
) | const |
Calculates a handle position for the given mouse position.
[in] | bd | The editor's view. The caller owns the pointed view. |
[in] | mg | The global matrix of the handle's parent object. |
[in] | mouse_pos | The mouse coordinates for which to calculate the handle position. |
向量 position |
The handle position.
向量 direction |
The normal used for the handle travel. For linear handle constraints it is the line on which a handle can travel. For planar and radial constraints it is the normal of the plane/disc. Otherwise it is not needed.
向量 center |
The handle constraint center, for radial and spherical handle constraints.
Float radius |
The handle constraint radius, for radial and spherical handle constraints.
HANDLECONSTRAINTTYPE type |
The handle constraint type: HANDLECONSTRAINTTYPE .