Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

physics/VisualDebugUtil

Go to the documentation of this file.
00001 /* **-*-c++-*-**************************************************************
00002   Copyright (C)2003 David Jung <opensim@pobox.com>
00003 
00004   This program/file is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008   
00009   This program is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU General Public License for more details. (http://www.gnu.org)
00013   
00014   You should have received a copy of the GNU General Public License
00015   along with this program; if not, write to the Free Software
00016   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017   
00018   $Id: VisualDebugUtil 1031 2004-02-11 20:46:36Z jungd $
00019   $Revision: 1.2 $
00020   $Date: 2004-02-11 15:46:36 -0500 (Wed, 11 Feb 2004) $
00021   $Author: jungd $
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   // Visual
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   // for Visual
00088   static Visual::Attributes attributes;
00089   static ref_ptr<osg::Group> node; // ==0 => no Visual has been created
00090 
00091 };
00092 
00093 
00094 } // physics
00095 
00096 #endif

Generated on Thu Jul 29 15:56:31 2004 for OpenSim by doxygen 1.3.6