Panda3D
|
00001 // Filename: stTransform.h 00002 // Created by: drose (06Oct10) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef STTRANSFORM_H 00016 #define STTRANSFORM_H 00017 00018 #include "pandabase.h" 00019 #include "transformState.h" 00020 #include "speedtree_api.h" 00021 #include "deg_2_rad.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : STTransform 00025 // Description : Represents a transform that may be applied to a 00026 // particular instance of a tree when added to the 00027 // SpeedTreeNode. 00028 //////////////////////////////////////////////////////////////////// 00029 class EXPCL_PANDASPEEDTREE STTransform { 00030 PUBLISHED: 00031 INLINE STTransform(); 00032 STTransform(const TransformState *trans); 00033 INLINE STTransform(const LPoint3 &pos, PN_stdfloat rotate = 0.0f, PN_stdfloat scale = 1.0f); 00034 INLINE STTransform(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat rotate, PN_stdfloat scale); 00035 INLINE STTransform(const STTransform ©); 00036 INLINE void operator = (const STTransform ©); 00037 00038 public: 00039 INLINE STTransform(const SpeedTree::CInstance &instance); 00040 INLINE operator SpeedTree::CInstance () const; 00041 INLINE operator CPT(TransformState) () const; 00042 00043 PUBLISHED: 00044 INLINE static const STTransform &ident_mat(); 00045 00046 INLINE void set_pos(const LPoint3 &pos); 00047 INLINE const LPoint3 &get_pos() const; 00048 INLINE void set_rotate(PN_stdfloat rotate); 00049 INLINE PN_stdfloat get_rotate() const; 00050 INLINE void set_scale(PN_stdfloat scale); 00051 INLINE PN_stdfloat get_scale() const; 00052 00053 INLINE void operator *= (const STTransform &other); 00054 INLINE STTransform operator * (const STTransform &other) const; 00055 00056 void output(ostream &out) const; 00057 00058 public: 00059 void write_datagram(BamWriter *manager, Datagram &dg); 00060 void fillin(DatagramIterator &scan, BamReader *manager); 00061 00062 public: 00063 LPoint3 _pos; 00064 PN_stdfloat _rotate; 00065 PN_stdfloat _scale; 00066 00067 static STTransform _ident_mat; 00068 }; 00069 00070 INLINE ostream &operator << (ostream &out, const STTransform &transform) { 00071 transform.output(out); 00072 return out; 00073 } 00074 00075 #include "stTransform.I" 00076 00077 #endif