gwnavruntime/channel/bubble.h Source File

bubble.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 #ifndef Navigation_Bubble_H
8 #define Navigation_Bubble_H
9 
10 
15 
16 
17 namespace Kaim
18 {
19 
20 class ScopedDisplayList;
21 class BubbleBlob;
22 
23 
24 
27 {
28  UndefinedBubbleType,
29  StartBubble,
30  EndBubble,
31  IntermediaryBubble
32 };
33 
35 class Bubble
36 {
37 public:
38  Bubble();
39  Bubble(const Vec3f& center, KyFloat32 radius, RotationDirection rotationDirection, BubbleType type = UndefinedBubbleType);
40 
41  void Reset();
42  void Set(const Vec3f& center, KyFloat32 radius, RotationDirection rotationDirection, BubbleType type = UndefinedBubbleType);
43 
44  void InitFromBlob(const BubbleBlob& blob);
45 
46  void SetCenter(const Vec3f& center);
47  void SetRadius(KyFloat32 radius);
48  void SetRotationDirection(RotationDirection rotationDirection);
49  void SetType(BubbleType type);
50 
51  void SetCenterAltitude(KyFloat32 newCenterAltitude);
52 
53  const Vec3f& GetCenter() const;
54  KyFloat32 GetRadius() const;
55  RotationDirection GetRotationDirection() const;
56  BubbleType GetType() const;
57  FunnelSide GetFunnelSide() const;
58 
59  bool IsInitialized() const;
60 
63  KyResult ComputeBiTangentDirection(const Bubble& arrivalBubble, Vec2f& biTangentDir) const;
64 
67  KyResult ComputeBiTangent(const Bubble& arrivalBubble, Vec2f& biTangentStart, Vec2f& biTangentEnd, Vec2f& biTangentNormalizedDir) const;
68  KyResult ComputeBiTangent(const Bubble& arrivalBubble, Vec2f& biTangentStart, Vec2f& biTangentEnd) const;
69 
73  KyResult ComputeBiTangent(const Bubble& arrivalBubble, Vec3f& biTangentStart, Vec3f& biTangentEnd, Vec2f& biTangentNormalizedDir) const;
74  KyResult ComputeBiTangent(const Bubble& arrivalBubble, Vec3f& biTangentStart, Vec3f& biTangentEnd) const;
75 
77  KyResult ComputeBiTangentBubble(const Vec3f& tangencyPosition, const Bubble& secondBubble, Vec3f& tangencyPositionOnSecondBubble, Bubble& biTangentBubble) const;
78 
80  KyResult ComputeTangentBubble(const Vec3f& tangencyPosition, const Vec3f& position, Bubble& tangentBubble) const;
81 
83  void ComputeMedianTurnAxisAndPoint(const Vec2f& entryDir, const Vec2f& exitDir, Vec2f &medianTurnAxis, Vec3f& midPoint) const;
84 
85  void Display(ScopedDisplayList& displayList) const;
86 
87  bool operator==(const Bubble& other) const;
88 private:
89  Vec3f m_center;
90  KyFloat32 m_radius;
91  RotationDirection m_rotationDirection;
92  BubbleType m_type;
93 };
94 
95 KY_INLINE Bubble::Bubble() { Reset(); }
96 KY_INLINE Bubble::Bubble(const Vec3f& center, KyFloat32 radius, RotationDirection rotationDirection, BubbleType type)
97 {
98  Set(center, radius, rotationDirection, type);
99 }
100 KY_INLINE void Bubble::Reset()
101 {
102  Set(Vec3f::Zero(), 0.0f, UninitializedRotationDirection, UndefinedBubbleType);
103 }
104 KY_INLINE void Bubble::Set(const Vec3f& center, KyFloat32 radius, RotationDirection rotationDirection, BubbleType type)
105 {
106  SetCenter(center);
107  SetRadius(radius);
108  SetRotationDirection(rotationDirection);
109  SetType(type);
110 }
111 
112 KY_INLINE void Bubble::SetCenter(const Vec3f& center) { m_center = center; }
113 KY_INLINE void Bubble::SetRadius(KyFloat32 radius) { m_radius = radius; }
114 KY_INLINE void Bubble::SetRotationDirection(RotationDirection rotationDirection) { m_rotationDirection = rotationDirection; }
115 KY_INLINE void Bubble::SetType(BubbleType type) { m_type = type; }
116 KY_INLINE void Bubble::SetCenterAltitude(KyFloat32 newCenterAltitude) { m_center.z = newCenterAltitude; }
117 
118 KY_INLINE const Vec3f& Bubble::GetCenter() const { return m_center; }
119 KY_INLINE KyFloat32 Bubble::GetRadius() const { return m_radius; }
120 KY_INLINE RotationDirection Bubble::GetRotationDirection() const { return m_rotationDirection; }
121 KY_INLINE BubbleType Bubble::GetType() const { return m_type; }
122 
123 KY_INLINE bool Bubble::IsInitialized() const { return m_rotationDirection != UninitializedRotationDirection; }
124 
125 KY_INLINE KyResult Bubble::ComputeBiTangent(const Bubble& arrivalBubble, Vec2f& biTangentStart, Vec2f& biTangentEnd) const
126 {
127  Vec2f unused;
128  return ComputeBiTangent(arrivalBubble, biTangentStart, biTangentEnd, unused);
129 }
130 KY_INLINE FunnelSide Bubble::GetFunnelSide() const
131 {
132  if (m_type != IntermediaryBubble)
133  return FunnelBothSides;
134 
135  return (
136  (m_rotationDirection == Clockwise ) ? FunnelRight :
137  (m_rotationDirection == CounterClockwise) ? FunnelLeft :
138  UndefinedFunnelSide);
139 }
140 KY_INLINE KyResult Bubble::ComputeBiTangent(const Bubble& arrivalBubble, Vec3f& biTangentStart, Vec3f& biTangentEnd) const
141 {
142  Vec2f unused;
143  return ComputeBiTangent(arrivalBubble, biTangentStart, biTangentEnd, unused);
144 }
145 
146 inline bool Bubble::operator==(const Bubble& other) const
147 {
148  return
149  m_center == other.m_center &&
150  m_radius == other.m_radius &&
151  m_rotationDirection == other.m_rotationDirection &&
152  m_type == other.m_type ;
153 }
154 
155 
156 
157 template <class OSTREAM>
158 inline OSTREAM& operator<<(OSTREAM& os, const Bubble& bubble)
159 {
160  os << "center=" << bubble.GetCenter() << " radius=" << bubble.GetRadius() << " direction=" << GetRotationDirectionLabel(bubble.GetRotationDirection());
161  return os;
162 }
163 
164 } // namespace Kaim
165 
166 #endif // Navigation_Bubble_H
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
KyFloat32 z
The size of the vector along the Z axis.
Definition: vec3f.h:229
KyResult ComputeBiTangentBubble(const Vec3f &tangencyPosition, const Bubble &secondBubble, Vec3f &tangencyPositionOnSecondBubble, Bubble &biTangentBubble) const
Computes the Bubble tangent to this Bubble at the provided position and tangent to arrivalBubble...
KyResult ComputeBiTangent(const Bubble &arrivalBubble, Vec2f &biTangentStart, Vec2f &biTangentEnd, Vec2f &biTangentNormalizedDir) const
Computes the segment starting from this Bubble and arriving on , tangent to both Bubbles and respecti...
static Vec3f Zero()
Returns a vector of zero size: (0,0,0).
Definition: vec3f.h:209
KyResult ComputeTangentBubble(const Vec3f &tangencyPosition, const Vec3f &position, Bubble &tangentBubble) const
Computes the Bubble tangent to this Bubble at the provided tangencyPosition and passing through an ar...
RotationDirection
Defines the 4 possible cases of possibly constrained rotation in the horizontal plane for a given ele...
Definition: rotation.h:20
BubbleType
Defines the type of a bubble accordingly to the place it has in a BubbleArray, a BubbleList, etc.
Definition: bubble.h:26
This class represents a circle with potential rotation limitation.
Definition: bubble.h:35
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
Definition: gamekitcrowddispersion.h:20
ScopedDisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:136
KyResult ComputeBiTangentDirection(const Bubble &arrivalBubble, Vec2f &biTangentDir) const
Computes the normalized direction of the segment starting from this Bubble and arriving on ...
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
void ComputeMedianTurnAxisAndPoint(const Vec2f &entryDir, const Vec2f &exitDir, Vec2f &medianTurnAxis, Vec3f &midPoint) const
Computes median turn axis and position accordingly to provided entry and exit axis.