Physsim::CollisionGeometry Class Reference

Defines collision geometry that may be used (in principle) many ways: for rigid bodies, non-rigid bodies, ... More...

#include <CollisionGeometry.h>

Inheritance diagram for Physsim::CollisionGeometry:

Physsim::Base List of all members.

Public Member Functions

 CollisionGeometry ()
 Constructs a CollisionGeometry with no triangle mesh, identity transformation and relative transformation.
CollisionGeometryPtr get_child (unsigned i) const
 Gets the 0-indexed child of this CollisionGeometry.
virtual void clone (BasePtr &cloned, bimap< BasePtr, BasePtr > *obj_map=NULL) const
 Clones this collision geometry.
virtual void load_state (BaseConstPtr object, bimap< BasePtr, BasePtr > *correspondence=NULL)
 Loads the state of this geometry from another CollisionGeometry object.
virtual void save_state (BasePtr object, bimap< BasePtr, BasePtr > *correspondence=NULL) const
 Saves the state of this body to another CollisionGeometry object with the same structure.
bool is_struct_identical (BaseConstPtr object) const
 Verifies that the structure is identical between two CollisionGeometry objects.
void set_transform (const Matrix4 &transform, bool rel_transform_accounted)
 Sets the transform of this CollisionGeometry.
void write_vrml (const std::string &filename) const
 Writes the collision geometry mesh to the specified VRML file.
void set_geometry (PrimitiveConstPtr primitive)
 Sets the collision geometry via a primitive.
void set_rel_transform (const Matrix4 &transform)
 Sets the relative transform (from its parent CollisionGeometry or dynamic body) for this CollisionGeometry.
std::list< CollisionGeometryPtr > get_sub_geometries () const
 Gets all descendant collision geometries (unordered).
virtual void save_to_xml (XMLTreePtr node, std::list< BaseConstPtr > &shared_objects) const
 Implements Base::save_to_xml().
virtual void load_from_xml (XMLTreeConstPtr node, std::map< std::string, BasePtr > &id_map)
 Implements Base::load_from_xml().
void set_max_tri_area (Real area)
 Sets the maximum triangle area for this geometry's mesh.
Real get_max_tri_area () const
 Gets the maximum triangle area for the collision mesh.
TriangleArrayConstPtr get_mesh () const
 Gets the collision mesh.
boost::weak_ptr< CollisionGeometryget_parent () const
 Gets the parent of this CollisionGeometry (or NULL if there is no parent).
void set_parent (boost::weak_ptr< CollisionGeometry > parent)
 Sets the parent of this CollisionGeometry (or NULL to indicate no parent).
unsigned num_children () const
 Gets the number of children of this CollisionGeometry.
const std::vector< CollisionGeometryPtr > & get_children () const
 Gets the children of this CollisionGeometry.
CollisionGeometryPtr get_child (unsigned i)
 Gets the i'th child of this CollisionGeometry.
void add_child (CollisionGeometryPtr child)
 Adds a child to this CollisionGeometry.
const Matrix4get_transform () const
 Gets the transform for this CollisionGeometry.
const Matrix4get_rel_transform () const
 Gets the relative transform (from its parent CollisionGeometry or dynamic body) for this CollisionGeometry.
void * get_collision_data () const
 Gets the associated collision data.
void set_collision_data (void *data)
 Sets the associated collision data.
boost::weak_ptr< RigidBodyget_rigid_body () const
 Gets the rigid body associated with this CollisionGeometry (if any).
void set_rigid_body (boost::weak_ptr< RigidBody > r)
 Sets the rigid body associated with this CollisionGeometry (if any).
bool is_convex () const
 Gets whether the mesh of this geometry is convex.
PrimitiveConstPtr get_geometry () const
 Gets the primitive geometry for this CollisionGeometry.

Protected Attributes

Matrix4 _transform
 The adjusted (i.e., relative transform considered) transform of the CollisionGeometry.
Matrix4 _rel_transform
 The relative transform to the CollisionGeometry frame.

Detailed Description

Defines collision geometry that may be used (in principle) many ways: for rigid bodies, non-rigid bodies, ...

In principle the geometry may be very complex, and may support nonstationarity (changing over time) or deformities (e.g., due to collision). Note that while the underlying geometry may be shared, it is not intended for CollisionGeometry objects to be shared.


Member Function Documentation

CollisionGeometryPtr CollisionGeometry::get_child ( unsigned  i  )  const

Gets the 0-indexed child of this CollisionGeometry.

This method outputs an error message to standard error if the index is invalid.

Parameters:
i the 0-index of the child
Returns:
a pointer to the i'th child, or NULL if the index was invalid

void CollisionGeometry::clone ( BasePtr &  cloned,
bimap< BasePtr, BasePtr > *  object_map = NULL 
) const [virtual]

Clones this collision geometry.

Clones this object, but does not perform a deep copy of the underlying geometry.

Reimplemented from Physsim::Base.

void CollisionGeometry::load_state ( BaseConstPtr  object,
bimap< BasePtr, BasePtr > *  correspondence = NULL 
) [virtual]

Loads the state of this geometry from another CollisionGeometry object.

The structure of the two geometries must be identical -- specifically, both must have the same number of children and parents (each of which has identical structure as well). A shallow copy of the underlying geometry is made.

Reimplemented from Physsim::Base.

void CollisionGeometry::save_state ( BasePtr  object,
bimap< BasePtr, BasePtr > *  correspondence = NULL 
) const [virtual]

Saves the state of this body to another CollisionGeometry object with the same structure.

The structure of the two rigid bodies must be identical -- specifically, both must have the same number of collision geometries (each of which has identical structure as well) and both must have one/no pointer to an articulated body.

Reimplemented from Physsim::Base.

void CollisionGeometry::set_transform ( const Matrix4 transform,
bool  rel_transform_accounted 
)

Sets the transform of this CollisionGeometry.

This method sets the base transform of this geometry. This geometry's true transform is the result of the relative transform applied to this transform. This method recursively calls itself on each of its children, so that the user need only make one call to set_transform() at the root of a tree of transforms. Note that the calling method must consider the relative transform applied to this geometry. If the transform of the parent / related body is T1 and the relative transform is T2 then set_transform() should be called with T1 * T2.

Parameters:
transform the transformation
rel_transform_accounted determines whether the relative transform is accounted for in transform; if false, transform will be transformed by the relative transform before storing and propagating
See also:
get_rel_transform()

set_rel_transform()

void CollisionGeometry::write_vrml ( const std::string &  filename  )  const

Writes the collision geometry mesh to the specified VRML file.

Note:
the mesh is transformed using the current transformation

void CollisionGeometry::set_geometry ( PrimitiveConstPtr  primitive  ) 

Sets the collision geometry via a primitive.

The primitive is not cloned, nor is it unaltered; this points to primitive on return.

void CollisionGeometry::set_max_tri_area ( Real  area  ) 

Sets the maximum triangle area for this geometry's mesh.

Note:
setting the maximum triangle area greater than the current maximum triangle area has no effect: the underlying mesh has already been subdivided, and neighboring coplanar triangles will not be merged. Additionally, if this object is serialized, the subdivided mesh will be saved rather than the original.

TriangleArrayConstPtr Physsim::CollisionGeometry::get_mesh (  )  const [inline]

Gets the collision mesh.

Note:
the mesh is not transformed -- it is not synchronized with the transform for the geometry, and must be transformed by the user manually.


The documentation for this class was generated from the following files:
Generated on Wed Oct 24 14:54:22 2007 for Physsim by  doxygen 1.5.1