HingeJoint Class Reference

#include <Joints.h>

Inherits Joint.

Collaboration diagram for HingeJoint:

List of all members.


Public Member Functions

 HingeJoint ()
virtual ~HingeJoint ()
void setMainEntity (int id)
void setAnchor (float anchorX, float anchorY, float anchorZ)
void setAxis (float axisX, float axisY, float axisZ)
void setAngles (float min, float max)
void checkAngles ()
virtual void getMemberValue (std::string type, void *result)
virtual void setMemberValue (std::string type, void *source)

Protected Member Functions

virtual void attachJoint (dBodyID obj1, dBodyID obj2)
virtual void detachJoint ()
void setODEAngles ()

Protected Attributes

gmtl::Vec3f anchor
gmtl::Vec3f axis
float minAngle
float maxAngle
float deltaAngle
float deltaAngleODE
float oldAngle
bool anglesSet
bool firstIsMain

Detailed Description

This class represents an hinge joint which can be defined by an Anchor of the Axis and the Axis itself. There is also the option to set the maximum and minimum angle of the joint.

Constructor & Destructor Documentation

HingeJoint::HingeJoint (  ) 

virtual HingeJoint::~HingeJoint (  )  [inline, virtual]


Member Function Documentation

void HingeJoint::attachJoint ( dBodyID  obj1,
dBodyID  obj2 
) [protected, virtual]

This method is called if the joint should be attached. It creates the ODE-joint, calculates the current anchor-position and axis-orientation and attaches the Joint.

Parameters:
obj1 first ODE-object to attach with
obj2 second ODE-object to attach with

Implements Joint.

void HingeJoint::checkAngles (  ) 

This method checks the angle of the HingeJoint for correctness and corrects it if needed. This is necessary because ODE stores the hinge-angle between -180 degrees and +180 degrees. If the angle gets above +180 deg ODE swaps to -180 deg and vice versa. If a user wants to use a HingeJoint with a maximum angle above 180 deg or a minimum angle below 180 deg the method corrects the ODE-swapping.

void HingeJoint::detachJoint (  )  [protected, virtual]

This method is called if the joint should be detached. If the maximum and minimum angles are set the method stores the angle-offset for correct angles in later use.

Implements Joint.

void HingeJoint::getMemberValue ( std::string  type,
void *  result 
) [virtual]

This method copies the value of the field with the passed name to the result-pointer. It is a little helper to avoid type-casts when accessing joint-pointers.

Parameters:
type name of the field
result destination where the value should be stored

Implements Joint.

void HingeJoint::setAnchor ( float  anchorX,
float  anchorY,
float  anchorZ 
)

This method sets the Anchor of the Joint in OBJECT-COORDINATES!!! This means that the Anchor is relative to the position of the main EntityTransform. Take care that the Anchor-offset is also scaled by the scale-Value of the EntityTransform. The reason for using object coordinates is because modelers can easily read the offset out of the modelling application.

Parameters:
anchorX X-position of the Anchor
anchorY Y-position of the Anchor
anchorZ Z-position of the Anchor

void HingeJoint::setAngles ( float  min,
float  max 
)

This method sets the maximum and minimum angle of the Axis.

Parameters:
min minimum Angle in rad
max maximum Angle in rad

void HingeJoint::setAxis ( float  axisX,
float  axisY,
float  axisZ 
)

This method sets the Axis of the Joint in OBJECT-COORDINATES!!! This means that the axis is rotated by the rotation-value of the main EntityTransform.

Parameters:
axisX X-value of the Axis
axisY Y-value of the Axis
axisZ Z-value of the Axis

void HingeJoint::setMainEntity ( int  id  )  [virtual]

This method sets the main EntityTransform, where the Joint should be attached to.

Parameters:
id 1 for the first EntityTransform, 2 for the second one

Reimplemented from Joint.

void HingeJoint::setMemberValue ( std::string  type,
void *  source 
) [virtual]

Implements Joint.

void HingeJoint::setODEAngles (  )  [protected]

This method sets the minimum and maximum angle of the ODE-hinge joint. The method checks if the first or the second EntityTransform is the mainEntity, because then the angles have to be set into different directions. The maxAngle-parameter is set two times, because ODE only accepts it if the maximum angle is above the minimum angle. To avoid checking this we easily set it two times.


Member Data Documentation

gmtl::Vec3f HingeJoint::anchor [protected]

bool HingeJoint::anglesSet [protected]

gmtl::Vec3f HingeJoint::axis [protected]

float HingeJoint::deltaAngle [protected]

float HingeJoint::deltaAngleODE [protected]

bool HingeJoint::firstIsMain [protected]

float HingeJoint::maxAngle [protected]

float HingeJoint::minAngle [protected]

float HingeJoint::oldAngle [protected]


The documentation for this class was generated from the following files:

Generated on Wed Oct 20 16:11:57 2010 for inVRs by doxygen 1.5.8