Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/egg/eggTransform3d.h

Go to the documentation of this file.
00001 // Filename: eggTransform3d.h
00002 // Created by:  drose (21Jun02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef EGGTRANSFORM3D_H
00020 #define EGGTRANSFORM3D_H
00021 
00022 #include "pandabase.h"
00023 #include "luse.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : EggTransform3d
00027 // Description : This represents the <Transform> entry of a group
00028 //               node: a list of component transform operations,
00029 //               applied in order, that describe a net transform
00030 //               matrix.  This is a 3-d transform, and therefore
00031 //               computes a 4x4 matrix.
00032 ////////////////////////////////////////////////////////////////////
00033 class EXPCL_PANDAEGG EggTransform3d {
00034 public:
00035   EggTransform3d();
00036   EggTransform3d(const EggTransform3d &copy);
00037   EggTransform3d &operator = (const EggTransform3d &copy);
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 &copy);
00089     INLINE void operator = (const Component &copy);
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

Generated on Fri May 2 00:38:01 2003 for Panda by doxygen1.3