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 "OgreSceneNode.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         StringUtil::StrStreamType name;
    00050         name << _TO_CHAR("SimpleRenderable") << ms_uGenNameCount++;
    00051         m_strName = name.str();
    00052     }
    00053
    00054     void SimpleRenderable::setMaterial( const String& matName )
    00055     {
    00056         m_strMatName = matName;
    00057         m_pMaterial = reinterpret_cast<Material*>(
    00058             MaterialManager::getSingleton().getByName( m_strMatName ) );
    00059         if (!m_pMaterial)
    00060             Except( Exception::ERR_ITEM_NOT_FOUND, "Could not find material " + m_strMatName,
    00061                 "SimpleRenderable::setMaterial" );
    00062
    00063         // Won't load twice anyway
    00064         m_pMaterial->load();
    00065     }
    00066
    00067     Material* SimpleRenderable::getMaterial(void) const
    00068     {
    00069         return m_pMaterial;
    00070     }
    00071
    00072     void SimpleRenderable::getRenderOperation(RenderOperation& op)
    00073     {
    00074         op = mRenderOp;
    00075     }
    00076
    00077     void SimpleRenderable::setRenderOperation( const RenderOperation& rend )
    00078     {
    00079         mRenderOp = rend;
    00080     }
    00081
    00082     void SimpleRenderable::setWorldTransform( const Matrix4& xform )
    00083     {
    00084         m_matWorldTransform = xform;
    00085     }
    00086
    00087     void SimpleRenderable::getWorldTransforms( Matrix4* xform ) const
    00088     {
    00089         *xform = m_matWorldTransform * mParentNode->_getFullTransform();
    00090     }
    00091     //-----------------------------------------------------------------------
    00092     const Quaternion& SimpleRenderable::getWorldOrientation(void) const
    00093     {
    00094         return mParentNode->_getDerivedOrientation();
    00095     }
    00096     //-----------------------------------------------------------------------
    00097     const Vector3& SimpleRenderable::getWorldPosition(void) const
    00098     {
    00099         return mParentNode->_getDerivedPosition();
    00100     }
    00101
    00102     void SimpleRenderable::_notifyCurrentCamera(Camera* cam)
    00103     {
    00104         m_pCamera = cam;
    00105     }
    00106
    00107     void SimpleRenderable::setBoundingBox( const AxisAlignedBox& box )
    00108     {
    00109         mBox = box;
    00110     }
    00111
    00112     const AxisAlignedBox& SimpleRenderable::getBoundingBox(void) const
    00113     {
    00114         return mBox;
    00115     }
    00116
    00117     void SimpleRenderable::_updateRenderQueue(RenderQueue* queue)
    00118     {
    00119         queue->addRenderable( this, mRenderQueueID, RENDERABLE_DEFAULT_PRIORITY);
    00120     }
    00121
    00122     SimpleRenderable::~SimpleRenderable()
    00123     {
    00124     }
    00125     //-----------------------------------------------------------------------
    00126     const String& SimpleRenderable::getName(void) const
    00127     {
    00128         return m_strName;
    00129     }
    00130     //-----------------------------------------------------------------------
    00131     const String& SimpleRenderable::getMovableType(void) const
    00132     {
    00133         static String movType = "SimpleRenderable";
    00134         return movType;
    00135     }
    00136     //-----------------------------------------------------------------------
    00137     const LightList& SimpleRenderable::getLights(void) const
    00138     {
    00139         static LightList dummyLightList;
    00140         // Use parent node
    00141         SceneNode* n = getParentSceneNode();
    00142         if (n)
    00143             return n->findLights(this->getBoundingRadius());
    00144         else
    00145             return dummyLightList;
    00146     }
    00147
    00148 }

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:46 2004