00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _PHYSICS_VISUALDEBUGUTIL_
00026 #define _PHYSICS_VISUALDEBUGUTIL_
00027
00028 #include <base/Object>
00029 #include <base/Transform>
00030 #include <physics/physics>
00031 #include <physics/Box>
00032 #include <physics/Sphere>
00033 #include <physics/Cylinder>
00034 #include <physics/Capsule>
00035 #include <base/Dimension3>
00036
00037 #include <gfx/Color4>
00038 #include <gfx/Visual>
00039
00040 #include <osg/MatrixTransform>
00041
00042
00043 namespace physics {
00044
00045
00046 class VisualDebugUtil : public gfx::Visual, virtual public base::Object
00047 {
00048 public:
00049 VisualDebugUtil() {}
00050 virtual ~VisualDebugUtil() {}
00051
00052 virtual String className() const { return String("VisualDebugUtil"); }
00053
00054 static void addDebugObject(ref<const Shape> shape, const String& name, base::Transform worldConfiguration, const gfx::Color4& color = gfx::Color4("lime green"));
00055 static void addDebugBoxObject(base::Dimension3 dimensions, const String& name, base::Transform worldConfiguration, const gfx::Color4& color = gfx::Color4("lime green"));
00056 static void addDebugSphereObject(Real radius, const String& name, base::Transform worldConfiguration, const gfx::Color4& color = gfx::Color4("lime green"));
00057 static void addDebugCylinderObject(Real height, Real radius, const String& name, base::Transform worldConfiguration, const gfx::Color4& color = gfx::Color4("lime green"));
00058 static void addDebugCapsuleObject(Real height, Real radius, const String& name, base::Transform worldConfiguration, const gfx::Color4& color = gfx::Color4("lime green"));
00059
00060
00061 static void setConfiguration(const String& name, const base::Transform& configuration);
00062 static void setColor(const String& name, const gfx::Color4& color);
00063 static void setColorAll(gfx::Color4& color);
00064
00065
00066 virtual bool visualTypeSupported(VisualType type) const { return (type==OSGVisual); }
00067 virtual osg::Node* createOSGVisual(Attributes visualAttributes=0) const;
00068
00069 static void updateVisual();
00070
00071 protected:
00072 struct DebugObjectData {
00073 DebugObjectData() {}
00074 DebugObjectData(const String& name, ref<const Shape> shape, const gfx::Color4& color, const base::Transform& configuration);
00075
00076 String name;
00077 ref<const Shape> shape;
00078 gfx::Color4 color;
00079 base::Transform configuration;
00080 ref_ptr<osg::MatrixTransform> transform;
00081 };
00082
00083 typedef std::map< String, DebugObjectData > ObjectMap;
00084
00085 static ObjectMap debugObjects;
00086
00087
00088 static Visual::Attributes attributes;
00089 static ref_ptr<osg::Group> node;
00090
00091 };
00092
00093
00094 }
00095
00096 #endif