Panda3D
 All Classes Functions Variables Enumerations
cLerpNodePathInterval.h
1 // Filename: cLerpNodePathInterval.h
2 // Created by: drose (27Aug02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CLERPNODEPATHINTERVAL_H
16 #define CLERPNODEPATHINTERVAL_H
17 
18 #include "directbase.h"
19 #include "cLerpInterval.h"
20 #include "nodePath.h"
21 #include "textureStage.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : CLerpNodePathInterval
25 // Description : An interval that lerps one or more properties (like
26 // pos, hpr, etc.) on a NodePath over time.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_DIRECT CLerpNodePathInterval : public CLerpInterval {
29 PUBLISHED:
30  CLerpNodePathInterval(const string &name, double duration,
31  BlendType blend_type, bool bake_in_start,
32  bool fluid,
33  const NodePath &node, const NodePath &other);
34 
35  INLINE const NodePath &get_node() const;
36  INLINE const NodePath &get_other() const;
37 
38  INLINE void set_start_pos(const LVecBase3 &pos);
39  INLINE void set_end_pos(const LVecBase3 &pos);
40  INLINE void set_start_hpr(const LVecBase3 &hpr);
41  INLINE void set_end_hpr(const LVecBase3 &hpr);
42  INLINE void set_end_hpr(const LQuaternion &quat);
43  INLINE void set_start_quat(const LQuaternion &quat);
44  INLINE void set_end_quat(const LVecBase3 &hpr);
45  INLINE void set_end_quat(const LQuaternion &quat);
46  INLINE void set_start_scale(const LVecBase3 &scale);
47  INLINE void set_start_scale(PN_stdfloat scale);
48  INLINE void set_end_scale(const LVecBase3 &scale);
49  INLINE void set_end_scale(PN_stdfloat scale);
50  INLINE void set_start_shear(const LVecBase3 &shear);
51  INLINE void set_end_shear(const LVecBase3 &shear);
52  INLINE void set_start_color(const LVecBase4 &color);
53  INLINE void set_end_color(const LVecBase4 &color);
54  INLINE void set_start_color_scale(const LVecBase4 &color_scale);
55  INLINE void set_end_color_scale(const LVecBase4 &color_scale);
56  INLINE void set_texture_stage(TextureStage *stage);
57  INLINE void set_start_tex_offset(const LVecBase2 &tex_offset);
58  INLINE void set_end_tex_offset(const LVecBase2 &tex_offset);
59  INLINE void set_start_tex_rotate(PN_stdfloat tex_rotate);
60  INLINE void set_end_tex_rotate(PN_stdfloat tex_rotate);
61  INLINE void set_start_tex_scale(const LVecBase2 &tex_scale);
62  INLINE void set_end_tex_scale(const LVecBase2 &tex_scale);
63 
64  INLINE void set_override(int override);
65  INLINE int get_override() const;
66 
67  virtual void priv_initialize(double t);
68  virtual void priv_instant();
69  virtual void priv_step(double t);
70  virtual void priv_reverse_initialize(double t);
71  virtual void priv_reverse_instant();
72 
73  virtual void output(ostream &out) const;
74 
75 private:
76  void setup_slerp();
77 
78  NodePath _node;
79  NodePath _other;
80 
81  enum Flags {
82  F_end_pos = 0x00000001,
83  F_end_hpr = 0x00000002,
84  F_end_quat = 0x00000004,
85  F_end_scale = 0x00000008,
86  F_end_color = 0x00000010,
87  F_end_color_scale = 0x00000020,
88  F_end_shear = 0x00000040,
89  F_end_tex_offset = 0x00000080,
90  F_end_tex_rotate = 0x00000100,
91  F_end_tex_scale = 0x00000200,
92 
93  F_start_pos = 0x00010000,
94  F_start_hpr = 0x00020000,
95  F_start_quat = 0x00040000,
96  F_start_scale = 0x00080000,
97  F_start_color = 0x00100000,
98  F_start_color_scale = 0x00200000,
99  F_start_shear = 0x00400000,
100  F_start_tex_offset = 0x00800000,
101  F_start_tex_rotate = 0x01000000,
102  F_start_tex_scale = 0x02000000,
103 
104  F_fluid = 0x10000000,
105  F_bake_in_start = 0x20000000,
106 
107  F_slerp_setup = 0x40000000,
108  };
109 
110  unsigned int _flags;
111  LPoint3 _start_pos, _end_pos;
112  LVecBase3 _start_hpr, _end_hpr;
113  LQuaternion _start_quat, _end_quat;
114  LVecBase3 _start_scale, _end_scale;
115  LVecBase3 _start_shear, _end_shear;
116  LColor _start_color, _end_color;
117  LVecBase4 _start_color_scale, _end_color_scale;
118  PT(TextureStage) _texture_stage;
119  LVecBase2 _start_tex_offset, _end_tex_offset;
120  PN_stdfloat _start_tex_rotate, _end_tex_rotate;
121  LVecBase2 _start_tex_scale, _end_tex_scale;
122 
123  int _override;
124  double _prev_d;
125  PN_stdfloat _slerp_angle;
126  PN_stdfloat _slerp_denom;
127  LQuaternion _slerp_c;
128 
129  void slerp_basic(LQuaternion &result, PN_stdfloat t) const;
130  void slerp_angle_0(LQuaternion &result, PN_stdfloat t) const;
131  void slerp_angle_180(LQuaternion &result, PN_stdfloat t) const;
132 
133  // Define a pointer to one of the above three methods.
134  void (CLerpNodePathInterval::*_slerp)(LQuaternion &result, PN_stdfloat t) const;
135 
136 public:
137  static TypeHandle get_class_type() {
138  return _type_handle;
139  }
140  static void init_type() {
141  CLerpInterval::init_type();
142  register_type(_type_handle, "CLerpNodePathInterval",
143  CLerpInterval::get_class_type());
144  }
145  virtual TypeHandle get_type() const {
146  return get_class_type();
147  }
148  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
149 
150 private:
151  static TypeHandle _type_handle;
152 };
153 
154 #include "cLerpNodePathInterval.I"
155 
156 #endif
157 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
virtual void priv_step(double t)
Advances the time on the interval.
Definition: cInterval.cxx:407
virtual void priv_instant()
This is called in lieu of priv_initialize() .
Definition: cInterval.cxx:390
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
virtual void priv_reverse_initialize(double t)
Similar to priv_initialize(), but this is called when the interval is being played backwards; it indi...
Definition: cInterval.cxx:439
An interval that lerps one or more properties (like pos, hpr, etc.) on a NodePath over time...
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
virtual void priv_initialize(double t)
This replaces the first call to priv_step(), and indicates that the interval has just begun...
Definition: cInterval.cxx:374
This is the base quaternion class.
Definition: lquaternion.h:96
virtual void priv_reverse_instant()
This is called in lieu of priv_reverse_initialize()
Definition: cInterval.cxx:456
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Defines the properties of a named stage of the multitexture pipeline.
Definition: textureStage.h:38
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
The base class for a family of intervals that linearly interpolate one or more numeric values over ti...
Definition: cLerpInterval.h:27