gwnavruntime/visualsystem/ivisualgeometrybuilder.h Source File

ivisualgeometrybuilder.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 
9 
10 // primary contact: GUAL - secondary contact: MAMU
11 #ifndef Navigation_IVisualGeometryBuilder_H
12 #define Navigation_IVisualGeometryBuilder_H
13 
21 
22 
23 namespace Kaim
24 {
25 
26 class OrientedBox2d;
27 class Box3f;
28 class Transform;
29 class IVisualGeometry;
30 class VisualBoxVertices;
31 
36 {
40 };
41 
42 class VisualGeometryBuildConfig
43 {
44 public:
45  VisualGeometryBuildConfig() : m_altitudeOffset(0.f), m_detailLevel(KY_VISUAL_DETAIL_LOW) {}
46  KyFloat32 m_altitudeOffset;
47  VisualGeometryDetailLevel m_detailLevel;
48 };
49 
50 class IVisualGeometryBuilder
51 {
52  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_VisualSystem)
53 public:
54  IVisualGeometryBuilder(IVisualGeometry* visualGeometry = KY_NULL);
55  virtual ~IVisualGeometryBuilder();
56 
57  void SetConfig(const VisualGeometryBuildConfig& config);
58  void SetVisualGeometry(IVisualGeometry* visualGeometry);
59 
60  bool IsInFillMode() const;
61  bool IsInCountMode() const;
62 
63  IVisualGeometry* GetVisualGeometry() const;
64  VisualGeometryBuildConfig& GetBuildConfig();
65 
66 
67  void BuildVisualGeometry();
68 
69 
70 protected :
71  virtual void DoBuild() = 0;
72 
73  void BuildSubVisualGeometry(IVisualGeometryBuilder& subGeometryBuilder);
74 
75  // By default, normal generation is Disabled. Once it has been enabled, it cannot be disabled anymore
76  // which means : In visualGeometry, either all the normals of triangles are computed, or none of them are computed
77  void EnableNormalGeneration();
78 
79 
80  //--------------- Shapes -------------
81 
83  void PushTextVarg( const Vec3f& pos, const VisualColor& color, const char* textFmt, ...);
84  void PushText(const Vec3f& pos, const VisualColor& color, const char* text, KyUInt32 textLength = 0);
85 
87  void PushLine(const Vec3f& P, const Vec3f& Q, const VisualColor& color, KyFloat32 pixelWidth = 1.f);
88 
90  void PushTriangle(const Vec3f& A, const Vec3f& B, const Vec3f& C, const VisualShapeColor& color);
91 
93  void PushTriangle(const Triangle3f& triangle, const VisualShapeColor& color);
94 
96  void PushVerticalCylinder(const Vec3f& P, KyFloat32 radius, KyFloat32 height, KyUInt32 subdivisions, const VisualShapeColor& color);
97 
99  void PushSegment(const Vec3f& A, const Vec3f& B, KyFloat32 halfWidth, const VisualShapeColor& color);
100 
102  void PushQuad(const Vec3f& A, const Vec3f& B, const Vec3f& C, const Vec3f& D, const VisualShapeColor& color);
103 
105  void PushQuad(const Vec3f& A, const Vec3f& B, KyFloat32 radius, const VisualShapeColor& color);
106 
108  void PushPoint(const Vec3f& P, const VisualShapeColor& color) { PushPoint(P, 0.1f, color); }
109 
111  void PushPoint(const Vec3f& P, KyFloat32 radius, const VisualShapeColor& color);
112 
114  void PushPyramid(const Vec3f& P, const Vec3f& Q, KyFloat32 halfWidth, const VisualShapeColor& color);
115 
118  void PushSquareTubeSegment(const Vec3f& P, const Vec3f& Q, KyFloat32 halfWidth, const VisualShapeColor& color);
119 
131  void PushArrow(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color, KyFloat32 headWidthRatio = 3.0f, KyFloat32 headLengthRatio = 0.33f);
132 
143  void PushBezierArrow(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color, KyFloat32 headWidthRatio = 3.0f, KyUInt32 directionnality = 0);
144 
148  void PushChristmasTree(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
149 
151  void PushSilex(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
152 
155  void PushDoubleSilex(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
156 
160  void PushCrossedRectangles(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
161 
163  void PushColumn(const Vec3f& P, KyFloat32 halfWidth, KyFloat32 height, const VisualShapeColor& color);
164 
165  void PushOrientedBox(const Transform& transform, const Box3f& extents, const VisualShapeColor& color);
166  void PushOrientedBox2d(const OrientedBox2d& orientedBox2d, const VisualShapeColor& color);
167 
169  void PushTetrahedron(const Vec3f& P, KyFloat32 halfWidth, const VisualShapeColor& color);
170 
172  void PushDisk(const Vec3f& P, KyFloat32 radius, KyUInt32 subdivisions, const VisualShapeColor& color);
173 
175  void PushDiskSector(const Vec3f& P, KyFloat32 radius, const Vec3f& startPos, const Vec3f& endPos, const RotationDirection rotDir, KyUInt32 subdivisions, const VisualShapeColor& color);
176 
178  void PushCorona(const Vec3f& P, KyFloat32 innerRadius, KyFloat32 outerRadius, KyUInt32 subdivisions, const VisualShapeColor& color);
179 
180  void PushStadium(const Vec3f& P, const Vec3f& Q, KyFloat32 radius, KyUInt32 subdivisions, const VisualShapeColor& color);
181 
183  void PushBox(const Box3f& box, const VisualShapeColor& color);
184 
187  void PushTriangleTubeSegment(const Vec3f& P, const Vec3f& Q, KyFloat32 halfWidth, const VisualShapeColor& color);
188 
196  void PushWall(const Vec3f& P, const Vec3f& Q, KyFloat32 upHeight, KyFloat32 downHeight, KyFloat32 halfWidth, const VisualShapeColor& color);
197 
198  void PushLadder(const Transform& transform, const Box3f& entrances, KyFloat32 ladderWidth, KyFloat32 rungsThickness, KyFloat32 rungsGapSize, const VisualShapeColor& shapeColor);
199 
200  void PushParabola(const Kaim::Vec3f& P, const Kaim::Vec3f& Q, KyFloat32 heightBias, KyUInt32 subdivisions, const VisualShapeColor& color);
201 
202  void PushFlag(const Vec3f& P, KyFloat32 height, KyFloat32 radius, const VisualShapeColor& color);
203 
204  // ...
205 private:
206  void IncrementTextCount(KyUInt32 increment);
207  void IncrementTriangleCount(KyUInt32 increment, const VisualColor& color);
208  void IncrementLineCount(KyUInt32 increment, const VisualColor& lineColor);
209 
210  void FillText(const Vec3f& pos, const VisualColor& color, const char* text, KyUInt32 textLength);
211  void FillLine(const Vec3f& P, const Vec3f& Q, const VisualColor& color, KyFloat32 width = 1.f);
212  void FillTriangle(const Vec3f& A, const Vec3f& B, const Vec3f& C, const VisualShapeColor& color);
213  void FillTriangle(const Triangle3f& triangle, const VisualShapeColor& color);
214  void FillVerticalCylinder(const Vec3f& P, KyFloat32 radius, KyFloat32 height, KyUInt32 subdivisions,
215  const VisualShapeColor& color);
216  void FillSegment(const Vec3f& A, const Vec3f& B, KyFloat32 halfWidth, const VisualShapeColor& color);
217  void FillQuad(const Vec3f& A, const Vec3f& B, KyFloat32 radius, const VisualShapeColor& color);
218  void FillQuad(const Vec3f& A, const Vec3f& B, const Vec3f& C, const Vec3f& D, const VisualShapeColor& color);
219  void FillPoint(const Vec3f& P, const VisualShapeColor& color) { PushPoint(P, 0.1f, color); }
220  void FillPoint(const Vec3f& P, KyFloat32 radius, const VisualShapeColor& color);
221  void FillPyramid(const Vec3f& P, const Vec3f& Q, KyFloat32 halfWidth, const VisualShapeColor& color);
222  void FillSquareTubeSegment(const Vec3f& P, const Vec3f& Q, KyFloat32 halfWidth, const VisualShapeColor& color);
223  void FillArrow(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color,
224  KyFloat32 headWidthRatio, KyFloat32 headLengthRatio);
225  void FillBezierArrow(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color,
226  KyFloat32 headWidthRatio, KyUInt32 directionnality);
227  void FillChristmasTree(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
228  void FillSilex(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
229  void FillDoubleSilex(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
230  void FillCrossedRectangles(const Vec3f& P, const Vec3f& Q, KyFloat32 bodyHalfWidth, const VisualShapeColor& color);
231  void FillColumn(const Vec3f& P, KyFloat32 halfWidth, KyFloat32 height, const VisualShapeColor& color);
232  void FillOrientedBox(const Transform& transform, const Box3f& extents, const VisualShapeColor& color);
233  void FillOrientedBox2d(const OrientedBox2d& orientedBox2d, const VisualShapeColor& color);
234  void FillTetrahedron(const Vec3f& P, KyFloat32 halfWidth, const VisualShapeColor& color);
235  void FillDisk(const Vec3f& P, KyFloat32 radius, KyUInt32 subdivisions, const VisualShapeColor& color);
236  void FillDiskSector(const Vec3f& P, KyFloat32 radius, const Vec3f& startPos, const Vec3f& endPos, const RotationDirection rotDir, KyUInt32 subdivisions, const VisualShapeColor& color);
237  void FillCorona(const Vec3f& P, KyFloat32 innerRadius, KyFloat32 outerRadius, KyUInt32 subdivisions, const VisualShapeColor& color);
238  void FillStadium(const Vec3f& P, const Vec3f& Q, KyFloat32 radius, KyUInt32 subdivisions, const VisualShapeColor& color);
239  void FillBox(const Box3f& box, const VisualShapeColor& color);
240  void FillTriangleTubeSegment(const Vec3f& P, const Vec3f& Q, KyFloat32 halfWidth, const VisualShapeColor& color);
241  void FillWall(const Vec3f& P, const Vec3f& Q, KyFloat32 upHeight, KyFloat32 downHeight, KyFloat32 halfWidth, const VisualShapeColor& color);
242  void FillLadder(const Transform& transform, const Box3f& entrances, KyFloat32 ladderWidth, KyFloat32 rungsThickness,
243  KyFloat32 rungsGapSize, const VisualShapeColor& shapeColor);
244  void FillParabola(const Kaim::Vec3f& P, const Kaim::Vec3f& Q, KyFloat32 heightBias, KyUInt32 subdivisions, const VisualShapeColor& color);
245  void FillFlag(const Vec3f& P, KyFloat32 height, KyFloat32 radius, const VisualShapeColor& color);
246 
247  void FillFromVisualBoxVertices(VisualBoxVertices& box, const VisualShapeColor& shapeColor);
248 
249  void SetCountMode();
250  void BeginFillMode();
251  void EndFillMode();
252 
253  void DebugIncrementTextCount(KyUInt32 increment);
254  void DebugIncrementTriangleCount(KyUInt32 increment, const VisualColor& color);
255  void DebugIncrementLineCount(KyUInt32 increment, const VisualColor& lineColor);
256 public:
257  void FillTriangleWithFinalPos(const Vec3f& A, const Vec3f& B, const Vec3f& C, VisualColor shapeColor);
258 
259  static bool CalculateFrontUpRight(const Vec3f& P, const Vec3f& Q, Vec3f& front, Vec3f& up, Vec3f& right);
260 
261 public:
262  enum BuildMode { BuildMode_COUNT, BuildMode_FILL };
263  BuildMode m_buildMode;
264 
265  VisualGeometryBuildConfig m_buildConfig;
266 
267  VisualGeometrySetupConfig m_setupConfig;
268  Ptr<IVisualGeometry> m_visualGeometry;
269 
270  // debug
271 #ifndef KY_BUILD_SHIPPING
272  VisualGeometrySetupConfig m_debugSetupConfig;
273 #endif
274 };
275 
276 
277 
278 }
279 
281 
282 #endif //Navigation_IVisualGeometryBuilder_H
Identifies a higher level of detail.
Definition: ivisualgeometrybuilder.h:39
#define KY_NULL
Null value.
Definition: types.h:247
RotationDirection
Defines the 4 possible cases of possibly constrained rotation in the horizontal plane for a given ele...
Definition: rotation.h:20
Identifies a lower level of detail.
Definition: ivisualgeometrybuilder.h:37
VisualGeometryDetailLevel
Enumerates the possible levels of detail that can be set for a VisualRepresentation.
Definition: ivisualgeometrybuilder.h:35
Definition: gamekitcrowddispersion.h:20
Identifies a higher level of detail.
Definition: ivisualgeometrybuilder.h:38
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23