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

OgreSimpleRenderable.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #include "OgreStableHeaders.h"
00026 #include "OgreSimpleRenderable.h"
00027 #include "OgreException.h"
00028 #include "OgreNode.h"
00029 
00030 #include "OgreMaterialManager.h"
00031 
00032 namespace Ogre {
00033 
00034     uint SimpleRenderable::ms_uGenNameCount = 0;
00035 
00036     SimpleRenderable::SimpleRenderable()
00037     {
00038         m_matWorldTransform = Matrix4::IDENTITY;
00039 
00040         m_strMatName = "BaseWhite"; 
00041         m_pMaterial = reinterpret_cast< Material* >( MaterialManager::getSingleton().getByName( "BaseWhite" ) );
00042 
00043         m_pParentSceneManager = NULL;
00044 
00045         mParentNode = NULL;
00046         m_pCamera = NULL;
00047 
00048         // Generate name
00049         m_strName << _TO_CHAR("SimpleRenderable") << ms_uGenNameCount ++;
00050     }
00051 
00052     void SimpleRenderable::setMaterial( const String& matName )
00053     {
00054         m_strMatName = matName;
00055         m_pMaterial = reinterpret_cast<Material*>(
00056             MaterialManager::getSingleton().getByName( m_strMatName ) );
00057         if (!m_pMaterial)
00058             Except( Exception::ERR_ITEM_NOT_FOUND, "Could not find material " + m_strMatName,
00059                 "SimpleRenderable::setMaterial" );
00060     
00061         // Won't load twice anyway
00062         m_pMaterial->load();
00063     }
00064 
00065     Material* SimpleRenderable::getMaterial(void) const
00066     {
00067         return m_pMaterial;
00068     }
00069 
00070     void SimpleRenderable::getRenderOperation(RenderOperation& op)
00071     {
00072         op = mRenderOp;
00073     }
00074 
00075     void SimpleRenderable::setRenderOperation( const RenderOperation& rend )
00076     {
00077         mRenderOp = rend;
00078     }
00079 
00080     void SimpleRenderable::setWorldTransform( const Matrix4& xform )
00081     {
00082         m_matWorldTransform = xform;
00083     }
00084 
00085     void SimpleRenderable::getWorldTransforms( Matrix4* xform ) const
00086     {
00087         *xform = m_matWorldTransform * mParentNode->_getFullTransform();
00088     }
00089     //-----------------------------------------------------------------------
00090     const Quaternion& SimpleRenderable::getWorldOrientation(void) const
00091     {
00092         return mParentNode->_getDerivedOrientation();
00093     }
00094     //-----------------------------------------------------------------------
00095     const Vector3& SimpleRenderable::getWorldPosition(void) const
00096     {
00097         return mParentNode->_getDerivedPosition();
00098     }
00099 
00100     void SimpleRenderable::_notifyCurrentCamera(Camera* cam)
00101     {
00102         m_pCamera = cam;
00103     }
00104 
00105     void SimpleRenderable::setBoundingBox( const AxisAlignedBox& box )
00106     {
00107         mBox = box;
00108     }
00109 
00110     const AxisAlignedBox& SimpleRenderable::getBoundingBox(void) const
00111     {
00112         return mBox;
00113     }
00114 
00115     void SimpleRenderable::_updateRenderQueue(RenderQueue* queue)
00116     {
00117         queue->addRenderable( this );
00118     }
00119 
00120     SimpleRenderable::~SimpleRenderable()
00121     {
00122     }
00123     //-----------------------------------------------------------------------
00124     const String& SimpleRenderable::getName(void) const
00125     {
00126         return m_strName;
00127     }
00128     //-----------------------------------------------------------------------
00129     const String& SimpleRenderable::getMovableType(void) const
00130     {
00131         static String movType = "SimpleRenderable";
00132         return movType;
00133     }
00134     //-----------------------------------------------------------------------
00135     const LightList& SimpleRenderable::getLights(void) const
00136     {
00137         static LightList dummyLightList;
00138         // Use parent node
00139         if (mParentNode)
00140             return mParentNode->getLights();
00141         else
00142             return dummyLightList;
00143     }
00144 
00145 }

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:28 2004