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

panda/src/distort/projectionScreen.h

Go to the documentation of this file.
00001 // Filename: projectionScreen.h
00002 // Created by:  drose (11Dec01)
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 PROJECTIONSCREEN_H
00020 #define PROJECTIONSCREEN_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "pandaNode.h"
00025 #include "lensNode.h"
00026 #include "geomNode.h"
00027 #include "nodePath.h"
00028 
00029 class Geom;
00030 class WorkingNodePath;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : ProjectionScreen
00034 // Description : A ProjectionScreen implements a simple system for
00035 //               projective texturing.  The ProjectionScreen node is
00036 //               the parent of a hierarchy of geometry that is
00037 //               considered a "screen"; the ProjectionScreen will
00038 //               automatically recompute all the UV's on its
00039 //               subordinate geometry according to the relative
00040 //               position and lens parameters of the indicated
00041 //               LensNode.
00042 //
00043 //               This does not take advantage of any hardware-assisted
00044 //               projective texturing; nor does it presently support
00045 //               multitexturing.  However, it does support any kind of
00046 //               lens, linear or nonlinear, that might be defined
00047 //               using the Lens interface, including fisheye and
00048 //               cylindrical lenses.
00049 ////////////////////////////////////////////////////////////////////
00050 class EXPCL_PANDAFX ProjectionScreen : public PandaNode {
00051 PUBLISHED:
00052   ProjectionScreen(const string &name = "");
00053   virtual ~ProjectionScreen();
00054 
00055 protected:
00056   ProjectionScreen(const ProjectionScreen &copy);
00057 
00058 public:
00059   virtual PandaNode *make_copy() const;
00060   virtual bool has_cull_callback() const;
00061   virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data);
00062 
00063 PUBLISHED:
00064   void set_projector(const NodePath &projector);
00065   INLINE const NodePath &get_projector() const;
00066 
00067   PT(GeomNode) generate_screen(const NodePath &projector,
00068                                const string &screen_name,
00069                                int num_x_verts, int num_y_verts,
00070                                float distance);
00071   void regenerate_screen(const NodePath &projector, const string &screen_name,
00072                          int num_x_verts, int num_y_verts, float distance);
00073   PT(PandaNode) make_flat_mesh(const NodePath &camera);
00074 
00075   INLINE void set_invert_uvs(bool invert_uvs);
00076   INLINE bool get_invert_uvs() const;
00077 
00078   INLINE void set_vignette_on(bool vignette_on);
00079   INLINE bool get_vignette_on() const;
00080 
00081   INLINE void set_vignette_color(const Colorf &vignette_color);
00082   INLINE const Colorf &get_vignette_color() const;
00083   INLINE void set_frame_color(const Colorf &frame_color);
00084   INLINE const Colorf &get_frame_color() const;
00085 
00086   void recompute();
00087 
00088 public:
00089   INLINE const UpdateSeq &get_last_screen() const;
00090   void recompute_if_stale();
00091 
00092 private:
00093   void do_recompute(const NodePath &this_np);
00094   void recompute_node(const WorkingNodePath &np, LMatrix4f &rel_mat, bool &computed_rel_mat);
00095   void recompute_child(const WorkingNodePath &np, LMatrix4f &rel_mat, bool &computed_rel_mat);
00096   void recompute_geom_node(const WorkingNodePath &np, LMatrix4f &rel_mat, bool &computed_rel_mat);
00097   void recompute_geom(Geom *geom, const LMatrix4f &rel_mat);
00098 
00099   PandaNode *
00100   make_mesh_node(PandaNode *result_parent, const WorkingNodePath &np,
00101                  const NodePath &camera,
00102                  LMatrix4f &rel_mat, bool &computed_rel_mat);
00103   void make_mesh_children(PandaNode *new_node, const WorkingNodePath &np,
00104                           const NodePath &camera,
00105                           LMatrix4f &rel_mat, bool &computed_rel_mat);
00106   PT(GeomNode) make_mesh_geom_node(const WorkingNodePath &np, 
00107                                    const NodePath &camera,
00108                                    LMatrix4f &rel_mat,
00109                                    bool &computed_rel_mat);
00110   PT(Geom) make_mesh_geom(Geom *geom, Lens *lens, LMatrix4f &rel_mat);
00111 
00112 
00113   NodePath _projector;
00114   PT(LensNode) _projector_node;
00115   bool _invert_uvs;
00116   bool _vignette_on;
00117   Colorf _vignette_color;
00118   Colorf _frame_color;
00119 
00120   PTA_Colorf _colors;
00121   LMatrix4f _rel_top_mat;
00122   bool _computed_rel_top_mat;
00123   bool _stale;
00124   UpdateSeq _projector_lens_change;
00125   UpdateSeq _last_screen;
00126 
00127 public:
00128   static TypeHandle get_class_type() {
00129     return _type_handle;
00130   }
00131   static void init_type() {
00132     PandaNode::init_type();
00133     register_type(_type_handle, "ProjectionScreen",
00134                   PandaNode::get_class_type());
00135   }
00136   virtual TypeHandle get_type() const {
00137     return get_class_type();
00138   }
00139   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00140 
00141 private:
00142   static TypeHandle _type_handle;
00143 };
00144 
00145 #include "projectionScreen.I"
00146 
00147 #endif

Generated on Fri May 2 00:36:41 2003 for Panda by doxygen1.3