AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
agxOSG/RenderProxyFactory.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#pragma once
18
19#include <agxOSG/export.h>
22
23#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
24#include <osg/ref_ptr>
25#include <osg/Group>
26#include <osg/MatrixTransform>
27#include <osg/Material>
28#include <osg/AutoTransform>
29#include <osg/Shape>
30#include <osg/ShapeDrawable>
31#include <osgText/Text>
32#include <agx/PopDisableWarnings.h> // End of disabled warnings.
33
35#include <agxOSG/RenderText.h>
36#include <agxOSG/utils.h>
38
39#ifdef _MSC_VER
40# pragma warning(push)
41# pragma warning( disable : 4355 ) // warning C4355: 'this' : used in base member initializer list
42#endif
43
44namespace agxOSG
45{
46
47 class SphereProxy;
48 class LineProxy;
49
51
64 {
65 public:
69 static void setCurrentDetailRatio(float detailRatio);
70
74 static float getCurrentDetailRatio();
75
79 static float getDefaultDetailRatio();
80
81 public:
83
88
89
94 agxRender::SphereProxy* createSphere(float radius) override;
95
101
108 agxRender::TextProxy* createText(const agx::String& text, const agx::Vec3& pos, float size = 1) override;
109
114 agxRender::LineProxy* createLine(const agx::Vec3& p1, const agx::Vec3& p2) override;
115
121
127 agxRender::CylinderProxy* createCylinder(float radius, float height) override;
128
134
141 agxRender::HollowCylinderProxy* createHollowCylinder(float outerRadius, float height, float thickness) override;
142
148
154 agxRender::CapsuleProxy* createCapsule(float radius, float height) override;
155
161
169 agxRender::WireShapeProxy* createWireShape(float radius, float height,
170 const agx::Vec3& previousEndPoint0, const agx::Vec3& previousEndPoint1) override;
171
176 agxRender::BoxProxy* createBox(const agx::Vec3& halfExtents) override;
177
183
189
195
201 agxRender::ConeProxy* createCone(float radius, float height) override;
202
208
215 agxRender::TruncatedConeProxy* createTruncatedCone(float topRadius, float bottomRadius, float height) override;
216
224 agxRender::HollowConeProxy* createHollowCone(float topRadius, float bottomRadius, float height, float thickness) override;
225
231
237 agxRender::PlaneProxy* createPlane(const agx::Vec3& normal, agx::Real distance) override;
238
244
250
252
253 agxRender::WireRenderProxy* createWire(float radius, const agx::Vec3& color) override;
254
255
258 agxData::Buffer* positions, agxData::Buffer* rotations, agxData::Buffer* radii, agxData::Buffer* colors,
259 agxData::Buffer* enableRendering, agxData::Value* bound, agx::Component* context) override;
260
266 osg::Group* getTextNode() { return m_textParent.get(); }
267
272 osg::Node* getRootNode() { return m_parent; }
273
277 osg::Group* getSolidRootNode() { return m_solidParent; }
278
282 osg::Group* getWireframeRootNode() { return m_wireframeParent; }
283
292
296 const agx::AffineMatrix4x4& getGlobalTransform() const { return m_invTransform; }
297
302
303
304 static osg::Geode* createGeode(osg::Shape* shape, osg::ShapeDrawable** shapeDrawable = nullptr, float detailRatio = RenderProxyFactory::getDefaultDetailRatio());
305
306 public:
308 template<typename T>
309 struct ShapeData {
310 ShapeData() : material(nullptr) {}
311 ShapeData(const ShapeData& other)
312 {
313 shape = other.shape;
314 geode = other.geode;
315 material = other.material;
316 stateSet = other.stateSet;
317 }
318
319 osg::ref_ptr<T> shape;
320 osg::ref_ptr<osg::Geode> geode;
321 osg::Material* material;
322 osg::ref_ptr<osg::StateSet> stateSet;
323 };
324
325
330 void addChild(osg::Node* node, agxRender::RenderProxy::RenderMode mode);
331 void addChild(osg::Node* node, agxRender::RenderProxy* proxy);
332
333 protected:
336
337 osg::ref_ptr<osg::Group> m_solidParent;
338 osg::ref_ptr<osg::Group> m_wireframeParent;
339 osg::ref_ptr<osg::Group> m_parent;
340 osg::ref_ptr<osg::Group> m_textParent;
344 };
345
346}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXOSG_EXPORT
A box shape for geometric intersection tests.
Definition: Box.h:33
Implements a Capsule shape for geometric intersection tests.
Definition: Capsule.h:35
A right circular cone shape for geometric intersection tests.
Definition: Cone.h:49
A cylinder shape for geometric intersection tests.
Definition: Cylinder.h:35
A HeightField is a collision shape that can be created from a grid structure, like an image.
A right circular hollow cone shape for geometric intersection tests.
Definition: HollowCone.h:46
A hollow cylinder shape for geometric intersection tests.
A line shape for intersection tests, mostly for depth sensing and picking.
A sphere class for geometric intersection tests.
Definition: Sphere.h:32
Triangle mesh for geometric intersection tests.
Definition: Trimesh.h:40
Abstract representation of a data buffer.
Definition: Buffer.h:56
Abstract representation of a value.
Definition: Value.h:49
Implementation of the abstract class from the agxRender namespace, this class is responsible for crea...
osg::Group * getTextNode()
The text node is not child of the node returned in getRootNode(), hence this node MUST be added separ...
static float getDefaultDetailRatio()
osg::ref_ptr< osg::Group > m_parent
agxRender::ContactsProxy * createContacts(const agxCollide::GeometryContactPtrVector &contacts) override
agxRender::RigidBodyBatchRenderProxy * createRigidBodies(const agx::RigidBodyPtrSetVector *enabledBodies) override
Interface for creating and returning batch rendering of rigid bodies (cm).
agxRender::HollowConeProxy * createHollowCone(agxCollide::HollowCone *shape) override
agxRender::HollowCylinderProxy * createHollowCylinder(float outerRadius, float height, float thickness) override
agxRender::WireShapeProxy * createWireShape(float radius, float height, const agx::Vec3 &previousEndPoint0, const agx::Vec3 &previousEndPoint1) override
agxRender::CylinderProxy * createCylinder(agxCollide::Cylinder *shape) override
void setRenderMode(agxRender::RenderProxy *proxy, osg::Node *node, agxRender::RenderProxy::RenderMode mode)
Set the RenderMode for a specified node.
agxRender::LineProxy * createLine(agxCollide::Line *shape) override
void addChild(osg::Node *node, agxRender::RenderProxy::RenderMode mode)
Add a child to the root, default getDefaultRenderMode() will be used for determining if the node shou...
agxRender::TextProxy * createText(const agx::String &text, const agx::Vec3 &pos, float size=1) override
agxRender::CapsuleProxy * createCapsule(float radius, float height) override
agxRender::LineProxy * createLine(const agx::Vec3 &p1, const agx::Vec3 &p2) override
agxRender::Graph::GraphRenderer * getGraphRenderer() override
agxRender::PlaneProxy * createPlane(agxCollide::Plane *shape) override
void setGlobalTransform(const agx::AffineMatrix4x4 &m) override
Set a transformation which will be applied to all transformations for RenderProxy's.
agxRender::RenderProxy * createSphereBatchRenderer(agxData::Buffer *positions, agxData::Buffer *rotations, agxData::Buffer *radii, agxData::Buffer *colors, agxData::Buffer *enableRendering, agxData::Value *bound, agx::Component *context) override
agxRender::SphereProxy * createSphere(float radius) override
agxRender::HollowCylinderProxy * createHollowCylinder(agxCollide::HollowCylinder *shape) override
const agx::AffineMatrix4x4 & getGlobalTransform() const
agxRender::TruncatedConeProxy * createCone(agxCollide::Cone *shape) override
agxRender::HollowConeProxy * createHollowCone(float topRadius, float bottomRadius, float height, float thickness) override
agxRender::PlaneProxy * createPlane(const agx::Vec3 &normal, agx::Real distance) override
osg::ref_ptr< osg::Group > m_solidParent
agxRender::TruncatedConeProxy * createTruncatedCone(float topRadius, float bottomRadius, float height) override
agxRender::CylinderProxy * createCylinder(float radius, float height) override
virtual ~RenderProxyFactory()
Destructor.
static float getCurrentDetailRatio()
agxRender::HeightFieldProxy * createHeightfield(agxCollide::HeightField *shape) override
Create and return a RenderProxy for a Heightfield.
agx::ref_ptr< agxOSG::GraphRenderer > m_graphRenderer
static osg::Geode * createGeode(osg::Shape *shape, osg::ShapeDrawable **shapeDrawable=nullptr, float detailRatio=RenderProxyFactory::getDefaultDetailRatio())
agxRender::TrimeshProxy * createTrimesh(agxCollide::Trimesh *shape) override
Create and return a RenderProxy for a Trimesh.
agxRender::BoxProxy * createBox(const agx::Vec3 &halfExtents) override
void setSphereBatchRenderModeSprites(bool flag)
static void setCurrentDetailRatio(float detailRatio)
Set new detail ratio for the rendered geometries.
agxRender::BoxProxy * createBox(agxCollide::Box *shape) override
agxRender::CapsuleProxy * createCapsule(agxCollide::Capsule *shape) override
osg::ref_ptr< osg::Group > m_textParent
agxRender::SphereProxy * createSphere(agxCollide::Sphere *shape) override
agxRender::WireRenderProxy * createWire(float radius, const agx::Vec3 &color) override
void addChild(osg::Node *node, agxRender::RenderProxy *proxy)
osg::ref_ptr< osg::Group > m_wireframeParent
agxRender::ConeProxy * createCone(float radius, float height) override
Subclass that implements a BoxProxy.
Subclass that implements a CapsuleProxy.
Subclass that implements a ConeProxy.
Class holding contacts that makes it possible to batch render these objects.
Subclass that implements a CylinderProxy.
Abstract base class that acts as an interface and can render the data from a Graph.
Definition: Graph.h:45
Subclass that implements a HeightfieldProxy.
Subclass that implements a HollowConeProxy.
Subclass that implements a CylinderProxy.
Subclass that implements a LineProxy.
Subclass that implements a PlaneProxy.
Abstract class which is responsible for returning a pointer to a specified RenderProxy type.
Abstract base class which encapsulated information for rendering a specific shape.
Class holding rigid bodies that makes it possible to batch render these objects.
Subclass that implements a SphereProxy.
Subclass that implements a TextProxy.
Subclass that implements a TrimeshProxy.
Subclass that implements a TruncatedConeProxy.
Subclass that implements a WireShapeProxy.
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
double Real
Definition: Real.h:41
Class for storing OSG specific data for each RenderProxy.