#include <primitive.h>
Inherited by Box, Capsule, Cylinder, DummyPrimitive, HeightField, Mesh, Plane, Ray, Sphere, and Transform.
Inheritance diagram for Primitive:
Public Types | |
Body = 1 | |
Geom = 2 | |
Draw = 4 | |
Child = 8 | |
Dyn = 1 | |
Stat = 2 | |
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 OSGPrimitive * | getOSGPrimitive ()=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. | |
void | setPosition (const osg::Vec3 &pos) |
set the position of the primitive (orientation is preserved) | |
void | setPose (const osg::Matrix &pose) |
set the pose of the primitive | |
osg::Vec3 | getPosition () const |
returns the position | |
osg::Matrix | getPose () const |
returns the pose | |
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 4th coordinate) | |
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 |
Static Protected Attributes | |
static bool | destroyGeom = true |
This is intended to bring OSG and ODE together and hide most implementation details.
enum Category |
enum Modes |
Primitive | ( | ) |
~Primitive | ( | ) | [virtual] |
void attachGeomAndSetColliderFlags | ( | ) | [protected, virtual] |
attaches geom to body (if any) and sets the category bits and collision bitfields.
assumes: mode & Geom != 0
dBodyID getBody | ( | ) | const |
returns ODE bodyID if there
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 |
returns the pose
osg::Vec3 getPosition | ( | ) | const |
returns the position
virtual void init | ( | const OdeHandle & | odeHandle, | |
double | mass, | |||
const OsgHandle & | osgHandle, | |||
char | mode = Body|Geom|Draw | |||
) | [pure virtual] |
registers primitive in ODE and OSG.
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)
_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.
cg | center of gravity vector | |
I | 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 | ) |
void setPosition | ( | const osg::Vec3 & | pos | ) |
set the position of the primitive (orientation is preserved)
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
return the given vector or axis transformed to local coordinates of the primitive (translation depends on 4th coordinate)
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.
dBodyID body [protected] |
bool destroyGeom = true [static, protected] |
dGeomID geom [protected] |
char mode [protected] |