⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ivp_template_constraint.hxx

📁 hl2 source code. Do not use it illegal.
💻 HXX
📖 第 1 页 / 共 2 页
字号:
     * 12 hinge that can be moved on a plane    drehbares Objekt auf Ebene
     * 13 movable on a plane   _  _  _  _  _  _ Doppelschiene
     * 20 direction                             verschiebbarer Punkt, Kugelbahn
     * 21 a cardanjoint moving on a rail        verschiebbares Kardangelenk
     * 22 a hinge that can be moved on a rail   Schiebescharnier
     * 23 slider, rail   _  _  _  _  _  _  _  _ Schieber, Schiene
     * 30 ball and socket                       Kugelgelenk
     * 31 cardanjoint                           Kardangelenk
     * 32 hinge                                 Scharnier
     * 33 fixed                                 fest verbunden
     *****************************************************************************/
    
    /******************************************************************************
     *  Parameters and their meanings:
     *  ------------------------------
     *
     *  objR:           The reference object pointer. NULL means 'no object' with the world system as object system.
     *  objA:           The attached object pointer. NULL means 'no object' with the world system as object system.
     *  anchor_ws:      The anchor point defines where the translation axes have their origin.
     *                  The point is given in world system.
     *  anchor_Ros:     The anchor point defines where the translation axes have their origin.
     *                  The point is given in the object system of the Reference object.
     *  fixed_axis_ws:  A vector representing the axis the rotation is fixed, given in world space.
     *                  This vector will be the X axis of the rotation axes.
     *  fixed_axis_Ros: A vector representing the axis the rotation is fixed, given in reference object space
     *                  This vector will be the X axis of the rotation axes.
     *  free_axis_ws:   A vector representing the axis the rotation is allowed, given in world space.
     *                  This vector will be the Z axis of the rotation axes.
     *  free_axis_Ros:  A vector representing the axis the rotation is allowed, given in the reference object space
     *                  This vector will be the Z axis of the rotation axes.
     *  known_axis_ws:  The axis that is given:
     *                  if fixedrotdim == 2 or fixedtransdim == 2: known_axis is the only free axis
     *                  if fixedrotdim == 1 or fixedtransdim == 1: known_axis is the only fixed axis
     *                  else: known_axis is not used.
     *  borderleft:     left rotation border of the hinge
     *  borderright:    right rotation border of the hinge
     *  distanceAR_Ros: a vector that is pointing from the anchor (of the reference object) to the point on the attached object
     *                  where the anchor should be. Seen in the object system of the Reference object.
     *  fixedtransdim:  How many of the translation coordinates are fixed (unmoveable for objects).
     *                  Ranging from 0 to 3. With this parameter, fixed coordinates are always beforen free coordinates,
     *                  if you think of {IVP_INDEX_X, IVP_INDEX_Y, IVP_INDEX_Z} as an enumeration.
     *  fixedrotdim:    How many of the rotation coordinates are fixed (unrotable for objects).
     *                  Ranging from 0 to 3. With this parameter, fixed coordinates are always beforen free coordinates,
     *                  if you think of {IVP_INDEX_X, IVP_INDEX_Y, IVP_INDEX_Z} as an enumeration.
     *  m_Rfs_f_Afs:    This matrix describes where the constraint translation axes should be on the attached object (Afs),
     *                  in the coordinate system of the translation axes of the Reference object (Rfs).
     *                  Use a NULL pointer if the attached object is in the correct position (the constraint is relaxed).
     *  m_Ros_f_Rfs:    the same as the variable with the same name.
     *  m_Ros_f_Rrs:    the same as the variable with the same name.
     *  type[6]:        IVP_CONSTRAINT_FIXED, IVP_CONSTRAINT_LIMITED, IVP_CONSTRAINT_FREE - just like the corresponding variable, look above.
     *  range_Rfs[6]:   how far the attached object is allowed to move or rotate in both directions from origin
     *                  when IVP_CONSTRAINT_LIMITED is set for this coordinate.
     *****************************************************************************/
    // maybe m_Rfs_f_Afs should be called transrot_displacementA_Rfs? [Author's note]


    /******************************************************************************
     *  Function:       set_constraint
     *  Note:           This function is one of the most complicated of all. If you want easier functions, look down to the inline functions.
     *  Description:    You can completely describe the linear components of a constraint with this function.
     *                  The parameters are described above. The anchor point and the known_axis vector are given in world coords.
     *****************************************************************************/
    void set_constraint_ws(IVP_Real_Object *objR, const IVP_U_Point *anchor_ws, const IVP_U_Point *known_axis_ws, const unsigned fixedtransdim, const unsigned fixedrotdim,
			   IVP_Real_Object *objA, const IVP_U_Matrix *m_Rfs_f_Afs);

    /******************************************************************************
     *  Function:       set_constraint
     *  Note:           This function is one of the most complicated of all. If you want easier functions, look down to the inline functions.
     *  Description:    You can completely describe the linear components of a constraint with this function.
     *                  The parameters are described above. The anchor point and the known_axis vector are given in objects coords of the Reference object.
     *****************************************************************************/
    void set_constraint_Ros(IVP_Real_Object *objR, const IVP_U_Point *anchor_Ros, const IVP_U_Point *known_axis_Ros, const unsigned fixedtransdim, const unsigned fixedrotdim,
			    IVP_Real_Object *objA, const IVP_U_Matrix *m_Rfs_f_Afs);


    /******************************************************************************
     *  Function:       set_stiffness_for_limited_axis
     *  Description:    allows to set for all limited axis a new stiffness.
     *                  Values between 0.0f ( == no force )
     *                         and     1.0f ( very stiff )
     *  Note:           Allows to remove the springy behaviour of limited axis
     *****************************************************************************/
    void set_stiffness_for_limited_axis(IVP_FLOAT stiffness);

    
    /******************************************************************************
     *  Function:       set_orientation
     *  Description:    Defines a constraint that enforces the objects to always have the same orientation.
     *****************************************************************************/
    void set_orientation(IVP_Real_Object *objR, IVP_Real_Object *objA) {
	set_constraint_ws(objR, NULL, NULL, 0, 3, objA, NULL);
    }

    /******************************************************************************
     *  Function:       set_ballsocket_ws
     *  Description:    Defines a constraint that allows objA to rotate around a point that is given in world coords and that is always in the same position relative to objR.
     *****************************************************************************/
    void set_ballsocket_ws(IVP_Real_Object *objR, const IVP_U_Point *anchor_ws, IVP_Real_Object *objA) {
	set_constraint_ws(objR, anchor_ws, NULL, 3, 0, objA, NULL);
    }

    /******************************************************************************
     *  Function:       set_ballsocket_Ros
     *  Description:    Defines a constraint that allows the objects to rotate around a point that is given in object coords of the Reference object.
     *****************************************************************************/
    void set_ballsocket_Ros(IVP_Real_Object *objR, const IVP_U_Point *anchor_Ros, IVP_Real_Object *objA) {
	set_constraint_Ros(objR, anchor_Ros, NULL, 3, 0, objA, NULL);
    }

    /******************************************************************************
     *  Function:       set_ballsocket_tense_Ros
     *  Description:    Defines a constraint that allows the objects to rotate around a point that is given in reference object space;
     *                  the vector that is pointing from the anchor to the point where the anchor should be on the Attached object
     *                  can be given in distanceAR_Ros. (the vector is given in reference  object space)
     *****************************************************************************/
    void set_ballsocket_tense_Ros(IVP_Real_Object *objR, const IVP_U_Point *anchor_Ros, IVP_Real_Object *objA, const IVP_U_Point *distanceAR_Ros) {
	IVP_U_Matrix m_displacement_Ros;
	m_displacement_Ros.init3();
	m_displacement_Ros.vv.set(distanceAR_Ros);
	set_constraint_Ros(objR, anchor_Ros, NULL, 3, 0, objA, &m_displacement_Ros);
    }

    /******************************************************************************
     *  Function:       set_cardanjoint_ws
     *  Description:    Defines a constraint that allows the objects to rotate around the anchor, but does not allow them to rotate
     *                  around the fixed axis. Anchor and axis are given in world coords.
     *****************************************************************************/
    void set_cardanjoint_ws(IVP_Real_Object *objR, const IVP_U_Point *anchor_ws, const IVP_U_Point *fixed_axis_ws, IVP_Real_Object *objA) {
        set_constraint_ws(objR, anchor_ws, fixed_axis_ws, 3, 1, objA, NULL);
    }

    /******************************************************************************
     *  Function:       set_cardanjoint_Ros
     *  Description:    Defines a constraint that allows the objects to rotate around the anchor, but does not allow them to rotate
     *                  around the fixed axis. Anchor and axis are given in object coords of the Reference object.
     *****************************************************************************/
    void set_cardanjoint_Ros(IVP_Real_Object *objR, const IVP_U_Point *anchor_Ros, const IVP_U_Point *fixed_axis_Ros, IVP_Real_Object *objA) {
	set_constraint_Ros(objR, anchor_Ros, fixed_axis_Ros, 3, 1, objA, NULL);
    }

    /******************************************************************************
     *  Function:       set_hinge_ws
     *  Description:    Defines a hinge constraint that allows the objects to rotate around the free axis which is mounted on the anchor.
     *                  anchor and axis are given in world coords.
     *****************************************************************************/
    void set_hinge_ws(IVP_Real_Object *objR, const IVP_U_Point *anchor_ws, const IVP_U_Point *free_axis_ws, IVP_Real_Object *objA) {
	set_constraint_ws(objR, anchor_ws, free_axis_ws, 3, 2, objA, NULL);
    }

    /******************************************************************************
     *  Function:       set_hinge_Ros
     *  Description:    Defines a hinge constraint that allows the objects to rotate around the free axis which is mounted on the anchor.
     *                  anchor and axis are given in object coords of the Reference object.
     *****************************************************************************/
    void set_hinge_Ros(IVP_Real_Object *objR, const IVP_U_Point *anchor_Ros, const IVP_U_Point *free_axis_Ros, IVP_Real_Object *objA) {
	set_constraint_Ros(objR, anchor_Ros, free_axis_Ros, 3, 2, objA, NULL);
    }

    /******************************************************************************
     *  Function:       set_hinge_Ros
     *  Description:    Defines a hinge constraint that allows the objects to rotate around the free axis which is mounted on the anchor,
     *                  but not to rotate beyond borderleft and borderright.
     *                  anchor and axis are given in object coords of the Reference object.
     *****************************************************************************/
    void set_hinge_Ros(IVP_Real_Object *objR, const IVP_U_Point *anchor_Ros, const IVP_U_Point *free_axis_Ros, IVP_Real_Object *objA,
		       IVP_FLOAT borderleft, IVP_FLOAT borderright);

    /******************************************************************************
     *  Function:       set_fixed
     *  Description:    Defines a completely fixed constraint. The attached object is fixed in its position to the reference object.
     *****************************************************************************/
    void set_fixed(IVP_Real_Object *objR, IVP_Real_Object *objA) {
	set_constraint_ws(objR, NULL, NULL, 3, 3, objA, NULL);
    }
    
public: // other functions
    /******************************************************************************
     *  Feature:        Constructor
     *  Description:    
     *****************************************************************************/
    IVP_Template_Constraint();

    //void set_target_angular_shift_os(const IVP_U_Quat &rot_attached);
    //void set_target_shift_os(const IVP_U_Point &trans_attached);
};

/********************************************************************************
 * How to finish a constraint:
 *
 * After you have defined your IVP_Environment *environment and filled up a
 * IVP_Template_Constraint template_constraint with values, do:
 * IVP_Constraint *constraint = environment->create_constraint(&template_constraint);
 * This will copy all values of template_constraint into the constraint. You can
 * reuse the template and change any values after you created a constraint from it;
 * these changes will not have any effect on the created constraint.
 * If you want to run-time-change a constraint, use the functions that are implemented
 * within the constraint. (see IVP_Constraint, ivp_constraint.hxx)
 * You can delete the constraint if you don't want it any more. (it was created by new())
 * Note: if any of the two objects of the constraints are deleted, the constraints deletes itself
 *******************************************************************************/

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -