00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org 00006 00007 Copyright (c) 2000-2013 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __Renderable_H__ 00029 #define __Renderable_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 #include "OgreCommon.h" 00033 00034 #include "OgreRenderOperation.h" 00035 #include "OgreMatrix4.h" 00036 #include "OgreMaterial.h" 00037 #include "OgrePlane.h" 00038 #include "OgreGpuProgram.h" 00039 #include "OgreVector4.h" 00040 #include "OgreException.h" 00041 #include "OgreUserObjectBindings.h" 00042 #include "OgreHeaderPrefix.h" 00043 00044 namespace Ogre { 00045 00063 class _OgreExport Renderable 00064 { 00065 public: 00071 class RenderSystemData {}; 00072 public: 00073 Renderable() : mPolygonModeOverrideable(true), mUseIdentityProjection(false), mUseIdentityView(false), mRenderSystemData(NULL) {} 00075 virtual ~Renderable() 00076 { 00077 if (mRenderSystemData) 00078 { 00079 delete mRenderSystemData; 00080 mRenderSystemData = NULL; 00081 } 00082 } 00088 virtual const MaterialPtr& getMaterial(void) const = 0; 00094 virtual Technique* getTechnique(void) const { return getMaterial()->getBestTechnique(0, this); } 00097 virtual void getRenderOperation(RenderOperation& op) = 0; 00098 00123 virtual bool preRender(SceneManager* sm, RenderSystem* rsys) 00124 { (void)sm; (void)rsys; return true; } 00125 00128 virtual void postRender(SceneManager* sm, RenderSystem* rsys) 00129 { (void)sm; (void)rsys; } 00130 00143 virtual void getWorldTransforms(Matrix4* xform) const = 0; 00144 00153 virtual unsigned short getNumWorldTransforms(void) const { return 1; } 00154 00164 void setUseIdentityProjection(bool useIdentityProjection) 00165 { 00166 mUseIdentityProjection = useIdentityProjection; 00167 } 00168 00178 bool getUseIdentityProjection(void) const { return mUseIdentityProjection; } 00179 00189 void setUseIdentityView(bool useIdentityView) 00190 { 00191 mUseIdentityView = useIdentityView; 00192 } 00193 00203 bool getUseIdentityView(void) const { return mUseIdentityView; } 00204 00210 virtual Real getSquaredViewDepth(const Camera* cam) const = 0; 00211 00216 virtual const LightList& getLights(void) const = 0; 00217 00224 virtual bool getCastsShadows(void) const { return false; } 00225 00241 void setCustomParameter(size_t index, const Vector4& value) 00242 { 00243 mCustomParameters[index] = value; 00244 } 00245 00250 void removeCustomParameter(size_t index) 00251 { 00252 mCustomParameters.erase(index); 00253 } 00254 00259 bool hasCustomParameter(size_t index) const 00260 { 00261 return mCustomParameters.find(index) != mCustomParameters.end(); 00262 } 00263 00268 const Vector4& getCustomParameter(size_t index) const 00269 { 00270 CustomParameterMap::const_iterator i = mCustomParameters.find(index); 00271 if (i != mCustomParameters.end()) 00272 { 00273 return i->second; 00274 } 00275 else 00276 { 00277 OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, 00278 "Parameter at the given index was not found.", 00279 "Renderable::getCustomParameter"); 00280 } 00281 } 00282 00307 virtual void _updateCustomGpuParameter( 00308 const GpuProgramParameters::AutoConstantEntry& constantEntry, 00309 GpuProgramParameters* params) const 00310 { 00311 CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data); 00312 if (i != mCustomParameters.end()) 00313 { 00314 params->_writeRawConstant(constantEntry.physicalIndex, i->second, 00315 constantEntry.elementCount); 00316 } 00317 } 00318 00324 virtual void setPolygonModeOverrideable(bool override) 00325 { 00326 mPolygonModeOverrideable = override; 00327 } 00328 00332 virtual bool getPolygonModeOverrideable(void) const 00333 { 00334 return mPolygonModeOverrideable; 00335 } 00336 00344 OGRE_DEPRECATED virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); } 00345 00349 OGRE_DEPRECATED virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); } 00350 00355 UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; } 00356 00361 const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; } 00362 00363 00377 class Visitor 00378 { 00379 public: 00381 virtual ~Visitor() { } 00391 virtual void visit(Renderable* rend, ushort lodIndex, bool isDebug, 00392 Any* pAny = 0) = 0; 00393 }; 00394 00399 virtual RenderSystemData * getRenderSystemData() const 00400 { 00401 return mRenderSystemData; 00402 } 00407 virtual void setRenderSystemData(RenderSystemData * val) const 00408 { 00409 mRenderSystemData = val; 00410 } 00411 00412 00413 protected: 00414 typedef map<size_t, Vector4>::type CustomParameterMap; 00415 CustomParameterMap mCustomParameters; 00416 bool mPolygonModeOverrideable; 00417 bool mUseIdentityProjection; 00418 bool mUseIdentityView; 00419 UserObjectBindings mUserObjectBindings; 00420 mutable RenderSystemData * mRenderSystemData; 00421 }; 00422 00426 } // namespace Ogre 00427 00428 #include "OgreHeaderSuffix.h" 00429 00430 #endif //__Renderable_H__
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:45