Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
primitive.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * Copyright (C) 2005-2011 LpzRobots development team *
4  * Georg Martius <georg dot martius at web dot de> *
5  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
6  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
7  * Ralf Der <ralfder at mis dot mpg dot de> *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  * *
24  ***************************************************************************/
25 #ifndef __PRIMITIVE_H
26 #define __PRIMITIVE_H
27 
28 #include <ode-dbl/common.h>
29 #include <selforg/storeable.h>
30 
31 #include <vector>
32 
33 #include "pos.h"
34 #include "pose.h"
35 #include "substance.h"
36 // another forward declaration "block"
37 #include "osgforwarddecl.h"
38 
39 namespace lpzrobots {
40 
41  /***** begin of forward declaration block *****/
42  class BoundingShape;
43  class OSGPrimitive;
44  class OSGPlane;
45  class OSGBox;
46  class OSGBoxTex;
47  class OSGSphere;
48  class OSGCapsule;
49  class OSGCylinder;
50  class OSGDummy;
51  class OSGMesh;
52  class TextureDescr;
53 
54  /* typedef */ struct GlobalData;
55 
56  class OdeHandle;
57  class OsgHandle;
58  class Color;
59  /***** end of forward declaration block *****/
60 
61 
62 /// returns the osg (4x4) pose matrix of the ode geom
63 Pose osgPose( dGeomID geom );
64 /// returns the osg (4x4) pose matrix of the ode body
65 Pose osgPose( dBodyID body );
66 /// converts a position vector and a rotation matrix from ode to osg 4x4 matrix
67 Pose osgPose( const double * position , const double * rotation );
68 /// converts the rotation component of pose into an ode rotation matrix
69 void odeRotation( const Pose& pose , dMatrix3& odematrix);
70 
71 /** counts number of max velocity violations at joints
72  * (Attention, this is a global variable, initialized to 0 at start)
73  */
75 
76 /**
77  Interface class for primitives represented in the physical and graphical world.
78  This is intended to bring OSG and ODE together and hide most implementation details.
79 */
80 class Primitive : public Storeable {
81 public:
82  /** Body means that it is a dynamic object with a body.
83  Geom means it has a geometrical represenation used for collision detection.
84  Draw means the primitive is drawn.
85  Density means that the mass is interpreted as a density
86  _Child and _Transform are only used internally and used for transformed geoms.
87  */
88 
89  /* typedef */ enum Modes {Body=1, Geom=2, Draw=4, Density=8,
90  _Child=16, _Transform=32};
91  /* typedef */ enum Category { Dyn=1, Stat=2};
92 
93 
94  Primitive ();
95  virtual ~Primitive ();
96  /** registers primitive in ODE and OSG.
97  @param osgHandle scruct with ODE variables inside (to specify space, world...)
98  @param mass Mass of the object in ODE (if withBody = true)
99  @param osgHandle scruct with OSG variables inside (scene node, color ...)
100  @param mode is a conjuction of Modes.
101  */
102  virtual void init(const OdeHandle& odeHandle, double mass,
103  const OsgHandle& osgHandle,
104  char mode = Body | Geom | Draw) = 0 ;
105 
106  /** Updates the OSG nodes with ODE coordinates.
107  This function must be overloaded (usually calls setMatrix of OsgPrimitives)
108  */
109  virtual void update() =0 ;
110 
111  /// returns the assoziated osg primitive if there or 0
112  virtual OSGPrimitive* getOSGPrimitive() = 0;
113 
114  /// sets the color for the underlaying osgprimitive
115  virtual void setColor(const Color& color);
116 
117  /// sets the color using the colorschema of osgHandle
118  virtual void setColor(const std::string& color);
119 
120  /// assigns a texture to the primitive
121  virtual void setTexture(const std::string& filename);
122  /// assigns a texture to the primitive, you can choose if the texture should be repeated
123  virtual void setTexture(const TextureDescr& texture);
124  /** assigns a texture to the x-th surface of the primitive.
125  You can choose how often to repeat
126  negative values of repeat correspond to length units.
127  E.g. assume a rectangle of size 5 in x direction: with repeatOnX = 2 the texture would be two times
128  rereated. With repeatOnX = -2 the texture would be 2.5 times repeated because the texture is
129  made to have the size 2
130  */
131  virtual void setTexture(int surface, const TextureDescr& texture);
132  /// assign a set of texture to the surfaces of the primitive
133  virtual void setTextures(const std::vector<TextureDescr>& textures);
134 
135 
136  /// set the position of the primitive (orientation is preserved)
137  virtual void setPosition(const Pos& pos);
138  /// set the pose of the primitive
139  virtual void setPose(const Pose& pose);
140  /// returns the position
141  virtual Pos getPosition() const;
142  /// returns the pose
143  virtual Pose getPose() const;
144  /// returns the velocity
145  virtual Pos getVel() const;
146  /// returns the angular velocity
147  virtual Pos getAngularVel() const;
148 
149  /** apply a force (in world coordinates) to the primitive and
150  returns true if it was possible */
151  virtual bool applyForce(osg::Vec3 force);
152  /** @see applyForce(osg::Vec3) */
153  virtual bool applyForce(double x, double y, double z);
154 
155  /** apply a torque (in world coordinates) to the primitive and
156  returns true if it was possible
157  */
158  virtual bool applyTorque(osg::Vec3 torque);
159  /** @see applyTorque(osg::Vec3) */
160  virtual bool applyTorque(double x, double y, double z);
161 
162  /** sets the mass of the body (uniform)
163  if density==true then mass is interpreted as a density
164  */
165  virtual void setMass(double mass, bool density = false) = 0;
166  /** sets full mass specification
167  \param cg center of gravity vector
168  \param I 3x3 interia tensor
169  */
170  void setMass(double mass, double cgx, double cgy, double cgz,
171  double I11, double I22, double I33,
172  double I12, double I13, double I23);
173 
174  /// returns ODE geomID if there
175  dGeomID getGeom() const { return geom; }
176  /// returns ODE bodyID if there
177  dBodyID getBody() const { return body; }
178 
179  /// checks whether the object has higher velocity than maxVel and limits it in case
180  bool limitLinearVel(double maxVel);
181 
182  /// checks whether the object has higher velocity than maxVel and limits it in case
183  bool limitAngularVel(double maxVel);
184 
185  /** applies a force to the body to decellerate its linear and angular velocity with
186  the given factors. (depends on stepwidth!)
187  */
188  void decellerate(double factorLin, double factorAng);
189 
190 
191  /// return the given point transformed to local coordinates of the primitive
192  osg::Vec3 toLocal(const osg::Vec3& pos) const;
193  /** return the given vector or axis transformed to local coordinates
194  of the primitive (translation depends on the 4th coordinate)
195  */
196  osg::Vec4 toLocal(const osg::Vec4& axis) const;
197 
198  /// transforms the given point in local corrds of the primitive to global coordinates
199  osg::Vec3 toGlobal(const osg::Vec3& pos) const;
200  /** transforms the given vector or axis in local corrds of the primitive to global coordinates
201  (translation depends on the 4th coordinate)
202  */
203  osg::Vec4 toGlobal(const osg::Vec4& axis) const;
204 
205  /**
206  * 20091023; guettler:
207  * hack for tasked simulations; there are some problems if running in parallel mode,
208  * if you do not destroy the geom, everything is fine (should be no problem because world is destroying geoms too)
209  * @param _destroyGeom set this to false if geoms must not be destroyed if the primitive is destroyed
210  */
211  static void setDestroyGeomFlag(bool _destroyGeom) {
212  destroyGeom = _destroyGeom;
213  }
214 
216 
217  void setSubstance(const Substance& substance);
218 
219  /* **** storable interface *******/
220  virtual bool store(FILE* f) const;
221 
222  virtual bool restore(FILE* f);
223 
224 
225 protected:
226  /** attaches geom to body (if any) and sets the category bits and collision bitfields.
227  assumes: mode & Geom != 0
228  */
229  virtual void attachGeomAndSetColliderFlags();
230 
231 public:
232  Substance substance; // substance description
233 protected:
234  dGeomID geom;
235  dBodyID body;
236  char mode;
238  int numVelocityViolations; ///< number of times the maximal velocity was exceeded
239 
240  // 20091023; guettler:
241  // hack for tasked simulations; there are some problems if running in parallel mode,
242  // if you do not destroy the geom, everything is fine (should be no problem because world is destroying geoms too)
243  static bool destroyGeom;
244 };
245 
246 
247 /** Plane primitive */
248 class Plane : public Primitive {
249 public:
250  Plane();
251  virtual ~Plane();
252  virtual void init(const OdeHandle& odeHandle, double mass,
253  const OsgHandle& osgHandle,
254  char mode = Body | Geom | Draw) ;
255 
256  virtual void update();
257  virtual OSGPrimitive* getOSGPrimitive();
258 
259  virtual void setMass(double mass, bool density = false);
260 
261 protected:
263 };
264 
265 
266 /** Box primitive */
267 class Box : public Primitive {
268 public:
269 
270  Box(float lengthX, float lengthY, float lengthZ);
271  Box(const osg::Vec3& dim);
272 
273  virtual ~Box();
274 
275  virtual void init(const OdeHandle& odeHandle, double mass,
276  const OsgHandle& osgHandle,
277  char mode = Body | Geom | Draw) ;
278 
279  virtual void update();
280  virtual OSGPrimitive* getOSGPrimitive();
281 
282  virtual void setMass(double mass, bool density = false);
283 protected:
285 };
286 
287 
288 /** Sphere primitive */
289 class Sphere : public Primitive {
290 public:
291  Sphere(float radius);
292  virtual ~Sphere();
293 
294  virtual void init(const OdeHandle& odeHandle, double mass,
295  const OsgHandle& osgHandle,
296  char mode = Body | Geom | Draw) ;
297 
298  virtual void update();
299  virtual OSGPrimitive* getOSGPrimitive();
300 
301  virtual void setMass(double mass, bool density = false);
302 
303 protected:
305 };
306 
307 /** Capsule primitive */
308 class Capsule : public Primitive {
309 public:
310  Capsule(float radius, float height);
311  virtual ~Capsule();
312  virtual void init(const OdeHandle& odeHandle, double mass,
313  const OsgHandle& osgHandle,
314  char mode = Body | Geom | Draw) ;
315 
316  virtual void update();
317  virtual OSGPrimitive* getOSGPrimitive();
318 
319  virtual void setMass(double mass, bool density = false);
320 
321 protected:
323 };
324 
325 /** Cylinder primitive */
326 class Cylinder : public Primitive {
327 public:
328  Cylinder(float radius, float height);
329  virtual ~Cylinder();
330  virtual void init(const OdeHandle& odeHandle, double mass,
331  const OsgHandle& osgHandle,
332  char mode = Body | Geom | Draw) ;
333 
334  virtual void update();
335  virtual OSGPrimitive* getOSGPrimitive();
336 
337  virtual void setMass(double mass, bool density = false);
338 protected:
340 };
341 
342 /** Ray primitive
343  The actual visual representation can have different length than the
344  ray object. This is specified by length.
345  SetLength is an efficient way to change the length at runtime.
346 */
347 class Ray : public Primitive {
348 public:
349  /**
350  @param thickness if thickness == 0 then a line is used and not a box
351  */
352  Ray(double range, float thickness, float length);
353  virtual ~Ray();
354  virtual void init(const OdeHandle& odeHandle, double mass,
355  const OsgHandle& osgHandle,
356  char mode = Geom | Draw) ;
357 
358  void setLength(float len);
359  virtual void update();
360  virtual OSGPrimitive* getOSGPrimitive();
361 
362  virtual void setMass(double mass, bool density = false);
363 protected:
364  double range;
365  float thickness;
366  float length;
368 };
369 
370 
371 
372 
373 /** Mesh primitive */
374 class Mesh : public Primitive {
375 public:
376  Mesh(const std::string& filename,float scale);
377  virtual ~Mesh();
378  virtual void init(const OdeHandle& odeHandle, double mass,
379  const OsgHandle& osgHandle,
380  char mode = Body | Geom | Draw) ;
381  virtual void update();
382  virtual OSGPrimitive* getOSGPrimitive();
383  virtual float getRadius();
384 
385  virtual void setMass(double mass, bool density = false);
386 
387  /**
388  * Sets the BoundingShape externally (e.g. XMLBoundingShape).
389  * Any existing BoundingShape will be deleted.
390  */
391  virtual void setBoundingShape(BoundingShape* boundingShape);
392 
393  virtual void setPose(const Pose& pose);
394 
395 protected:
397  const std::string filename;
398  float scale;
401 
402 };
403 
404 
405 /**
406  Primitive for transforming a geom (primitive without body)
407  in respect to a body (primitive with body).
408  Hides complexity of ODE TransformGeoms.
409 */
410 class Transform : public Primitive {
411 public:
412  /**
413  @param parent primitive should have a body and should be initialised
414  @param child is transformed by pose in respect to parent.
415  This Primitive must NOT have a body and should not be initialised
416  */
417  Transform(Primitive* parent, Primitive* child, const Pose& pose, bool deleteChild = true);
418 
419  /// destructor deletes child object // it should be virtual by yuichi
420  virtual ~Transform();
421 
422  /** initialised the transform object. This automatically
423  initialises the child geom.
424  @param mass mass of the child
425  @param mode is the mode for the child, except that Body bit is ignored (child can't have a body)
426  */
427  virtual void init(const OdeHandle& odeHandle, double mass,
428  const OsgHandle& osgHandle,
429  char mode = Body | Geom | Draw);
430 
431  virtual void update();
432  virtual OSGPrimitive* getOSGPrimitive();
433 
434  virtual void setMass(double mass, bool density = false);
435 
436  // setting the pose is not supported
437  virtual void setPose(const Pose& pose) override {}
438 
439 protected:
444 };
445 
446 /**
447  Dummy Primitive which returns 0 for geom and body.
448  Only useful for representing the static world in terms of primitives
449  or if virtual objects are created, but then the position and speed has
450  to be set manually.
451 */
452 class DummyPrimitive : public Primitive {
453 public:
454 
456  body=0;
457  geom=0;
458  }
459  virtual void init(const OdeHandle& odeHandle, double mass,
460  const OsgHandle& osgHandle, char mode = Body | Geom | Draw) {
461  }
462  virtual void update() {}
463  virtual OSGPrimitive* getOSGPrimitive() { return 0; }
464 
465  virtual void setMass(double mass, bool density = false) {}
466 
467  virtual void setPosition(Pos pos){
468  this->pos=pos;
469  }
470  virtual Pos getPosition() const {
471  return pos;
472  }
473  virtual void setVel(Pos vel){
474  this->vel=vel;
475  }
476  virtual Pos getVel() const {
477  return vel;
478  }
479 
480 private:
481  Pos vel;
482  Pos pos;
483 };
484 
485 
486 }
487 #endif
Box(float lengthX, float lengthY, float lengthZ)
Definition: primitive.cpp:403
float thickness
Definition: primitive.h:365
Capsule primitive.
Definition: primitive.h:308
virtual void setPose(const Pose &pose)
set the pose of the primitive
Definition: primitive.cpp:799
float length
Definition: primitive.h:366
Interface for objects, that can be stored and restored to/from a file stream (binary).
Definition: storeable.h:33
bool substanceManuallySet
Definition: primitive.h:237
virtual void setVel(Pos vel)
Definition: primitive.h:473
int getNumVelocityViolations()
Definition: primitive.h:215
OSGPrimitive * osgprimitive
Definition: primitive.h:367
Data structure for accessing the ODE.
Definition: odehandle.h:44
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:686
Cylinder primitive.
Definition: primitive.h:326
Graphical capsule (a cylinder with round ends)
Definition: osgprimitive.h:198
OSGCapsule * osgcapsule
Definition: primitive.h:322
Physical substance definition, used for collision detection/treatment What we need is mu...
Definition: substance.h:103
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:542
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.cpp:573
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:382
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.cpp:363
static void setDestroyGeomFlag(bool _destroyGeom)
20091023; guettler: hack for tasked simulations; there are some problems if running in parallel mode...
Definition: primitive.h:211
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:664
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.h:463
Pose osgPose(dGeomID geom)
returns the osg (4x4) pose matrix of the ode geom
Definition: primitive.cpp:52
Graphical Mesh or arbitrary OSG model.
Definition: osgprimitive.h:253
Capsule(float radius, float height)
Definition: primitive.cpp:511
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.h:462
osg::Vec3 toGlobal(const osg::Vec3 &pos) const
transforms the given point in local corrds of the primitive to global coordinates ...
Definition: primitive.cpp:307
Graphical box with Textures.
Definition: osgprimitive.h:159
virtual void setPosition(const Pos &pos)
set the position of the primitive (orientation is preserved)
Definition: primitive.cpp:147
Interface class for graphic primitives like spheres, boxes, and meshes, which can be drawn by OSG...
Definition: osgprimitive.h:62
virtual Pos getAngularVel() const
returns the angular velocity
Definition: primitive.cpp:203
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:731
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:415
void decellerate(double factorLin, double factorAng)
applies a force to the body to decellerate its linear and angular velocity with the given factors...
Definition: primitive.cpp:278
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:594
BoundingShape * boundshape
Definition: primitive.h:399
Sphere(float radius)
Definition: primitive.cpp:460
bool deleteChild
Definition: primitive.h:443
Sphere primitive.
Definition: primitive.h:289
dBodyID getBody() const
returns ODE bodyID if there
Definition: primitive.h:177
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:361
Primitive()
Definition: primitive.cpp:82
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.cpp:632
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.cpp:470
Definition: pos.h:36
Data structure for accessing the OpenSceneGraph.
Definition: osghandle.h:79
char mode
Definition: primitive.h:236
virtual ~Box()
Definition: primitive.cpp:411
Substance substance
Definition: primitive.h:232
Definition: primitive.h:89
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:670
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:500
Ray(double range, float thickness, float length)
Definition: primitive.cpp:614
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:468
dBodyID body
Definition: primitive.h:235
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:439
Modes
Body means that it is a dynamic object with a body.
Definition: primitive.h:89
int numVelocityViolations
number of times the maximal velocity was exceeded
Definition: primitive.h:238
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.h:465
virtual ~Mesh()
Definition: primitive.cpp:742
virtual ~Capsule()
Definition: primitive.cpp:515
Definition: primitive.h:91
virtual ~Transform()
destructor deletes child object // it should be virtual by yuichi
Definition: primitive.cpp:681
dGeomID geom
Definition: primitive.h:234
float scale
Definition: primitive.h:398
virtual bool applyTorque(osg::Vec3 torque)
apply a torque (in world coordinates) to the primitive and returns true if it was possible ...
Definition: primitive.cpp:221
osg::Matrix Pose
Definition: pose.h:35
class for reading bounding shape description files (.bbox) and to create appropriate geoms ...
Definition: boundingshape.h:63
Vec3f Vec3
Definition: osgforwarddecl.h:42
void setSubstance(const Substance &substance)
Definition: primitive.cpp:315
Definition: primitive.h:89
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:551
holds texture file and repeat information.
Definition: osgprimitive.h:42
Transform(Primitive *parent, Primitive *child, const Pose &pose, bool deleteChild=true)
Definition: primitive.cpp:677
virtual ~Plane()
Definition: primitive.cpp:357
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:727
int globalNumVelocityViolations
counts number of max velocity violations at joints (Attention, this is a global variable, initialized to 0 at start)
Definition: primitive.cpp:48
Definition: primitive.h:89
Graphical sphere.
Definition: osgprimitive.h:184
Interface class for primitives represented in the physical and graphical world.
Definition: primitive.h:80
virtual ~Ray()
Definition: primitive.cpp:626
virtual bool store(FILE *f) const
stores the object to the given file stream (ASCII preferred).
Definition: primitive.cpp:320
virtual Pos getVel() const
returns the velocity
Definition: primitive.h:476
virtual Pos getPosition() const
returns the position
Definition: primitive.h:470
virtual Pose getPose() const
returns the pose
Definition: primitive.cpp:187
Definition: primitive.h:90
virtual void setMass(double mass, bool density=false)=0
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.h:90
bool limitAngularVel(double maxVel)
checks whether the object has higher velocity than maxVel and limits it in case
Definition: primitive.cpp:261
Pose poseWithoutBodyAndGeom
Definition: primitive.h:400
Primitive * child
Definition: primitive.h:441
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:571
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:841
Definition: color.h:32
Mesh primitive.
Definition: primitive.h:374
Box primitive.
Definition: primitive.h:267
virtual bool applyForce(osg::Vec3 force)
apply a force (in world coordinates) to the primitive and returns true if it was possible ...
Definition: primitive.cpp:209
Ray primitive The actual visual representation can have different length than the ray object...
Definition: primitive.h:347
virtual void setTextures(const std::vector< TextureDescr > &textures)
assign a set of texture to the surfaces of the primitive
Definition: primitive.cpp:142
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.cpp:748
virtual ~Sphere()
Definition: primitive.cpp:464
Primitive * parent
Definition: primitive.h:440
dGeomID getGeom() const
returns ODE geomID if there
Definition: primitive.h:175
virtual ~Primitive()
Definition: primitive.cpp:86
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:491
OSGPlane * osgplane
Definition: primitive.h:262
virtual void setBoundingShape(BoundingShape *boundingShape)
Sets the BoundingShape externally (e.g.
Definition: primitive.cpp:793
Mesh(const std::string &filename, float scale)
Definition: primitive.cpp:737
OSGSphere * osgsphere
Definition: primitive.h:304
virtual void setPosition(Pos pos)
Definition: primitive.h:467
virtual void setPose(const Pose &pose)
set the pose of the primitive
Definition: primitive.cpp:156
virtual void update()=0
Updates the OSG nodes with ODE coordinates.
osg::Vec3 toLocal(const osg::Vec3 &pos) const
return the given point transformed to local coordinates of the primitive
Definition: primitive.cpp:293
static bool destroyGeom
Definition: primitive.h:243
virtual Pos getVel() const
returns the velocity
Definition: primitive.cpp:197
virtual ~Cylinder()
Definition: primitive.cpp:567
virtual void setColor(const Color &color)
sets the color for the underlaying osgprimitive
Definition: primitive.cpp:116
virtual bool restore(FILE *f)
loads the object from the given file stream (ASCII preferred).
Definition: primitive.cpp:332
void setLength(float len)
Definition: primitive.cpp:648
virtual void update()
Updates the OSG nodes with ODE coordinates.
Definition: primitive.cpp:826
virtual void setPose(const Pose &pose) override
set the pose of the primitive
Definition: primitive.h:437
Plane primitive.
Definition: primitive.h:248
Cylinder(float radius, float height)
Definition: primitive.cpp:563
DummyPrimitive()
Definition: primitive.h:455
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:391
Definition: primitive.h:91
Vec4f Vec4
Definition: osgforwarddecl.h:44
virtual Pos getPosition() const
returns the position
Definition: primitive.cpp:181
Graphical cylinder.
Definition: osgprimitive.h:215
Primitive for transforming a geom (primitive without body) in respect to a body (primitive with body)...
Definition: primitive.h:410
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.cpp:521
Plane()
Definition: primitive.cpp:353
bool limitLinearVel(double maxVel)
checks whether the object has higher velocity than maxVel and limits it in case
Definition: primitive.cpp:245
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
initialised the transform object.
Definition: primitive.cpp:688
virtual void setTexture(const std::string &filename)
assigns a texture to the primitive
Definition: primitive.cpp:127
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)=0
registers primitive in ODE and OSG.
OSGBoxTex * osgbox
Definition: primitive.h:284
Pose pose
Definition: primitive.h:442
Dummy Primitive which returns 0 for geom and body.
Definition: primitive.h:452
Graphical plane (represented as a large thin box, because OSG does not draw planes) ...
Definition: osgprimitive.h:130
virtual float getRadius()
Definition: primitive.cpp:824
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:448
const std::string filename
Definition: primitive.h:397
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:746
Definition: primitive.h:89
void odeRotation(const Pose &pose, dMatrix3 &odematrix)
converts the rotation component of pose into an ode rotation matrix
Definition: primitive.cpp:70
virtual OSGPrimitive * getOSGPrimitive()=0
returns the assoziated osg primitive if there or 0
double range
Definition: primitive.h:364
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:630
Category
Definition: primitive.h:91
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.cpp:417
virtual void attachGeomAndSetColliderFlags()
attaches geom to body (if any) and sets the category bits and collision bitfields.
Definition: primitive.cpp:97
virtual OSGPrimitive * getOSGPrimitive()
returns the assoziated osg primitive if there or 0
Definition: primitive.cpp:519
OSGCylinder * osgcylinder
Definition: primitive.h:339
virtual void init(const OdeHandle &odeHandle, double mass, const OsgHandle &osgHandle, char mode=Body|Geom|Draw)
registers primitive in ODE and OSG.
Definition: primitive.h:459
virtual void setMass(double mass, bool density=false)
sets the mass of the body (uniform) if density==true then mass is interpreted as a density ...
Definition: primitive.cpp:603
OSGMesh * osgmesh
Definition: primitive.h:396