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

panda/src/pgraph/compassEffect.h

Go to the documentation of this file.
00001 // Filename: compassEffect.h
00002 // Created by:  drose (16Jul02)
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 COMPASSEFFECT_H
00020 #define COMPASSEFFECT_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "renderEffect.h"
00025 #include "luse.h"
00026 #include "nodePath.h"
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : CompassEffect
00030 // Description : A CompassEffect causes a node to inherit its rotation
00031 //               (or pos or scale, if specified) from some other
00032 //               reference node in the graph, or more often from the
00033 //               root.
00034 //
00035 //               In its purest form, a CompassEffect is used to keep
00036 //               the node's rotation fixed relative to the top of the
00037 //               scene graph, despite other transforms that may exist
00038 //               above the node.  Hence the name: the node behaves
00039 //               like a magnetic compass, always pointing in the same
00040 //               direction.
00041 //
00042 //               As an couple of generalizing extensions, the
00043 //               CompassEffect may also be set up to always orient its
00044 //               node according to some other reference node than the
00045 //               root of the scene graph.  Furthermore, it may
00046 //               optionally adjust any of pos, rotation, or scale,
00047 //               instead of necessarily rotation; and it may adjust
00048 //               individual pos and scale components.  (Rotation may
00049 //               not be adjusted on an individual component basis;
00050 //               that's just asking for trouble.)
00051 //
00052 //               Be careful when using the pos and scale modes.  In
00053 //               these modes, it's possible for the CompassEffect to
00054 //               move its node far from its normal bounding volume,
00055 //               causing culling to fail.  If this is an issue, you
00056 //               may need to explicitly set a large (or infinite)
00057 //               bounding volume on the effect node.
00058 ////////////////////////////////////////////////////////////////////
00059 class EXPCL_PANDA CompassEffect : public RenderEffect {
00060 private:
00061   INLINE CompassEffect();
00062 
00063 PUBLISHED:
00064   enum Properties {
00065     P_x     = 0x001,
00066     P_y     = 0x002,
00067     P_z     = 0x004,
00068     P_pos   = 0x007,
00069     P_rot   = 0x008,
00070     P_sx    = 0x010,
00071     P_sy    = 0x020,
00072     P_sz    = 0x040,
00073     P_scale = 0x070,
00074     P_all   = 0x07f,
00075   };
00076   static CPT(RenderEffect) make(const NodePath &reference, 
00077                                 int properties = P_rot);
00078 
00079   INLINE const NodePath &get_reference() const;
00080   INLINE int get_properties() const;
00081 
00082 public:
00083   virtual bool safe_to_transform() const;
00084   virtual void output(ostream &out) const;
00085 
00086   CPT(TransformState) do_compass(const TransformState *net_transform,
00087                                  const TransformState *node_transform) const;
00088 
00089 protected:
00090   virtual int compare_to_impl(const RenderEffect *other) const;
00091 
00092 private:
00093   NodePath _reference;
00094   int _properties;
00095 
00096 public:
00097   static void register_with_read_factory();
00098   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00099 
00100 protected:
00101   static TypedWritable *make_from_bam(const FactoryParams &params);
00102   void fillin(DatagramIterator &scan, BamReader *manager);
00103   
00104 public:
00105   static TypeHandle get_class_type() {
00106     return _type_handle;
00107   }
00108   static void init_type() {
00109     RenderEffect::init_type();
00110     register_type(_type_handle, "CompassEffect",
00111                   RenderEffect::get_class_type());
00112   }
00113   virtual TypeHandle get_type() const {
00114     return get_class_type();
00115   }
00116   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00117 
00118 private:
00119   static TypeHandle _type_handle;
00120 };
00121 
00122 #include "compassEffect.I"
00123 
00124 #endif
00125 

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