Skylicht Engine
Loading...
Searching...
No Matches
CSceneDebug.h
1/*
2!@
3MIT License
4
5Copyright (c) 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "Utils/CSingleton.h"
28#include "TextBillboard/CTextBillboardManager.h"
29
30namespace Skylicht
31{
36 {
37 core::line3df line;
38 SColor color;
39 };
40
45 {
47 SColor color;
48 };
49
53 struct SBoxDebug
54 {
56 SColor color;
57 };
58
62 struct STriDebug
63 {
65 SColor color;
66 };
67
84 class SKYLICHT_API CSceneDebug
85 {
86 public:
88
89 protected:
92
95
98
101
104
106 CSceneDebug* m_noZDebug;
107
108 public:
113
117 virtual ~CSceneDebug();
118
129
137 void addCircle(const core::vector3df& pos, float radius, const core::vector3df& normal, const SColor& color);
138
147 void addEclipse(const core::vector3df& pos, float radiusZ, float radiusX, const core::vector3df& normal, const SColor& color);
148
154 void addTri(const core::triangle3df& tri, const SColor& color);
155
161 void addLine(const core::line3df& line, const SColor& color);
162
169 void addLine(const core::vector3df& v1, const core::vector3df& v2, const SColor& color);
170
176 void addLinestrip(const core::array<core::vector3df>& point, const SColor& color);
177
183 void addLinestrip(const std::vector<core::vector3df>& point, const SColor& color);
184
190 void addBoudingBox(const core::aabbox3df& box, const SColor& color);
191
199 void addTransformBBox(const core::aabbox3df& box, const SColor& color, const core::matrix4& mat);
200
207 void addSphere(const core::vector3df& pos, float radius, const SColor& color);
208
215 void addPosition(const core::vector3df& pos, float length, const SColor& color);
216
223 void addTransform(const core::matrix4& mat, float vectorLength);
224
231 void addText(const core::vector3df& pos, const char* string, const SColor& color);
232
239 void addText2D(const core::vector2df& pos, const char* string, const SColor& color);
240
244 void clearText();
245
246 void clear()
247 {
248 clearLines();
250 clearBoxs();
251 clearTri();
252 clearText();
253 }
254
259
264
268 void clearBoxs();
269
273 void clearTri();
274
280 {
281 return m_lines.size();
282 }
283
289 {
290 return m_linestrip.size();
291 }
292
298 {
299 return m_boxs.size();
300 }
301
307 {
308 return m_tri.size();
309 }
310
318 inline const SLineDebug& getLine(int i)
319 {
320 return *m_lines[i];
321 }
322
330 inline const SLineStripDebug& getLineStrip(int i)
331 {
332 return *m_linestrip[i];
333 }
334
342 inline const SBoxDebug& getBox(int i)
343 {
344 return *m_boxs[i];
345 }
346
354 inline const STriDebug& getTri(int i)
355 {
356 return *m_tri[i];
357 }
358 };
359}
core::array< SBoxDebug * > m_boxs
Array of debug boxes.
Definition CSceneDebug.h:97
u32 getLineStripCount()
Get the number of debug linestrips currently stored.
Definition CSceneDebug.h:288
void addTransform(const core::matrix4 &mat, float vectorLength)
Adds debug axis lines at a transformed position (visualizes transform matrix axes)....
void addTri(const core::triangle3df &tri, const SColor &color)
Adds a debug triangle to the scene.
const SLineStripDebug & getLineStrip(int i)
Get a reference to the debug linestrip at the specified index.
Definition CSceneDebug.h:330
const SBoxDebug & getBox(int i)
Get a reference to the debug box at the specified index.
Definition CSceneDebug.h:342
u32 getLinesCount()
Get the number of debug lines currently stored.
Definition CSceneDebug.h:279
CSceneDebug * getNoZDebug()
Returns the singleton instance dedicated for "No Z Debug" visualization.
void addText(const core::vector3df &pos, const char *string, const SColor &color)
Adds a 3D debug text billboard at the given scene position.
void addText2D(const core::vector2df &pos, const char *string, const SColor &color)
Adds a 2D debug text billboard at the given screen position.
CSceneDebug()
Constructor. Initializes internal arrays.
void clearLineStrip()
Clears all debug linestrips.
u32 getBoxCount()
Get the number of debug boxes currently stored.
Definition CSceneDebug.h:297
core::array< SLineDebug * > m_lines
Array of debug lines.
Definition CSceneDebug.h:91
core::array< CRenderTextData * > m_texts
Array of debug text billboards.
Definition CSceneDebug.h:103
void clearTri()
Clears all debug triangles.
virtual ~CSceneDebug()
Destructor. Cleans up all debug primitives and the noZDebug instance.
core::array< SLineStripDebug * > m_linestrip
Array of debug linestrips.
Definition CSceneDebug.h:94
void addBoudingBox(const core::aabbox3df &box, const SColor &color)
Adds a debug axis-aligned bounding box to the scene.
core::array< STriDebug * > m_tri
Array of debug triangles.
Definition CSceneDebug.h:100
void addLinestrip(const core::array< core::vector3df > &point, const SColor &color)
Adds a debug linestrip (connected line segments) to the scene.
void addLine(const core::line3df &line, const SColor &color)
Adds a debug line to the scene.
void clearBoxs()
Clears all debug bounding boxes.
const STriDebug & getTri(int i)
Get a reference to the debug triangle at the specified index.
Definition CSceneDebug.h:354
void addLine(const core::vector3df &v1, const core::vector3df &v2, const SColor &color)
Adds a debug line to the scene.
void addCircle(const core::vector3df &pos, float radius, const core::vector3df &normal, const SColor &color)
Adds a debug circle to the scene.
void clearText()
Clears all debug text billboards.
void addEclipse(const core::vector3df &pos, float radiusZ, float radiusX, const core::vector3df &normal, const SColor &color)
Adds a debug ellipse to the scene.
void addPosition(const core::vector3df &pos, float length, const SColor &color)
Adds debug axis lines to visualize a position and orientation.
void addTransformBBox(const core::aabbox3df &box, const SColor &color, const core::matrix4 &mat)
Adds a debug bounding box with a transformation applied. The box is drawn with its edges transformed ...
void addLinestrip(const std::vector< core::vector3df > &point, const SColor &color)
Adds a debug linestrip to the scene.
void addSphere(const core::vector3df &pos, float radius, const SColor &color)
Adds a debug sphere (as two circles) to the scene.
u32 getTriCount()
Get the number of debug triangles currently stored.
Definition CSceneDebug.h:306
void clearLines()
Clears all debug lines.
const SLineDebug & getLine(int i)
Get a reference to the debug line at the specified index.
Definition CSceneDebug.h:318
Self reallocating template array (like stl vector) with additional features.
Definition irrArray.h:23
Class representing a 32 bit ARGB color.
Definition SColor.h:285
#define DECLARE_SINGLETON(className)
Declare the standard singleton accessors for a class.
Definition CSingleton.h:36
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
triangle3d< f32 > triangle3df
Typedef for a f32 3d triangle.
Definition triangle3d.h:335
vector2d< f32 > vector2df
Typedef for f32 2d vector.
Definition vector2d.h:323
line3d< f32 > line3df
Typedef for an f32 line.
Definition line3d.h:136
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
aabbox3d< f32 > aabbox3df
Typedef for a f32 3d bounding box.
Definition aabbox3d.h:351
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
Structure to hold debug box information.
Definition CSceneDebug.h:54
Structure to hold debug line information.
Definition CSceneDebug.h:36
Structure to hold debug linestrip information.
Definition CSceneDebug.h:45
Structure to hold debug triangle information.
Definition CSceneDebug.h:63