Panda3D

cLerpNodePathInterval.h

00001 // Filename: cLerpNodePathInterval.h
00002 // Created by:  drose (27Aug02)
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 CLERPNODEPATHINTERVAL_H
00016 #define CLERPNODEPATHINTERVAL_H
00017 
00018 #include "directbase.h"
00019 #include "cLerpInterval.h"
00020 #include "nodePath.h"
00021 #include "textureStage.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : CLerpNodePathInterval
00025 // Description : An interval that lerps one or more properties (like
00026 //               pos, hpr, etc.) on a NodePath over time.
00027 ////////////////////////////////////////////////////////////////////
00028 class EXPCL_DIRECT CLerpNodePathInterval : public CLerpInterval {
00029 PUBLISHED:
00030   CLerpNodePathInterval(const string &name, double duration, 
00031                         BlendType blend_type, bool bake_in_start,
00032                         bool fluid,
00033                         const NodePath &node, const NodePath &other);
00034 
00035   INLINE const NodePath &get_node() const;
00036   INLINE const NodePath &get_other() const;
00037 
00038   INLINE void set_start_pos(const LVecBase3 &pos);
00039   INLINE void set_end_pos(const LVecBase3 &pos);
00040   INLINE void set_start_hpr(const LVecBase3 &hpr);
00041   INLINE void set_end_hpr(const LVecBase3 &hpr);
00042   INLINE void set_end_hpr(const LQuaternion &quat);
00043   INLINE void set_start_quat(const LQuaternion &quat);
00044   INLINE void set_end_quat(const LVecBase3 &hpr);
00045   INLINE void set_end_quat(const LQuaternion &quat);
00046   INLINE void set_start_scale(const LVecBase3 &scale);
00047   INLINE void set_start_scale(PN_stdfloat scale);
00048   INLINE void set_end_scale(const LVecBase3 &scale);
00049   INLINE void set_end_scale(PN_stdfloat scale);
00050   INLINE void set_start_shear(const LVecBase3 &shear);
00051   INLINE void set_end_shear(const LVecBase3 &shear);
00052   INLINE void set_start_color(const LVecBase4 &color);
00053   INLINE void set_end_color(const LVecBase4 &color);
00054   INLINE void set_start_color_scale(const LVecBase4 &color_scale);
00055   INLINE void set_end_color_scale(const LVecBase4 &color_scale);
00056   INLINE void set_texture_stage(TextureStage *stage);
00057   INLINE void set_start_tex_offset(const LVecBase2 &tex_offset);
00058   INLINE void set_end_tex_offset(const LVecBase2 &tex_offset);
00059   INLINE void set_start_tex_rotate(PN_stdfloat tex_rotate);
00060   INLINE void set_end_tex_rotate(PN_stdfloat tex_rotate);
00061   INLINE void set_start_tex_scale(const LVecBase2 &tex_scale);
00062   INLINE void set_end_tex_scale(const LVecBase2 &tex_scale);
00063 
00064   INLINE void set_override(int override);
00065   INLINE int get_override() const;
00066 
00067   virtual void priv_initialize(double t);
00068   virtual void priv_instant();
00069   virtual void priv_step(double t);
00070   virtual void priv_reverse_initialize(double t);
00071   virtual void priv_reverse_instant();
00072 
00073   virtual void output(ostream &out) const;
00074 
00075 private:
00076   void setup_slerp();
00077 
00078   NodePath _node;
00079   NodePath _other;
00080 
00081   enum Flags {
00082     F_end_pos            = 0x00000001,
00083     F_end_hpr            = 0x00000002,
00084     F_end_quat           = 0x00000004,
00085     F_end_scale          = 0x00000008,
00086     F_end_color          = 0x00000010,
00087     F_end_color_scale    = 0x00000020,
00088     F_end_shear          = 0x00000040,
00089     F_end_tex_offset     = 0x00000080,
00090     F_end_tex_rotate     = 0x00000100,
00091     F_end_tex_scale      = 0x00000200,
00092 
00093     F_start_pos          = 0x00010000,
00094     F_start_hpr          = 0x00020000,
00095     F_start_quat         = 0x00040000,
00096     F_start_scale        = 0x00080000,
00097     F_start_color        = 0x00100000,
00098     F_start_color_scale  = 0x00200000,
00099     F_start_shear        = 0x00400000,
00100     F_start_tex_offset   = 0x00800000,
00101     F_start_tex_rotate   = 0x01000000,
00102     F_start_tex_scale    = 0x02000000,
00103 
00104     F_fluid              = 0x10000000,
00105     F_bake_in_start      = 0x20000000,
00106     
00107     F_slerp_setup        = 0x40000000,
00108   };
00109   
00110   unsigned int _flags;
00111   LPoint3 _start_pos, _end_pos;
00112   LVecBase3 _start_hpr, _end_hpr;
00113   LQuaternion _start_quat, _end_quat;
00114   LVecBase3 _start_scale, _end_scale;
00115   LVecBase3 _start_shear, _end_shear;
00116   LColor _start_color, _end_color;
00117   LVecBase4 _start_color_scale, _end_color_scale;
00118   PT(TextureStage) _texture_stage;
00119   LVecBase2 _start_tex_offset, _end_tex_offset;
00120   PN_stdfloat _start_tex_rotate, _end_tex_rotate;
00121   LVecBase2 _start_tex_scale, _end_tex_scale;
00122 
00123   int _override;
00124   double _prev_d;
00125   PN_stdfloat _slerp_angle;
00126   PN_stdfloat _slerp_denom;
00127   LQuaternion _slerp_c;
00128 
00129   void slerp_basic(LQuaternion &result, PN_stdfloat t) const;
00130   void slerp_angle_0(LQuaternion &result, PN_stdfloat t) const;
00131   void slerp_angle_180(LQuaternion &result, PN_stdfloat t) const;
00132 
00133   // Define a pointer to one of the above three methods.
00134   void (CLerpNodePathInterval::*_slerp)(LQuaternion &result, PN_stdfloat t) const;
00135   
00136 public:
00137   static TypeHandle get_class_type() {
00138     return _type_handle;
00139   }
00140   static void init_type() {
00141     CLerpInterval::init_type();
00142     register_type(_type_handle, "CLerpNodePathInterval",
00143                   CLerpInterval::get_class_type());
00144   }
00145   virtual TypeHandle get_type() const {
00146     return get_class_type();
00147   }
00148   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00149 
00150 private:
00151   static TypeHandle _type_handle;
00152 };
00153 
00154 #include "cLerpNodePathInterval.I"
00155 
00156 #endif
00157 
 All Classes Functions Variables Enumerations