gwnavruntime/queries/blobs/insideposfromoutsideposquerydisplaylistbuilder.h Source File

insideposfromoutsideposquerydisplaylistbuilder.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_InsidePosFromOutsidePosQuery_DisplayListBuilder_H
9 #define Navigation_InsidePosFromOutsidePosQuery_DisplayListBuilder_H
10 
15 
16 namespace Kaim
17 {
18 
19 class InsidePosFromOutsidePosQueryDisplayListBuilder : public IDisplayListBuilder
20 {
21 private:
22  void DrawSearchBox(const InsidePosFromOutsidePosQueryBlob* 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 InsidePosFromOutsidePosQueryBlob* queryBlob = (InsidePosFromOutsidePosQueryBlob*) blob;
42  KyUInt32 subdivisionCount = 24;
43 
44  InsidePosFromOutsidePosQueryOutputBlob* queryOutputBlob = queryBlob->m_queryOutput.Ptr();
45  if (queryOutputBlob != NULL)
46  {
47  Vec3f offsetVector = Vec3f::UnitZ();
48  KyFloat32 pointRadius = 0.1f;
49 
50  const bool useCast = queryBlob->m_castDirection != Vec2f(KyFloat32MAXVAL, KyFloat32MAXVAL);
51  VisualShapeColor shapeColor;
52  switch((InsidePosFromOutsidePosQueryResult)queryOutputBlob->m_result)
53  {
56  {
57  DrawSearchBox(queryBlob, VisualColor::Orange, displayList);
58 
59  shapeColor.m_lineColor = VisualColor::White;
60  displayList->PushPoint(queryBlob->m_inputPos3f, pointRadius, shapeColor);
61  }
62  break;
65  {
66  DrawSearchBox(queryBlob, VisualColor::Red, displayList);
67 
68  shapeColor.m_lineColor = VisualColor::Red;
69  displayList->PushPoint(queryBlob->m_inputPos3f, pointRadius, shapeColor);
70  if (useCast)
71  displayList->PushLine(queryBlob->m_inputPos3f, queryBlob->m_inputPos3f + Vec3f(queryBlob->m_castDirection * 2.f * queryBlob->m_horizontalTolerance), shapeColor.m_lineColor);
72  }
73  break;
75  {
76  DrawSearchBox(queryBlob, VisualColor::LightGreen, displayList);
77  displayList->PushText(queryOutputBlob->m_insidePos3f + offsetVector, VisualColor::Lime, "Inside pos");
78 
79  shapeColor.m_lineColor = VisualColor::Lime;
80  displayList->PushDisk(queryOutputBlob->m_insidePos3f, queryBlob->m_distFromObstacle, subdivisionCount, shapeColor);
81 
82  shapeColor.m_lineColor = VisualColor::Lime;
83  displayList->PushPoint(queryBlob->m_inputPos3f, pointRadius, shapeColor);
84 
85  shapeColor.SetOnlyTriangleColor(VisualColor::Lime);
86  displayList->PushArrow(queryBlob->m_inputPos3f, queryOutputBlob->m_insidePos3f, 0.001f, shapeColor);
87 
88  if (useCast)
89  displayList->PushLine(queryBlob->m_inputPos3f, queryBlob->m_inputPos3f + Vec3f(queryBlob->m_castDirection * 2.f * queryBlob->m_horizontalTolerance), VisualColor::LightGreen);
90 
91  }
92  break;
93  }
94  }
95  }
96 };
97 
98 }
99 
100 #endif
InsidePosFromOutsidePosQueryResult
Enumerates the possible results of an InsidePosFromOutsidePosQuery.
Definition: baseinsideposfromoutsideposquery.h:26
Indicates that the query was completed successfully, and a valid position on the NavMesh was found wi...
Definition: baseinsideposfromoutsideposquery.h:34
#define KyFloat32MAXVAL
The maximum value that can be stored in the KyFloat32 variable type.
Definition: types.h:227
Indicates the query has not yet been initialized.
Definition: baseinsideposfromoutsideposquery.h:28
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 insufficient working memory caused the query to stop.
Definition: baseinsideposfromoutsideposquery.h:31
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
static const VisualColor White
Represents the color with RGBA values (255, 255, 255, 255).  
Definition: visualcolor.h:234
Indicates the query has not yet been launched.
Definition: baseinsideposfromoutsideposquery.h:29
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates that a valid position was not found within the query's bounding box.
Definition: baseinsideposfromoutsideposquery.h:33
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43