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() : mPolygonModeOverrideable(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 
00134         virtual bool getNormaliseNormals(void) const { return false; }
00135 
00140         virtual const LightList& getLights(void) const = 0;
00141 
00142         virtual const PlaneList& getClipPlanes() const { return msDummyPlaneList; };
00143 
00150         virtual bool getCastsShadows(void) const { return false; }
00151 
00167         void setCustomParameter(size_t index, const Vector4& value) 
00168         {
00169             mCustomParameters[index] = value;
00170         }
00171 
00176         const Vector4& getCustomParameter(size_t index) const
00177         {
00178             CustomParameterMap::const_iterator i = mCustomParameters.find(index);
00179             if (i != mCustomParameters.end())
00180             {
00181                 return i->second;
00182             }
00183             else
00184             {
00185                 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 
00186                     "Parameter at the given index was not found.",
00187                     "Renderable::getCustomParameter");
00188             }
00189         }
00190 
00215         virtual void _updateCustomGpuParameter(
00216             const GpuProgramParameters::AutoConstantEntry& constantEntry,
00217             GpuProgramParameters* params) const
00218         {
00219             CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data);
00220             if (i != mCustomParameters.end())
00221             {
00222                 params->setConstant(constantEntry.index, i->second);
00223             }
00224         }
00225 
00231         virtual void setPolygonModeOverrideable(bool override)
00232         {
00233             mPolygonModeOverrideable = override;
00234         }
00235 
00239         virtual bool getPolygonModeOverrideable(void) const
00240         {
00241             return mPolygonModeOverrideable;
00242         }
00243 
00244 
00245     protected:
00246         static const PlaneList msDummyPlaneList;
00247         typedef std::map<size_t, Vector4> CustomParameterMap;
00248         CustomParameterMap mCustomParameters;
00249         bool mPolygonModeOverrideable;
00250     };
00251 
00252 
00253 
00254 }
00255 
00256 #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 Mar 12 14:37:47 2006