Panda3D
|
00001 // Filename: billboardEffect.h 00002 // Created by: drose (14Mar02) 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 BILLBOARDEFFECT_H 00016 #define BILLBOARDEFFECT_H 00017 00018 #include "pandabase.h" 00019 00020 #include "renderEffect.h" 00021 #include "luse.h" 00022 #include "nodePath.h" 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : BillboardEffect 00026 // Description : Indicates that geometry at this node should 00027 // automatically rotate to face the camera, or any other 00028 // arbitrary node. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_PANDA_PGRAPH BillboardEffect : public RenderEffect { 00031 private: 00032 INLINE BillboardEffect(); 00033 00034 PUBLISHED: 00035 static CPT(RenderEffect) make(const LVector3 &up_vector, 00036 bool eye_relative, 00037 bool axial_rotate, 00038 PN_stdfloat offset, 00039 const NodePath &look_at, 00040 const LPoint3 &look_at_point); 00041 INLINE static CPT(RenderEffect) make_axis(); 00042 INLINE static CPT(RenderEffect) make_point_eye(); 00043 INLINE static CPT(RenderEffect) make_point_world(); 00044 00045 INLINE bool is_off() const; 00046 INLINE const LVector3 &get_up_vector() const; 00047 INLINE bool get_eye_relative() const; 00048 INLINE bool get_axial_rotate() const; 00049 INLINE PN_stdfloat get_offset() const; 00050 INLINE const NodePath &get_look_at() const; 00051 INLINE const LPoint3 &get_look_at_point() const; 00052 00053 public: 00054 virtual bool safe_to_transform() const; 00055 virtual CPT(TransformState) prepare_flatten_transform(const TransformState *net_transform) const; 00056 virtual void output(ostream &out) const; 00057 00058 virtual bool has_cull_callback() const; 00059 virtual void cull_callback(CullTraverser *trav, CullTraverserData &data, 00060 CPT(TransformState) &node_transform, 00061 CPT(RenderState) &node_state) const; 00062 00063 virtual bool has_adjust_transform() const; 00064 virtual void adjust_transform(CPT(TransformState) &net_transform, 00065 CPT(TransformState) &node_transform, 00066 PandaNode *node) const; 00067 00068 protected: 00069 virtual int compare_to_impl(const RenderEffect *other) const; 00070 00071 private: 00072 void compute_billboard(CPT(TransformState) &node_transform, 00073 const TransformState *net_transform, 00074 const TransformState *camera_transform) const; 00075 00076 private: 00077 bool _off; 00078 LVector3 _up_vector; 00079 bool _eye_relative; 00080 bool _axial_rotate; 00081 PN_stdfloat _offset; 00082 NodePath _look_at; 00083 LPoint3 _look_at_point; 00084 00085 public: 00086 static void register_with_read_factory(); 00087 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00088 00089 protected: 00090 static TypedWritable *make_from_bam(const FactoryParams ¶ms); 00091 void fillin(DatagramIterator &scan, BamReader *manager); 00092 00093 public: 00094 static TypeHandle get_class_type() { 00095 return _type_handle; 00096 } 00097 static void init_type() { 00098 RenderEffect::init_type(); 00099 register_type(_type_handle, "BillboardEffect", 00100 RenderEffect::get_class_type()); 00101 } 00102 virtual TypeHandle get_type() const { 00103 return get_class_type(); 00104 } 00105 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00106 00107 private: 00108 static TypeHandle _type_handle; 00109 }; 00110 00111 #include "billboardEffect.I" 00112 00113 #endif 00114