Primitive Class Reference

Interface class for primitives represented in the physical and graphical world. More...

#include <primitive.h>

Inherited by Box, Capsule, Cylinder, DummyPrimitive, HeightField, Mesh, Plane, Ray, Sphere, and Transform.

Collaboration diagram for Primitive:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Modes { Body = 1, Geom = 2, Draw = 4, Child = 8 }
 

Body means that it is a dynamic object with a body.

More...
enum  Category { Dyn = 1, Stat = 2 }

Public Member Functions

 Primitive ()
virtual ~Primitive ()
virtual void init (const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)=0
 registers primitive in ODE and OSG.
virtual void update ()=0
 Updates the OSG nodes with ODE coordinates.
virtual OSGPrimitivegetOSGPrimitive ()=0
 returns the assoziated osg primitive if there or 0
virtual void setColor (const Color &color)
 sets the color for the underlaying osgprimitive
virtual void setTexture (const std::string &filename)
 assigns a texture to the primitive
virtual void setTexture (const std::string &filename, double repeatOnX, double repeatOnY)
 assigns a texture to the primitive, you can choose if the texture should be repeated
virtual void setTexture (int surface, const std::string &filename, double repeatOnX, double repeatOnY)
 assigns a texture to the x-th surface of the primitive, you can choose how often to repeat negative values of repeat correspond to length units.
virtual void setPosition (const Pos &pos)
 set the position of the primitive (orientation is preserved)
virtual void setPose (const osg::Matrix &pose)
 set the pose of the primitive
virtual Pos getPosition () const
 returns the position
virtual osg::Matrix getPose () const
 returns the pose
virtual Pos getVel () const
 returns the velocity
virtual Pos getAngularVel () const
 returns the angular velocity
virtual bool applyForce (osg::Vec3 force)
 apply a force (in world coordinates) to the primitive and returns true if it was possible
virtual bool applyTorque (osg::Vec3 torque)
 apply a torque (in world coordinates) to the primitive and returns true if it was possible
virtual void setMass (double mass)=0
 sets the mass of the body (uniform)
void setMass (double mass, double cgx, double cgy, double cgz, double I11, double I22, double I33, double I12, double I13, double I23)
 sets full mass specification
dGeomID getGeom () const
 returns ODE geomID if there
dBodyID getBody () const
 returns ODE bodyID if there
bool limitLinearVel (double maxVel)
 checks whether the object has higher velocity than maxVel and limits it in case
osg::Vec3 toLocal (const osg::Vec3 &pos) const
 return the given point transformed to local coordinates of the primitive
osg::Vec4 toLocal (const osg::Vec4 &axis) const
 return the given vector or axis transformed to local coordinates of the primitive (translation depends on the 4th coordinate)
void setSubstance (Substance substance)

Static Public Member Functions

static void setDestroyGeomFlag (bool _destroyGeom)
 20091023; guettler: hack for tasked simulations; there are some problems if running in parallel mode, if you do not destroy the geom, everything is fine (should be no problem because world is destroying geoms too)

Public Attributes

Substance substance

Protected Member Functions

virtual void attachGeomAndSetColliderFlags ()
 attaches geom to body (if any) and sets the category bits and collision bitfields.

Protected Attributes

dGeomID geom
dBodyID body
char mode
bool substanceManuallySet

Static Protected Attributes

static bool destroyGeom = true

Detailed Description

Interface class for primitives represented in the physical and graphical world.

This is intended to bring OSG and ODE together and hide most implementation details.


Member Enumeration Documentation

enum Category
Enumerator:
Dyn 
Stat 
enum Modes

Body means that it is a dynamic object with a body.

Geom means it has a geometrical represenation used for collision detection. Draw means the primitive is drawn Child is only used internally and is used for transformed geoms.

Enumerator:
Body 
Geom 
Draw 
Child 

Constructor & Destructor Documentation

Primitive (  ) 
~Primitive (  )  [virtual]

Member Function Documentation

bool applyForce ( osg::Vec3  force  )  [virtual]

apply a force (in world coordinates) to the primitive and returns true if it was possible

bool applyTorque ( osg::Vec3  torque  )  [virtual]

apply a torque (in world coordinates) to the primitive and returns true if it was possible

void attachGeomAndSetColliderFlags (  )  [protected, virtual]

attaches geom to body (if any) and sets the category bits and collision bitfields.

assumes: mode & Geom != 0

Pos getAngularVel (  )  const [virtual]

