gwnavruntime/queries/blobs/segmentcastquerydisplaylistbuilder.h Source File

segmentcastquerydisplaylistbuilder.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 // Primary contact: MAMU - secondary contact: NOBODY
8 #ifndef Navigation_SegmentCastQuery_DisplayListBuilder_H
9 #define Navigation_SegmentCastQuery_DisplayListBuilder_H
10 
15 
16 namespace Kaim
17 {
18 
19 class SegmentCastQueryDisplayListBuilder : public IDisplayListBuilder
20 {
21 private:
22  virtual void DoBuild(ScopedDisplayList* displayList, char* blob, KyUInt32 /*deepBlobSize*/ = 0)
23  {
24  const SegmentCastQueryBlob* queryBlob = (SegmentCastQueryBlob*) blob;
25  KyFloat32 triangleZOffset = 0.1f;
26 
27  SegmentCastQueryOutputBlob* queryOutputBlob = queryBlob->m_queryOutput.Ptr();
28  if (queryOutputBlob != NULL)
29  {
30  Vec3f offsetVector = Vec3f::UnitZ();
31 
32  VisualShapeColor shapeColor;
33  switch((SegmentCastQueryResult)queryOutputBlob->m_result)
34  {
35  case SEGMENTCAST_NOT_INITIALIZED: break;
37  {
38  displayList->PushText(queryBlob->m_startPos3f + offsetVector, VisualColor::Red, "Not processed...");
39 
40  shapeColor.m_lineColor = VisualColor::Orange;
41  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_startPos3f + queryBlob->m_normalizedDir2d * queryBlob->m_maxDist,
42  queryBlob->m_radius, shapeColor);
43  }
44  break;
46  {
47  shapeColor.m_lineColor = VisualColor::Red;
48  displayList->PushText(queryBlob->m_startPos3f + offsetVector, shapeColor.m_lineColor, "Start outside!");
49  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_startPos3f + queryBlob->m_normalizedDir2d * queryBlob->m_maxDist,
50  queryBlob->m_radius, shapeColor);
51  }
52  break;
54  {
55  shapeColor.m_lineColor = VisualColor::Red;
56  displayList->PushText(queryBlob->m_startPos3f + offsetVector, shapeColor.m_lineColor, "Start NavTag forbidden!");
57 
58  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
59  triangle.A.z += triangleZOffset;
60  triangle.B.z += triangleZOffset;
61  triangle.C.z += triangleZOffset;
62  displayList->PushTriangle(triangle, shapeColor);
63  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_startPos3f + queryBlob->m_normalizedDir2d * queryBlob->m_maxDist,
64  queryBlob->m_radius, shapeColor);
65  }
66  break;
68  {
69  shapeColor.m_lineColor = VisualColor::Lime;
70 
71  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
72  triangle.A.z += triangleZOffset;
73  triangle.B.z += triangleZOffset;
74  triangle.C.z += triangleZOffset;
75  displayList->PushTriangle(triangle, shapeColor);
76 
77  shapeColor.m_lineColor = VisualColor::Orange;
78  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_startPos3f + queryBlob->m_normalizedDir2d * queryBlob->m_maxDist,
79  queryBlob->m_radius, shapeColor);
80  }
81  break;
83  {
84  shapeColor.m_lineColor = VisualColor::Lime;
85 
86  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
87  triangle.A.z += triangleZOffset;
88  triangle.B.z += triangleZOffset;
89  triangle.C.z += triangleZOffset;
90  displayList->PushTriangle(triangle, shapeColor);
91 
92  shapeColor.m_lineColor = VisualColor::Red;
93  displayList->PushLine(queryOutputBlob->m_collisionPos3f, queryOutputBlob->m_collisionPos3f + offsetVector, shapeColor.m_lineColor);
94  displayList->PushText(queryOutputBlob->m_collisionPos3f + offsetVector, shapeColor.m_lineColor, "Collision point (arrival error)");
95  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_startPos3f + queryBlob->m_normalizedDir2d * queryBlob->m_maxDist,
96  queryBlob->m_radius, shapeColor);
97  }
98  break;
100  {
101  shapeColor.m_lineColor = VisualColor::Lime;
102 
103  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
104  triangle.A.z += triangleZOffset;
105  triangle.B.z += triangleZOffset;
106  triangle.C.z += triangleZOffset;
107  displayList->PushTriangle(triangle, shapeColor);
108 
109  shapeColor.m_lineColor = VisualColor::Red;
110  displayList->PushText(queryBlob->m_startPos3f + offsetVector, shapeColor.m_lineColor, "Lack of working memory!");
111  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_startPos3f + queryBlob->m_normalizedDir2d * queryBlob->m_maxDist,
112  queryBlob->m_radius, shapeColor);
113  }
114  break;
116  {
117  shapeColor.m_lineColor = VisualColor::Red;
118  displayList->PushText(queryBlob->m_startPos3f + offsetVector, shapeColor.m_lineColor, "Unknown error!");
119  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_startPos3f + queryBlob->m_normalizedDir2d * queryBlob->m_maxDist,
120  queryBlob->m_radius, shapeColor);
121  }
122  break;
124  {
125  shapeColor.m_lineColor = VisualColor::Lime;
126  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
127  triangle.A.z += triangleZOffset;
128  triangle.B.z += triangleZOffset;
129  triangle.C.z += triangleZOffset;
130  displayList->PushTriangle(triangle, shapeColor);
131  triangle = queryOutputBlob->m_arrivalTriangle.m_triangle;
132  triangle.A.z += triangleZOffset;
133  triangle.B.z += triangleZOffset;
134  triangle.C.z += triangleZOffset;
135  displayList->PushTriangle(triangle, shapeColor);
136  displayList->PushQuad(queryBlob->m_startPos3f, queryOutputBlob->m_arrivalPos3f, queryBlob->m_radius, shapeColor);
137  }
138  break;
140  {
141  shapeColor.m_lineColor = VisualColor::Lime;
142  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
143  triangle.A.z += triangleZOffset;
144  triangle.B.z += triangleZOffset;
145  triangle.C.z += triangleZOffset;
146  displayList->PushTriangle(triangle, shapeColor);
147  triangle = queryOutputBlob->m_arrivalTriangle.m_triangle;
148  triangle.A.z += triangleZOffset;
149  triangle.B.z += triangleZOffset;
150  triangle.C.z += triangleZOffset;
151  displayList->PushTriangle(triangle, shapeColor);
152 
153  shapeColor.m_lineColor = VisualColor::Orange;
154  displayList->PushLine(queryOutputBlob->m_collisionPos3f, queryOutputBlob->m_collisionPos3f + offsetVector, shapeColor.m_lineColor);
155  displayList->PushText(queryOutputBlob->m_collisionPos3f + offsetVector, shapeColor.m_lineColor, "Collision point");
156  displayList->PushQuad(queryBlob->m_startPos3f, queryOutputBlob->m_arrivalPos3f, queryBlob->m_radius, shapeColor);
157  }
158  break;
159  }
160 
161  QueryDynamicOutputBlob* queryDynamicOutputBlob = queryOutputBlob->m_queryDynamicOutputBlobRef.Ptr();
162  if (queryDynamicOutputBlob != NULL)
163  {
164  QueryDynamicOutputDisplayListBuilder dynamicOutputDLBuilder;
165  dynamicOutputDLBuilder.Build(displayList, (char*)queryDynamicOutputBlob, 0);
166  }
167  }
168  }
169 };
170 
171 }
172 
173 #endif
Indicates that insufficient working memory caused the query to stop.
Definition: basesegmentcastquery.h:32
Indicates that an error occured during the query computation.
Definition: basesegmentcastquery.h:33
Indicates that the NavTag at the starting point was forbidden.
Definition: basesegmentcastquery.h:29
Definition: SF_RefCount.h:377
static const VisualColor Lime
Represents the color with RGBA values ( 0, 255, 0, 255).  
Definition: visualcolor.h:172
Indicates that the query has not yet been initialized.
Definition: basesegmentcastquery.h:25
static const VisualColor Orange
Represents the color with RGBA values (255, 165, 0, 255).  
Definition: visualcolor.h:195
Indicates that the query has not yet been launched.
Definition: basesegmentcastquery.h:26
static const VisualColor Red
Represents the color with RGBA values (255, 0, 0, 255).  
Definition: visualcolor.h:209
SegmentCastQueryResult
Enumerates the possible results of a SegmentCastQuery.
Definition: basesegmentcastquery.h:23
static Vec3f UnitZ()
Returns the normalized orientation of the Z axis.
Definition: vec3f.h:218
Indicates that moving back the collision point resulted in an arrival position that is outside of the...
Definition: basesegmentcastquery.h:31
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basesegmentcastquery.h:28
Definition: gamekitcrowddispersion.h:20
Indicates that the segment was able to travel its maximum distance without collision.
Definition: basesegmentcastquery.h:35
Indicates that the starting point is very close to a NavMesh border. Either the segment does not fit ...
Definition: basesegmentcastquery.h:30
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates that a final arrival position was calculated successfully.
Definition: basesegmentcastquery.h:36
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43