00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00027
00028
00029
00030
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 ©);
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 ¶ms);
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