Panda3D
|
00001 // Filename: bulletDebugNode.h 00002 // Created by: enn0x (23Jan10) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef __BULLET_DEBUG_NODE_H__ 00016 #define __BULLET_DEBUG_NODE_H__ 00017 00018 #include "pandabase.h" 00019 00020 #include "bullet_includes.h" 00021 00022 #include "geomNode.h" 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : BulletDebugNode 00026 // Description : 00027 //////////////////////////////////////////////////////////////////// 00028 class EXPCL_PANDABULLET BulletDebugNode : public GeomNode { 00029 00030 PUBLISHED: 00031 BulletDebugNode(const char *name="debug"); 00032 INLINE ~BulletDebugNode(); 00033 00034 virtual void draw_mask_changed(); 00035 00036 INLINE void show_wireframe(bool show); 00037 INLINE void show_constraints(bool show); 00038 INLINE void show_bounding_boxes(bool show); 00039 INLINE void show_normals(bool show); 00040 00041 public: 00042 virtual bool safe_to_flatten() const; 00043 virtual bool safe_to_transform() const; 00044 virtual bool safe_to_modify_transform() const; 00045 virtual bool safe_to_combine() const; 00046 virtual bool safe_to_combine_children() const; 00047 virtual bool safe_to_flatten_below() const; 00048 00049 private: 00050 void sync_b2p(btDynamicsWorld *world); 00051 00052 struct Line { 00053 LVecBase3 _p0; 00054 LVecBase3 _p1; 00055 UnalignedLVecBase4 _color; 00056 }; 00057 00058 struct Triangle { 00059 LVecBase3 _p0; 00060 LVecBase3 _p1; 00061 LVecBase3 _p2; 00062 UnalignedLVecBase4 _color; 00063 }; 00064 00065 class DebugDraw : public btIDebugDraw { 00066 00067 public: 00068 DebugDraw() {}; 00069 00070 virtual void setDebugMode(int mode); 00071 virtual int getDebugMode() const; 00072 virtual void reportErrorWarning(const char *warning); 00073 00074 virtual void drawLine(const btVector3 &from, const btVector3 &to, 00075 const btVector3 &color); 00076 virtual void drawContactPoint(const btVector3 &point, 00077 const btVector3 &normal, btScalar distance, int lifetime, 00078 const btVector3 &color); 00079 virtual void draw3dText(const btVector3 &location, const char *text); 00080 virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, 00081 const btVector3 &v2, const btVector3 &color, btScalar); 00082 virtual void drawTriangle(const btVector3 &v0, const btVector3 &v1, 00083 const btVector3 &v2, const btVector3 &n0, const btVector3 &n1, 00084 const btVector3 &n2, const btVector3 &color, btScalar alpha); 00085 virtual void drawSphere(btScalar radius, const btTransform &transform, 00086 const btVector3 &color); 00087 00088 public: 00089 pvector<Line> _lines; 00090 pvector<Triangle> _triangles; 00091 00092 bool _normals; 00093 int _mode; 00094 }; 00095 00096 DebugDraw _drawer; 00097 00098 bool _wireframe; 00099 bool _constraints; 00100 bool _bounds; 00101 00102 friend class BulletWorld; 00103 00104 //////////////////////////////////////////////////////////////////// 00105 public: 00106 static TypeHandle get_class_type() { 00107 return _type_handle; 00108 } 00109 static void init_type() { 00110 GeomNode::init_type(); 00111 register_type(_type_handle, "BulletDebugNode", 00112 GeomNode::get_class_type()); 00113 } 00114 virtual TypeHandle get_type() const { 00115 return get_class_type(); 00116 } 00117 virtual TypeHandle force_init_type() { 00118 init_type(); 00119 return get_class_type(); 00120 } 00121 00122 private: 00123 static TypeHandle _type_handle; 00124 }; 00125 00126 #include "bulletDebugNode.I" 00127 00128 #endif // __BULLET_DEBUG_NODE_H__ 00129