Panda3D
 All Classes Functions Variables Enumerations
bulletDebugNode.h
1 // Filename: bulletDebugNode.h
2 // Created by: enn0x (23Jan10)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef __BULLET_DEBUG_NODE_H__
16 #define __BULLET_DEBUG_NODE_H__
17 
18 #include "pandabase.h"
19 
20 #include "bullet_includes.h"
21 
22 #include "geomNode.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : BulletDebugNode
26 // Description :
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDABULLET BulletDebugNode : public GeomNode {
29 
30 PUBLISHED:
31  BulletDebugNode(const char *name="debug");
32  INLINE ~BulletDebugNode();
33 
34  virtual void draw_mask_changed();
35 
36  INLINE void show_wireframe(bool show);
37  INLINE void show_constraints(bool show);
38  INLINE void show_bounding_boxes(bool show);
39  INLINE void show_normals(bool show);
40 
41 public:
42  virtual bool safe_to_flatten() const;
43  virtual bool safe_to_transform() const;
44  virtual bool safe_to_modify_transform() const;
45  virtual bool safe_to_combine() const;
46  virtual bool safe_to_combine_children() const;
47  virtual bool safe_to_flatten_below() const;
48 
49 private:
50  void sync_b2p(btDynamicsWorld *world);
51 
52  struct Line {
53  LVecBase3 _p0;
54  LVecBase3 _p1;
55  UnalignedLVecBase4 _color;
56  };
57 
58  struct Triangle {
59  LVecBase3 _p0;
60  LVecBase3 _p1;
61  LVecBase3 _p2;
62  UnalignedLVecBase4 _color;
63  };
64 
65  class DebugDraw : public btIDebugDraw {
66 
67  public:
68  DebugDraw() {};
69 
70  virtual void setDebugMode(int mode);
71  virtual int getDebugMode() const;
72  virtual void reportErrorWarning(const char *warning);
73 
74  virtual void drawLine(const btVector3 &from, const btVector3 &to,
75  const btVector3 &color);
76  virtual void drawContactPoint(const btVector3 &point,
77  const btVector3 &normal, btScalar distance, int lifetime,
78  const btVector3 &color);
79  virtual void draw3dText(const btVector3 &location, const char *text);
80  virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1,
81  const btVector3 &v2, const btVector3 &color, btScalar);
82  virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1,
83  const btVector3 &v2, const btVector3 &n0, const btVector3 &n1,
84  const btVector3 &n2, const btVector3 &color, btScalar alpha);
85  virtual void drawSphere(btScalar radius, const btTransform &transform,
86  const btVector3 &color);
87 
88  public:
89  pvector<Line> _lines;
90  pvector<Triangle> _triangles;
91 
92  bool _normals;
93  int _mode;
94  };
95 
96  DebugDraw _drawer;
97 
98  bool _wireframe;
99  bool _constraints;
100  bool _bounds;
101 
102  friend class BulletWorld;
103 
104 ////////////////////////////////////////////////////////////////////
105 public:
106  static TypeHandle get_class_type() {
107  return _type_handle;
108  }
109  static void init_type() {
110  GeomNode::init_type();
111  register_type(_type_handle, "BulletDebugNode",
112  GeomNode::get_class_type());
113  }
114  virtual TypeHandle get_type() const {
115  return get_class_type();
116  }
117  virtual TypeHandle force_init_type() {
118  init_type();
119  return get_class_type();
120  }
121 
122 private:
123  static TypeHandle _type_handle;
124 };
125 
126 #include "bulletDebugNode.I"
127 
128 #endif // __BULLET_DEBUG_NODE_H__
129 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
This is an &quot;unaligned&quot; LVecBase4.
Definition: lvecBase4.h:299
virtual bool safe_to_modify_transform() const
Returns true if it is safe to automatically adjust the transform on this kind of node.
Definition: pandaNode.cxx:266
virtual bool safe_to_combine_children() const
Returns true if it is generally safe to combine the children of this PandaNode with each other...
Definition: pandaNode.cxx:295
virtual bool safe_to_flatten() const
Returns true if it is generally safe to flatten out this particular kind of PandaNode by duplicating ...
Definition: geomNode.cxx:358
virtual bool safe_to_transform() const
Returns true if it is generally safe to transform this particular kind of PandaNode by calling the xf...
Definition: pandaNode.cxx:249
virtual bool safe_to_combine() const
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of...
Definition: geomNode.cxx:377
virtual bool safe_to_flatten_below() const
Returns true if a flatten operation may safely continue past this node, or false if nodes below this ...
Definition: pandaNode.cxx:307
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37