OgreRenderable.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Renderable_H__
29 #define __Renderable_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreCommon.h"
33 
34 #include "OgreRenderOperation.h"
35 #include "OgreMatrix4.h"
36 #include "OgreMaterial.h"
37 #include "OgrePlane.h"
38 #include "OgreGpuProgram.h"
39 #include "OgreVector4.h"
40 #include "OgreException.h"
41 #include "OgreUserObjectBindings.h"
42 #include "OgreHeaderPrefix.h"
43 
44 namespace Ogre {
45 
64  {
65  public:
71  class RenderSystemData {};
72  public:
73  Renderable() : mPolygonModeOverrideable(true), mUseIdentityProjection(false), mUseIdentityView(false), mRenderSystemData(NULL) {}
75  virtual ~Renderable()
76  {
77  if (mRenderSystemData)
78  {
79  delete mRenderSystemData;
80  mRenderSystemData = NULL;
81  }
82  }
88  virtual const MaterialPtr& getMaterial(void) const = 0;
94  virtual Technique* getTechnique(void) const { return getMaterial()->getBestTechnique(0, this); }
97  virtual void getRenderOperation(RenderOperation& op) = 0;
98 
123  virtual bool preRender(SceneManager* sm, RenderSystem* rsys)
124  { (void)sm; (void)rsys; return true; }
125 
128  virtual void postRender(SceneManager* sm, RenderSystem* rsys)
129  { (void)sm; (void)rsys; }
130 
143  virtual void getWorldTransforms(Matrix4* xform) const = 0;
144 
153  virtual unsigned short getNumWorldTransforms(void) const { return 1; }
154 
164  void setUseIdentityProjection(bool useIdentityProjection)
165  {
166  mUseIdentityProjection = useIdentityProjection;
167  }
168 
178  bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
179 
189  void setUseIdentityView(bool useIdentityView)
190  {
191  mUseIdentityView = useIdentityView;
192  }
193 
203  bool getUseIdentityView(void) const { return mUseIdentityView; }
204 
210  virtual Real getSquaredViewDepth(const Camera* cam) const = 0;
211 
216  virtual const LightList& getLights(void) const = 0;
217 
224  virtual bool getCastsShadows(void) const { return false; }
225 
241  void setCustomParameter(size_t index, const Vector4& value)
242  {
243  mCustomParameters[index] = value;
244  }
245 
250  void removeCustomParameter(size_t index)
251  {
252  mCustomParameters.erase(index);
253  }
254 
259  bool hasCustomParameter(size_t index) const
260  {
261  return mCustomParameters.find(index) != mCustomParameters.end();
262  }
263 
268  const Vector4& getCustomParameter(size_t index) const
269  {
270  CustomParameterMap::const_iterator i = mCustomParameters.find(index);
271  if (i != mCustomParameters.end())
272  {
273  return i->second;
274  }
275  else
276  {
278  "Parameter at the given index was not found.",
279  "Renderable::getCustomParameter");
280  }
281  }
282 
308  const GpuProgramParameters::AutoConstantEntry& constantEntry,
309  GpuProgramParameters* params) const
310  {
311  CustomParameterMap::const_iterator i = mCustomParameters.find(constantEntry.data);
312  if (i != mCustomParameters.end())
313  {
314  params->_writeRawConstant(constantEntry.physicalIndex, i->second,
315  constantEntry.elementCount);
316  }
317  }
318 
324  virtual void setPolygonModeOverrideable(bool override)
325  {
326  mPolygonModeOverrideable = override;
327  }
328 
332  virtual bool getPolygonModeOverrideable(void) const
333  {
334  return mPolygonModeOverrideable;
335  }
336 
344  virtual void setUserAny(const Any& anything) { getUserObjectBindings().setUserAny(anything); }
345 
349  virtual const Any& getUserAny(void) const { return getUserObjectBindings().getUserAny(); }
350 
355  UserObjectBindings& getUserObjectBindings() { return mUserObjectBindings; }
356 
361  const UserObjectBindings& getUserObjectBindings() const { return mUserObjectBindings; }
362 
363 
377  class Visitor
378  {
379  public:
381  virtual ~Visitor() { }
391  virtual void visit(Renderable* rend, ushort lodIndex, bool isDebug,
392  Any* pAny = 0) = 0;
393  };
394 
400  {
401  return mRenderSystemData;
402  }
407  virtual void setRenderSystemData(RenderSystemData * val) const
408  {
409  mRenderSystemData = val;
410  }
411 
412 
413  protected:
421  };
422 
426 } // namespace Ogre
427 
428 #include "OgreHeaderSuffix.h"
429 
430 #endif //__Renderable_H__

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:44