8 #ifndef Navigation_AStarQuery_DisplayListBuilder_H
9 #define Navigation_AStarQuery_DisplayListBuilder_H
21 class AStarQueryDisplayListBuilder :
public IDisplayListBuilder
24 static void BuildVerticalForbiddenWallLogo(ScopedDisplayList* displayList,
25 const Vec3f& A,
const Vec3f& B,
const Vec3f& C,
const Vec3f& ,
const Vec2f& AtoBDir2d)
28 const Vec3f center = (A+C) * 0.5;
33 const Vec3f frontPlane(AtoBDir2d.PerpCCW());
36 VisualShapeColor whiteshapeColor;
38 const Vec3f frontOffset = frontPlane *segmentRadius;
39 Vec3f corner1 = center - radius*0.75f * AtoBDir2d - radius*0.25f *
Vec3f::UnitZ() + frontOffset;
40 Vec3f corner2 = center + radius*0.75f * AtoBDir2d - radius*0.25f *
Vec3f::UnitZ() + frontOffset;
41 Vec3f corner3 = center + radius*0.75f * AtoBDir2d + radius*0.25f *
Vec3f::UnitZ() + frontOffset;
42 Vec3f corner4 = center - radius*0.75f * AtoBDir2d + radius*0.25f *
Vec3f::UnitZ() + frontOffset;
43 displayList->PushQuad(corner1, corner2, corner3, corner4, whiteshapeColor);
46 VisualShapeColor redshapeColor;
48 const Vec3f frontOffset = frontPlane *segmentRadius * 0.5f;
49 const KyFloat32 sqrt2Over2 = 0.7071067f * radius;
50 Vec3f v0 = frontOffset + center + radius * AtoBDir2d + 0.f *
Vec3f::UnitZ();
51 Vec3f v1 = frontOffset + center + sqrt2Over2 * AtoBDir2d + sqrt2Over2 *
Vec3f::UnitZ();
52 Vec3f v2 = frontOffset + center + 0.f * AtoBDir2d + radius *
Vec3f::UnitZ();
53 Vec3f v3 = frontOffset + center - sqrt2Over2 * AtoBDir2d + sqrt2Over2 *
Vec3f::UnitZ();
54 Vec3f v4 = frontOffset + center - radius * AtoBDir2d - 0.f *
Vec3f::UnitZ();
55 Vec3f v5 = frontOffset + center - sqrt2Over2 * AtoBDir2d - sqrt2Over2 *
Vec3f::UnitZ();
56 Vec3f v6 = frontOffset + center - 0.f * AtoBDir2d - radius *
Vec3f::UnitZ();
57 Vec3f v7 = frontOffset + center + sqrt2Over2 * AtoBDir2d - sqrt2Over2 *
Vec3f::UnitZ();
58 displayList->PushTriangle(center + frontOffset, v0, v1, redshapeColor);
59 displayList->PushTriangle(center + frontOffset, v1, v2, redshapeColor);
60 displayList->PushTriangle(center + frontOffset, v2, v3, redshapeColor);
61 displayList->PushTriangle(center + frontOffset, v3, v4, redshapeColor);
62 displayList->PushTriangle(center + frontOffset, v4, v5, redshapeColor);
63 displayList->PushTriangle(center + frontOffset, v5, v6, redshapeColor);
64 displayList->PushTriangle(center + frontOffset, v6, v7, redshapeColor);
65 displayList->PushTriangle(center + frontOffset, v7, v0, redshapeColor);
70 static void BuildPropagationBox(ScopedDisplayList* displayList,
const Vec3f& start,
const Vec3f& dest,
KyFloat32 propagationRadius)
73 box2d.InitAs2dInflatedSegment(start, dest, propagationRadius);
75 Vec3f B = box2d.m_a + box2d.m_normalizedOrientation*box2d.m_length;
76 Vec3f C = box2d.m_a + box2d.m_normalizedOrientation.PerpCCW()*box2d.m_width;
77 Vec3f D = B + (C - A);
81 BuildOpenBox(displayList, start, dest, A, B, C, D, box2d.m_normalizedOrientation, minAlt, maxAlt,
true);
85 static void BuildOpenBox(ScopedDisplayList* displayList,
const Vec3f& start,
const Vec3f& dest,
86 Vec3f& A, Vec3f& B, Vec3f& C, Vec3f& D,
const Vec2f& AtoBDir2d,
KyFloat32 minAlt,
KyFloat32 maxAlt,
bool doLinkToStartAndDest)
101 VisualShapeColor shapeColor;
104 if (doLinkToStartAndDest)
106 displayList->PushLine(A, start, shapeColor.m_triangleColor);
107 displayList->PushLine(C, start, shapeColor.m_triangleColor);
108 displayList->PushLine(A2, start, shapeColor.m_triangleColor);
109 displayList->PushLine(C2, start, shapeColor.m_triangleColor);
110 displayList->PushLine(B, dest, shapeColor.m_triangleColor);
111 displayList->PushLine(D, dest, shapeColor.m_triangleColor);
112 displayList->PushLine(B2, dest, shapeColor.m_triangleColor);
113 displayList->PushLine(D2, dest, shapeColor.m_triangleColor);
118 BuildVerticalForbiddenWallLogo(displayList, A, B, B2, A2, AtoBDir2d);
119 displayList->PushQuad( A, B, B2, A2, shapeColor);
121 BuildVerticalForbiddenWallLogo(displayList, C, A, A2, C2, AtoBDir2d.PerpCW());
122 displayList->PushQuad(C, A, A2, C2, shapeColor);
124 BuildVerticalForbiddenWallLogo(displayList, D, C, C2, D2, -AtoBDir2d);
125 displayList->PushQuad(D, C, C2, D2, shapeColor);
127 BuildVerticalForbiddenWallLogo(displayList, B, D, D2, B2, AtoBDir2d.PerpCCW());
128 displayList->PushQuad(B, D, D2, B2, shapeColor);
132 virtual void DoBuild(ScopedDisplayList* displayList,
char* blob,
KyUInt32 = 0)
134 const AStarQueryBlob* aStarQueryBlob = (AStarQueryBlob*) blob;
136 AStarQueryOutputBlob* aStarQueryOutputBlob = aStarQueryBlob->m_queryOutput.Ptr();
137 if (aStarQueryOutputBlob != NULL)
140 VisualShapeColor shapeColor;
143 KY_PUSH_ERROR_ON_MISSING_EXPLICIT_CASE_LABEL
162 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
167 displayList->PushText(aStarQueryBlob->m_startPos3f + offsetVector, shapeColor.m_triangleColor,
"Start outside!");
168 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
173 displayList->PushText(aStarQueryBlob->m_startPos3f + offsetVector, shapeColor.m_triangleColor,
"Start NavTag forbidden!");
174 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
179 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Destination outside!");
180 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
185 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Destination NavTag forbidden!");
186 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
191 BuildPropagationBox(displayList, aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, aStarQueryBlob->m_propagationBoxExtent);
192 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Path not found !");
193 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
198 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"NavData changed!");
199 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
204 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Lack of working memory!");
205 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
210 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Computation Error");
211 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
216 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Channel Config Error");
217 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
222 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Channel Computation Error");
223 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
228 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"startPos=destPos, no Path computed");
234 PathDisplayListBuilder pathDisplay;
235 pathDisplay.DisplayPath(displayList, &aStarQueryOutputBlob->m_pathBlob);
236 if (aStarQueryOutputBlob->m_abstractPathBlob.m_nodePositions.GetCount() != 0)
239 pathDisplay.DisplayPath(displayList, &aStarQueryOutputBlob->m_abstractPathBlob);
245 displayList->PushText(aStarQueryBlob->m_destPos3f + offsetVector, shapeColor.m_triangleColor,
"Query Canceled");
246 displayList->PushLine(aStarQueryBlob->m_startPos3f, aStarQueryBlob->m_destPos3f, shapeColor.m_triangleColor);
250 KY_POP_ERROR_ON_MISSING_EXPLICIT_CASE_LABEL
Indicates that a path could not be found between the start and destination points.
Definition: baseastarquery.h:50
Unused. Kept here for backward compatibility.
Definition: baseastarquery.h:43
static const VisualColor Lime
Represents the color with RGBA values ( 0, 255, 0, 255).
Definition: visualcolor.h:172
Indicates that a computation error caused the query to stop.
Definition: baseastarquery.h:55
Indicates that insufficient working memory caused the query to stop.
Definition: baseastarquery.h:52
static const VisualColor Black
Represents the color with RGBA values ( 0, 0, 0, 255).
Definition: visualcolor.h:103
Indicates that a computation error caused the query to stop.
Definition: baseastarquery.h:53
Indicates that the refined path is being clamped to navMesh according to the altitude tolerance...
Definition: baseastarquery.h:41
static const VisualColor Orange
Represents the color with RGBA values (255, 165, 0, 255).
Definition: visualcolor.h:195
Indicates that the NavTag at the starting point is forbidden.
Definition: baseastarquery.h:47
Indicates the query has not yet been launched.
Definition: baseastarquery.h:32
Indicates that the channel is initialized, the channel is being computed.
Definition: baseastarquery.h:44
T Min(const T &a, const T &b)
Returns the lesser of the two specified values.
Definition: fastmath.h:113
static const VisualColor Red
Represents the color with RGBA values (255, 0, 0, 255).
Definition: visualcolor.h:209
Indicates that the NavTag at the destination point is forbidden.
Definition: baseastarquery.h:49
Indicates that the input channelComputerConfig is invalid.
Definition: baseastarquery.h:54
Indicates that the refining process is being initialized.
Definition: baseastarquery.h:37
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: baseastarquery.h:46
static Vec3f UnitZ()
Returns the normalized orientation of the Z axis.
Definition: vec3f.h:218
Indicates that the Astar traversal algorithm has been launched, but has not yet completed.
Definition: baseastarquery.h:34
static const VisualColor DimGray
Represents the color with RGBA values (105, 105, 105, 255).
Definition: visualcolor.h:136
Indicates the query has not yet been initialized.
Definition: baseastarquery.h:31
Indicates that the refiner is done, but the path has not yet been clamped to the navMesh.
Definition: baseastarquery.h:40
Indicates that the computation has been canceled.
Definition: baseastarquery.h:56
T Max(const T &a, const T &b)
Returns the greater of the two specified values.
Definition: fastmath.h:121
Definition: gamekitcrowddispersion.h:20
KyFloat32 DotProduct(const Vec2f &v1, const Vec2f &v2)
Returns the dot product of v1 and v2.
Definition: vec2f.h:187
static const VisualColor White
Represents the color with RGBA values (255, 255, 255, 255).
Definition: visualcolor.h:234
Indicates that the cost from nodes that are on navMesh are beeing recomputed since they may have been...
Definition: baseastarquery.h:38
Indicates that query starting location and ending location are equals. computing a Path would have le...
Definition: baseastarquery.h:58
Indicates that the query has stopped and must be relaunched because of a change in the NavData...
Definition: baseastarquery.h:51
Indicates that the clamping algorithm has completed, but the path has not yet been built...
Definition: baseastarquery.h:42
Indicates that the Astar traversal algorithm traversed AbstractGraph, and the Abstract path is being ...
Definition: baseastarquery.h:36
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates that the Astar traversal algorithm is finished, and that a path is found and is prepared to...
Definition: baseastarquery.h:35
Indicates that the destination point of the query is outside the NavMesh.
Definition: baseastarquery.h:48
Indicates that a path has been found between the start and destination.
Definition: baseastarquery.h:59
Indicates that the path found is being refined.
Definition: baseastarquery.h:39
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
AStarQueryResult
Enumerates the possible results of an AStarQuery.
Definition: baseastarquery.h:29