00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PROJECTIONSCREEN_H
00016 #define PROJECTIONSCREEN_H
00017
00018 #include "pandabase.h"
00019
00020 #include "pandaNode.h"
00021 #include "lensNode.h"
00022 #include "geomNode.h"
00023 #include "nodePath.h"
00024 #include "internalName.h"
00025 #include "pointerTo.h"
00026
00027 class Geom;
00028 class WorkingNodePath;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class EXPCL_PANDAFX ProjectionScreen : public PandaNode {
00055 PUBLISHED:
00056 ProjectionScreen(const string &name = "");
00057 virtual ~ProjectionScreen();
00058
00059 protected:
00060 ProjectionScreen(const ProjectionScreen ©);
00061
00062 public:
00063 virtual PandaNode *make_copy() const;
00064 virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00065
00066 PUBLISHED:
00067 void set_projector(const NodePath &projector);
00068 INLINE const NodePath &get_projector() const;
00069
00070 PT(GeomNode) generate_screen(const NodePath &projector,
00071 const string &screen_name,
00072 int num_x_verts, int num_y_verts,
00073 PN_stdfloat distance, PN_stdfloat fill_ratio);
00074 void regenerate_screen(const NodePath &projector, const string &screen_name,
00075 int num_x_verts, int num_y_verts, PN_stdfloat distance,
00076 PN_stdfloat fill_ratio);
00077 PT(PandaNode) make_flat_mesh(const NodePath &this_np, const NodePath &camera);
00078
00079 INLINE void set_texcoord_name(const string &texcoord_name);
00080 INLINE string get_texcoord_name() const;
00081
00082 INLINE void set_invert_uvs(bool invert_uvs);
00083 INLINE bool get_invert_uvs() const;
00084
00085 INLINE void set_vignette_on(bool vignette_on);
00086 INLINE bool get_vignette_on() const;
00087
00088 INLINE void set_vignette_color(const LColor &vignette_color);
00089 INLINE const LColor &get_vignette_color() const;
00090 INLINE void set_frame_color(const LColor &frame_color);
00091 INLINE const LColor &get_frame_color() const;
00092
00093 INLINE void set_auto_recompute(bool auto_recompute);
00094 INLINE bool get_auto_recompute() const;
00095
00096 void recompute();
00097 INLINE const UpdateSeq &get_last_screen() const;
00098 bool recompute_if_stale();
00099 bool recompute_if_stale(const NodePath &this_np);
00100
00101 private:
00102 void do_recompute(const NodePath &this_np);
00103 void recompute_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat);
00104 void recompute_child(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat);
00105 void recompute_geom_node(const WorkingNodePath &np, LMatrix4 &rel_mat, bool &computed_rel_mat);
00106 void recompute_geom(Geom *geom, const LMatrix4 &rel_mat);
00107
00108 PandaNode *
00109 make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np,
00110 const NodePath &camera,
00111 LMatrix4 &rel_mat, bool &computed_rel_mat);
00112 void make_mesh_children(PandaNode *new_node, const WorkingNodePath &np,
00113 const NodePath &camera,
00114 LMatrix4 &rel_mat, bool &computed_rel_mat);
00115 PT(GeomNode) make_mesh_geom_node(const WorkingNodePath &np,
00116 const NodePath &camera,
00117 LMatrix4 &rel_mat,
00118 bool &computed_rel_mat);
00119 PT(Geom) make_mesh_geom(const Geom *geom, Lens *lens, LMatrix4 &rel_mat);
00120
00121
00122 NodePath _projector;
00123 PT(LensNode) _projector_node;
00124 PT(InternalName) _texcoord_name;
00125 bool _invert_uvs;
00126 bool _vignette_on;
00127 LColor _vignette_color;
00128 LColor _frame_color;
00129
00130 LMatrix4 _rel_top_mat;
00131 bool _computed_rel_top_mat;
00132 bool _stale;
00133 UpdateSeq _projector_lens_change;
00134 UpdateSeq _last_screen;
00135 bool _auto_recompute;
00136
00137 public:
00138 static TypeHandle get_class_type() {
00139 return _type_handle;
00140 }
00141 static void init_type() {
00142 PandaNode::init_type();
00143 register_type(_type_handle, "ProjectionScreen",
00144 PandaNode::get_class_type());
00145 }
00146 virtual TypeHandle get_type() const {
00147 return get_class_type();
00148 }
00149 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00150
00151 private:
00152 static TypeHandle _type_handle;
00153 };
00154
00155 #include "projectionScreen.I"
00156
00157 #endif