00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __SGL_TRANSFORM_HPP
00026 #define __SGL_TRANSFORM_HPP
00027
00028 #include <sgl.h>
00029 #include <sglMatrix.hpp>
00030 #include <sglGroup.hpp>
00031
00032
00033
00066 template <class T>
00067 class SGL_DLL_API sglTransform : public sglGroup
00068 {
00069 public:
00071 sglTransform() { loadIdentity(); }
00073 virtual ~sglTransform() {}
00074
00076 void loadIdentity();
00077
00084 void setTranslation(T x, T y, T z);
00085
00094 void setRotation(T angle, T x, T y, T z);
00095
00102 void setRotation(T h, T p, T r);
00103
00110 void setMatrix(const sglMat4<T> &m);
00111
00115 const sglMat4<T> &getMatrix() const { return m_matrix; }
00116
00117
00118 virtual sglBound::IntersectResultEnum intersect(
00119 sglIntersectf &isector) const;
00120
00121
00122 virtual sglBound::IntersectResultEnum intersect(
00123 sglIntersectd &isector) const;
00124
00125
00126 virtual void pick(sglPickf &pick_state, unsigned int cull_flags) const;
00127
00128
00129 virtual void pick(sglPickd &pick_state, unsigned int cull_flags) const;
00130
00131
00132 virtual void computeTxToParent(sglMat4f &curr_mat) const;
00133
00134
00135 virtual void computeTxToParent(sglMat4d &curr_mat) const;
00136
00137
00138 virtual sglNode *clone(unsigned int mode) const;
00139
00140
00141 virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00142
00143 protected:
00144
00145 virtual void computeBound();
00146
00147
00148 virtual void cull(sglCull<float> &trav_state,
00149 unsigned int cull_flags) const;
00150
00151
00152 virtual void cull(sglCull<double> &trav_state,
00153 unsigned int cull_flags) const;
00154
00155 void checkForIdentity();
00156 void checkForDeformation();
00157
00158 void copyTo(sglTransform *dst, unsigned int mode) const;
00159
00160 private:
00161 sglTransform(const sglTransform &);
00162 sglTransform& operator=(const sglTransform &);
00163
00164 protected:
00165 sglMat4<T> m_matrix;
00166 sglMat4<T> m_inv_mat;
00167 bool m_is_ident;
00168 bool m_rescale;
00169 bool m_normalize;
00170 };
00171
00172
00173
00174
00175
00177 typedef sglTransform<float> sglTransformf;
00179 typedef sglTransform<double> sglTransformd;
00180
00181 #endif