Panda3D
 All Classes Functions Variables Enumerations
eggTransform.h
1 // Filename: eggTransform.h
2 // Created by: drose (21Jun02)
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 EGGTRANSFORM_H
16 #define EGGTRANSFORM_H
17 
18 #include "pandabase.h"
19 #include "luse.h"
20 #include "eggObject.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : EggTransform
24 // Description : This represents the <Transform> entry of a group
25 // or texture node: a list of component transform
26 // operations, applied in order, that describe a net
27 // transform matrix.
28 //
29 // This may be either a 3-d transform, and therefore
30 // described by a 4x4 matrix, or a 2-d transform,
31 // described by a 3x3 matrix.
32 ////////////////////////////////////////////////////////////////////
33 class EXPCL_PANDAEGG EggTransform {
34 PUBLISHED:
35  EggTransform();
36  EggTransform(const EggTransform &copy);
37  EggTransform &operator = (const EggTransform &copy);
38  virtual ~EggTransform();
39 
40  INLINE void clear_transform();
41 
42  void add_translate2d(const LVector2d &translate);
43  void add_translate3d(const LVector3d &translate);
44  void add_rotate2d(double angle);
45  void add_rotx(double angle);
46  void add_roty(double angle);
47  void add_rotz(double angle);
48  void add_rotate3d(double angle, const LVector3d &axis);
49  void add_rotate3d(const LQuaterniond &quat);
50  void add_scale2d(const LVecBase2d &scale);
51  void add_scale3d(const LVecBase3d &scale);
52  void add_uniform_scale(double scale);
53  INLINE void add_matrix3(const LMatrix3d &mat);
54  INLINE void add_matrix4(const LMatrix4d &mat);
55 
56  INLINE bool has_transform() const;
57  INLINE bool has_transform2d() const;
58  INLINE void set_transform2d(const LMatrix3d &mat);
59  INLINE bool has_transform3d() const;
60  INLINE void set_transform3d(const LMatrix4d &mat);
61  INLINE LMatrix3d get_transform2d() const;
62  INLINE const LMatrix4d &get_transform3d() const;
63  INLINE bool transform_is_identity() const;
64 
65  enum ComponentType {
66  CT_invalid,
67  CT_translate2d,
68  CT_translate3d,
69  CT_rotate2d,
70  CT_rotx,
71  CT_roty,
72  CT_rotz,
73  CT_rotate3d,
74  CT_scale2d,
75  CT_scale3d,
76  CT_uniform_scale,
77  CT_matrix3,
78  CT_matrix4
79  };
80 
81  INLINE int get_num_components() const;
82  INLINE ComponentType get_component_type(int n) const;
83  INLINE double get_component_number(int n) const;
84  INLINE const LVecBase2d &get_component_vec2(int n) const;
85  INLINE const LVecBase3d &get_component_vec3(int n) const;
86  INLINE const LMatrix3d &get_component_mat3(int n) const;
87  INLINE const LMatrix4d &get_component_mat4(int n) const;
88 
89  void write(ostream &out, int indent_level,
90  const string &label) const;
91 
92 protected:
93  void internal_clear_transform();
94  void internal_add_matrix(const LMatrix3d &mat);
95  void internal_add_matrix(const LMatrix4d &mat);
96  INLINE void internal_set_transform(const LMatrix3d &mat);
97  INLINE void internal_set_transform(const LMatrix4d &mat);
98 
99  virtual void transform_changed();
100 
101 private:
102  class Component {
103  public:
104  INLINE Component(ComponentType type, double number = 0.0);
105  INLINE Component(const Component &copy);
106  INLINE void operator = (const Component &copy);
107  INLINE ~Component();
108 
109  ComponentType _type;
110  double _number;
111  LVecBase2d *_vec2;
112  LVecBase3d *_vec3;
113  LMatrix3d *_mat3;
114  LMatrix4d *_mat4;
115  };
116 
117  bool _is_transform_2d;
119  Components _components;
120  LMatrix4d _transform;
121 };
122 
123 #include "eggTransform.I"
124 
125 #endif
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:4716
This is a two-component vector offset.
Definition: lvector2.h:416
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:1241
This is the base quaternion class.
Definition: lquaternion.h:974
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:4375
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:1455
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:746
This represents the &lt;Transform&gt; entry of a group or texture node: a list of component transform opera...
Definition: eggTransform.h:33