gwnavruntime/queries/blobs/segmentcangoquerydisplaylistbuilder.h Source File

segmentcangoquerydisplaylistbuilder.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_SegmentCanGoQuery_DisplayListBuilder_H
9 #define Navigation_SegmentCanGoQuery_DisplayListBuilder_H
10 
15 
16 namespace Kaim
17 {
18 
19 class SegmentCanGoQueryDisplayListBuilder : public IDisplayListBuilder
20 {
21 private:
22  virtual void DoBuild(ScopedDisplayList* displayList, char* blob, KyUInt32 /*deepBlobSize*/ = 0)
23  {
24  const SegmentCanGoQueryBlob* queryBlob = (SegmentCanGoQueryBlob*) blob;
25  KyFloat32 triangleZOffset = 0.1f;
26 
27  SegmentCanGoQueryOutputBlob* queryOutputBlob = queryBlob->m_queryOutput.Ptr();
28  if (queryOutputBlob != NULL)
29  {
30  Vec3f offsetVector = Vec3f::UnitZ();
31  KyFloat32 arrowHalfWidth = 0.05f;
32 
33  VisualShapeColor shapeColor;
34  switch((SegmentCanGoQueryResult)queryOutputBlob->m_result)
35  {
36  case SEGMENTCANGO_NOT_INITIALIZED: break;
38  {
39  shapeColor.m_triangleColor = VisualColor::Orange;
40  displayList->PushArrow(queryBlob->m_startPos3f, queryBlob->m_destPos3f, arrowHalfWidth, shapeColor, 3.0f, 0.1f);
41 
42  shapeColor.SetOnlyLineColor(shapeColor.m_triangleColor);
43  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
44  }
45  break;
47  {
48  shapeColor.m_lineColor = VisualColor::Red;
49  displayList->PushText(queryBlob->m_startPos3f + offsetVector, shapeColor.m_lineColor, "Start outside!");
50  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
51  }
52  break;
54  {
55  shapeColor.m_lineColor = VisualColor::Red;
56 
57  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
58  triangle.A.z += triangleZOffset;
59  triangle.B.z += triangleZOffset;
60  triangle.C.z += triangleZOffset;
61  displayList->PushTriangle(triangle, shapeColor);
62  displayList->PushText(queryBlob->m_startPos3f + offsetVector, VisualColor::Red, "Start NavTag forbidden!");
63  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
64  }
65  break;
67  {
68  shapeColor.m_lineColor = VisualColor::Lime;
69 
70  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
71  triangle.A.z += triangleZOffset;
72  triangle.B.z += triangleZOffset;
73  triangle.C.z += triangleZOffset;
74  displayList->PushTriangle(triangle, shapeColor);
75 
76  shapeColor.m_lineColor = VisualColor::Red;
77  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
78  }
79  break;
81  {
82  shapeColor.m_lineColor = VisualColor::Lime;
83 
84  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
85  triangle.A.z += triangleZOffset;
86  triangle.B.z += triangleZOffset;
87  triangle.C.z += triangleZOffset;
88  displayList->PushTriangle(triangle, shapeColor);
89 
90  shapeColor.m_lineColor = VisualColor::Red;
91  displayList->PushText(queryBlob->m_destPos3f + offsetVector, shapeColor.m_lineColor, "Arrival in wrong floor!");
92  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
93  }
94  break;
96  {
97  shapeColor.m_lineColor = VisualColor::Lime;
98 
99  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
100  triangle.A.z += triangleZOffset;
101  triangle.B.z += triangleZOffset;
102  triangle.C.z += triangleZOffset;
103  displayList->PushTriangle(triangle, shapeColor);
104 
105  shapeColor.m_lineColor = VisualColor::Red;
106  displayList->PushText(queryBlob->m_destPos3f + offsetVector, shapeColor.m_lineColor, "Lack of working memory!");
107  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
108  }
109  break;
111  {
112  shapeColor.m_lineColor = VisualColor::Red;
113  displayList->PushText(queryBlob->m_destPos3f + offsetVector, shapeColor.m_lineColor, "Unknown error!");
114  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
115  }
116  break;
118  {
119  shapeColor.m_lineColor = VisualColor::Lime;
120 
121  Triangle3f triangle = queryOutputBlob->m_startTriangle.m_triangle;
122  triangle.A.z += triangleZOffset;
123  triangle.B.z += triangleZOffset;
124  triangle.C.z += triangleZOffset;
125  displayList->PushTriangle(triangle, shapeColor);
126  triangle = queryOutputBlob->m_destTriangle.m_triangle;
127  triangle.A.z += triangleZOffset;
128  triangle.B.z += triangleZOffset;
129  triangle.C.z += triangleZOffset;
130  displayList->PushQuad(queryBlob->m_startPos3f, queryBlob->m_destPos3f, queryBlob->m_radius, shapeColor);
131  }
132  break;
133  }
134 
135  QueryDynamicOutputBlob* queryDynamicOutputBlob = queryOutputBlob->m_queryDynamicOutputBlobRef.Ptr();
136  if (queryDynamicOutputBlob != NULL)
137  {
138  QueryDynamicOutputDisplayListBuilder dynamicOutputDLBuilder;
139  dynamicOutputDLBuilder.Build(displayList, (char*)queryDynamicOutputBlob, 0);
140  }
141  }
142  }
143 };
144 
145 }
146 
147 #endif
Indicates that the query has not yet been initialized.
Definition: basesegmentcangoquery.h:24
Indicates that insufficient working memory caused the query to stop.
Definition: basesegmentcangoquery.h:31
Indicates that the query has not yet been launched.
Definition: basesegmentcangoquery.h:25
Definition: SF_RefCount.h:377
static const VisualColor Lime
Represents the color with RGBA values ( 0, 255, 0, 255).  
Definition: visualcolor.h:172
static const VisualColor Orange
Represents the color with RGBA values (255, 165, 0, 255).  
Definition: visualcolor.h:195
Indicates that the segment can pass in a straight line from its starting point to the ending point wi...
Definition: basesegmentcangoquery.h:34
static const VisualColor Red
Represents the color with RGBA values (255, 0, 0, 255).  
Definition: visualcolor.h:209
SegmentCanGoQueryResult
Enumerates the possible results of a SegmentCanGoQuery.
Definition: basesegmentcangoquery.h:22
Indicates that none of the above results occurred, which may indicate that the start and end points l...
Definition: basesegmentcangoquery.h:30
Indicates that an unknown error occurred during the query processing.
Definition: basesegmentcangoquery.h:32
static Vec3f UnitZ()
Returns the normalized orientation of the Z axis.
Definition: vec3f.h:218
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basesegmentcangoquery.h:27
Indicates that a collision was detected between the starting and ending points.
Definition: basesegmentcangoquery.h:29
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates that the NavTag at the starting point was forbidden.
Definition: basesegmentcangoquery.h:28
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43