gwnavruntime/queries/blobs/trianglefromposquerydisplaylistbuilder.h Source File

trianglefromposquerydisplaylistbuilder.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
11 
12 namespace Kaim
13 {
14 
15 class TriangleFromPosQueryDisplayListBuilder : public IDisplayListBuilder
16 {
17 public:
18  TriangleFromPosQueryDisplayListBuilder() { Clear(); }
19 
20 private:
21  const TriangleFromPosQueryBlob* m_query;
22  TriangleFromPosQueryOutputBlob* m_output;
23  DisplayList* m_displayList;
24 
25 private:
26  void Clear()
27  {
28  m_query = nullptr;
29  m_output = nullptr;
30  m_displayList = nullptr;
31  }
32 
33  void StartText(Color color, const char* text)
34  {
35  m_displayList->PushText(m_query->m_inputPos3f.OffsetZ(1.0f), color, text);
36  }
37 
38  void StartPoint(Color color)
39  {
40  m_displayList->PushPoint(m_query->m_inputPos3f, color);
41  }
42 
43  void StartTriangle(Color color)
44  {
45  m_displayList->PushTriangle(m_output->m_resultTrianglePtr.m_triangle.OffsetZ(0.1f), color);
46  }
47 
48  void PushSpatializationRange(Color color)
49  {
50  const KyFloat32 above = m_query->m_positionSpatializationRange.m_rangeAbovePosition;
51  const KyFloat32 below = m_query->m_positionSpatializationRange.m_rangeBelowPosition;
52  const Vec3f& rangeTop = m_query->m_inputPos3f.OffsetZ(above);
53  const Vec3f& rangeBottom = m_query->m_inputPos3f.OffsetZ(-below);
54  m_displayList->PushLine(rangeBottom, rangeTop, color);
55  }
56 
57  virtual void DoBuild(DisplayList* displayList, char* blob)
58  {
59  m_query = (TriangleFromPosQueryBlob*)blob;
60  m_output = m_query->m_queryOutput.Ptr();
61  m_displayList = displayList;
62  if (m_output == nullptr)
63  return;
64 
65  switch ((TriangleFromPosQueryResult)m_output->m_result)
66  {
68  break;
70  StartPoint(Color::Orange);
71  PushSpatializationRange(Color::Cyan);
72  break;
74  StartPoint(Color::Red);
75  StartText(Color::Red, "No triangle found!");
76  PushSpatializationRange(Color::Cyan);
77  break;
79  StartPoint(Color::Red);
80  StartText(Color::Red, "Lack of working memory!");
81  PushSpatializationRange(Color::Cyan);
82  break;
84  StartPoint(Color::Green);
85  StartTriangle(Color::Green);
86  PushSpatializationRange(Color::Cyan);
87  break;
88  }
89  }
90 };
91 
92 }
93 
Indicates the query has not yet been initialized.
Definition: trianglefromposquery.h:25
TriangleFromPosQueryResult
Enumerates the possible results of a TriangleFromPosQuery.
Definition: trianglefromposquery.h:23
Indicates that insufficient working memory caused the query to stop.
Definition: trianglefromposquery.h:29
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that the point provided is outside the navigable boundaries of the NavMesh.
Definition: trianglefromposquery.h:28
Indicates that the query was completed successfully; a triangle was found.
Definition: trianglefromposquery.h:31
float KyFloat32
float
Definition: types.h:32
Indicates the query has not yet been launched.
Definition: trianglefromposquery.h:26