00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PORTALCLIPPER_H
00016 #define PORTALCLIPPER_H
00017
00018 #include "pandabase.h"
00019
00020 #include "geom.h"
00021 #include "geomVertexData.h"
00022 #include "sceneSetup.h"
00023 #include "renderState.h"
00024 #include "portalNode.h"
00025 #include "transformState.h"
00026 #include "geometricBoundingVolume.h"
00027 #include "boundingHexahedron.h"
00028 #include "pointerTo.h"
00029 #include "drawMask.h"
00030 #include "typedObject.h"
00031 #include "pStatCollector.h"
00032 #include "config_pgraph.h"
00033
00034 #include "geom.h"
00035 #include "geomNode.h"
00036
00037 class PandaNode;
00038 class PortalNode;
00039 class CullHandler;
00040 class CullTraverserData;
00041 class CullableObject;
00042 class NodePath;
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 class EXPCL_PANDA_PGRAPH PortalClipper : public TypedObject {
00053 public:
00054 PortalClipper(GeometricBoundingVolume *frustum, SceneSetup *scene_setup);
00055 ~PortalClipper();
00056
00057 INLINE bool is_partial_portal_in_view();
00058 INLINE bool is_facing_view(const LPlane &portal_plane);
00059 INLINE bool is_whole_portal_in_view(const LMatrix4 &cmat);
00060
00061 bool prepare_portal(const NodePath &node_path);
00062
00063 void draw_lines();
00064 INLINE void draw_camera_frustum();
00065 void draw_hexahedron(BoundingHexahedron *frustum);
00066
00067 INLINE void move_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
00068 void move_to(const LVecBase3 &v);
00069
00070 INLINE void draw_to(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
00071 void draw_to(const LVecBase3 &v);
00072
00073 void draw_current_portal();
00074
00075 INLINE BoundingHexahedron *get_reduced_frustum() const;
00076 INLINE void set_reduced_frustum(BoundingHexahedron *bh);
00077 INLINE void get_reduced_viewport(LPoint2& min, LPoint2& max) const;
00078 INLINE void set_reduced_viewport(const LPoint2& min, const LPoint2& max);
00079 INLINE const RenderState* get_clip_state() const;
00080 INLINE void set_clip_state(const RenderState* clip_state);
00081
00082 public:
00083 static TypeHandle get_class_type() {
00084 return _type_handle;
00085 }
00086 static void init_type() {
00087 TypedObject::init_type();
00088 register_type(_type_handle, "PortalClipper",
00089 TypedObject::get_class_type());
00090 }
00091 virtual TypeHandle get_type() const {
00092 return get_class_type();
00093 }
00094 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00095
00096 private:
00097 static TypeHandle _type_handle;
00098
00099 private:
00100 class Point {
00101 public:
00102 INLINE Point();
00103 INLINE Point(const LVecBase3 &point, const LColor &color);
00104 INLINE Point(const Point ©);
00105 INLINE void operator = (const Point ©);
00106
00107 LVertex _point;
00108 UnalignedLVecBase4 _color;
00109 };
00110
00111 typedef pvector<Point> SegmentList;
00112 typedef pvector<SegmentList> LineList;
00113
00114 LineList _list;
00115 LColor _color;
00116
00117 PT(GeomVertexData) _created_data;
00118
00119 BoundingHexahedron *_view_frustum;
00120 BoundingHexahedron *_reduced_frustum;
00121 LPoint2 _reduced_viewport_min;
00122 LPoint2 _reduced_viewport_max;
00123 CPT(RenderState) _clip_state;
00124
00125 PortalNode *_portal_node;
00126
00127
00128
00129
00130 public:
00131 PT(GeomNode) _previous;
00132 SceneSetup *_scene_setup;
00133 };
00134
00135 #include "portalClipper.I"
00136
00137 #endif
00138
00139
00140