AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
agxOSG/SimulationObject.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGXOSG_SIMULATIONOBJECT_H
18#define AGXOSG_SIMULATIONOBJECT_H
19
20#include <agxOSG/export.h>
21
22#include <agx/observer_ptr.h>
23
24#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
25#include <osg/Node>
26#include <agx/PopDisableWarnings.h> // End of disabled warnings.
27
29#include <agx/Bound.h>
30#include <agx/Material.h>
31
32#define DEFAULT_DETAIL_RATIO 1.0f
33
35
36
37namespace agxCollide {
38 class Geometry;
39 class Trimesh;
40}
41
42namespace agx {
43 class RigidBody;
44}
45
46namespace osg {
47 class Geode;
48}
49
50
51namespace agxOSG
52{
53
54
55
56
66 class AGXOSG_EXPORT SimulationObject : public agxSDK::SimulationObject
67 {
68 public:
70 explicit SimulationObject( agxCollide::Geometry *geom, agx::RigidBody *body, osg::Node *node=nullptr ) : agxSDK::SimulationObject( geom, body), m_node( node )
71 {
72 // LOGGER_WARNING() << "SimulationObject( agxCollide::" << std::endl << LOGGER_END();
73 }
74 explicit SimulationObject( ) {
75 // LOGGER_WARNING() << "SimulationObject()" << std::endl << LOGGER_END();
76 }
77
79
80 ~SimulationObject() {
81 // LOGGER_WARNING() << "~SimulationObject()" << std::endl << LOGGER_END();
82 }
83
85 SimulationObject( const SimulationObject& copy) : agxSDK::SimulationObject( copy ) {
86 m_node = copy.m_node;
87 // LOGGER_WARNING() << "SimulationObject( const SimulationObject& copy) " << std::endl << LOGGER_END();
88 }
89
90 SimulationObject& operator= (const SimulationObject& copy )
91 {
92 if (this == &copy)
93 return *this;
94
95
96 this->m_geometry = copy.m_geometry;
97 this->m_body = copy.m_body;
98 m_node = copy.m_node;
99
100 return *this;
101 }
102
103
104 osg::Node *getNode() { return m_node.get(); }
105
107 operator const osg::Node *() const { return m_node.get(); }
109 operator osg::Node *() { return m_node.get(); }
110
111 // virtual bool operator ==(const SimulationObject& obj)
112 // {
113 // return ( m_geometry.get() == obj.m_geometry.get() && m_body.get() == obj.m_body.get() && m_node.get() == obj.m_node.get());
114 // }
115
140 static SimulationObject createBox( const agx::String& name,
141 const agx::AffineMatrix4x4& transform,
142 const agx::Vec3& halfExtent,
143 osg::Group *root,
144 agxSDK::Simulation* simulation,
146 bool createGeometry=true,
147 bool createBody=true,
148 bool addAxes=false
149 );
150
151
177 static SimulationObject createPlane( const agx::String& name,
178 const agx::AffineMatrix4x4& transform,
179 osg::Group *root,
180 agxSDK::Simulation* simulation=nullptr,
182 bool createGeometry=true,
183 bool createBody=true
184 );
185
214 static SimulationObject createHeightField( const agx::String& name,
215 const agx::AffineMatrix4x4& transform,
216 const agx::String& filename, const agx::Real& sizeX, const agx::Real& sizeY,
217 const agx::Real& low, const agx::Real& high,
218 osg::Group *root,
219 agxSDK::Simulation* simulation=nullptr,
221 bool createGeometry=true,
222 bool createBody=true
223 );
224
256 static SimulationObject createHeightField( const agx::String& name,
257 const agx::AffineMatrix4x4& transform,
258 const agx::RealVector& heights,
259 size_t resolutionX,
260 size_t resolutionY,
261 agx::Real sizeX,
262 agx::Real sizeY,
263 agx::Real bottomMargin,
264 osg::Group *root,
265 agxSDK::Simulation* simulation=nullptr,
267 bool createGeometry=true,
268 bool createBody=true
269 );
270
271
272
299 static SimulationObject createCylinder( const agx::String& name,
300 const agx::AffineMatrix4x4& transform,
301 agx::Real radius, agx::Real height,
302 osg::Group *root,
303 agxSDK::Simulation* simulation=nullptr,
305 bool createGeometry=true,
306 bool createBody=true,
307 bool addAxes=false
308 );
309
335 static SimulationObject createCapsule( const agx::String& name,
336 const agx::AffineMatrix4x4& transform,
337 agx::Real radius, agx::Real height,
338 osg::Group *root,
339 agxSDK::Simulation* simulation=nullptr,
341 bool createGeometry=true,
342 bool createBody=true
343 );
344
345
370 static SimulationObject createSphere( const agx::String& name,
371 const agx::AffineMatrix4x4& transform,
372 agx::Real radius,
373 osg::Group *root,
374 agxSDK::Simulation* simulation=nullptr,
376 bool createGeometry=true,
377 bool createBody=true
378 );
379
405 static SimulationObject createTrimesh( const agx::String& name,
406 const agx::AffineMatrix4x4& transform,
407 const agx::String& filename,
408 osg::Group *root,
409 agxSDK::Simulation* simulation=nullptr,
411 bool createGeometry=true,
412 bool createBody=true
413 );
414
439 static SimulationObject createTrimesh( const agx::String& name,
440 const agx::AffineMatrix4x4& transform,
441 agxCollide::Trimesh* cloneTrimesh,
442 osg::Group *root,
443 agxSDK::Simulation* simulation=nullptr,
445 bool createGeometry=true,
446 bool createBody=true
447 );
448
449
475 static SimulationObject createTrimesh( const agx::String& name,
476 const agx::AffineMatrix4x4& transform,
477 const agx::String& filename,
478 agx::Real bottomMargin,
479 osg::Group *root,
480 agxSDK::Simulation* simulation=nullptr,
482 bool createGeometry=true,
483 bool createBody=true
484 );
485
486
487 // static agx::ParticleSystem *createParticleSystem(const agx::String& name, osg::Group *root, agxSDK::Simulation* simulation=nullptr);
488
489 protected:
490 osg::ref_ptr<osg::Node> m_node;
491 };
492
493
494 AGXOSG_EXPORT agx::RigidBody *buildContainer(const agx::Bound3& bound, agx::Real thickness, agxSDK::Simulation* simulation, osg::Group *root, bool addCeiling = false, agx::Material *material = agx::Material::getDefaultMaterial(), osg::Vec4 color = osg::Vec4(0, 1, 0, 0.1f));
495
496 // Create a osg Geode from a specified shape
497 AGXOSG_EXPORT osg::Geode* createGeode( osg::Shape *shape, const agx::String& name, float detailRatio = DEFAULT_DETAIL_RATIO );
498
499}
500
502
503#endif /* _AGXOSG_SIMULATIONOBJECT_H_ */
#define DEFAULT_DETAIL_RATIO
#define AGXOSG_EXPORT
The geometry representation used by the collision detection engine.
Definition: Geometry.h:92
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:40
Deprecated, used only for internal examples*.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition: Simulation.h:131
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:378
static Material * getDefaultMaterial()
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:49
MotionControl
The MotionControl enumeration indicates what makes a RigidBody move.
Definition: RigidBody.h:60
@ STATIC
This body will never move.
Definition: RigidBody.h:61
@ DYNAMICS
This body moves from the influence of forces.
Definition: RigidBody.h:63
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
This namespace consists of a set of classes for handling geometric intersection tests including boole...
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
AGXOSG_EXPORT osg::Geode * createSphere(const agx::Vec3 &center, const agx::Vec4 &color, float radius)
Create and return a new Sphere to render.
AGXOSG_EXPORT osg::MatrixTransform * createCylinder(const agx::AffineMatrix4x4 &transform, const agx::Vec4 &color, float radius, float height)
Create and return a new Cylinder to render.
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 agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:31
const Node * getNode(const IteratorCompatibleContainer &container, agx::Real distanceFromStart)
Finds the wire node given current distance from the start of the wire (wire defined to be iterator co...
Definition: WireUtils.h:392
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:41