gwnavruntime/visualdebug/messages/lodmaxblob.h Source File

lodmaxblob.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 #ifndef Navigation_LodMaxBlob_H
9 #define Navigation_LodMaxBlob_H
10 
19 
20 
21 namespace Kaim
22 {
23 
24 
29 class LodMaxBlob
30 {
31  KY_ROOT_BLOB_CLASS(Runtime, LodMaxBlob, 0)
32 
33 public:
34  LodMaxBlob() : m_visualDebugId(KyUInt32MAXVAL) {}
35 
36  KyUInt32 m_visualDebugId; // the id of the visualdebug element.
37  Vec3f m_shapePosition; // the 3D position of the shape.
38 };
39 
40 inline void SwapEndianness(Kaim::Endianness::Target e, LodMaxBlob& self)
41 {
42  SwapEndianness(e, self.m_visualDebugId);
43  SwapEndianness(e, self.m_shapePosition);
44 }
45 
46 
47 class LodMaxBlobBuilder : public BaseBlobBuilder<LodMaxBlob>
48 {
49 public:
50  LodMaxBlobBuilder(KyUInt32 visualDebugId, const Vec3f& shapePosition)
51  : m_visualDebugId(visualDebugId), m_shapePosition(shapePosition) {}
52 
53  virtual void DoBuild()
54  {
55  BLOB_SET(m_blob->m_visualDebugId, m_visualDebugId);
56  BLOB_SET(m_blob->m_shapePosition, m_shapePosition);
57  }
58 private:
59  KyUInt32 m_visualDebugId;
60  Vec3f m_shapePosition;
61 };
62 
63 
64 class LodMaxHintDisplayListBuilder
65 {
66 public:
67  static void DisplayLodMaxHint(ScopedDisplayList* displayList, const LodMaxBlob* lodMaxBlob)
68  {
69  if (lodMaxBlob == KY_NULL)
70  return;
71 
72  KyFloat32 radius = 0.3f;
73  KyFloat32 radius_div_3 = radius / 3.0f;
74 
75  KyFloat32 fadeFactor = 0.8f;
76  const VisualColor color(VisualColor::Gold);
77  const VisualColor fadeColor(
78  KyUInt8(color.m_r * fadeFactor),
79  KyUInt8(color.m_g * fadeFactor),
80  KyUInt8(color.m_b * fadeFactor));
81  VisualShapeColor shapeColor(color, fadeColor);
82 
83  // Horizontal box
84 
85  Vec3f horizontalBoxMin = lodMaxBlob->m_shapePosition;
86  horizontalBoxMin.x -= radius;
87  horizontalBoxMin.y -= radius_div_3;
88  horizontalBoxMin.z -= radius_div_3;
89 
90  Vec3f horizontalBoxMax = lodMaxBlob->m_shapePosition;
91  horizontalBoxMax.x += radius;
92  horizontalBoxMax.y += radius_div_3;
93  horizontalBoxMax.z += radius_div_3;
94 
95  displayList->PushBox(Box3f(horizontalBoxMin, horizontalBoxMax), shapeColor);
96 
97 
98  // Vertical box
99 
100  Vec3f verticalBoxMin = lodMaxBlob->m_shapePosition;
101  verticalBoxMin.x -= radius_div_3;
102  verticalBoxMin.y -= radius_div_3;
103  verticalBoxMin.z -= radius;
104 
105  Vec3f verticalBoxMax = lodMaxBlob->m_shapePosition;
106  verticalBoxMax.x += radius_div_3;
107  verticalBoxMax.y += radius_div_3;
108  verticalBoxMax.z += radius;
109 
110  displayList->PushBox(Box3f(verticalBoxMin, verticalBoxMax), shapeColor);
111  }
112 };
113 
114 }
115 
116 #endif
#define BLOB_SET(blob, value)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:136
#define KY_NULL
Null value.
Definition: types.h:247
static const VisualColor Gold
Represents the color with RGBA values (255, 215, 0, 255).  
Definition: visualcolor.h:144
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
Send this blob to display a shape saying that the visual element with id m_visualDebugId is at LOD ma...
Definition: lodmaxblob.h:30
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
LodMaxBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:117
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
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