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

TransformStack.h

Go to the documentation of this file.
00001 // Copyright NVIDIA Corporation 2002-2004
00002 // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
00003 // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
00004 // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
00005 // AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
00006 // BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
00007 // WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
00008 // BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
00009 // ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
00010 // BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 
00011 
00012 #pragma once
00013 
00015 #include "nvsgcommon.h"
00016 
00017 #include <stack>
00018 #include "nvmath/Mat44f.h"
00019  
00020 namespace nvutil
00021 {
00023 
00039   class TransformStack
00040   {
00041     public:
00043 
00044       TransformStack();
00045 
00046     public:
00048       NVSG_API const nvmath::Mat44f    getClipToModel( void )  const;
00049 
00051       NVSG_API const nvmath::Mat44f  & getClipToView( void )   const;
00052 
00054       NVSG_API const nvmath::Mat44f    getModelToClip( void )  const;
00055 
00057       NVSG_API const nvmath::Mat44f    getModelToView( void )  const;
00058 
00060       NVSG_API const nvmath::Mat44f  & getModelToWorld( void ) const;
00061 
00063       NVSG_API const nvmath::Mat44f  & getViewToClip( void )   const;
00064 
00066       NVSG_API const nvmath::Mat44f    getViewToModel( void )  const;
00067 
00069       NVSG_API const nvmath::Mat44f  & getViewToWorld( void )  const;
00070 
00072       NVSG_API const nvmath::Mat44f  & getWorldToModel( void ) const;
00073 
00075       NVSG_API const nvmath::Mat44f  & getWorldToView( void )  const;
00076 
00078       NVSG_API size_t    getStackDepth( void )   const;
00079 
00081       NVSG_API void      popModelToWorld( void );
00082 
00084 
00085       NVSG_API void      pushModelToWorld( const nvmath::Mat44f &modelWorld    
00086                                          , const nvmath::Mat44f &worldModel    
00087                                          );
00088 
00090 
00091       NVSG_API void      setViewToClip( const nvmath::Mat44f &viewClip         
00092                                       , const nvmath::Mat44f &clipView         
00093                                       );
00094 
00096 
00097       NVSG_API void      setWorldToView( const nvmath::Mat44f &worldView       
00098                                        , const nvmath::Mat44f &viewWorld       
00099                                        );
00100 
00101     private :
00102       std::stack<nvmath::Mat44f> m_modelWorld;     
00103       std::stack<nvmath::Mat44f> m_worldModel;     
00104       nvmath::Mat44f        m_worldView;      
00105       nvmath::Mat44f        m_viewWorld;      
00106       nvmath::Mat44f        m_viewClip;       
00107       nvmath::Mat44f        m_clipView;       
00108   };
00109 
00110 
00111   inline  TransformStack::TransformStack()
00112   {
00113     m_modelWorld.push( nvmath::cIdentity44f );
00114     m_worldModel.push( nvmath::cIdentity44f );
00115   }
00116 
00117   inline  const nvmath::Mat44f    TransformStack::getClipToModel( void )  const
00118   {
00119     return( m_worldModel.top() * m_viewWorld * m_clipView );
00120   }
00121 
00122   inline  const nvmath::Mat44f  & TransformStack::getClipToView( void )   const
00123   {
00124     return( m_clipView );
00125   }
00126 
00127   inline  const nvmath::Mat44f    TransformStack::getModelToClip( void )  const
00128   {
00129     return( m_viewClip * m_worldView * m_modelWorld.top() );
00130   }
00131 
00132   inline  const nvmath::Mat44f    TransformStack::getModelToView( void )  const
00133   {
00134     return( m_worldView * m_modelWorld.top() );
00135   }
00136 
00137   inline  const nvmath::Mat44f  & TransformStack::getModelToWorld( void ) const
00138   {
00139     return( m_modelWorld.top() );
00140   }
00141   
00142   inline  const nvmath::Mat44f  & TransformStack::getViewToClip( void )   const
00143   {
00144     return( m_viewClip );
00145   }
00146   
00147   inline  const nvmath::Mat44f    TransformStack::getViewToModel( void )  const
00148   {
00149     return( m_worldModel.top() * m_viewWorld );
00150   }
00151   
00152   inline  const nvmath::Mat44f  & TransformStack::getViewToWorld( void )  const
00153   {
00154     return( m_viewWorld );
00155   }
00156   
00157   inline  const nvmath::Mat44f  & TransformStack::getWorldToModel( void ) const
00158   {
00159     return( m_worldModel.top() );
00160   }
00161   
00162   inline  const nvmath::Mat44f  & TransformStack::getWorldToView( void )  const
00163   {
00164     return( m_worldView );
00165   }
00166 
00167   inline  size_t  TransformStack::getStackDepth( void ) const
00168   {
00169     __ASSERT( m_modelWorld.size() == m_worldModel.size() );
00170     return( m_modelWorld.size() );
00171   }
00172 
00173   inline  void  TransformStack::popModelToWorld( void )
00174   {
00175     m_modelWorld.pop();
00176     m_worldModel.pop();
00177   }
00178 
00179   inline  void  TransformStack::pushModelToWorld( const nvmath::Mat44f &modelWorld, const nvmath::Mat44f &worldModel )
00180   {
00181     m_modelWorld.push( m_modelWorld.top() * modelWorld );
00182     m_worldModel.push( worldModel * m_worldModel.top() );
00183   }
00184 
00185   inline  void  TransformStack::setViewToClip( const nvmath::Mat44f &viewClip, const nvmath::Mat44f &clipView )
00186   {
00187     m_viewClip = viewClip;
00188     m_clipView = clipView;
00189   }
00190 
00191   inline  void  TransformStack::setWorldToView( const nvmath::Mat44f &worldView, const nvmath::Mat44f &viewWorld )
00192   {
00193     m_worldView = worldView;
00194     m_viewWorld = viewWorld;
00195   }
00196 }

Generated on Tue Mar 1 13:19:19 2005 for NVSGSDK by NVIDIA