gwnavruntime/queries/blobs/bestgraphvertexpathfinderquerydisplaylistbuilder.h Source File

bestgraphvertexpathfinderquerydisplaylistbuilder.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: LAPA - secondary contact: NOBODY
8 #ifndef Navigation_BestGraphVertexPathFinderQuery_DisplayListBuilder_H
9 #define Navigation_BestGraphVertexPathFinderQuery_DisplayListBuilder_H
10 
16 
17 namespace Kaim
18 {
19 
20 class BestGraphVertexPathFinderQueryDisplayListBuilder : public IDisplayListBuilder
21 {
22 public:
23  static void BuildPropagationCylinder(ScopedDisplayList* displayList, const Vec3f& center, KyFloat32 radius)
24  {
25  VisualShapeColor shapeColor;
26  shapeColor.m_lineColor = VisualColor::Black;
27  shapeColor.m_triangleColor = VisualColor::DimGray;
28 
29  const KyFloat32 heigth = 200.f;
30  const Vec3f P = center - heigth * 0.5f * Vec3f::UnitZ();
31 
32  const KyUInt32 subdivisionCount = 14;
33  const KyFloat32 angleStep = ((float)(KY_MATH_PI) * 2.0f) / subdivisionCount;
34  const KyFloat32 cosAngleStep = Cosf(angleStep);
35  const KyFloat32 sinAngleStep = Sinf(angleStep);
36  const KyFloat32 cosAngleHalfStep = Cosf(angleStep*0.5f);
37  const KyFloat32 sinAngleHalfStep = Sinf(angleStep*0.5f);
38  const Vec3f heightVector(0.0f, 0.0f, heigth);
39 
40  Vec2f curStepDir(1.0f, 0.0f);
41  Vec3f v0 = P + radius * curStepDir;
42  for(KyUInt32 i = 0; i < subdivisionCount; i++)
43  {
44 
45  const KyFloat32 formerDirX = curStepDir.x;
46 
47  Vec2f planeDir;
48  planeDir.x = cosAngleHalfStep * formerDirX - sinAngleHalfStep * curStepDir.y;
49  planeDir.y = sinAngleHalfStep * formerDirX + cosAngleHalfStep * curStepDir.y;
50 
51  curStepDir.x = cosAngleStep * formerDirX - sinAngleStep * curStepDir.y;
52  curStepDir.y = sinAngleStep * formerDirX + cosAngleStep * curStepDir.y;
53 
54 
55  const Vec3f v1 = P + radius * curStepDir;
56 
57  displayList->PushQuad(v0, v1, v1 + heightVector, v0 + heightVector, shapeColor);
58 
59  if (i%2 == 0)
60  {
61  AStarQueryDisplayListBuilder::BuildVerticalForbiddenWallLogo(
62  displayList, v0, v1, v1 + heightVector, v0 + heightVector, planeDir.PerpCCW());
63  }
64 
65  v0 = v1;
66  }
67  }
68 
69 private:
70  virtual void DoBuild(ScopedDisplayList* displayList, char* blob, KyUInt32 /*deepBlobSize*/)
71  {
72  const BestGraphVertexPathFinderQueryBlob* bestGraphVertexPathFinderQueryBlob = (BestGraphVertexPathFinderQueryBlob*) blob;
73 
74  BestGraphVertexPathFinderQueryOutputBlob* bestGraphVertexPathFinderQueryOutputBlob = bestGraphVertexPathFinderQueryBlob->m_queryOutput.Ptr();
75  if (bestGraphVertexPathFinderQueryOutputBlob != NULL)
76  {
77  Vec3f offsetVector = Vec3f::UnitZ();
78  VisualColor textColor = VisualColor::Red;
79  switch((BestGraphVertexPathFinderQueryResult)bestGraphVertexPathFinderQueryOutputBlob->m_result)
80  {
82  break;
83 
94  break;
95 
97  {
98  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Start outside!");
99  break;
100  }
102  {
103  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Start NavTag forbidden!");
104  break;
105  }
107  {
108  BuildPropagationCylinder(displayList, bestGraphVertexPathFinderQueryBlob->m_startPos3f,
109  bestGraphVertexPathFinderQueryBlob->m_propagationRadius);
110  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Path not found !");
111  break;
112  }
114  {
115  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "NavData changed!");
116  break;
117  }
119  {
120  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Lack of working memory!");
121  break;
122  }
124  {
125  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Computation Error");
126  break;
127  }
129  {
130  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Channel Config Error");
131  break;
132  }
133 
135  {
136  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Channel Computation Error");
137  break;
138  }
140  {
141  PathDisplayListBuilder pathDisplayListBuilder;
142  pathDisplayListBuilder.DisplayPath(displayList, &bestGraphVertexPathFinderQueryOutputBlob->m_pathBlob);
143  }
144  break;
145 
147  displayList->PushText(bestGraphVertexPathFinderQueryBlob->m_startPos3f + offsetVector, textColor, "Query Canceled");
148  break;
149  }
150  }
151  }
152 };
153 
154 }
155 
156 #endif
Indicates that the input channelComputerConfig is invalid.
Definition: basebestgraphvertexpathfinderquery.h:43
static const VisualColor Black
Represents the color with RGBA values ( 0, 0, 0, 255).  
Definition: visualcolor.h:103
Indicates the query has not yet been initialized.
Definition: basebestgraphvertexpathfinderquery.h:24
Indicates the query has not yet been launched.
Definition: basebestgraphvertexpathfinderquery.h:25
static const VisualColor Red
Represents the color with RGBA values (255, 0, 0, 255).  
Definition: visualcolor.h:209
Indicates that the astar traversal algorithm has been launched, but has not yet completed.
Definition: basebestgraphvertexpathfinderquery.h:27
Indicates that insufficient working memory caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:41
Indicates that the computation has been canceled.
Definition: basebestgraphvertexpathfinderquery.h:45
Indicates that the refiner is done, the channel is going to be initialized.
Definition: basebestgraphvertexpathfinderquery.h:34
static Vec3f UnitZ()
Returns the normalized orientation of the Z axis.
Definition: vec3f.h:218
Indicates that the refining process is being initialized.
Definition: basebestgraphvertexpathfinderquery.h:29
static const VisualColor DimGray
Represents the color with RGBA values (105, 105, 105, 255).  
Definition: visualcolor.h:136
Indicates that the refined path is being clamped to navMesh according to the altitude tolerance...
Definition: basebestgraphvertexpathfinderquery.h:32
Definition: gamekitcrowddispersion.h:20
Indicates that the clamping algorithm has completed, but the path has not yet been built...
Definition: basebestgraphvertexpathfinderquery.h:33
Indicates that the NavTag at the starting point is forbidden.
Definition: basebestgraphvertexpathfinderquery.h:38
Indicates that a path has been found between the start and destination.
Definition: basebestgraphvertexpathfinderquery.h:47
Indicates that a path could not be found between the start and destination points.
Definition: basebestgraphvertexpathfinderquery.h:39
Indicates that the channel is initialized, the channel is being computed.
Definition: basebestgraphvertexpathfinderquery.h:35
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates that a computation error caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:44
Indicates that the astar traversal algorithm is finished, and that the path found is ready to be refi...
Definition: basebestgraphvertexpathfinderquery.h:28
BestGraphVertexPathFinderQueryResult
Enumerates the possible results of an BestGraphVertexPathFinderQuery.
Definition: basebestgraphvertexpathfinderquery.h:22
Indicates that the path found is being refined.
Definition: basebestgraphvertexpathfinderquery.h:30
Indicates that the query has stopped and must be relaunched because of a change in the NavData...
Definition: basebestgraphvertexpathfinderquery.h:40
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basebestgraphvertexpathfinderquery.h:37
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
Indicates that the refiner is done, but the path has not yet been clamped to the navMesh.
Definition: basebestgraphvertexpathfinderquery.h:31
Indicates that a computation error caused the query to stop.
Definition: basebestgraphvertexpathfinderquery.h:42