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

OgreRenderable.h

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 (c) 2000-2005 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 #ifndef __Renderable_H__
00026 #define __Renderable_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreCommon.h"
00030 
00031 #include "OgreRenderOperation.h"
00032 #include "OgreMatrix4.h"
00033 #include "OgreMaterial.h"
00034 #include "OgrePlane.h"
00035 #include "OgreGpuProgram.h"
00036 #include "OgreVector4.h"
00037 #include "OgreException.h"
00038 
00039 namespace Ogre {
00040 
00052     class _OgreExport Renderable
00053     {
00054     public:
00055         Renderable() : mRenderDetailOverrideable(true) {}
00057         virtual ~Renderable() { }
00063         virtual const MaterialPtr& getMaterial(void) const = 0;
00069         virtual Technique* getTechnique(void) const { return getMaterial()->getBestTechnique(); }
00072         virtual void getRenderOperation(RenderOperation& op) = 0;
00082         virtual void getWorldTransforms(Matrix4* xform) const = 0;
00088         virtual const Quaternion& getWorldOrientation(void) const = 0;
00094         virtual const Vector3& getWorldPosition(void) const = 0;
00095 
00104         virtual unsigned short getNumWorldTransforms(void) const { return 1; }
00105 
00114         virtual bool useIdentityProjection(void) const { return false; }
00115 
00124         virtual bool useIdentityView(void) const { return false; }
00125 
00131         virtual Real getSquaredViewDepth(const Camera* cam) const = 0;
00132 
00135         virtual SceneDetailLevel getRenderDetail() const {return SDL_SOLID;} 
00136 
00138         virtual bool getNormaliseNormals(void) const { return false; }
00139 
00144         virtual const LightList& getLights(void) const = 0;
00145 
00146         virtual const PlaneList& getClipPlanes() const { return msDummyPlaneList; };
00147 
00154         virtual bool getCastsShadows(void) const { return false; }
00155 
00171         void setCustomParameter(size_t index, const Vector4& value) 
00172         {
00173             mCustomParameters[index] = value;
00174         }
00175 
00180         const Vector4& getCustomParameter(size_t index) const
00181         {
00182             CustomParameterMap::const_iterator i = mCustomParameters.find(index);
00183             if (i != mCustomParameters.end())
00184             {
00185                 return i->second;
00186             }
00187             else
00188             {
00189                 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 
00190                     "Parameter at the given index was not found.",
00191                     "Renderable::getCustomParameter");
00192             }
00193         }
00194 
00219         virtual void _updateCustomGpuParameter(
00220             const GpuProgramParameters::AutoConstantEntry& constantEntry,
00221             GpuProgramParameters* params) const
00222         {
00223             CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data);
00224             if (i != mCustomParameters.end())
00225             {
00226                 params->setConstant(constantEntry.index, i->second);
00227             }
00228         }
00229 
00235         virtual void setRenderDetailOverrideable(bool override)
00236         {
00237             mRenderDetailOverrideable = override;
00238         }
00239 
00243         virtual bool getRenderDetailOverrideable(void) const
00244         {
00245             return mRenderDetailOverrideable;
00246         }
00247 
00248 
00249     protected:
00250         static const PlaneList msDummyPlaneList;
00251         typedef std::map<size_t, Vector4> CustomParameterMap;
00252         CustomParameterMap mCustomParameters;
00253         bool mRenderDetailOverrideable;
00254     };
00255 
00256 
00257 
00258 }
00259 
00260 #endif //__Renderable_H__

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:50 2006