AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
RenderSingleton.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#ifdef _MSC_VER
20# pragma warning(push)
21# pragma warning( disable : 4251 )
22// warning C4251: 'X' : class 'Y' needs to have dll-interface to be used by clients of class 'Z'
23#endif
24
26#include <agx/Singleton.h>
27#include <agx/Vec4.h>
28#include <agx/AffineMatrix4x4.h>
29#include <agxRender/Color.h>
30
31// Forward declarations
32namespace agx
33{
34 class Constraint;
35 class ConstraintImplementation;
36}
37
38namespace agxSDK
39{
40 class Simulation;
41}
42
43namespace agxRender
44{
45 class RenderManager;
46
48 float scale,
49 const agx::Vec4f& colorIdentifier,
50 agxRender::RenderManager* mgr = nullptr );
52 float scale,
53 agxRender::RenderManager* mgr = nullptr,
54 agx::Bool overrideInvalid = false );
56 float scale,
57 agxRender::RenderManager* mgr = nullptr,
58 agx::Bool overrideInvalid = false );
59
62 {
63 public:
66
68 static bool isInitialized();
69
72
75
77 void clearAll();
78
81
84 {
85 public:
86 Point() = default;
87
88 Point( const agx::Vec3& position,
89 agx::Real size = agx::Real( 0.4 ),
90 const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
91 : m_position( position )
92 , m_size( size )
93 , m_color( color ) {}
94
96 {
97 return m_position;
98 }
99
101 {
102 return m_size;
103 }
104
106 {
107 return m_color;
108 }
109
110 private:
111 agx::Vec3 m_position;
112 agx::Real m_size = 0.0;
113 agx::Vec4f m_color;
114 };
115
118 {
119 public:
120 Line() = default;
121
122 Line( const agx::Vec3& start,
123 const agx::Vec3& end,
124 agx::Real size = 0.02f,
125 const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ),
126 bool asArrow = false )
127 : m_start( start )
128 , m_end( end )
129 , m_size( size )
130 , m_color( color )
131 , m_asArrow( asArrow )
132 {
133 }
134
136 {
137 return m_start;
138 }
139
141 {
142 return m_end;
143 }
144
146 {
147 return m_size;
148 }
149
151 {
152 return m_color;
153 }
154
155 bool& asArrow()
156 {
157 return m_asArrow;
158 }
159
160 private:
161 agx::Vec3 m_start;
162 agx::Vec3 m_end;
163 agx::Real m_size = 0.0;
164 agx::Vec4f m_color;
165 bool m_asArrow = false;
166 };
167
170 {
171 public:
172 Text() = default;
173
174 Text( const agx::String& text,
175 const agx::Vec2& position,
176 const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
177 : m_text( text )
178 , m_position( position )
179 , m_color( color )
180 {
181 }
182
184 {
185 return m_text;
186 }
187
189 {
190 return m_position;
191 }
192
194 {
195 return m_color;
196 }
197
198 private:
199 agx::String m_text;
200 agx::Vec2 m_position;
201 agx::Vec4f m_color;
202 };
203
204
207 {
208 public:
209 Triangle() = default;
210
211 Triangle( const agx::Vec3& v0,
212 const agx::Vec3& v1,
213 const agx::Vec3& v2,
214 agx::Real size = 0.02f,
215 const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
216 : m_v0( v0 )
217 , m_v1( v1 )
218 , m_v2( v2 )
219 , m_size( size )
220 , m_color( color )
221 {
222 }
223
225 {
226 return m_color;
227 }
228
230 {
231 return m_v0;
232 }
233
235 {
236 return m_v1;
237 }
238
240 {
241 return m_v2;
242 }
243
245 {
246 return m_size;
247 }
248
249 private:
250 agx::Vec3 m_v0;
251 agx::Vec3 m_v1;
252 agx::Vec3 m_v2;
253 agx::Real m_size = 0.0;
254 agx::Vec4f m_color;
255 };
256
258 {
259 public:
260 Frame() = default;
261
263 agx::Real scale = agx::Real( 0.5 ),
264 const agx::Vec4f& color = agx::Vec4f( 1, 1, 1, 1 ) )
265 : m_frame( frame )
266 , m_scale( scale )
267 , m_color( color )
268 {
269 }
270
271 const agx::AffineMatrix4x4& getFrame() const { return m_frame; }
272
273 agx::Real getScale() const { return m_scale; }
274
275 agx::Vec4f getColor() const { return m_color; }
276
277 private:
278 agx::AffineMatrix4x4 m_frame;
279 agx::Real m_scale = 1.0;
280 agx::Vec4f m_color;
281 };
282
286 void add( const Point& point );
287
291 void add( const agx::Vec3& position, agx::Real size, const agx::Vec4f& color )
292 {
293 add( Point( position, size, color ) );
294 }
298 void addStatic( const Point& point );
299
303 void addStatic( const agx::Vec3& position, agx::Real size, const agx::Vec4f& color )
304 {
305 addStatic( Point( position, size, color ) );
306 }
307
311 void add( const Line& line );
312
316 void add( const agx::Vec3& start, const agx::Vec3& end, agx::Real size, const agx::Vec4f& color, bool asArrow = false )
317 {
318 add( Line( start, end, size, color, asArrow ) );
319 }
320
324 void addStatic( const Line& line );
325
329 void addStatic( const agx::Vec3& start, const agx::Vec3& end, agx::Real size, const agx::Vec4f& color, bool asArrow = false )
330 {
331 addStatic( Line( start, end, size, color, asArrow ) );
332 }
333
337 void add( const Text& text );
338
342 void add( const agx::String& text, const agx::Vec2& position, const agx::Vec4f& color )
343 {
344 add( Text( text, position, color ) );
345 }
346
350 void addStatic( const Text& text );
351
355 void addStatic( const agx::String& text, const agx::Vec2& position, const agx::Vec4f& color )
356 {
357 addStatic( Text( text, position, color ) );
358 }
359
363 void add( const Triangle& triangle );
364
368 void add( const agx::Vec3& v0, const agx::Vec3& v1, const agx::Vec3& v2, const agx::Real size, const agx::Vec4f& color )
369 {
370 add(Triangle(v0, v1, v2, size, color));
371 }
372
376 void addStatic( const Triangle& triangle);
377
381 void addStatic( const agx::Vec3& v0, const agx::Vec3& v1, const agx::Vec3& v2, const agx::Real size, const agx::Vec4f& color )
382 {
383 addStatic(Triangle(v0, v1, v2, size, color));
384 }
385
389 void add( const agx::AffineMatrix4x4& frame, agx::Real scale, const agx::Vec4f& color );
390
394 void addStatic( const agx::AffineMatrix4x4& frame, agx::Real scale, const agx::Vec4f& color );
395
396 SINGLETON_CLASSNAME_METHOD();
397
398 protected:
400 virtual void shutdown() override;
401
402 private:
403 static RenderSingleton* s_instance;
404 agx::Vector<Point> m_staticPoints;
405 agx::Vector<Point> m_points;
406 agx::Vector<Line> m_staticLines;
407 agx::Vector<Line> m_lines;
408 agx::Vector<Text> m_staticText;
409 agx::Vector<Text> m_text;
410 agx::Vector<Triangle> m_staticTriangles;
411 agx::Vector<Triangle> m_triangles;
412 agx::Vector<Frame> m_staticFrames;
413 agx::Vector<Frame> m_frames;
414 };
415}
416
417#ifdef _MSC_VER
418# pragma warning(pop)
419#endif
420
#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), bool asArrow=false)
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 add(const agx::Vec3 &start, const agx::Vec3 &end, agx::Real size, const agx::Vec4f &color, bool asArrow=false)
Add temporary line (cylinder)
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 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 &start, const agx::Vec3 &end, agx::Real size, const agx::Vec4f &color, bool asArrow=false)
Add static line (cylinder)
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.
Definition: Vec4Template.h:35
Templated vector class.
Definition: agx/Vector.h:53
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:41