integration/gwnavruntimeglue/bulletcollisioninterface/internals.h Source File

internals.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 KyRuntimeGlue_Internals_H
8 #define KyRuntimeGlue_Internals_H
9 
10 KY_INLINE Kaim::Vec3f btVectorToVec3f(const btVector3& btVec)
11 {
12  return Kaim::Vec3f(btVec[0], btVec[1], btVec[2]);
13 }
14 
15 KY_INLINE btVector3 Vec3fTobtVector(const Kaim::Vec3f& vec3f)
16 {
17  return btVector3(vec3f[0], vec3f[1], vec3f[2]);
18 }
19 
20 Kaim::VisualColor btColorToVisualColor(const btVector3& btColor)
21 {
22  return Kaim::VisualColor((KyUInt8)btColor[0], (KyUInt8)btColor[1], (KyUInt8)btColor[2]);
23 }
24 
25 class CollisionInterfaceDebugDraw : public btIDebugDraw
26 {
27 public:
28 
29  CollisionInterfaceDebugDraw() : m_displayList(KY_NULL), m_debugMode(0) {}
30  virtual ~CollisionInterfaceDebugDraw() {}
31 
32  virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color)
33  {
34  const Kaim::Vec3f a = btVectorToVec3f(from);
35  const Kaim::Vec3f b = btVectorToVec3f(to);
36  const Kaim::VisualColor c = btColorToVisualColor(color);
37  m_displayList->PushLine(a, b, c);
38  }
39 
40  virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& fromColor, const btVector3& /*toColor*/)
41  {
42  drawLine(from, to, fromColor);
43  }
44 
45  virtual void drawTriangle(const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& color, btScalar alpha)
46  {
47  const Kaim::VisualColor visCol = btColorToVisualColor(color);
48  Kaim::VisualShapeColor shapeCol;
49  shapeCol.SetOnlyTriangleColor(visCol);
50  m_displayList->PushTriangle(btVectorToVec3f(a), btVectorToVec3f(b), btVectorToVec3f(c), shapeCol);
51  }
52 
53  virtual void drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& /*n0*/,const btVector3& /*n1*/,const btVector3& /*n2*/,const btVector3& color, btScalar alpha)
54  {
55  drawTriangle(v0,v1,v2,color,alpha);
56  }
57 
58  virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color) {}
59 
60  virtual void reportErrorWarning(const char* warningString) {}
61 
62  virtual void draw3dText(const btVector3& location,const char* textString)
63  {
64  const Kaim::Vec3f loc = btVectorToVec3f(location);
65  m_displayList->PushText(loc, Kaim::VisualColor::Coral, textString);
66  }
67 
68  virtual void setDebugMode(int debugMode)
69  {
70  m_debugMode = debugMode;
71  }
72 
73  virtual int getDebugMode() const
74  {
75  return btIDebugDraw::DBG_DrawWireframe;
76  }
77 
78  void BeginFrame(Kaim::ScopedDisplayList* displayList)
79  {
80  m_displayList = displayList;
81  }
82 
83  void EndFrame()
84  {
85  m_displayList = KY_NULL;
86  }
87 
88 private:
89  Kaim::ScopedDisplayList* m_displayList;
90  int m_debugMode;
91 };
92 
93 #endif //KyRuntimeGlue_Internals_H
#define KY_NULL
Null value.
Definition: types.h:247
Represents a single RGBA color.
Definition: visualcolor.h:19
static const VisualColor Coral
Represents the color with RGBA values (255, 127, 80, 255).  
Definition: visualcolor.h:112
unsigned char KyUInt8
Type used internally to represent an unsigned 8-bit integer.
Definition: types.h:41
ScopedDisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:136
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23