Panda3D
collisionFloorMesh.h
1 // Filename: collisionFloorMesh.h
2 // Created by: zpavlov (28Jun07)
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 COLLISIONFLOORMESH_H
16 #define COLLISIONFLOORMESH_H
17 
18 #include "pandabase.h"
19 
20 #include "collisionPlane.h"
21 #include "clipPlaneAttrib.h"
22 #include "look_at.h"
23 #include "pvector.h"
24 
25 class GeomNode;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : CollisionFloorMesh
29 // Description : This object represents a solid made entirely of triangles, which
30 // will only be tested again z axis aligned rays
31 ////////////////////////////////////////////////////////////////////
32 class EXPCL_PANDA_COLLIDE CollisionFloorMesh : public CollisionSolid {
33 public:
34  typedef struct {
35  unsigned int p1;
36  unsigned int p2;
37  unsigned int p3;
38  PN_stdfloat min_x;
39  PN_stdfloat max_x;
40  PN_stdfloat min_y;
41  PN_stdfloat max_y;
43 
44 PUBLISHED:
45 
46  INLINE CollisionFloorMesh();
47 
48  INLINE void add_vertex(const LPoint3 &vert);
49  void add_triangle(unsigned int pointA, unsigned int pointB, unsigned int pointC);
50 
51  INLINE unsigned int get_num_vertices() const;
52  INLINE const LPoint3 &get_vertex(unsigned int index) const;
53  MAKE_SEQ(get_vertices, get_num_vertices, get_vertex);
54  INLINE unsigned int get_num_triangles() const;
55  INLINE LPoint3i get_triangle(unsigned int index) const;
56  MAKE_SEQ(get_triangles, get_num_triangles, get_triangle);
57 
58  virtual LPoint3 get_collision_origin() const;
59 
60 public:
61  CollisionFloorMesh(const CollisionFloorMesh &copy);
62  virtual CollisionSolid *make_copy();
63 
64 public:
65 
66  virtual void xform(const LMatrix4 &mat);
67 
68  virtual PStatCollector &get_volume_pcollector();
70 
71  virtual void output(ostream &out) const;
72  virtual void write(ostream &out, int indent_level = 0) const;
73 
74  INLINE static void flush_level();
75 
76 protected:
77  virtual PT(BoundingVolume) compute_internal_bounds() const;
78 
79  virtual PT(CollisionEntry)
80  test_intersection_from_ray(const CollisionEntry &entry) const;
81  virtual PT(CollisionEntry)
82  test_intersection_from_sphere(const CollisionEntry &entry) const;
83 
84  virtual void fill_viz_geom();
85 
86 private:
87  typedef pvector<LPoint3> Vertices;
89 
90  Vertices _vertices;
91  Triangles _triangles;
92 
93  static PStatCollector _volume_pcollector;
94  static PStatCollector _test_pcollector;
95 
96 protected:
97  void fillin(DatagramIterator& scan, BamReader* manager);
98 
99 public:
100  static void register_with_read_factory();
101  virtual void write_datagram(BamWriter* manager, Datagram &me);
102 
103  static TypedWritable *make_CollisionFloorMesh(const FactoryParams &params);
104  static TypeHandle get_class_type() {
105  return _type_handle;
106  }
107  static void init_type() {
108  CollisionSolid::init_type();
109  register_type(_type_handle, "CollisionFloorMesh",
110  CollisionSolid::get_class_type());
111  }
112  virtual TypeHandle get_type() const {
113  return get_class_type();
114  }
115  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
116 
117 private:
118  static TypeHandle _type_handle;
119 };
120 
121 #include "collisionFloorMesh.I"
122 
123 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
Defines a single collision event.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
This object represents a solid made entirely of triangles, which will only be tested again z axis ali...
virtual PStatCollector & get_test_pcollector()
Returns a PStatCollector that is used to count the number of intersection tests made against a solid ...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:940
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:37