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: 00056 virtual ~Renderable() { } 00062 virtual const MaterialPtr& getMaterial(void) const = 0; 00068 virtual Technique* getTechnique(void) const { return getMaterial()->getBestTechnique(); } 00071 virtual void getRenderOperation(RenderOperation& op) = 0; 00081 virtual void getWorldTransforms(Matrix4* xform) const = 0; 00087 virtual const Quaternion& getWorldOrientation(void) const = 0; 00093 virtual const Vector3& getWorldPosition(void) const = 0; 00094 00103 virtual unsigned short getNumWorldTransforms(void) const { return 1; } 00104 00113 virtual bool useIdentityProjection(void) const { return false; } 00114 00123 virtual bool useIdentityView(void) const { return false; } 00124 00130 virtual Real getSquaredViewDepth(const Camera* cam) const = 0; 00131 00134 virtual SceneDetailLevel getRenderDetail() const {return SDL_SOLID;} 00135 00137 virtual bool getNormaliseNormals(void) const { return false; } 00138 00143 virtual const LightList& getLights(void) const = 0; 00144 00145 virtual const PlaneList& getClipPlanes() const { return msDummyPlaneList; }; 00146 00153 virtual bool getCastsShadows(void) const { return false; } 00154 00170 void setCustomParameter(size_t index, const Vector4& value) 00171 { 00172 mCustomParameters[index] = value; 00173 } 00174 00179 const Vector4& getCustomParameter(size_t index) const 00180 { 00181 CustomParameterMap::const_iterator i = mCustomParameters.find(index); 00182 if (i != mCustomParameters.end()) 00183 { 00184 return i->second; 00185 } 00186 else 00187 { 00188 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 00189 "Parameter at the given index was not found.", 00190 "Renderable::getCustomParameter"); 00191 } 00192 } 00193 00218 virtual void _updateCustomGpuParameter( 00219 const GpuProgramParameters::AutoConstantEntry& constantEntry, 00220 GpuProgramParameters* params) const 00221 { 00222 CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data); 00223 if (i != mCustomParameters.end()) 00224 { 00225 params->setConstant(constantEntry.index, i->second); 00226 } 00227 } 00228 00229 00230 protected: 00231 static const PlaneList msDummyPlaneList; 00232 typedef std::map<size_t, Vector4> CustomParameterMap; 00233 CustomParameterMap mCustomParameters; 00234 }; 00235 00236 00237 00238 } 00239 00240 #endif //__Renderable_H__
Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:21 2005