~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/environment/pagedgeometry/include/BatchPage.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------------------
 
2
Copyright (c) 2006 John Judnich
 
3
 
 
4
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
 
5
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
 
6
    1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
 
7
    2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
 
8
    3. This notice may not be removed or altered from any source distribution.
 
9
-------------------------------------------------------------------------------------*/
 
10
 
 
11
//BatchPage.h
 
12
//BatchPage is an extension to PagedGeometry which displays entities as static geometry.
 
13
//-------------------------------------------------------------------------------------
 
14
 
 
15
#ifndef __BatchPage_H__
 
16
#define __BatchPage_H__
 
17
 
 
18
#include "PagedGeometry.h"
 
19
#include "BatchedGeometry.h"
 
20
 
 
21
#include <OgrePrerequisites.h>
 
22
#include <OgreStringConverter.h>
 
23
 
 
24
namespace PagedGeometry {
 
25
 
 
26
/**
 
27
\brief The BatchPage class renders entities as StaticGeometry.
 
28
 
 
29
This is one of the geometry page types included in the StaticGeometry engine. These
 
30
page types should be added to a PagedGeometry object with PagedGeometry::addDetailLevel()
 
31
so the PagedGeometry will know how you want your geometry displayed.
 
32
 
 
33
To use this page type, use:
 
34
\code
 
35
PagedGeometry::addDetailLevel<BatchPage>(farRange);
 
36
\endcode
 
37
 
 
38
This page type uses batched geometry (Ogre::StaticGeometry) to represent the entities.
 
39
Batched geometry is generally much faster than plain entities, since video card state
 
40
changes and transform calculations can be minimized. Batched geometry can be anywhere
 
41
from 2 to 20 times faster than plain entities.
 
42
*/
 
43
class BatchPage: public GeometryPage
 
44
{
 
45
public:
 
46
        void init(PagedGeometry *geom);
 
47
        ~BatchPage();
 
48
        
 
49
        void addEntity(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color);
 
50
        void build();
 
51
        void removeEntities();
 
52
 
 
53
        void setVisible(bool visible);
 
54
        void setFade(bool enabled, Ogre::Real visibleDist, Ogre::Real invisibleDist);
 
55
 
 
56
        void addEntityToBoundingBox() {}
 
57
        void clearBoundingBox() {}
 
58
        const Ogre::AxisAlignedBox &getBoundingBox() { return batch->getBoundingBox(); }
 
59
 
 
60
private:
 
61
        void _updateShaders();
 
62
 
 
63
        bool fadeEnabled, shadersSupported;
 
64
        Ogre::Real visibleDist, invisibleDist;
 
65
        std::vector<Ogre::MaterialPtr> unfadedMaterials;
 
66
 
 
67
        Ogre::SceneManager *sceneMgr;
 
68
        BatchedGeometry *batch;
 
69
 
 
70
        static unsigned long refCount;
 
71
        static unsigned long GUID;
 
72
        static inline Ogre::String getUniqueID(const Ogre::String &prefix)
 
73
        {
 
74
                return prefix + Ogre::StringConverter::toString(++GUID);
 
75
        }
 
76
};
 
77
 
 
78
}
 
79
 
 
80
#endif