OgreQueuedProgressiveMeshGenerator.h
Go to the documentation of this file.
/*
* -----------------------------------------------------------------------------
* This source file is part of OGRE
* (Object-oriented Graphics Rendering Engine)
* For the latest info, see http://www.ogre3d.org/
*
* Copyright (c) 2000-2013 Torus Knot Software Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* -----------------------------------------------------------------------------
*/
#ifndef __QueuedProgressiveMeshGenerator_H_
#define __QueuedProgressiveMeshGenerator_H_
#include "OgreProgressiveMeshGenerator.h"
#include "OgreSingleton.h"
#include "OgreWorkQueue.h"
#include "OgreFrameListener.h"
namespace Ogre
{
struct PMGenRequest {
struct VertexBuffer {
size_t vertexCount;
Vector3* vertexBuffer;
VertexBuffer() :
vertexBuffer(0) { }
};
struct IndexBuffer {
size_t indexSize;
size_t indexCount;
unsigned char* indexBuffer; // size in bytes = indexSize * indexCount
IndexBuffer() :
indexBuffer(0) { }
};
struct SubmeshInfo {
vector<IndexBuffer>::type genIndexBuffers; // order: lodlevel/generated index buffer
IndexBuffer indexBuffer;
VertexBuffer vertexBuffer;
bool useSharedVertexBuffer;
};
vector<SubmeshInfo>::type submesh;
VertexBuffer sharedVertexBuffer;
LodConfig config;
String meshName;
~PMGenRequest();
};
class _OgreExport PMWorker :
public Singleton<PMWorker>,
private WorkQueue::RequestHandler,
private ProgressiveMeshGenerator,
public LodAlloc
{
public:
PMWorker();
virtual ~PMWorker();
void addRequestToQueue(PMGenRequest* request);
void clearPendingLodRequests();
static PMWorker& getSingleton(void);
static PMWorker* getSingletonPtr(void);
private:
PMGenRequest* mRequest; // This is a copy of the current processed request from stack. This is needed to pass it to overloaded functions like bakeLods().
ushort mChannelID;
WorkQueue::Response* handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ);
void buildRequest(LodConfig& lodConfigs);
void tuneContainerSize();
void initialize();
void addVertexBuffer(const PMGenRequest::VertexBuffer& vertexBuffer, bool useSharedVertexLookup);
void addIndexBuffer(PMGenRequest::IndexBuffer& indexBuffer, bool useSharedVertexLookup, unsigned short submeshID);
void bakeLods();
};
class _OgreExport PMInjectorListener
{
public:
PMInjectorListener(){}
virtual ~PMInjectorListener(){}
virtual bool shouldInject(PMGenRequest* request) = 0;
virtual void injectionCompleted(PMGenRequest* request) = 0;
};
class _OgreExport PMInjector :
public Singleton<PMInjector>,
public WorkQueue::ResponseHandler,
public LodAlloc
{
public:
PMInjector();
virtual ~PMInjector();
static PMInjector& getSingleton(void);
static PMInjector* getSingletonPtr(void);
void handleResponse(const WorkQueue::Response* res, const WorkQueue* srcQ);
void setInjectorListener(PMInjectorListener* injectorListener) {mInjectorListener = injectorListener;}
void removeInjectorListener() {mInjectorListener = 0;}
protected:
// Copies every generated LOD level to the mesh.
void inject(PMGenRequest* request);
PMInjectorListener* mInjectorListener;
};
class _OgreExport QueuedProgressiveMeshGenerator :
public ProgressiveMeshGeneratorBase
{
public:
void generateLodLevels(LodConfig& lodConfig);
virtual ~QueuedProgressiveMeshGenerator();
private:
void copyVertexBuffer(VertexData* data, PMGenRequest::VertexBuffer& out);
void copyIndexBuffer(IndexData* data, PMGenRequest::IndexBuffer& out);
void copyBuffers(Mesh* mesh, PMGenRequest* req);
};
}
#endif
Ogre::PMGenRequest::SubmeshInfo::vertexBuffer
VertexBuffer vertexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:60
OgreWorkQueue.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::ProgressiveMeshGeneratorBase
Definition: OgreProgressiveMeshGenerator.h:41
Ogre::vector::type
std::vector< T, A > type
Definition: OgrePrerequisites.h:494
Ogre::WorkQueue
Interface to a general purpose request / response style background work queue.
Definition: OgreWorkQueue.h:70
Ogre::PMInjector::removeInjectorListener
void removeInjectorListener()
Definition: OgreQueuedProgressiveMeshGenerator.h:188
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:49
Ogre::PMInjector
Injects the output of a request to the mesh in a thread safe way.
Definition: OgreQueuedProgressiveMeshGenerator.h:143
Ogre::PMGenRequest::meshName
String meshName
Definition: OgreQueuedProgressiveMeshGenerator.h:66
Ogre::IndexData
Summary class collecting together index data source information.
Definition: OgreVertexIndexData.h:242
Ogre::PMGenRequest::VertexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:44
Ogre::PMInjector::mInjectorListener
PMInjectorListener * mInjectorListener
Definition: OgreQueuedProgressiveMeshGenerator.h:194
Ogre::PMGenRequest::SubmeshInfo
Definition: OgreQueuedProgressiveMeshGenerator.h:57
Ogre::PMWorker
Processes requests.
Definition: OgreQueuedProgressiveMeshGenerator.h:73
Ogre::PMGenRequest::sharedVertexBuffer
VertexBuffer sharedVertexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:64
OgreFrameListener.h
Ogre::ProgressiveMeshGenerator
Improved version of ProgressiveMesh.
Definition: OgreProgressiveMeshGenerator.h:72
Ogre::PMInjectorListener::~PMInjectorListener
virtual ~PMInjectorListener()
Definition: OgreQueuedProgressiveMeshGenerator.h:135
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgreSingleton.h
Ogre::WorkQueue::Request
General purpose request structure.
Definition: OgreWorkQueue.h:83
Ogre::PMGenRequest::~PMGenRequest
~PMGenRequest()
Ogre::PMGenRequest::VertexBuffer::VertexBuffer
VertexBuffer()
Definition: OgreQueuedProgressiveMeshGenerator.h:47
Ogre::PMGenRequest::SubmeshInfo::useSharedVertexBuffer
bool useSharedVertexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:61
Ogre::PMWorker::mRequest
PMGenRequest * mRequest
Definition: OgreQueuedProgressiveMeshGenerator.h:119
Ogre::WorkQueue::Response
General purpose response structure.
Definition: OgreWorkQueue.h:122
OgreProgressiveMeshGenerator.h
Ogre::PMGenRequest::SubmeshInfo::genIndexBuffers
vector< IndexBuffer >::type genIndexBuffers
Definition: OgreQueuedProgressiveMeshGenerator.h:58
Ogre::PMGenRequest::SubmeshInfo::indexBuffer
IndexBuffer indexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:59
Ogre::Mesh
Resource holding data about 3D mesh.
Definition: OgreMesh.h:93
Ogre::PMInjector::setInjectorListener
void setInjectorListener(PMInjectorListener *injectorListener)
Definition: OgreQueuedProgressiveMeshGenerator.h:187
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::PMWorker::mChannelID
ushort mChannelID
Definition: OgreQueuedProgressiveMeshGenerator.h:120
Ogre::PMGenRequest
Request data structure.
Definition: OgreQueuedProgressiveMeshGenerator.h:43
Ogre::PMGenRequest::VertexBuffer::vertexCount
size_t vertexCount
Definition: OgreQueuedProgressiveMeshGenerator.h:45
Ogre::PMGenRequest::config
LodConfig config
Definition: OgreQueuedProgressiveMeshGenerator.h:65
Ogre::PMGenRequest::IndexBuffer::indexCount
size_t indexCount
Definition: OgreQueuedProgressiveMeshGenerator.h:52
Ogre::WorkQueue::ResponseHandler
Interface definition for a handler of responses.
Definition: OgreWorkQueue.h:196
Ogre::QueuedProgressiveMeshGenerator
Creates a request for the worker.
Definition: OgreQueuedProgressiveMeshGenerator.h:200
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::LodConfig
Definition: OgreLodConfig.h:104
Ogre::PMGenRequest::IndexBuffer::IndexBuffer
IndexBuffer()
Definition: OgreQueuedProgressiveMeshGenerator.h:54
Ogre::PMGenRequest::VertexBuffer::vertexBuffer
Vector3 * vertexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:46
Ogre::PMInjectorListener::PMInjectorListener
PMInjectorListener()
Definition: OgreQueuedProgressiveMeshGenerator.h:134
Ogre::PMGenRequest::IndexBuffer::indexBuffer
unsigned char * indexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:53
Ogre::Singleton
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::PMGenRequest::IndexBuffer::indexSize
size_t indexSize
Definition: OgreQueuedProgressiveMeshGenerator.h:51
Ogre::PMGenRequest::IndexBuffer
Definition: OgreQueuedProgressiveMeshGenerator.h:50
Ogre::PMInjectorListener
Definition: OgreQueuedProgressiveMeshGenerator.h:131
Ogre::WorkQueue::RequestHandler
Interface definition for a handler of requests.
Definition: OgreWorkQueue.h:161
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::PMGenRequest::submesh
vector< SubmeshInfo >::type submesh
Definition: OgreQueuedProgressiveMeshGenerator.h:63

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