OgreManualObject.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 __OgreManualObject_H__
#define __OgreManualObject_H__
#include "OgrePrerequisites.h"
#include "OgreMovableObject.h"
#include "OgreRenderable.h"
#include "OgreResourceGroupManager.h"
#include "OgreHeaderPrefix.h"
namespace Ogre
{
class _OgreExport ManualObject : public MovableObject
{
public:
ManualObject(const String& name);
virtual ~ManualObject();
//pre-declare ManualObjectSection
class ManualObjectSection;
virtual void clear(void);
virtual void estimateVertexCount(size_t vcount);
virtual void estimateIndexCount(size_t icount);
virtual void begin(const String& materialName,
RenderOperation::OperationType opType = RenderOperation::OT_TRIANGLE_LIST, const String & groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
virtual void setDynamic(bool dyn) { mDynamic = dyn; }
virtual bool getDynamic() const { return mDynamic; }
virtual void beginUpdate(size_t sectionIndex);
virtual void position(const Vector3& pos);
virtual void position(Real x, Real y, Real z);
virtual void normal(const Vector3& norm);
virtual void normal(Real x, Real y, Real z);
virtual void tangent(const Vector3& tan);
virtual void tangent(Real x, Real y, Real z);
virtual void textureCoord(Real u);
virtual void textureCoord(Real u, Real v);
virtual void textureCoord(Real u, Real v, Real w);
virtual void textureCoord(Real x, Real y, Real z, Real w);
virtual void textureCoord(const Vector2& uv);
virtual void textureCoord(const Vector3& uvw);
virtual void textureCoord(const Vector4& xyzw);
virtual void colour(const ColourValue& col);
virtual void colour(Real r, Real g, Real b, Real a = 1.0f);
virtual void index(uint32 idx);
virtual void triangle(uint32 i1, uint32 i2, uint32 i3);
virtual void quad(uint32 i1, uint32 i2, uint32 i3, uint32 i4);
virtual size_t getCurrentVertexCount() const;
virtual size_t getCurrentIndexCount() const;
virtual ManualObjectSection* end(void);
virtual void setMaterialName(size_t subIndex, const String& name, const String & group = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
virtual MeshPtr convertToMesh(const String& meshName,
const String& groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
void setUseIdentityProjection(bool useIdentityProjection);
bool getUseIdentityProjection(void) const { return mUseIdentityProjection; }
void setUseIdentityView(bool useIdentityView);
bool getUseIdentityView(void) const { return mUseIdentityView; }
void setBoundingBox(const AxisAlignedBox& box) { mAABB = box; }
ManualObjectSection* getSection(unsigned int index) const;
unsigned int getNumSections(void) const;
void setKeepDeclarationOrder(bool keepOrder) { mKeepDeclarationOrder = keepOrder; }
bool getKeepDeclarationOrder() const { return mKeepDeclarationOrder; }
// MovableObject overrides
const String& getMovableType(void) const;
const AxisAlignedBox& getBoundingBox(void) const;
Real getBoundingRadius(void) const;
void _updateRenderQueue(RenderQueue* queue);
EdgeData* getEdgeList(void);
bool hasEdgeList(void);
ShadowRenderableListIterator getShadowVolumeRenderableIterator(
ShadowTechnique shadowTechnique, const Light* light,
HardwareIndexBufferSharedPtr* indexBuffer, size_t* indexBufferUsedSize,
bool extrudeVertices, Real extrusionDist, unsigned long flags = 0);
class _OgreExport ManualObjectSection : public Renderable, public MovableAlloc
{
protected:
ManualObject* mParent;
String mMaterialName;
String mGroupName;
mutable MaterialPtr mMaterial;
RenderOperation mRenderOperation;
bool m32BitIndices;
public:
ManualObjectSection(ManualObject* parent, const String& materialName,
RenderOperation::OperationType opType, const String & groupName = ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
virtual ~ManualObjectSection();
RenderOperation* getRenderOperation(void);
const String& getMaterialName(void) const { return mMaterialName; }
const String& getMaterialGroup(void) const { return mGroupName; }
void setMaterialName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME );
void set32BitIndices(bool n32) { m32BitIndices = n32; }
bool get32BitIndices() const { return m32BitIndices; }
// Renderable overrides
const MaterialPtr& getMaterial(void) const;
void getRenderOperation(RenderOperation& op);
void getWorldTransforms(Matrix4* xform) const;
Real getSquaredViewDepth(const Ogre::Camera *) const;
const LightList &getLights(void) const;
};
class _OgreExport ManualObjectSectionShadowRenderable : public ShadowRenderable
{
protected:
ManualObject* mParent;
// Shared link to position buffer
HardwareVertexBufferSharedPtr mPositionBuffer;
// Shared link to w-coord buffer (optional)
HardwareVertexBufferSharedPtr mWBuffer;
public:
ManualObjectSectionShadowRenderable(ManualObject* parent,
HardwareIndexBufferSharedPtr* indexBuffer, const VertexData* vertexData,
bool createSeparateLightCap, bool isLightCap = false);
~ManualObjectSectionShadowRenderable();
void getWorldTransforms(Matrix4* xform) const;
HardwareVertexBufferSharedPtr getPositionBuffer(void) { return mPositionBuffer; }
HardwareVertexBufferSharedPtr getWBuffer(void) { return mWBuffer; }
virtual void rebindIndexBuffer(const HardwareIndexBufferSharedPtr& indexBuffer);
};
typedef vector<ManualObjectSection*>::type SectionList;
void visitRenderables(Renderable::Visitor* visitor,
bool debugRenderables = false);
protected:
bool mDynamic;
SectionList mSectionList;
ManualObjectSection* mCurrentSection;
bool mCurrentUpdating;
struct TempVertex
{
Vector3 position;
Vector3 normal;
Vector3 tangent;
Vector4 texCoord[OGRE_MAX_TEXTURE_COORD_SETS];
ushort texCoordDims[OGRE_MAX_TEXTURE_COORD_SETS];
ColourValue colour;
};
TempVertex mTempVertex;
bool mFirstVertex;
bool mTempVertexPending;
char* mTempVertexBuffer;
size_t mTempVertexSize;
uint32* mTempIndexBuffer;
size_t mTempIndexSize;
size_t mDeclSize;
size_t mEstVertexCount;
size_t mEstIndexCount;
ushort mTexCoordIndex;
AxisAlignedBox mAABB;
Real mRadius;
bool mAnyIndexed;
EdgeData* mEdgeList;
ShadowRenderableList mShadowRenderables;
bool mUseIdentityProjection;
bool mUseIdentityView;
bool mKeepDeclarationOrder;
virtual void resetTempAreas(void);
virtual void resizeTempVertexBufferIfNeeded(size_t numVerts);
virtual void resizeTempIndexBufferIfNeeded(size_t numInds);
virtual void copyTempVertexToBuffer(void);
};
class _OgreExport ManualObjectFactory : public MovableObjectFactory
{
protected:
MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
public:
ManualObjectFactory() {}
~ManualObjectFactory() {}
static String FACTORY_TYPE_NAME;
const String& getType(void) const;
void destroyInstance( MovableObject* obj);
};
}
#include "OgreHeaderSuffix.h"
#endif
Ogre::ShadowRenderable
Class which represents the renderable aspects of a set of shadow volume faces.
Definition: OgreShadowCaster.h:52
Ogre::ManualObjectFactory::ManualObjectFactory
ManualObjectFactory()
Definition: OgreManualObject.h:557
Ogre::ManualObject::ManualObjectSectionShadowRenderable
Nested class to allow shadows.
Definition: OgreManualObject.h:447
Ogre::ManualObject::ManualObjectSection::mGroupName
String mGroupName
Definition: OgreManualObject.h:407
Ogre::VectorIterator
Concrete IteratorWrapper for nonconst access to the underlying container.
Definition: OgreIteratorWrapper.h:186
Ogre::ManualObjectFactory
Factory object for creating ManualObject instances.
Definition: OgreManualObject.h:552
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
Ogre::ManualObject::getKeepDeclarationOrder
bool getKeepDeclarationOrder() const
Gets whether or not the declaration order is to be kept or not.
Definition: OgreManualObject.h:379
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::ManualObject::mUseIdentityView
bool mUseIdentityView
Whether to use identity view for sections.
Definition: OgreManualObject.h:533
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:60
Ogre::HardwareIndexBufferSharedPtr
Shared pointer implementation used to share index buffers.
Definition: OgreHardwareIndexBuffer.h:79
Ogre::ManualObject::mCurrentUpdating
bool mCurrentUpdating
Are we updating?
Definition: OgreManualObject.h:487
OgreRenderable.h
OgreMovableObject.h
Ogre::ManualObject::setKeepDeclarationOrder
void setKeepDeclarationOrder(bool keepOrder)
Sets whether or not to keep the original declaration order when queuing the renderables.
Definition: OgreManualObject.h:373
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:49
Ogre::ManualObjectFactory::FACTORY_TYPE_NAME
static String FACTORY_TYPE_NAME
Definition: OgreManualObject.h:560
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::ManualObject::mKeepDeclarationOrder
bool mKeepDeclarationOrder
Keep declaration order or let the queue optimize it.
Definition: OgreManualObject.h:535
Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME
static String AUTODETECT_RESOURCE_GROUP_NAME
Special resource group name which causes resource group to be automatically determined based on searc...
Definition: OgreResourceGroupManager.h:270
Ogre::Vector2
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:92
Ogre::ManualObject::mTempVertex
TempVertex mTempVertex
Temp storage.
Definition: OgreManualObject.h:499
Ogre::ManualObject::ManualObjectSectionShadowRenderable::mWBuffer
HardwareVertexBufferSharedPtr mWBuffer
Definition: OgreManualObject.h:454
Ogre::ManualObject::setDynamic
virtual void setDynamic(bool dyn)
Use before defining geometry to indicate that you intend to update the geometry regularly and want th...
Definition: OgreManualObject.h:159
Ogre::ManualObject::getUseIdentityView
bool getUseIdentityView(void) const
Returns whether or not to use an &#39;identity&#39; view.
Definition: OgreManualObject.h:346
Ogre::ManualObject::TempVertex::position
Vector3 position
Definition: OgreManualObject.h:491
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
static String DEFAULT_RESOURCE_GROUP_NAME
Default resource group name.
Definition: OgreResourceGroupManager.h:266
Ogre::ShadowTechnique
ShadowTechnique
An enumeration of broad shadow techniques.
Definition: OgreCommon.h:190
Ogre::ManualObject::mTempVertexPending
bool mTempVertexPending
Temp vertex data to copy?
Definition: OgreManualObject.h:503
Ogre::ManualObject::ManualObjectSectionShadowRenderable::mParent
ManualObject * mParent
Definition: OgreManualObject.h:450
Ogre::ManualObject
Class providing a much simplified interface to generating manual objects with custom geometry...
Definition: OgreManualObject.h:106
Ogre::EdgeData
This class contains the information required to describe the edge connectivity of a given set of vert...
Definition: OgreEdgeListBuilder.h:52
Ogre::ManualObject::ManualObjectSectionShadowRenderable::getPositionBuffer
HardwareVertexBufferSharedPtr getPositionBuffer(void)
Definition: OgreManualObject.h:463
Ogre::ManualObject::TempVertex
Temporary vertex structure.
Definition: OgreManualObject.h:489
Ogre::ManualObject::mSectionList
SectionList mSectionList
List of subsections.
Definition: OgreManualObject.h:483
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Ogre::ManualObject::ManualObjectSection::mRenderOperation
RenderOperation mRenderOperation
Definition: OgreManualObject.h:409
Ogre::HardwareVertexBufferSharedPtr
Shared pointer implementation used to share vertex buffers.
Definition: OgreHardwareVertexBuffer.h:86
Ogre::ManualObject::mEstVertexCount
size_t mEstVertexCount
Estimated vertex count.
Definition: OgreManualObject.h:515
OgrePrerequisites.h
Ogre::ManualObject::mShadowRenderables
ShadowRenderableList mShadowRenderables
List of shadow renderables.
Definition: OgreManualObject.h:529
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Definition: OgreRenderable.h:377
Ogre::ManualObject::mFirstVertex
bool mFirstVertex
First vertex indicator.
Definition: OgreManualObject.h:501
Ogre::ManualObject::ManualObjectSection
Built, renderable section of geometry.
Definition: OgreManualObject.h:402
Ogre::ManualObject::mEdgeList
EdgeData * mEdgeList
Edge list, used if stencil shadow casting is enabled.
Definition: OgreManualObject.h:527
Ogre::ManualObject::mTempVertexBuffer
char * mTempVertexBuffer
System-memory buffer whilst we establish the size required.
Definition: OgreManualObject.h:505
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::ManualObject::ManualObjectSection::m32BitIndices
bool m32BitIndices
Definition: OgreManualObject.h:410
Ogre::ManualObject::ManualObjectSection::mParent
ManualObject * mParent
Definition: OgreManualObject.h:405
Ogre::ManualObject::ManualObjectSection::set32BitIndices
void set32BitIndices(bool n32)
Set whether we need 32-bit indices.
Definition: OgreManualObject.h:427
Ogre::ManualObject::mCurrentSection
ManualObjectSection * mCurrentSection
Current section.
Definition: OgreManualObject.h:485
Ogre::RenderOperation::OperationType
OperationType
The rendering operation type to perform.
Definition: OgreRenderOperation.h:48
Ogre::ManualObject::mEstIndexCount
size_t mEstIndexCount
Estimated index count.
Definition: OgreManualObject.h:517
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::ManualObject::getDynamic
virtual bool getDynamic() const
Gets whether this object is marked as dynamic.
Definition: OgreManualObject.h:161
Ogre::ManualObject::ManualObjectSectionShadowRenderable::mPositionBuffer
HardwareVertexBufferSharedPtr mPositionBuffer
Definition: OgreManualObject.h:452
Ogre::ManualObject::TempVertex::tangent
Vector3 tangent
Definition: OgreManualObject.h:493
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::ManualObject::mTexCoordIndex
ushort mTexCoordIndex
Current texture coordinate.
Definition: OgreManualObject.h:519
OGRE_MAX_TEXTURE_COORD_SETS
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:68
Ogre::ManualObject::getUseIdentityProjection
bool getUseIdentityProjection(void) const
Returns whether or not to use an &#39;identity&#39; projection.
Definition: OgreManualObject.h:324
Ogre::ManualObject::mRadius
Real mRadius
Bounding sphere.
Definition: OgreManualObject.h:523
Ogre::RenderOperation::OT_TRIANGLE_LIST
A list of triangles, 3 vertices per triangle.
Definition: OgreRenderOperation.h:56
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::ManualObject::mTempVertexSize
size_t mTempVertexSize
System memory allocation size, in bytes.
Definition: OgreManualObject.h:507
Ogre::ManualObject::mAABB
AxisAlignedBox mAABB
Bounding box.
Definition: OgreManualObject.h:521
Ogre::ManualObject::mDynamic
bool mDynamic
Dynamic?
Definition: OgreManualObject.h:481
Ogre::SharedPtr< Mesh >
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::ManualObject::ManualObjectSection::mMaterial
MaterialPtr mMaterial
Definition: OgreManualObject.h:408
OgreHeaderPrefix.h
Ogre::ManualObject::SectionList
vector< ManualObjectSection * >::type SectionList
Definition: OgreManualObject.h:472
Ogre::ManualObject::TempVertex::colour
ColourValue colour
Definition: OgreManualObject.h:496
Ogre::ManualObjectFactory::~ManualObjectFactory
~ManualObjectFactory()
Definition: OgreManualObject.h:558
Ogre::ManualObject::ManualObjectSection::getMaterialName
const String & getMaterialName(void) const
Retrieve the material name in use.
Definition: OgreManualObject.h:421
Ogre::ManualObject::setBoundingBox
void setBoundingBox(const AxisAlignedBox &box)
Sets the bounding box.
Definition: OgreManualObject.h:355
Ogre::RenderOperation
&#39;New&#39; rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::ManualObject::mUseIdentityProjection
bool mUseIdentityProjection
Whether to use identity projection for sections.
Definition: OgreManualObject.h:531
OgreResourceGroupManager.h
Ogre::ManualObject::mTempIndexBuffer
uint32 * mTempIndexBuffer
System-memory buffer whilst we establish the size required.
Definition: OgreManualObject.h:509
Ogre::ManualObject::ManualObjectSectionShadowRenderable::getWBuffer
HardwareVertexBufferSharedPtr getWBuffer(void)
Definition: OgreManualObject.h:464
Ogre::MovableObjectFactory
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
Definition: OgreMovableObject.h:578
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::ManualObject::ManualObjectSection::mMaterialName
String mMaterialName
Definition: OgreManualObject.h:406
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::ManualObject::ManualObjectSection::get32BitIndices
bool get32BitIndices() const
Get whether we need 32-bit indices.
Definition: OgreManualObject.h:429
Ogre::ManualObject::ManualObjectSection::getMaterialGroup
const String & getMaterialGroup(void) const
Retrieve the material group in use.
Definition: OgreManualObject.h:423
Ogre::ManualObject::mDeclSize
size_t mDeclSize
Current declaration vertex size.
Definition: OgreManualObject.h:513
Ogre::ManualObject::mTempIndexSize
size_t mTempIndexSize
System memory allocation size, in bytes.
Definition: OgreManualObject.h:511
Ogre::ManualObject::mAnyIndexed
bool mAnyIndexed
Any indexed geometry on any sections?
Definition: OgreManualObject.h:525
Ogre::Light
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::ManualObject::TempVertex::normal
Vector3 normal
Definition: OgreManualObject.h:492

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