Primitive Class Reference

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

#include <primitive.h>

Inherits Storeable.

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,
  _Transform = 16
}
 

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 setColor (const std::string &color)
 sets the color using the colorschema of osgHandle
virtual void setTexture (const std::string &filename)
 assigns a texture to the primitive
virtual void setTexture (const TextureDescr &texture)
 assigns a texture to the primitive, you can choose if the texture should be repeated
virtual void setTexture (int surface, const TextureDescr &texture)
 assigns a texture to the x-th surface of the primitive.
virtual void setTextures (const std::vector< TextureDescr > &textures)
 assign a set of texture to the surfaces of the primitive
virtual void setPosition (const Pos &pos)
 set the position of the primitive (orientation is preserved)
virtual void setPose (const Pose &pose)
 set the pose of the primitive
virtual Pos getPosition () const
 returns the position
virtual Pose 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 applyForce (double x, double y, double z)
virtual bool applyTorque (osg::Vec3 torque)
 apply a torque (in world coordinates) to the primitive and returns true if it was possible
virtual bool applyTorque (double x, double y, double z)
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
bool limitAngularVel (double maxVel)
 checks whether the object has higher velocity than maxVel and limits it in case
void decellerate (double factorLin, double factorAng)
 applies a force to the body to decellerate its linear and angular velocity with the given factors.
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)
osg::Vec3 toGlobal (const osg::Vec3 &pos) const
 transforms the given point in local corrds of the primitive to global coordinates
osg::Vec4 toGlobal (const osg::Vec4 &axis) const
 transforms the given vector or axis in local corrds of the primitive to global coordinates (translation depends on the 4th coordinate)
int getNumVelocityViolations ()
void setSubstance (Substance substance)
virtual bool store (FILE *f) const
 stores the object to the given file stream (binary).
virtual bool restore (FILE *f)
 loads the object from the given file stream (binary).

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
int numVelocityViolations
 number of times the maximal velocity was exceeded

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 and _Transform are only used internally and used for transformed geoms.

Enumerator:
Body 
Geom 
Draw 
_Child 
_Transform 

Constructor & Destructor Documentation

Primitive (  ) 
~Primitive (  )  [virtual]

Member Function Documentation

bool applyForce ( double  x,
double  y,
double  z 
) [virtual]
bool applyForce ( osg::Vec3  force  )  [virtual]

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

bool applyTorque ( double  x,
double  y,
double  z 
) [virtual]
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

void decellerate ( double  factorLin,
double  factorAng 
)

applies a force to the body to decellerate its linear and angular velocity with the given factors.

(depends on stepwidth!)

Pos getAngularVel (  )  const [virtual]

returns the angular velocity

dBodyID getBody (  )  const [inline]

returns ODE bodyID if there

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

returns ODE geomID if there

int getNumVelocityViolations (  )  [inline]
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.

Pose 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 limitAngularVel ( double  maxVel  ) 

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

bool limitLinearVel ( double  maxVel  ) 

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

bool restore ( FILE *  f  )  [virtual]

loads the object from the given file stream (binary).

Implements Storeable.

void setColor ( const std::string &  color  )  [virtual]

sets the color using the colorschema of osgHandle

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 Pose pose  )  [virtual]

set the pose of the primitive

Reimplemented in 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 TextureDescr texture 
) [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 = -2 the texture would be 2.5 times repeated because the texture is made to have the size 2

void setTexture ( const TextureDescr texture  )  [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

void setTextures ( const std::vector< TextureDescr > &  textures  )  [virtual]

assign a set of texture to the surfaces of the primitive

bool store ( FILE *  f  )  const [virtual]

stores the object to the given file stream (binary).

Implements Storeable.

osg::Vec4 toGlobal ( const osg::Vec4 axis  )  const

transforms the given vector or axis in local corrds of the primitive to global coordinates (translation depends on the 4th coordinate)

osg::Vec3 toGlobal ( const osg::Vec3 pos  )  const

transforms the given point in local corrds of the primitive to global coordinates

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)

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]
int numVelocityViolations [protected]

number of times the maximal velocity was exceeded

bool substanceManuallySet [protected]

The documentation for this class was generated from the following files:
Generated on Thu Jun 28 14:48:50 2012 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.6.3