AGX Dynamics  2.37.2.0
agxSDK/SimulationObject.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXSDK_SIMULATIONOBJECT_H
18 #define AGXSDK_SIMULATIONOBJECT_H
19 
20 #include <agx/agxPhysics_export.h>
21 
22 #include <agxCollide/Geometry.h>
23 #include <agx/RigidBody.h>
24 
25 namespace agxSDK {
26  class Simulation;
27 }
28 
29 
30 namespace agxSDK
31 {
32 
33 
40  {
41  public:
42 
44  SimulationObject( agxCollide::Geometry *geom, agx::RigidBody *body ) : m_geometry( geom ), m_body( body ) {}
45 
47  //explicit SimulationObject( agxCollide::GeometryRef geom, agx::RigidBodyRef body ) : m_geometry( geom ), m_body( body ) {}
48 
49  explicit SimulationObject( ) {}
50 
53  m_geometry = copy.m_geometry;
54  m_body = copy.m_body;
55  }
56 
57 
58  SimulationObject& operator= (const SimulationObject& copy )
59  {
60  if (this == &copy)
61  return *this;
62 
63  m_geometry = copy.m_geometry;
64  m_body = copy.m_body;
65  return *this;
66  }
67 
69 
71  agxCollide::Geometry *getGeometry() { return m_geometry.get(); }
72  void setGeometry( agxCollide::Geometry *geom ) { m_geometry = geom; }
73 
75  agx::RigidBody *getRigidBody() { return m_body.get(); }
76  void setRigidBody( agx::RigidBody * body ) { m_body = body; }
77 
79  operator agx::RigidBody *() { return m_body.get(); }
81  operator agxCollide::Geometry *() { return m_geometry.get(); }
83  operator const agx::RigidBody *() const { return m_body.get(); }
85  operator const agxCollide::Geometry *() const { return m_geometry.get(); }
86 
87 
88  // / \return true if obj contains the same geometry and body as this object.
89  // virtual bool operator ==(const SimulationObject& obj)
90  // {
91  // return ( m_geometry.get() == obj.m_geometry.get() && m_body.get() == obj.m_body.get());
92  // }
93 
94 
115  static SimulationObject createBox( const agx::String& name,
117  const agx::Vec3& halfExtent,
118  agxSDK::Simulation* simulation,
120  bool createGeometry=true,
121  bool createBody = true
122  );
123 
124 
146  static SimulationObject createCylinder( const agx::String& name,
147  const agx::AffineMatrix4x4& transform,
148  agx::Real radius, agx::Real height,
149  agxSDK::Simulation* simulation,
151  bool createGeometry=true,
152  bool createBody=true
153  );
154 
175  static SimulationObject createSphere( const agx::String& name,
176  const agx::AffineMatrix4x4& transform,
177  agx::Real radius,
178  agxSDK::Simulation* simulation,
180  bool createGeometry=true,
181  bool createBody=true
182  );
183 
184 
206  static SimulationObject createPlane( const agx::String& name,
207  const agx::AffineMatrix4x4& transform,
208  agxSDK::Simulation* simulation,
210  bool createGeometry=true,
211  bool createBody=false
212  );
213 
238  static SimulationObject createHeightField( const agx::String& name,
239  const agx::AffineMatrix4x4& transform,
240  const agx::String& filename, const agx::Real& sizeX, const agx::Real& sizeY,
241  const agx::Real& low, const agx::Real& high,
242  agxSDK::Simulation* simulation,
244  bool createGeometry=true,
245  bool createBody=false
246  );
247 
275  static SimulationObject createHeightField( const agx::String& name,
276  const agx::AffineMatrix4x4& transform,
277  const agx::RealVector& heights,
278  size_t resolutionX,
279  size_t resolutionY,
280  agx::Real sizeX,
281  agx::Real sizeY,
282  agx::Real bottomMargin,
283  agxSDK::Simulation* simulation,
285  bool createGeometry=true,
286  bool createBody=false
287  );
288 
310  static SimulationObject createCapsule( const agx::String& name,
311  const agx::AffineMatrix4x4& transform,
312  agx::Real radius, agx::Real height,
313  agxSDK::Simulation* simulation,
315  bool createGeometry=true,
316  bool createBody=true
317  );
318 
339  static SimulationObject createTrimesh( const agx::String& name,
340  const agx::AffineMatrix4x4& transform,
341  const agx::String& filename,
342  agxSDK::Simulation* simulation,
344  bool createGeometry=true,
345  bool createBody=true
346  );
347 
348 
369  static SimulationObject createTrimesh( const agx::String& name,
370  const agx::AffineMatrix4x4& transform,
371  agxCollide::Shape* cloneTrimesh,
372  agxSDK::Simulation* simulation,
374  bool createGeometry=true,
375  bool createBody=true
376  );
377 
399  static SimulationObject createTrimesh( const agx::String& name,
400  const agx::AffineMatrix4x4& transform,
401  const agx::String& filename,
402  agx::Real bottomMargin,
403  agxSDK::Simulation* simulation,
405  bool createGeometry=true,
406  bool createBody=true
407  );
408 
409 
410  protected:
413  };
414 
415 }
416 
417 
418 
419 #endif
420 
void setGeometry(agxCollide::Geometry *geom)
void setRigidBody(agx::RigidBody *body)
Base class for a shape.
Definition: Shape.h:53
This body will never move.
Definition: RigidBody.h:67
Deprecated, used only for internal examples*.
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
#define AGXPHYSICS_EXPORT
AGXOSG_EXPORT agxCollide::Trimesh * createTrimesh(osg::Node *node)
Extracts mesh data from an osg::Node, creates an agxCollide::Trimesh from it and returns the result...
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
SimulationObject(agxCollide::Geometry *geom, agx::RigidBody *body)
Constructor for a SimulationObject that will store a reference to a Geometry and a RigidBody...
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
This body moves from the influence of forces.
Definition: RigidBody.h:69
agxCollide::Geometry * getGeometry()
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:126
agxCollide::GeometryRef m_geometry
double Real
Definition: Real.h:42
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
Definition: RigidBody.h:65
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
SimulationObject(const SimulationObject &copy)
Copy constructor.
SimulationObject()
Constructor for a SimulationObject that will store a reference to a Geometry and a RigidBody...