OgreQueuedProgressiveMeshGenerator.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 
29 #ifndef __QueuedProgressiveMeshGenerator_H_
30 #define __QueuedProgressiveMeshGenerator_H_
31 
33 #include "OgreSingleton.h"
34 #include "OgreWorkQueue.h"
35 #include "OgreFrameListener.h"
36 
37 namespace Ogre
38 {
39 
43 struct PMGenRequest {
44  struct VertexBuffer {
45  size_t vertexCount;
48  vertexBuffer(0) { }
49  };
50  struct IndexBuffer {
51  size_t indexSize;
52  size_t indexCount;
53  unsigned char* indexBuffer; // size in bytes = indexSize * indexCount
55  indexBuffer(0) { }
56  };
57  struct SubmeshInfo {
58  vector<IndexBuffer>::type genIndexBuffers; // order: lodlevel/generated index buffer
62  };
68 };
69 
74  public Singleton<PMWorker>,
77  public LodAlloc
78 {
79 public:
81  virtual ~PMWorker();
84 
100  static PMWorker& getSingleton(void);
116  static PMWorker* getSingletonPtr(void);
117 
118 private:
119  PMGenRequest* mRequest; // This is a copy of the current processed request from stack. This is needed to pass it to overloaded functions like bakeLods().
121 
123  void buildRequest(LodConfig& lodConfigs);
125  void initialize();
126  void addVertexBuffer(const PMGenRequest::VertexBuffer& vertexBuffer, bool useSharedVertexLookup);
127  void addIndexBuffer(PMGenRequest::IndexBuffer& indexBuffer, bool useSharedVertexLookup, unsigned short submeshID);
128  void bakeLods();
129 };
130 
132 {
133 public:
136  virtual bool shouldInject(PMGenRequest* request) = 0;
137  virtual void injectionCompleted(PMGenRequest* request) = 0;
138 };
139 
144  public Singleton<PMInjector>,
146  public LodAlloc
147 {
148 public:
150  virtual ~PMInjector();
151 
167  static PMInjector& getSingleton(void);
184 
185  void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
186 
187  void setInjectorListener(PMInjectorListener* injectorListener) {mInjectorListener = injectorListener;}
188  void removeInjectorListener() {mInjectorListener = 0;}
189 protected:
190 
191  // Copies every generated LOD level to the mesh.
192  void inject(PMGenRequest* request);
193 
195 };
196 
202 {
203 public:
204 
206  void generateLodLevels(LodConfig& lodConfig);
207 
209 
210 private:
213  void copyBuffers(Mesh* mesh, PMGenRequest* req);
214 };
215 
216 }
217 #endif
#define _OgreExport
Definition: OgrePlatform.h:257
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Summary class collecting together index data source information.
Resource holding data about 3D mesh.
Definition: OgreMesh.h:94
virtual void injectionCompleted(PMGenRequest *request)=0
virtual bool shouldInject(PMGenRequest *request)=0
Injects the output of a request to the mesh in a thread safe way.
PMInjectorListener * mInjectorListener
static PMInjector * getSingletonPtr(void)
Override standard Singleton retrieval.
static PMInjector & getSingleton(void)
Override standard Singleton retrieval.
void setInjectorListener(PMInjectorListener *injectorListener)
void inject(PMGenRequest *request)
void handleResponse(const WorkQueue::Response *res, const WorkQueue *srcQ)
The handler method every subclass must implement.
virtual ~PMInjector()
void addRequestToQueue(PMGenRequest *request)
WorkQueue::Response * handleRequest(const WorkQueue::Request *req, const WorkQueue *srcQ)
The handler method every subclass must implement.
static PMWorker & getSingleton(void)
Override standard Singleton retrieval.
virtual ~PMWorker()
void addIndexBuffer(PMGenRequest::IndexBuffer &indexBuffer, bool useSharedVertexLookup, unsigned short submeshID)
static PMWorker * getSingletonPtr(void)
Override standard Singleton retrieval.
void clearPendingLodRequests()
void tuneContainerSize()
void buildRequest(LodConfig &lodConfigs)
void addVertexBuffer(const PMGenRequest::VertexBuffer &vertexBuffer, bool useSharedVertexLookup)
Improved version of ProgressiveMesh.
void generateLodLevels(LodConfig &lodConfig)
Generates the LOD levels for a mesh.
void copyBuffers(Mesh *mesh, PMGenRequest *req)
void copyIndexBuffer(IndexData *data, PMGenRequest::IndexBuffer &out)
void copyVertexBuffer(VertexData *data, PMGenRequest::VertexBuffer &out)
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:65
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
Summary class collecting together vertex source information.
Interface definition for a handler of requests.
General purpose request structure.
Definition: OgreWorkQueue.h:84
Interface definition for a handler of responses.
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:71
_StringBase String
unsigned short ushort
vector< SubmeshInfo >::type submesh
General purpose response structure.
std::vector< T, A > type

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