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