OGRE 14.3
Object-Oriented Graphics Rendering Engine
|
collects together all the vertex-related information used to render geometry. More...
#include <OgreVertexIndexData.h>
Classes | |
struct | HardwareAnimationData |
Struct used to hold hardware morph / pose vertex data information. More... | |
Public Types | |
typedef std::vector< HardwareAnimationData > | HardwareAnimationDataList |
Public Member Functions | |
VertexData (HardwareBufferManagerBase *mgr=0) | |
Constructor. | |
VertexData (VertexDeclaration *dcl, VertexBufferBinding *bind) | |
Constructor. | |
~VertexData () | |
VertexData * | _cloneRemovingBlendData () const |
Internal method to clone vertex data definitions but to remove blend buffers. | |
ushort | allocateHardwareAnimationElements (ushort count, bool animateNormals) |
Allocate elements to serve a holder of morph / pose target data for hardware morphing / pose blending. | |
VertexData * | clone (bool copyData=true, HardwareBufferManagerBase *mgr=0) const |
Clones this vertex data, potentially including replicating any vertex buffers. | |
void | closeGapsInBindings (void) |
Remove any gaps in the vertex buffer bindings. | |
void | convertPackedColour (VertexElementType srcType, VertexElementType destType) |
Convert all packed colour values (VET_COLOUR_*) in buffers used to another type. | |
void | convertVertexElement (VertexElementSemantic semantic, VertexElementType dstType, uint16 index=0) |
Convert the type of a vertex element of the given semantic. | |
void | prepareForShadowVolume (void) |
Modifies the vertex data to be suitable for use for rendering shadow geometry as in [10]. | |
void | removeUnusedBuffers (void) |
Remove all vertex buffers that never used by the vertex declaration. | |
void | reorganiseBuffers (VertexDeclaration *newDeclaration, HardwareBufferManagerBase *mgr=0) |
Reorganises the data in the vertex buffers according to the new vertex declaration passed in. | |
Public Attributes | |
HardwareVertexBufferSharedPtr | hardwareShadowVolWBuffer |
Additional shadow volume vertex buffer storage. | |
HardwareAnimationDataList | hwAnimationDataList |
VertexElements used for hardware morph / pose animation. | |
uint32 | hwAnimDataItemsUsed |
Number of hardware animation data items used. | |
bool | mDeleteDclBinding |
Whether this class should delete the declaration and binding. | |
VertexBufferBinding * | vertexBufferBinding |
Defines which vertex buffers are bound to which sources. | |
uint32 | vertexCount |
The number of vertices to process in this particular rendering group. | |
VertexDeclaration * | vertexDeclaration |
Declaration of the the format of the vertex input. | |
uint32 | vertexStart |
The position in the bound buffers to start reading vertex data from. This allows you to use a single buffer for many different renderables. | |
collects together all the vertex-related information used to render geometry.
The RenderOperation requires a pointer to a VertexData object, and it is also used in Mesh and SubMesh to store the vertex positions, normals, texture coordinates etc. VertexData can either be used alone (in order to render unindexed geometry, where the stream of vertices defines the triangles), or in combination with IndexData where the triangles are defined by indexes which refer to the entries in VertexData. It’s worth noting that you don’t necessarily have to use VertexData to store your applications geometry; all that is required is that you can build a VertexData structure when it comes to rendering. This is pretty easy since all of VertexData’s members are pointers, so you could maintain your vertex buffers and declarations in alternative structures if you like, so long as you can convert them for rendering.
Ogre::VertexData::VertexData | ( | HardwareBufferManagerBase * | mgr = 0 | ) |
Constructor.
mgr | Optional HardwareBufferManager from which to create resources |
Ogre::VertexData::VertexData | ( | VertexDeclaration * | dcl, |
VertexBufferBinding * | bind | ||
) |
Constructor.
dcl | The VertexDeclaration to use |
bind | The VertexBufferBinding to use |
Ogre::VertexData::~VertexData | ( | ) |
VertexData * Ogre::VertexData::clone | ( | bool | copyData = true , |
HardwareBufferManagerBase * | mgr = 0 |
||
) | const |
Clones this vertex data, potentially including replicating any vertex buffers.
copyData | Whether to create new vertex buffers too or just reference the existing ones |
mgr | If supplied, the buffer manager through which copies should be made |
Modifies the vertex data to be suitable for use for rendering shadow geometry as in [10].
Preparing vertex data to generate a shadow volume involves firstly ensuring that the vertex buffer containing the positions is a standalone vertex buffer, with no other components in it. This method will therefore break apart any existing vertex buffers if position is sharing a vertex buffer. Secondly, it will double the size of this vertex buffer so that there are 2 copies of the position data for the mesh. The first half is used for the original, and the second half is used for the 'extruded' version. The vertex count used to render will remain the same though, so as not to add any overhead to regular rendering of the object. Both copies of the position are required in one buffer because shadow volumes stretch from the original mesh to the extruded version.
It's important to appreciate that this method can fundamentally change the structure of your vertex buffers, although in reality they will be new buffers. As it happens, if other objects are using the original buffers then they will be unaffected because the reference counting will keep them intact. However, if you have made any assumptions about the structure of the vertex data in the buffers of this object, you may have to rethink them.
Because shadow volumes are rendered in turn, no additional index buffer space is allocated by this method, a shared index buffer allocated by the shadow rendering algorithm is used for addressing this extended vertex buffer.
void Ogre::VertexData::convertVertexElement | ( | VertexElementSemantic | semantic, |
VertexElementType | dstType, | ||
uint16 | index = 0 |
||
) |
Convert the type of a vertex element of the given semantic.
currently the following conversions are supported:
semantic | The semantic of the element to convert |
dstType | The type to convert to |
index | Optional index for multi-input semantics like texture coordinates |
void Ogre::VertexData::reorganiseBuffers | ( | VertexDeclaration * | newDeclaration, |
HardwareBufferManagerBase * | mgr = 0 |
||
) |
Reorganises the data in the vertex buffers according to the new vertex declaration passed in.
Note that new vertex buffers are created and written to, so if the buffers being referenced by this vertex data object are also used by others, then the original buffers will not be damaged by this operation. Once this operation has completed, the new declaration passed in will overwrite the current one. This version of the method derives the buffer usages from the existing buffers, by using the 'most flexible' usage from the equivalent sources.
newDeclaration | The vertex declaration which will be used for the reorganised buffer state. Note that the new delcaration must not include any elements which do not already exist in the current declaration; you can drop elements by excluding them from the declaration if you wish, however. |
mgr | Optional pointer to the manager to use to create new declarations and buffers etc. If not supplied, the HardwareBufferManager singleton will be used |
Remove any gaps in the vertex buffer bindings.
This is useful if you've removed elements and buffers from this vertex data and want to remove any gaps in the vertex buffer bindings. This method is mainly useful when reorganising vertex data manually.
Remove all vertex buffers that never used by the vertex declaration.
This is useful if you've removed elements from the vertex declaration and want to unreference buffers that never used any more. This method is mainly useful when reorganising vertex data manually.
void Ogre::VertexData::convertPackedColour | ( | VertexElementType | srcType, |
VertexElementType | destType | ||
) |
Convert all packed colour values (VET_COLOUR_*) in buffers used to another type.
srcType | The source colour type to assume if the ambiguous VET_COLOUR is encountered. |
destType | The destination colour type, must be VET_COLOUR_ABGR or VET_COLOUR_ARGB. |
Allocate elements to serve a holder of morph / pose target data for hardware morphing / pose blending.
This method will allocate the given number of 3D texture coordinate sets for use as a morph target or target pose offset (3D position). These elements will be saved in hwAnimationDataList. It will also assume that the source of these new elements will be new buffers which are not bound at this time, so will start the sources to 1 higher than the current highest binding source. The caller is expected to bind these new buffers when appropriate. For morph animation the original position buffer will be the 'from' keyframe data, whilst for pose animation it will be the original vertex data. If normals are animated, then twice the number of 3D texture coordinates are required
VertexData * Ogre::VertexData::_cloneRemovingBlendData | ( | ) | const |
Internal method to clone vertex data definitions but to remove blend buffers.
VertexDeclaration* Ogre::VertexData::vertexDeclaration |
Declaration of the the format of the vertex input.
Note that this is created for you on construction.
VertexBufferBinding* Ogre::VertexData::vertexBufferBinding |
Defines which vertex buffers are bound to which sources.
Note that this is created for you on construction.
bool Ogre::VertexData::mDeleteDclBinding |
Whether this class should delete the declaration and binding.
uint32 Ogre::VertexData::vertexStart |
The position in the bound buffers to start reading vertex data from. This allows you to use a single buffer for many different renderables.
uint32 Ogre::VertexData::vertexCount |
The number of vertices to process in this particular rendering group.
uint32 Ogre::VertexData::hwAnimDataItemsUsed |
Number of hardware animation data items used.
HardwareAnimationDataList Ogre::VertexData::hwAnimationDataList |
VertexElements used for hardware morph / pose animation.
HardwareVertexBufferSharedPtr Ogre::VertexData::hardwareShadowVolWBuffer |
Additional shadow volume vertex buffer storage.
This additional buffer is only used where we have prepared this VertexData for use in shadow volume construction, and where the current render system supports vertex programs. This buffer contains the 'w' vertex position component which will be used by that program to differentiate between extruded and non-extruded vertices. This 'w' component cannot be included in the original position buffer because DirectX does not allow 4-component positions in the fixed-function pipeline, and the original position buffer must still be usable for fixed-function rendering.
Note that we don't store any vertex declaration or vertex buffer binding here because this can be reused in the shadow algorithm.