OgreLodStrategy.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 __Lod_Strategy_H__
29 #define __Lod_Strategy_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreMesh.h"
34 
35 #include "OgreMovableObject.h"
36 #include "OgreCamera.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre {
40 
55  {
56  protected:
59 
61  virtual Real getValueImpl(const MovableObject *movableObject, const Camera *camera) const = 0;
62 
63  public:
65  LodStrategy(const String& name);
66 
68  virtual ~LodStrategy();
69 
71  virtual Real getBaseValue() const = 0;
72 
74  virtual Real transformBias(Real factor) const = 0;
75 
83  virtual Real transformUserValue(Real userValue) const;
84 
86  Real getValue(const MovableObject *movableObject, const Camera *camera) const;
87 
89  virtual ushort getIndex(Real value, const Mesh::MeshLodUsageList& meshLodUsageList) const = 0;
90 
92  virtual ushort getIndex(Real value, const Material::LodValueList& materialLodValueList) const = 0;
93 
95  virtual void sort(Mesh::MeshLodUsageList& meshLodUsageList) const = 0;
96 
98  virtual bool isSorted(const Mesh::LodValueList& values) const = 0;
99 
101  void assertSorted(const Mesh::LodValueList& values) const;
102 
104  const String& getName() const { return mName; }
105 
106  protected:
108  static bool isSortedAscending(const Mesh::LodValueList& values);
110  static bool isSortedDescending(const Mesh::LodValueList& values);
111 
113  static void sortAscending(Mesh::MeshLodUsageList& meshLodUsageList);
115  static void sortDescending(Mesh::MeshLodUsageList& meshLodUsageList);
116 
118  static ushort getIndexAscending(Real value, const Mesh::MeshLodUsageList& meshLodUsageList);
120  static ushort getIndexDescending(Real value, const Mesh::MeshLodUsageList& meshLodUsageList);
121 
123  static ushort getIndexAscending(Real value, const Material::LodValueList& materialLodValueList);
125  static ushort getIndexDescending(Real value, const Material::LodValueList& materialLodValueList);
126 
127  };
131 } // namespace
132 
133 #include "OgreHeaderSuffix.h"
134 
135 #endif
OgreHeaderSuffix.h
Ogre::Mesh::MeshLodUsageList
vector< MeshLodUsage >::type MeshLodUsageList
Definition: OgreMesh.h:103
Ogre::LodStrategy::sortAscending
static void sortAscending(Mesh::MeshLodUsageList &meshLodUsageList)
Implementation of sort suitable for ascending values.
Ogre::Mesh::LodValueList
vector< Real >::type LodValueList
Definition: OgreMesh.h:102
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:59
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::LodStrategy::isSorted
virtual bool isSorted(const Mesh::LodValueList &values) const =0
Determine if the LOD values are sorted from greatest detail to least detail.
OgreMesh.h
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Ogre::LodStrategy::getValueImpl
virtual Real getValueImpl(const MovableObject *movableObject, const Camera *camera) const =0
Compute the LOD value for a given movable object relative to a given camera.
Ogre::LodStrategy::assertSorted
void assertSorted(const Mesh::LodValueList &values) const
Assert that the LOD values are sorted from greatest detail to least detail.
Ogre::LodStrategy::isSortedAscending
static bool isSortedAscending(const Mesh::LodValueList &values)
Implementation of isSorted suitable for ascending values.
Ogre::LodStrategy::sortDescending
static void sortDescending(Mesh::MeshLodUsageList &meshLodUsageList)
Implementation of sort suitable for descending values.
Ogre::LodStrategy::getIndex
virtual ushort getIndex(Real value, const Material::LodValueList &materialLodValueList) const =0
Get the index of the LOD usage which applies to a given value.
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:61
Ogre::LodStrategy::getIndexDescending
static ushort getIndexDescending(Real value, const Mesh::MeshLodUsageList &meshLodUsageList)
Implementation of getIndex suitable for descending values.
Ogre::LodStrategy::sort
virtual void sort(Mesh::MeshLodUsageList &meshLodUsageList) const =0
Sort mesh LOD usage list from greatest to least detail.
Ogre::LodStrategy::mName
String mName
Name of this strategy.
Definition: OgreLodStrategy.h:58
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::LodStrategy::getName
const String & getName() const
Get the name of this strategy.
Definition: OgreLodStrategy.h:104
Ogre::LodStrategy
Strategy for determining level of detail.
Definition: OgreLodStrategy.h:55
OgreHeaderPrefix.h
OgrePrerequisites.h
Ogre::Material::LodValueList
vector< Real >::type LodValueList
distance list used to specify LOD
Definition: OgreMaterial.h:95
Ogre::LodStrategy::transformBias
virtual Real transformBias(Real factor) const =0
Transform LOD bias so it only needs to be multiplied by the LOD value.
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::LodStrategy::~LodStrategy
virtual ~LodStrategy()
Virtual destructor.
Ogre::LodStrategy::LodStrategy
LodStrategy(const String &name)
Constructor accepting name.
OgreMovableObject.h
Ogre::LodStrategy::getBaseValue
virtual Real getBaseValue() const =0
Get the value of the first (highest) level of detail.
Ogre::LodStrategy::getIndex
virtual ushort getIndex(Real value, const Mesh::MeshLodUsageList &meshLodUsageList) const =0
Get the index of the LOD usage which applies to a given value.
Ogre::LodStrategy::transformUserValue
virtual Real transformUserValue(Real userValue) const
Transform user supplied value to internal value.
Ogre::LodStrategy::getIndexAscending
static ushort getIndexAscending(Real value, const Material::LodValueList &materialLodValueList)
Implementation of getIndex suitable for ascending values.
Ogre::LodStrategy::isSortedDescending
static bool isSortedDescending(const Mesh::LodValueList &values)
Implementation of isSorted suitable for descending values.
Ogre::LodStrategy::getIndexDescending
static ushort getIndexDescending(Real value, const Material::LodValueList &materialLodValueList)
Implementation of getIndex suitable for descending values.
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
OgreCamera.h
Ogre::LodStrategy::getIndexAscending
static ushort getIndexAscending(Real value, const Mesh::MeshLodUsageList &meshLodUsageList)
Implementation of getIndex suitable for ascending values.
Ogre::LodStrategy::getValue
Real getValue(const MovableObject *movableObject, const Camera *camera) const
Compute the LOD value for a given movable object relative to a given camera.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.