Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/collide/collisionVisualizer.h

Go to the documentation of this file.
00001 // Filename: collisionVisualizer.h
00002 // Created by:  drose (16Apr03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef COLLISIONVISUALIZER_H
00020 #define COLLISIONVISUALIZER_H
00021 
00022 #include "pandabase.h"
00023 #include "pandaNode.h"
00024 #include "collisionRecorder.h"
00025 #include "nodePath.h"
00026 
00027 #ifdef DO_COLLISION_RECORDING
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : CollisionVisualizer
00031 // Description : This class is used to help debug the work the
00032 //               collisions system is doing.  It shows the polygons
00033 //               that are detected as collisions, as well as those
00034 //               that are simply considered for collisions.
00035 //
00036 //               It may be parented anywhere in the scene graph where
00037 //               it will be rendered to achieve this.
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDA CollisionVisualizer : public PandaNode, public CollisionRecorder {
00040 PUBLISHED:
00041   CollisionVisualizer(const string &name);
00042   virtual ~CollisionVisualizer();
00043 
00044   void clear();
00045 
00046 public:
00047   // from parent class PandaNode.
00048   virtual PandaNode *make_copy() const;
00049   virtual bool has_cull_callback() const;
00050   virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00051   virtual void output(ostream &out) const;
00052 
00053   // from parent class CollisionRecorder.
00054   virtual void begin_traversal();
00055   virtual void collision_tested(const CollisionEntry &entry, bool detected);
00056 
00057 private:
00058   CPT(RenderState) get_detected_state();
00059   CPT(RenderState) get_tested_state();
00060 
00061 private:
00062   class SolidInfo {
00063   public:
00064     INLINE SolidInfo();
00065     int _detected_count;
00066     int _missed_count;
00067   };
00068   typedef pmap<CPT(CollisionSolid), SolidInfo> Solids;
00069 
00070   class CollisionPoint {
00071   public:
00072     LPoint3f _point;
00073     LVector3f _normal;
00074   };
00075   typedef pvector<CollisionPoint> Points;
00076 
00077   class VizInfo {
00078   public:
00079     Solids _solids;
00080     Points _points;
00081   };
00082 
00083   typedef map<CPT(TransformState), VizInfo> Data;
00084   Data _data;
00085 
00086 public:
00087   static TypeHandle get_class_type() {
00088     return _type_handle;
00089   }
00090 
00091   static void init_type() {
00092     PandaNode::init_type();
00093     CollisionRecorder::init_type();
00094     register_type(_type_handle, "CollisionVisualizer",
00095                   PandaNode::get_class_type(),
00096                   CollisionRecorder::get_class_type());
00097   }
00098   virtual TypeHandle get_type() const {
00099     return get_class_type();
00100   }
00101   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00102 
00103 private:
00104   static TypeHandle _type_handle;
00105 };
00106 
00107 #include "collisionVisualizer.I"
00108 
00109 #endif  // DO_COLLISION_RECORDING  
00110 
00111 #endif

Generated on Fri May 2 00:35:48 2003 for Panda by doxygen1.3