returns the angular velocity

dBodyID getBody (  )  const

returns ODE bodyID if there

Examples:
template_sphererobot/main.cpp.
dGeomID getGeom (  )  const

returns ODE geomID if there

virtual OSGPrimitive* getOSGPrimitive (  )  [pure virtual]

returns the assoziated osg primitive if there or 0

Implemented in HeightField, Plane, Box, Sphere, Capsule, Cylinder, Ray, Mesh, Transform, and DummyPrimitive.

osg::Matrix getPose (  )  const [virtual]

returns the pose

Pos getPosition (  )  const [virtual]

returns the position

Reimplemented in DummyPrimitive.

Pos getVel (  )  const [virtual]

returns the velocity

Reimplemented in DummyPrimitive.

virtual void init ( const OdeHandle odeHandle,
double  mass,
const OsgHandle osgHandle,
char  mode = Body|Geom|Draw 
) [pure virtual]

registers primitive in ODE and OSG.

Parameters:
osgHandle scruct with ODE variables inside (to specify space, world...)
mass Mass of the object in ODE (if withBody = true)
osgHandle scruct with OSG variables inside (scene node, color ...)
mode is a conjuction of Modes.

Implemented in HeightField, Plane, Box, Sphere, Capsule, Cylinder, Ray, Mesh, Transform, and DummyPrimitive.

bool limitLinearVel ( double  maxVel  ) 

checks whether the object has higher velocity than maxVel and limits it in case

void setColor ( const Color color  )  [virtual]

sets the color for the underlaying osgprimitive

static void setDestroyGeomFlag ( bool  _destroyGeom  )  [inline, static]

20091023; guettler: hack for tasked simulations; there are some problems if running in parallel mode, if you do not destroy the geom, everything is fine (should be no problem because world is destroying geoms too)

Parameters:
_destroyGeom set this to false if geoms must not be destroyed if the primitive is destroyed
void setMass ( double  mass,
double  cgx,
double  cgy,
double  cgz,
double  I11,
double  I22,
double  I33,
double  I12,
double  I13,
double  I23 
)

sets full mass specification

sets full mass specification.

Parameters:
cg center of gravity vector
I 3x3 interia tensor

cg is center of gravity vector I are parts of the 3x3 interia tensor

virtual void setMass ( double  mass  )  [pure virtual]

sets the mass of the body (uniform)

Implemented in HeightField, Plane, Box, Sphere, Capsule, Cylinder, Ray, Mesh, Transform, and DummyPrimitive.

void setPose ( const osg::Matrix pose  )  [virtual]

set the pose of the primitive

Reimplemented in HeightField, and Mesh.

void setPosition ( const Pos pos  )  [virtual]

set the position of the primitive (orientation is preserved)

void setSubstance ( Substance  substance  ) 
void setTexture ( int  surface,
const std::string &  filename,
double  repeatOnX,
double  repeatOnY 
) [virtual]

assigns a texture to the x-th surface of the primitive, you can choose how often to repeat negative values of repeat correspond to length units.

E.g. assume a rectangle of size 5 in x direction: with repeatOnX = 2 the texture would be two times rereated. With repeatOnX = -1 the texture would be 5 times repeated because the texture is made to have the size 1

void setTexture ( const std::string &  filename,
double  repeatOnX,
double  repeatOnY 
) [virtual]

assigns a texture to the primitive, you can choose if the texture should be repeated

void setTexture ( const std::string &  filename  )  [virtual]

assigns a texture to the primitive

osg::Vec4 toLocal ( const osg::Vec4 axis  )  const

return the given vector or axis transformed to local coordinates of the primitive (translation depends on the 4th coordinate)

return the given vector or axis transformed to local coordinates of the primitive (translation depends on 4th coordinate)

osg::Vec3 toLocal ( const osg::Vec3 pos  )  const

return the given point transformed to local coordinates of the primitive

virtual void update (  )  [pure virtual]

Updates the OSG nodes with ODE coordinates.

This function must be overloaded (usually calls setMatrix of OsgPrimitives)

Implemented in HeightField, Plane, Box, Sphere, Capsule, Cylinder, Ray, Mesh, Transform, and DummyPrimitive.


Member Data Documentation

dBodyID body [protected]
bool destroyGeom = true [static, protected]
dGeomID geom [protected]
char mode [protected]
bool substanceManuallySet [protected]

The documentation for this class was generated from the following files:
Generated on Fri Nov 4 10:59:40 2011 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3