#include <transformable.h>

Public Types | |
| enum | CoordSysEnum { REL_CS, ABS_CS } |
| typedef osg::MatrixTransform | TransformableNode |
Public Member Functions | |
| Transformable (const std::string &name="Transformable") | |
| Transformable (TransformableNode &node, const std::string &name="Transformable") | |
| Overloaded constructor will use the supplied node instead of creating one internally. | |
| virtual bool | AddChild (DeltaDrawable *child) |
| Add a DeltaDrawable child. | |
| virtual void | RemoveChild (DeltaDrawable *child) |
| Remove a DeltaDrawable child. | |
| virtual void | SetTransform (const Transform &xform, CoordSysEnum cs=ABS_CS) |
| Sets the Transform to reposition this Transformable. | |
| virtual void | GetTransform (Transform &xform, CoordSysEnum cs=ABS_CS) const |
| Get the current Transform of this Transformable. | |
| TransformableNode * | GetMatrixNode () |
| Convenience function to return back the internal matrix transform node. | |
| const TransformableNode * | GetMatrixNode () const |
| Convenience function to return back the internal matrix transform node. | |
| const osg::Matrix & | GetMatrix () const |
| |
| void | SetMatrix (const osg::Matrix &mat) |
| set the matrix for this transformable. Call this instead of getMatrixNode->setMatrix | |
| virtual void | RenderProxyNode (bool enable=true) |
| Render method for an object which may not have geometry. | |
| virtual bool | GetIsRenderingProxyNode () const |
| Returns if we are rendering the proxy node. | |
| void | SetNormalRescaling (bool enable) |
| Automatically rescales normals if you scale your objects. | |
| bool | GetNormalRescaling () const |
| Checks if we are rescaling normals for this object. | |
| dGeomID | GetGeomID () const |
| Returns the ODE geometry identifier associated with this object. | |
| CollisionGeomType * | GetCollisionGeomType () const |
| Returns the type of collision geometry associated with this object. | |
| void | GetCollisionGeomDimensions (std::vector< float > &dimensions) |
| Returns the dimensions of collision geometry associated with this object. | |
| void | SetCollisionDetection (bool enabled) |
| Sets whether or not collisions detection will be performed. | |
| bool | GetCollisionDetection () const |
| Gets whether or not collisions with other Transformables will be detected. | |
| void | SetCollisionGeom (dGeomID geom) |
| Sets this object's collision geometry to the specified ODE geom. | |
| void | SetCollisionSphere (float radius) |
| Sets this object's collision geometry to a sphere with the specified radius. | |
| void | SetCollisionSphere (osg::Node *node=0) |
| Sets this object's collision geometry to a sphere with radius derived from the specified OpenSceneGraph node. | |
| void | SetCollisionBox (float lx, float ly, float lz) |
| Sets this object's collision geometry to a box with the specified dimensions. | |
| void | SetCollisionBox (osg::Node *node=0) |
| Sets this object's collision geometry to a box with parameters derived from the specified OpenSceneGraph node. | |
| void | SetCollisionCappedCylinder (float radius, float length) |
| Sets this object's collision geometry to a capped cylinder (oriented along the z axis) with the specified radius and length. | |
| void | SetCollisionCappedCylinder (osg::Node *node=NULL) |
| Sets this object's collision geometry to a capped cylinder with parameters derived from the given OpenSceneGraph node. | |
| void | SetCollisionRay (float length) |
| Sets this object's collision geometry to a ray (along the z axis) with the specified length. | |
| void | SetCollisionMesh (osg::Node *node=NULL) |
| Sets this object's collision geometry to a triangle mesh derived from the given OpenSceneGraph node. | |
| void | ClearCollisionGeometry () |
| Removes any collision geometry specified for this object. | |
| virtual void | PrePhysicsStepUpdate () |
| Updates the state of this object just before a physical simulation step. | |
| virtual bool | FilterContact (dContact *contact, Transformable *collider) |
| Modifies or cancels the specified contact joint definition according to the relationship between this object and the specified collider. | |
| virtual void | PostPhysicsStepUpdate () |
| Updates the state of this object just after a physical simulation step. | |
| void | RenderCollisionGeometry (bool enable=true) |
| Enable or disable the rendering of the collision geometry. | |
| bool | GetRenderCollisionGeometry () const |
| Are we currently rendering the collision geometry? | |
| virtual void | AddedToScene (Scene *scene) |
| Supply the Scene this Transformable has been added to. | |
| void | SetCollisionCategoryBits (unsigned long bits) |
| Set the category bits of this collision geom. | |
| unsigned long | GetCollisionCategoryBits () const |
| void | SetCollisionCollideBits (unsigned long bits) |
| Set the collide bits of this collision geom. | |
| unsigned long | GetCollisionCollideBits () const |
| osg::Node * | GetOSGNode () |
| required by DeltaDrawable | |
| const osg::Node * | GetOSGNode () const |
Static Public Member Functions | |
| static bool | GetAbsoluteMatrix (const osg::Node *node, osg::Matrix &wcMatrix) |
| Gets the world coordinate matrix for the supplied node. | |
Static Public Attributes | |
| static const std::string | COLLISION_GEODE_ID |
| Used to identify the collision geometry node if RenderCollisionGeometry is set to true. | |
Protected Member Functions | |
| void | ReplaceMatrixNode (TransformableNode *matrixTransform) |
| Replaces the scene graph node with a new MatrixTransform. | |
| virtual | ~Transformable () |
Protected Attributes | |
| Transform | mGeomTransform |
| The last geometry transform reported to ODE. | |
Classes | |
| class | CollisionGeomType |
| We need an enumeration to allow the user to set which type of collision geometry to use. More... | |
The default coordinate system of dtCore is +X to the right, +Y forward into the screen, and +Z is up. Therefore, heading is around the Z axis, pitch is around the X axis, and roll is around the Y axis. The angles are all right-hand-rule.
The Transformable class creates a osg::MatrixTransform node for the protected member mNode.
| typedef osg::MatrixTransform dtCore::Transformable::TransformableNode |
| Transformable::Transformable | ( | const std::string & | name = "Transformable" |
) |
| Transformable::Transformable | ( | TransformableNode & | node, | |
| const std::string & | name = "Transformable" | |||
| ) |
Overloaded constructor will use the supplied node instead of creating one internally.
| node | : A node this class should use internally | |
| name | : The name of this instance |
| Transformable::~Transformable | ( | ) | [protected, virtual] |
| void Transformable::ReplaceMatrixNode | ( | TransformableNode * | matrixTransform | ) | [protected] |
Replaces the scene graph node with a new MatrixTransform.
WARNING! This function is a big fat hack to get RepliacntBody to play nice with our API. This will almost certainly be removed in future version, so don't get to comfy using it! ;) Properties set on this Transformable are merged onto the new node, however the old collision geometry will remain.
| matrixTransform | The node you wish to squeeze into this Transformable. |
| bool Transformable::AddChild | ( | DeltaDrawable * | child | ) | [virtual] |
Add a DeltaDrawable child.
Add a child to this Transformable.
This will allow the child to be repositioned whenever the parent moves. An optional offset may be applied to the child. Any number of children may be added to a parent. The child's position in relation to the parent's will not change (ie: the child will *not* snap to the parent's position) unless the offset is overwritten using SetTransform() on the child.
| *child | : The child to add to this Transformable |
Reimplemented from dtCore::DeltaDrawable.
Reimplemented in dtCore::Light.
| void Transformable::RemoveChild | ( | DeltaDrawable * | child | ) | [virtual] |
Remove a DeltaDrawable child.
Remove a child from this Transformable.
This will detach the child from its parent so that its free to be repositioned on its own.
| *child | : The child Transformable to be removed |
Reimplemented from dtCore::DeltaDrawable.
Reimplemented in dtCore::Light.
| void Transformable::SetTransform | ( | const Transform & | xform, | |
| CoordSysEnum | cs = ABS_CS | |||
| ) | [virtual] |
Sets the Transform to reposition this Transformable.
Set position/attitude of this Transformable using the supplied Transform.
Note that if this function is overriden, then GetMatrix()->getMatrix() may return diffirent values.
| xform | The value to set on this Transformable. | |
| cs | The coordinate system of the returned Transform. For absolute, use ABS_CS, and for relative, us REL_CS. |
If the CoordSysEnum is ABS_CS, then the Transformable is positioned assuming absolute world coordinates and the Transformable parent/child relative position is recalculated. If the CoordSysEnum is REL_CS, then the Transformable is positioned relative to it's parent's Transform. (Note - if REL_CS is supplied and the Transformable does not have a parent, the Transform is assumed to be an absolute world coordinate.
| *xform | : The new Transform to position this instance | |
| cs | : Optional parameter describing the coordinate system of xform Defaults to ABS_CS. |
Reimplemented in dtAudio::Sound.
| void Transformable::GetTransform | ( | Transform & | xform, | |
| CoordSysEnum | cs = ABS_CS | |||
| ) | const [virtual] |
Get the current Transform of this Transformable.
| xform | The value will by assigned to this reference. | |
| cs | The coordinate system of the returned Transform. For absolute, use ABS_CS, and for relative, us REL_CS. | |
| *xform | : The Transform to be filled in | |
| cs | : Optional parameter to select either the absolute world coordinate or the parent relative coordinate (default == ABS_CS) |
| TransformableNode* dtCore::Transformable::GetMatrixNode | ( | ) | [inline] |
Convenience function to return back the internal matrix transform node.
| const TransformableNode* dtCore::Transformable::GetMatrixNode | ( | ) | const [inline] |
Convenience function to return back the internal matrix transform node.
| const osg::Matrix & Transformable::GetMatrix | ( | ) | const |
| void Transformable::SetMatrix | ( | const osg::Matrix & | mat | ) |
set the matrix for this transformable. Call this instead of getMatrixNode->setMatrix
| void Transformable::RenderProxyNode | ( | bool | enable = true |
) | [virtual] |
| virtual bool dtCore::Transformable::GetIsRenderingProxyNode | ( | ) | const [inline, virtual] |
Returns if we are rendering the proxy node.
| bool Transformable::GetAbsoluteMatrix | ( | const osg::Node * | node, | |
| osg::Matrix & | wcMatrix | |||
| ) | [static] |
Gets the world coordinate matrix for the supplied node.
Calculates the world coordinate system matrix using the supplied node.
| node | The node to start from | |
| wcMatrix | The matrix to fill |
| node | : the node to calculate the world coordinate matrix from | |
| wcMat | : The supplied matrix to return with world coordinates |
| void Transformable::SetNormalRescaling | ( | bool | enable | ) |
Automatically rescales normals if you scale your objects.
| bool Transformable::GetNormalRescaling | ( | ) | const |
Checks if we are rescaling normals for this object.
| dGeomID dtCore::Transformable::GetGeomID | ( | ) | const [inline] |
Returns the ODE geometry identifier associated with this object.
| Transformable::CollisionGeomType * Transformable::GetCollisionGeomType | ( | ) | const |
Returns the type of collision geometry associated with this object.
| void Transformable::GetCollisionGeomDimensions | ( | std::vector< float > & | dimensions | ) |
Returns the dimensions of collision geometry associated with this object.
Note: This is not const function since it requires an update to the underlying ODE geometry if we are out of sync with OSG.
| dimensions | The dimenstions of the object's collision geometry. What is filled into the vector is dependent on Collision type. CUBE : ( lx, ly, lz ) SPHERE : ( radius ) CYLINDER : ( radius, length ) RAY : ( length, start_x, start_y, start_z, dir_x, dir_y, dir_z ) | |
| dimensions | The dimenstions of the object's collision geometry. What is filled into the vector is dependent on Collision type. CUBE : ( lx, ly, lz ) SPHERE : ( radius ) CYLINDER : ( radius, length ) RAY : ( length, start_x, start_y, start_z, dir_x, dir_y, dir_z ) |
| void Transformable::SetCollisionDetection | ( | bool | enabled | ) |
Sets whether or not collisions detection will be performed.
Note: This does not handle collisions in any way, the user is still responsible for implementing collision response (or just use Physical). Collision detected is enabled by default if a collision shape has been set.
| enabled | true if the Transformable will perform collision detection |
| solid | true if the Transformable is solid |
| bool Transformable::GetCollisionDetection | ( | ) | const |
Gets whether or not collisions with other Transformables will be detected.
true if the Transformable is solid
| void Transformable::SetCollisionGeom | ( | dGeomID | geom | ) |
Sets this object's collision geometry to the specified ODE geom.
| geom | the new collision geom |
| void Transformable::SetCollisionSphere | ( | float | radius | ) |
Sets this object's collision geometry to a sphere with the specified radius.
| radius | the radius of the collision sphere |
| void Transformable::SetCollisionSphere | ( | osg::Node * | node = 0 |
) |
Sets this object's collision geometry to a sphere with radius derived from the specified OpenSceneGraph node.
| node | the node from which to obtain the sphere radius (if 0, attempt to use own node) | |
| node | the node from which to obtain the sphere radius (if NULL, attempt to use own node) |
| void Transformable::SetCollisionBox | ( | float | lx, | |
| float | ly, | |||
| float | lz | |||
| ) |
Sets this object's collision geometry to a box with the specified dimensions.
| lx | the length of the box in the x direction | |
| ly | the length of the box in the y direction | |
| lz | the length of the box in the z direction |
| void Transformable::SetCollisionBox | ( | osg::Node * | node = 0 |
) |
Sets this object's collision geometry to a box with parameters derived from the specified OpenSceneGraph node.
| node | the node from which to obtain the box parameters (if 0, attempt to use own node) |
| void Transformable::SetCollisionCappedCylinder | ( | float | radius, | |
| float | length | |||
| ) |
Sets this object's collision geometry to a capped cylinder (oriented along the z axis) with the specified radius and length.
| radius | the radius of the cylinder | |
| length | the length of the cylinder |
| void Transformable::SetCollisionCappedCylinder | ( | osg::Node * | node = NULL |
) |
Sets this object's collision geometry to a capped cylinder with parameters derived from the given OpenSceneGraph node.
| node | the node from which to obtain the cylinder parameters (if 0, attempt to use own node) | |
| node | the node from which to obtain the cylinder parameters (if NULL, attempt to use own node) |
| void Transformable::SetCollisionRay | ( | float | length | ) |
Sets this object's collision geometry to a ray (along the z axis) with the specified length.
| length | the length of the ray |
| void Transformable::SetCollisionMesh | ( | osg::Node * | node = NULL |
) |
Sets this object's collision geometry to a triangle mesh derived from the given OpenSceneGraph node.
| node | the node from which to obtain the mesh data (if 0, attempt to use own node) |
| void Transformable::ClearCollisionGeometry | ( | ) |
Removes any collision geometry specified for this object.
| void Transformable::PrePhysicsStepUpdate | ( | ) | [virtual] |
Updates the state of this object just before a physical simulation step.
Should only be called by dtCore::Scene. The default implementation updates the state of the body to reflect any user-applied transformation.
| virtual bool dtCore::Transformable::FilterContact | ( | dContact * | contact, | |
| Transformable * | collider | |||
| ) | [inline, virtual] |
Modifies or cancels the specified contact joint definition according to the relationship between this object and the specified collider.
Should only be called by dtCore::Scene.
This is false by default since most things that move should not cause collisions (Lights, Isector's, Camera, etc.)
| contact | the joint definition to modify | |
| collider | the object with which this is colliding |
Reimplemented in dtCore::InfiniteTerrain, and dtCore::Physical.
| virtual void dtCore::Transformable::PostPhysicsStepUpdate | ( | ) | [inline, virtual] |
Updates the state of this object just after a physical simulation step.
Should only be called by dtCore::Scene. The default implementation here does nothing. Physical overrides it and copies the new object position into the user-accessible transformation.
Reimplemented in dtCore::Physical.
| void Transformable::RenderCollisionGeometry | ( | bool | enable = true |
) |
Enable or disable the rendering of the collision geometry.
This will draw a purple outline of shape the collision detection routine is using.
| enable | If true, the scene will now render the collision geomertry. |
| bool dtCore::Transformable::GetRenderCollisionGeometry | ( | ) | const [inline] |
Are we currently rendering the collision geometry?
| void Transformable::AddedToScene | ( | Scene * | scene | ) | [virtual] |
Supply the Scene this Transformable has been added to.
This typically gets called from Scene::AddDrawable().
Normally this is done inside Scene::RegisterCollidable.
| scene | The Scene to which this Transformable is being added to. |
If the param scene is 0, this will unregister this Transformable from the previous parent Scene. If this Transformable already has a parent Scene, it will first remove itself from the old Scene (Scene::RemoveDrawable()), then re-register with the new Scene.
| scene | The Scene this Transformable has been added to |
Reimplemented from dtCore::DeltaDrawable.
Reimplemented in dtActors::Cal3DGameActor, dtActors::GameMeshActor, dtActors::MeshTerrainActor, dtCore::Camera, and dtCore::Light.
| void Transformable::SetCollisionCategoryBits | ( | unsigned long | bits | ) |
Set the category bits of this collision geom.
Here's the defaults:
dtCore::Camera: 1 dtCore::Compass: 2 dtCore::InfiniteTerrain: 3 dtCore::ISector: 4 dtCore::Object: 5 dtCore::ParticlSsystem: 6 dtCore::Physical: 7 dtCore::PointAxis: 8 dtCore::PositionalLight: 9 dtCore::SpotLight: 10 dtCore::Transformable: 11
dtChar::Character: 12 dtAudio::Listener: 13 dtAudio::Sound: 14 dtHLA::Entity: 15 dtTerrain::Terrain: 16
| unsigned long Transformable::GetCollisionCategoryBits | ( | ) | const |
| void Transformable::SetCollisionCollideBits | ( | unsigned long | bits | ) |
Set the collide bits of this collision geom.
If you want this geom to collide with a geom of category bit 00000010 for example, make sure these collide bits contain 00000010. The UNSIGNED_BIT macro in dtCore/macros.h comes in handy here. UNSIGNED_BIT(4) = 00000100
| unsigned long Transformable::GetCollisionCollideBits | ( | ) | const |
| osg::Node * Transformable::GetOSGNode | ( | ) | [virtual] |
| const osg::Node * Transformable::GetOSGNode | ( | ) | const [virtual] |
Implements dtCore::DeltaDrawable.
const std::string Transformable::COLLISION_GEODE_ID [static] |
Used to identify the collision geometry node if RenderCollisionGeometry is set to true.
Transform dtCore::Transformable::mGeomTransform [protected] |
The last geometry transform reported to ODE.