Panda3D
portalClipper.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file portalClipper.h
10  * @author masad
11  * @date 2004-05-04
12  */
13 
14 #ifndef PORTALCLIPPER_H
15 #define PORTALCLIPPER_H
16 
17 #include "pandabase.h"
18 
19 #include "geom.h"
20 #include "geomVertexData.h"
21 #include "sceneSetup.h"
22 #include "renderState.h"
23 #include "portalNode.h"
24 #include "transformState.h"
26 #include "boundingHexahedron.h"
27 #include "pointerTo.h"
28 #include "drawMask.h"
29 #include "typedObject.h"
30 #include "pStatCollector.h"
31 #include "config_pgraph.h"
32 
33 #include "geom.h"
34 #include "geomNode.h"
35 
36 class PandaNode;
37 class PortalNode;
38 class CullHandler;
39 class CullTraverserData;
40 class CullableObject;
41 class NodePath;
42 
43 /**
44  * This object performs a depth-first traversal of the scene graph, with
45  * optional view-frustum culling, collecting CullState and searching for
46  * GeomNodes. Each renderable Geom encountered is passed along with its
47  * associated RenderState to the CullHandler object.
48  */
49 class EXPCL_PANDA_PGRAPH PortalClipper : public TypedObject {
50 public:
51  PortalClipper(GeometricBoundingVolume *frustum, SceneSetup *scene_setup);
52  ~PortalClipper();
53 
54  INLINE bool is_partial_portal_in_view();
55  INLINE bool is_facing_view(const LPlane &portal_plane);
56  INLINE bool is_whole_portal_in_view(const LMatrix4 &cmat);
57 
58  bool prepare_portal(const NodePath &node_path);
59 
60  void draw_lines();
61  INLINE void draw_camera_frustum();
62  void draw_hexahedron(BoundingHexahedron *frustum);
63 
64  INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
65  void move_to(const LVecBase3 &v);
66 
67  INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
68  void draw_to(const LVecBase3 &v);
69 
70  void draw_current_portal();
71 
72  INLINE BoundingHexahedron *get_reduced_frustum() const;
73  INLINE void set_reduced_frustum(BoundingHexahedron *bh);
74  INLINE void get_reduced_viewport(LPoint2& min, LPoint2& max) const;
75  INLINE void set_reduced_viewport(const LPoint2& min, const LPoint2& max);
76  INLINE const RenderState* get_clip_state() const;
77  INLINE void set_clip_state(const RenderState* clip_state);
78 
79 public:
80  static TypeHandle get_class_type() {
81  return _type_handle;
82  }
83  static void init_type() {
85  register_type(_type_handle, "PortalClipper",
86  TypedObject::get_class_type());
87  }
88  virtual TypeHandle get_type() const {
89  return get_class_type();
90  }
91  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
92 
93 private:
94  static TypeHandle _type_handle;
95 
96 private:
97  class Point {
98  public:
99  INLINE Point();
100  INLINE Point(const LVecBase3 &point, const LColor &color);
101  INLINE Point(const Point &copy);
102  INLINE void operator = (const Point &copy);
103 
104  LVertex _point;
105  UnalignedLVecBase4 _color;
106  };
107 
108  typedef pvector<Point> SegmentList;
110 
111  LineList _list;
112  LColor _color;
113 
114  PT(GeomVertexData) _created_data;
115 
116  BoundingHexahedron *_view_frustum;
117  BoundingHexahedron *_reduced_frustum;
118  LPoint2 _reduced_viewport_min;
119  LPoint2 _reduced_viewport_max;
120  CPT(RenderState) _clip_state; // each portal node needs to know the clip state of its "parent" portal Node
121 
122  const PortalNode *_portal_node; // current working portal for dereference ease
123 
124  // int _num_vert; LVertex _coords[4];
125 
126 public:
127  PT(GeomNode) _previous;
128  SceneSetup *_scene_setup;
129 };
130 
131 #include "portalClipper.I"
132 
133 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Definition: typedObject.cxx:44
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
Definition: typedObject.h:88
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
A node in the scene graph that can hold a Portal Polygon, which is a rectangle.
Definition: portalNode.h:30
This defines the abstract interface for an object that receives Geoms identified by the CullTraverser...
Definition: cullHandler.h:28
The smallest atom of cull.
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Definition: portalClipper.h:49
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
Definition: renderState.h:47
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
This object holds the camera position, etc., and other general setup information for rendering a part...
Definition: sceneSetup.h:32
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:34
This defines a bounding convex hexahedron.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.