Panda3D
 All Classes Functions Variables Enumerations
lensNode.h
00001 // Filename: lensNode.h
00002 // Created by:  drose (26Feb02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef LENSNODE_H
00016 #define LENSNODE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "pandaNode.h"
00021 #include "lens.h"
00022 #include "perspectiveLens.h"
00023 #include "pointerTo.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : LensNode
00027 // Description : A node that contains a Lens.  The most important
00028 //               example of this kind of node is a Camera, but other
00029 //               kinds of nodes also contain a lens (for instance, a
00030 //               Spotlight).
00031 ////////////////////////////////////////////////////////////////////
00032 class EXPCL_PANDA_PGRAPH LensNode : public PandaNode {
00033 PUBLISHED:
00034   LensNode(const string &name, Lens *lens = NULL);
00035 
00036 protected:
00037   LensNode(const LensNode &copy);
00038 public:
00039   virtual void output(ostream &out) const;
00040   virtual void write(ostream &out, int indent_level = 0) const;
00041 
00042   virtual void xform(const LMatrix4 &mat);
00043   virtual PandaNode *make_copy() const;
00044 
00045 PUBLISHED:
00046   INLINE void copy_lens(const Lens &lens);
00047   INLINE void copy_lens(int index, const Lens &lens);
00048   INLINE void set_lens(Lens *lens);
00049   void set_lens(int index, Lens *lens);
00050   INLINE Lens *get_lens(int index = 0) const;
00051   
00052   bool set_lens_active(int index, bool active);
00053   INLINE bool get_lens_active(int index) const;
00054 
00055   INLINE bool activate_lens(int index);
00056   INLINE bool deactivate_lens(int index);
00057 
00058   INLINE bool is_in_view(const LPoint3 &pos);
00059   bool is_in_view(int index, const LPoint3 &pos);
00060 
00061   void show_frustum();
00062   void hide_frustum();
00063 
00064 protected:
00065   PT(PandaNode) _shown_frustum;
00066 
00067   class LensSlot {
00068   public:
00069     PT(Lens) _lens;
00070     bool _is_active;
00071   };
00072 
00073   typedef pvector<LensSlot> Lenses;
00074   Lenses _lenses;
00075   
00076 public:
00077   static void register_with_read_factory();
00078   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00079   virtual int complete_pointers(TypedWritable **plist,
00080                                 BamReader *manager);
00081 
00082 protected:
00083   static TypedWritable *make_from_bam(const FactoryParams &params);
00084   void fillin(DatagramIterator &scan, BamReader *manager);
00085 
00086 public:
00087   static TypeHandle get_class_type() {
00088     return _type_handle;
00089   }
00090   static void init_type() {
00091     PandaNode::init_type();
00092     register_type(_type_handle, "LensNode",
00093                   PandaNode::get_class_type());
00094   }
00095   virtual TypeHandle get_type() const {
00096     return get_class_type();
00097   }
00098   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00099 
00100 private:
00101   static TypeHandle _type_handle;
00102 };
00103 
00104 #include "lensNode.I"
00105 
00106 #endif
 All Classes Functions Variables Enumerations