AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
RenderSingleton.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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 AGXRENDER_RENDERERSINGLETON_H
18#define AGXRENDER_RENDERERSINGLETON_H
19
20#ifdef _MSC_VER
21# pragma warning(push)
22# pragma warning( disable : 4251 )
23// warning C4251: 'X' : class 'Y' needs to have dll-interface to be used by clients of class 'Z'
24#endif
25
27#include <agx/Singleton.h>
28#include <agx/Vec4.h>
29#include <agx/AffineMatrix4x4.h>
30
31#include <agxRender/Color.h>
32
33// Forward declarations
34namespace agx
35{
36 class Constraint;
37 class ConstraintImplementation;
38}
39
40namespace agxSDK
41{
42 class Simulation;
43}
44
45namespace agxRender
46{
47 class RenderManager;
48
49 AGXPHYSICS_EXPORT void debugRenderFrame( const agx::AffineMatrix4x4& transform, float scale, const agx::Vec4f& colorIdentifier, agxRender::RenderManager* mgr = nullptr );
50 AGXPHYSICS_EXPORT void debugRenderConstraintFrames( const agx::Constraint* constraint, float scale, agxRender::RenderManager* mgr = nullptr, agx::Bool overrideInvalid = false );
51 AGXPHYSICS_EXPORT void debugRenderConstraintFrames( const agx::ConstraintImplementation* constraint, float scale, agxRender::RenderManager* mgr = nullptr, agx::Bool overrideInvalid = false );
52
55 {
56 public:
57
60
62 static bool isInitialized();
63
66
69
71 void clearAll();
72
75
78 {
79 public:
80 Point() {}
81 Point( const agx::Vec3& position, agx::Real size = agx::Real(0.4), const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
82 : m_position( position ), m_size( size ), m_color( color ) {}
83
85 return m_position;
86 }
88 return m_size;
89 }
91 return m_color;
92 }
93
94 private:
95 agx::Vec3 m_position;
97 agx::Vec4f m_color;
98 };
99
102 {
103 public:
104 Line() {}
105 Line( const agx::Vec3& start, const agx::Vec3& end, agx::Real size = 0.02f, const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
106 : m_start( start ), m_end( end ), m_size( size ), m_color( color ) {}
107
109 return m_start;
110 }
112 return m_end;
113 }
115 return m_size;
116 }
118 return m_color;
119 }
120
121 private:
122 agx::Vec3 m_start;
123 agx::Vec3 m_end;
125 agx::Vec4f m_color;
126 };
127
130 {
131 public:
132 Text() {}
133 Text( const agx::String& text, const agx::Vec2& position, const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
134 : m_text( text ), m_position( position ), m_color( color ) {}
135
137 return m_text;
138 }
140 return m_position;
141 }
143 return m_color;
144 }
145
146 private:
147 agx::String m_text;
148 agx::Vec2 m_position;
149 agx::Vec4f m_color;
150 };
151
152
155 {
156 public:
158 Triangle( const agx::Vec3& v0, const agx::Vec3& v1, const agx::Vec3& v2, agx::Real size = 0.02f, const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
159 : m_v0( v0 ), m_v1( v1 ), m_v2( v2 ), m_size(size), m_color( color ) {}
160
162 return m_color;
163 }
164
166 return m_v0;
167 }
169 return m_v1;
170 }
172 return m_v2;
173 }
175 return m_size;
176 }
177
178 private:
179 agx::Vec3 m_v0;
180 agx::Vec3 m_v1;
181 agx::Vec3 m_v2;
183 agx::Vec4f m_color;
184 };
185
187 {
188 public:
189 Frame() {}
190 Frame( const agx::AffineMatrix4x4& frame, agx::Real scale = agx::Real( 0.5 ), const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) ) : m_frame( frame ), m_scale( scale ), m_color( color ) {}
191
192 const agx::AffineMatrix4x4& getFrame() const { return m_frame; }
193 agx::Real getScale() const { return m_scale; }
194 agx::Vec4f getColor() const { return m_color; }
195
196 private:
197 agx::AffineMatrix4x4 m_frame;
198 agx::Real m_scale;
199 agx::Vec4f m_color;
200 };
201
205 void add( const Point& point );
209 void add( const agx::Vec3& position, agx::Real size, const agx::Vec4f& color ) {
210 add( Point( position, size, color ) );
211 }
215 void addStatic( const Point& point );
219 void addStatic( const agx::Vec3& position, agx::Real size, const agx::Vec4f& color ) {
220 addStatic( Point( position, size, color ) );
221 }
222
226 void add( const Line& line );
230 void add( const agx::Vec3& start, const agx::Vec3& end, agx::Real size, const agx::Vec4f& color ) {
231 add( Line( start, end, size, color ) );
232 }
236 void addStatic( const Line& line );
240 void addStatic( const agx::Vec3& start, const agx::Vec3& end, agx::Real size, const agx::Vec4f& color ) {
241 addStatic( Line( start, end, size, color ) );
242 }
243
247 void add( const Text& text );
251 void add( const agx::String& text, const agx::Vec2& position, const agx::Vec4f& color ) {
252 add( Text( text, position, color ) );
253 }
257 void addStatic( const Text& text );
261 void addStatic( const agx::String& text, const agx::Vec2& position, const agx::Vec4f& color ) {
262 addStatic( Text( text, position, color ) );
263 }
264
268 void add(const Triangle& triangle);
272 void add(const agx::Vec3& v0, const agx::Vec3& v1, const agx::Vec3& v2, const agx::Real size, const agx::Vec4f& color) {
273 add(Triangle(v0, v1, v2, size, color));
274 }
278 void addStatic( const Triangle& triangle);
282 void addStatic(const agx::Vec3& v0, const agx::Vec3& v1, const agx::Vec3& v2, const agx::Real size, const agx::Vec4f& color) {
283 addStatic(Triangle(v0, v1, v2, size, color));
284 }
285
289 void add( const agx::AffineMatrix4x4& frame, agx::Real scale, const agx::Vec4f& color );
290
294 void addStatic( const agx::AffineMatrix4x4& frame, agx::Real scale, const agx::Vec4f& color );
295
296 SINGLETON_CLASSNAME_METHOD();
297
298 protected:
300 virtual void shutdown() override;
301
302 private:
303 static RenderSingleton* s_instance;
304 agx::Vector< Point > m_staticPoints;
305 agx::Vector< Point > m_points;
306 agx::Vector< Line > m_staticLines;
307 agx::Vector< Line > m_lines;
308 agx::Vector< Text > m_staticText;
309 agx::Vector< Text > m_text;
310 agx::Vector< Triangle > m_staticTriangles;
311 agx::Vector< Triangle > m_triangles;
312 agx::Vector< Frame > m_staticFrames;
313 agx::Vector< Frame > m_frames;
314 };
315}
316
317#ifdef _MSC_VER
318# pragma warning(pop)
319#endif
320
321#endif
#define AGXPHYSICS_EXPORT
#define m_size
Definition agx/Vector.h:429
Class for managing the rendering of geometries, shapes, rigid bodies, constraints etc.
const agx::AffineMatrix4x4 & getFrame() const
Frame(const agx::AffineMatrix4x4 &frame, agx::Real scale=agx::Real(0.5), const agx::Vec4f &color=agx::Vec4f(1, 1, 1, 1))
Defines a Line to be used in DebugRendering.
Line(const agx::Vec3 &start, const agx::Vec3 &end, agx::Real size=0.02f, const agx::Vec4f &color=agx::Vec4f(1, 1, 1, 1))
Defines a point to be used in DebugRendering.
Point(const agx::Vec3 &position, agx::Real size=agx::Real(0.4), const agx::Vec4f &color=agx::Vec4f(1, 1, 1, 1))
Defines Text to be used in DebugRendering.
Text(const agx::String &text, const agx::Vec2 &position, const agx::Vec4f &color=agx::Vec4f(1, 1, 1, 1))
Defines a Triangle to be used in DebugRendering.
Triangle(const agx::Vec3 &v0, const agx::Vec3 &v1, const agx::Vec3 &v2, agx::Real size=0.02f, const agx::Vec4f &color=agx::Vec4f(1, 1, 1, 1))
Utility class for creating debug rendering objects.
void clearAll()
Clear everything.
void add(const agx::String &text, const agx::Vec2 &position, const agx::Vec4f &color)
Add temporary text.
void addStatic(const agx::String &text, const agx::Vec2 &position, const agx::Vec4f &color)
Add static text.
void add(const Text &text)
Add temporary text.
void add(const Triangle &triangle)
Add temporary triangle.
void addStatic(const Triangle &triangle)
Add static triangle.
void add(const Line &line)
Add temporary line (cylinder)
void addStatic(const agx::AffineMatrix4x4 &frame, agx::Real scale, const agx::Vec4f &color)
Add static frame.
void add(const agx::Vec3 &position, agx::Real size, const agx::Vec4f &color)
Add temporary point (sphere).
void addStatic(const Text &text)
Add static text.
void addStatic(const agx::Vec3 &v0, const agx::Vec3 &v1, const agx::Vec3 &v2, const agx::Real size, const agx::Vec4f &color)
Add static triangle.
void addStatic(const Point &point)
Add static point (sphere).
void add(const agx::Vec3 &v0, const agx::Vec3 &v1, const agx::Vec3 &v2, const agx::Real size, const agx::Vec4f &color)
Add temporary triangle.
virtual void shutdown() override
Implement this method to cleanup your Singleton class.
static RenderSingleton * instance()
void clearStatics()
Clear statistics.
void add(const Point &point)
Add temporary point (sphere).
void add(const agx::Vec3 &start, const agx::Vec3 &end, agx::Real size, const agx::Vec4f &color)
Add temporary line (cylinder)
void addStatic(const agx::Vec3 &start, const agx::Vec3 &end, agx::Real size, const agx::Vec4f &color)
Add static line (cylinder)
void addStatic(const Line &line)
Add static line (cylinder)
void add(const agx::AffineMatrix4x4 &frame, agx::Real scale, const agx::Vec4f &color)
Add temporary frame.
void clearTemporaries()
Clear the list of temporary RenderProxies.
void render(agxRender::RenderManager *mgr)
Called by Simulation to update the debug rendering.
void addStatic(const agx::Vec3 &position, agx::Real size, const agx::Vec4f &color)
Add static point (sphere).
The base class for a constraint.
Definition Constraint.h:89
Base class for Singletons that should have its shutdown called explicitly before exit of the applicat...
Definition Singleton.h:31
A class holding 4 dimensional vectors and providing basic arithmetic.
Namespace containing classes for handling debug rendering of collision geometries,...
Definition Constraint.h:36
AGXPHYSICS_EXPORT void debugRenderFrame(const agx::AffineMatrix4x4 &transform, float scale, const agx::Vec4f &colorIdentifier, agxRender::RenderManager *mgr=nullptr)
AGXPHYSICS_EXPORT void debugRenderConstraintFrames(const agx::Constraint *constraint, float scale, agxRender::RenderManager *mgr=nullptr, agx::Bool overrideInvalid=false)
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
bool Bool
Definition Integer.h:40
double Real
Definition Real.h:42