MercuryMatrixStack.h

Go to the documentation of this file.
00001 #ifndef _MERCURY_MATRIX_STACK_H
00002 #define _MERCURY_MATRIX_STACK_H
00003 
00004 #include "MercuryUtil.h"
00005 #include "MercuryMatrix.h"
00006 
00007 static const unsigned int MAXMATRIXSTACKSIZE = 100;
00008 
00009 class MercuryMatrixStack
00010 {
00011 public:
00012     MercuryMatrixStack() { m_iMatrixDepth = 0;  } 
00013     inline void Push() { ASSERT( m_iMatrixDepth < MAXMATRIXSTACKSIZE ); m_vMatrix[m_iMatrixDepth+1] = m_vMatrix[m_iMatrixDepth]; ++m_iMatrixDepth; } 
00014     inline void Pop() { ASSERT( m_iMatrixDepth ); --m_iMatrixDepth; }; 
00015     inline void LoadIdentity() { m_vMatrix[m_iMatrixDepth].Identity(); }
00016     inline void LoadMatrix( const MercuryMatrix& m) { m_vMatrix[m_iMatrixDepth] = m; }
00017     inline const MercuryMatrix& GetTop() const { return m_vMatrix[m_iMatrixDepth]; }
00018     inline MercuryMatrix& GetTop() { return  m_vMatrix[m_iMatrixDepth]; }
00019 
00020 private:
00021     MercuryMatrix m_vMatrix[MAXMATRIXSTACKSIZE];
00022     unsigned int m_iMatrixDepth;
00023 };
00024 
00025 #endif
00026 
00027 /* 
00028  * Copyright (c) 2006 Joshua Allen
00029  * All rights reserved.
00030  *
00031  * Redistribution and use in source and binary forms, with or
00032  * without modification, are permitted provided that the following
00033  * conditions are met:
00034  *  -   Redistributions of source code must retain the above
00035  *      copyright notice, this list of conditions and the following disclaimer.
00036  *  -   Redistributions in binary form must reproduce the above copyright
00037  *      notice, this list of conditions and the following disclaimer in
00038  *      the documentation and/or other materials provided with the distribution.
00039  *  -   Neither the name of the Mercury Engine nor the names of its
00040  *      contributors may be used to endorse or promote products derived from
00041  *      this software without specific prior written permission.
00042  *
00043  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00044  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00045  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00046  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00047  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00048  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00049  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00050  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00051  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00052  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00053  */
00054 

Hosted by SourceForge.net Logo