gwnavruntime/queries/blobs/nearestborderhalfedgefromposquerydisplaylistbuilder.h Source File

nearestborderhalfedgefromposquerydisplaylistbuilder.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_NearestBorderHalfEdgeFromPosQuery_DisplayListBuilder_H
9 #define Navigation_NearestBorderHalfEdgeFromPosQuery_DisplayListBuilder_H
10 
15 
16 namespace Kaim
17 {
18 
19 class NearestBorderHalfEdgeFromPosQueryDisplayListBuilder : public IDisplayListBuilder
20 {
21 private:
22  void DrawSearchBox(const NearestBorderHalfEdgeFromPosQueryBlob* queryBlob, const VisualColor& color, ScopedDisplayList* displayList)
23  {
24  Vec3f boxMax(queryBlob->m_inputPos3f);
25  Vec3f boxMin(queryBlob->m_inputPos3f);
26  boxMin.x -= queryBlob->m_horizontalTolerance;
27  boxMin.y -= queryBlob->m_horizontalTolerance;
28  boxMin.z -= queryBlob->m_positionSpatializationRange.m_rangeBelowPosition;
29 
30  boxMax.x += queryBlob->m_horizontalTolerance;
31  boxMax.y += queryBlob->m_horizontalTolerance;
32  boxMax.z += queryBlob->m_positionSpatializationRange.m_rangeAbovePosition;
33 
34  VisualShapeColor shapeColor;
35  shapeColor.m_lineColor = color;
36  displayList->PushBox(Box3f(boxMin, boxMax), shapeColor);
37  }
38 
39  virtual void DoBuild(ScopedDisplayList* displayList, char* blob, KyUInt32 /*deepBlobSize*/ = 0)
40  {
41  const NearestBorderHalfEdgeFromPosQueryBlob* queryBlob = (NearestBorderHalfEdgeFromPosQueryBlob*) blob;
42 
43  NearestBorderHalfEdgeFromPosQueryOutputBlob* queryOutputBlob = queryBlob->m_queryOutput.Ptr();
44  if (queryOutputBlob != NULL)
45  {
46  Vec3f offsetVector = Vec3f::UnitZ();
47  KyFloat32 flagRadius = 0.3f;
48 
49  VisualShapeColor shapeColor;
50  switch((NearestBorderHalfEdgeFromPosQueryResult)queryOutputBlob->m_result)
51  {
54  {
55  shapeColor.m_lineColor = VisualColor::Orange;
56  displayList->PushPoint(queryBlob->m_inputPos3f, flagRadius, shapeColor);
57  DrawSearchBox(queryBlob, VisualColor::Orange, displayList);
58  }
59  break;
61  {
62  DrawSearchBox(queryBlob, VisualColor::Red, displayList);
63  }
64  break;
66  {
67  displayList->PushText(queryBlob->m_inputPos3f + offsetVector, VisualColor::Red, "Lack of memory");
68  DrawSearchBox(queryBlob, VisualColor::Red, displayList);
69  }
70  break;
72  {
73  DrawSearchBox(queryBlob, VisualColor::LightGreen, displayList);
74  shapeColor.m_lineColor = VisualColor::Lime;
75  displayList->PushPoint(queryOutputBlob->m_nearestPosOnHalfEdge, flagRadius, shapeColor);
76 
77 
78  shapeColor.SetOnlyTriangleColor(VisualColor::Lime);
79  displayList->PushArrow(queryBlob->m_inputPos3f, queryOutputBlob->m_nearestPosOnHalfEdge, 0.05f, shapeColor);
80  displayList->PushText(queryOutputBlob->m_nearestPosOnHalfEdge + offsetVector, shapeColor.m_triangleColor, "Nearest half edge");
81  displayList->PushLine(queryOutputBlob->m_nearestHalfEdgeOnBorder.m_startPos3f, queryOutputBlob->m_nearestHalfEdgeOnBorder.m_endPos3f,
82  shapeColor.m_triangleColor);
83 
84 
85  shapeColor.m_triangleColor = VisualColor::Orange;
86  Vec3f prevHalfEdgeMiddle = (queryOutputBlob->m_prevHalfEdgeOnBorder.m_startPos3f + queryOutputBlob->m_prevHalfEdgeOnBorder.m_endPos3f) * 0.5f;
87  displayList->PushLine(queryOutputBlob->m_prevHalfEdgeOnBorder.m_startPos3f, queryOutputBlob->m_prevHalfEdgeOnBorder.m_endPos3f,
88  shapeColor.m_triangleColor);
89  displayList->PushArrow(queryBlob->m_inputPos3f, prevHalfEdgeMiddle, 0.01f, shapeColor);
90  displayList->PushText(prevHalfEdgeMiddle + offsetVector, shapeColor.m_triangleColor, "Prev");
91 
92  Vec3f nextHalfEdgeMiddle = (queryOutputBlob->m_nextHalfEdgeOnBorder.m_startPos3f + queryOutputBlob->m_nextHalfEdgeOnBorder.m_endPos3f) * 0.5f;
93  displayList->PushLine(queryOutputBlob->m_nextHalfEdgeOnBorder.m_startPos3f, queryOutputBlob->m_nextHalfEdgeOnBorder.m_endPos3f,
94  shapeColor.m_triangleColor);
95  displayList->PushArrow(queryBlob->m_inputPos3f, nextHalfEdgeMiddle, 0.01f, shapeColor);
96  displayList->PushText(nextHalfEdgeMiddle + offsetVector, shapeColor.m_triangleColor, "Next");
97  }
98  break;
99  }
100  }
101  }
102 };
103 
104 }
105 
106 #endif
Indicates that the query was completed successfully, and a NavMesh border was found.
Definition: basenearestborderhalfedgefromposquery.h:37
Indicates that a NavMesh border was not found within the query's bounding box.
Definition: basenearestborderhalfedgefromposquery.h:34
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
static const VisualColor Red
Represents the color with RGBA values (255, 0, 0, 255).  
Definition: visualcolor.h:209
static const VisualColor LightGreen
Represents the color with RGBA values (144, 238, 144, 255).  
Definition: visualcolor.h:164
static Vec3f UnitZ()
Returns the normalized orientation of the Z axis.
Definition: vec3f.h:218
Definition: gamekitcrowddispersion.h:20
Indicates that insufficient working memory caused the query to stop.
Definition: basenearestborderhalfedgefromposquery.h:35
NearestBorderHalfEdgeFromPosQueryResult
Enumerates the possible results of a NearestBorderHalfEdgeFromPosQuery.
Definition: basenearestborderhalfedgefromposquery.h:29
Indicates the query has not yet been initialized.
Definition: basenearestborderhalfedgefromposquery.h:31
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates the query has not yet been launched.
Definition: basenearestborderhalfedgefromposquery.h:32
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43