00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGTRANSFORM3D_H
00020 #define EGGTRANSFORM3D_H
00021
00022 #include "pandabase.h"
00023 #include "luse.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class EXPCL_PANDAEGG EggTransform3d {
00034 public:
00035 EggTransform3d();
00036 EggTransform3d(const EggTransform3d ©);
00037 EggTransform3d &operator = (const EggTransform3d ©);
00038 virtual ~EggTransform3d();
00039
00040 INLINE void clear_transform();
00041
00042 void add_translate(const LVector3d &translate);
00043 void add_rotx(double angle);
00044 void add_roty(double angle);
00045 void add_rotz(double angle);
00046 void add_rotate(double angle, const LVector3d &axis);
00047 void add_rotate(const LQuaterniond &quat);
00048 void add_scale(const LVecBase3d &scale);
00049 void add_uniform_scale(double scale);
00050 INLINE void add_matrix(const LMatrix4d &mat);
00051
00052 INLINE bool has_transform() const;
00053 INLINE void set_transform(const LMatrix4d &mat);
00054 INLINE const LMatrix4d &get_transform() const;
00055 INLINE bool transform_is_identity() const;
00056
00057 enum ComponentType {
00058 CT_invalid,
00059 CT_translate,
00060 CT_rotx,
00061 CT_roty,
00062 CT_rotz,
00063 CT_rotate,
00064 CT_scale,
00065 CT_uniform_scale,
00066 CT_matrix
00067 };
00068
00069 INLINE int get_num_components() const;
00070 INLINE ComponentType get_component_type(int n) const;
00071 INLINE double get_component_number(int n) const;
00072 INLINE const LVector3d &get_component_vector(int n) const;
00073 INLINE const LMatrix4d &get_component_matrix(int n) const;
00074
00075 void write(ostream &out, int indent_level) const;
00076
00077 protected:
00078 void internal_clear_transform();
00079 void internal_add_matrix(const LMatrix4d &mat);
00080 INLINE void internal_set_transform(const LMatrix4d &mat);
00081
00082 virtual void transform_changed();
00083
00084 private:
00085 class Component {
00086 public:
00087 INLINE Component(ComponentType type, double number = 0.0);
00088 INLINE Component(const Component ©);
00089 INLINE void operator = (const Component ©);
00090 INLINE ~Component();
00091
00092 ComponentType _type;
00093 double _number;
00094 LVector3d *_vector;
00095 LMatrix4d *_matrix;
00096 };
00097
00098 typedef pvector<Component> Components;
00099 Components _components;
00100 LMatrix4d _transform;
00101 };
00102
00103 #include "eggTransform3d.I"
00104
00105 #endif