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

sglTransform.hpp

00001 /*****************************************************************************
00002  * SGL: A Scene Graph Library
00003  *
00004  * Copyright (C) 1997-2001  Scott McMillan   All Rights Reserved.
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  *****************************************************************************
00020  *     File: sglTransform.hpp
00021  *  Created: 14 November 1998
00022  *  Summary: transform the model view matrix before traversing the children
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);  // radians
00095 
00102    void setRotation(T h, T p, T r);  // radians
00103 
00110    void setMatrix(const sglMat4<T> &m);
00111 
00115    const sglMat4<T> &getMatrix() const { return m_matrix; }
00116 
00117    // See sglNode::intersect(f) for details.
00118    virtual sglBound::IntersectResultEnum intersect(
00119       sglIntersectf &isector) const;
00120 
00121    // See sglNode::intersect(d) for details.
00122    virtual sglBound::IntersectResultEnum intersect(
00123       sglIntersectd &isector) const;
00124 
00125    // See sglNode::pick(f) for details.
00126    virtual void pick(sglPickf &pick_state, unsigned int cull_flags) const;
00127 
00128    // See sglNode::pick(d) for details.
00129    virtual void pick(sglPickd &pick_state, unsigned int cull_flags) const;
00130 
00131    // See sglNode::computeTxToParent() for details.
00132    virtual void computeTxToParent(sglMat4f &curr_mat) const;
00133 
00134    // See sglNode::computeTxToParent() for details.
00135    virtual void computeTxToParent(sglMat4d &curr_mat) const;
00136 
00137    // See sglNode::clone() for details.
00138    virtual sglNode *clone(unsigned int mode) const;
00139 
00140    // See sglObject::printInfo() for details.
00141    virtual void printInfo(ostream &ostrm, const char *indent_string) const;
00142 
00143 protected:
00144    // compute the bounding sphere
00145    virtual void computeBound();
00146 
00147    // See sglNode::cull(f) for details
00148    virtual void cull(sglCull<float> &trav_state,
00149                      unsigned int cull_flags) const;
00150 
00151    // See sglNode::cull(d) for details
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:  // not implemented
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 // convenience types:
00174 //    template class 'should' only be float or double
00175 
00177 typedef sglTransform<float>  sglTransformf;
00179 typedef sglTransform<double> sglTransformd;
00180 
00181 #endif

Generated at Mon Jul 1 18:00:06 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001