本文整理汇总了C++中HardwareVertexBufferSharedPtr::setIsInstanceData方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwareVertexBufferSharedPtr::setIsInstanceData方法的具体用法?C++ HardwareVertexBufferSharedPtr::setIsInstanceData怎么用?C++ HardwareVertexBufferSharedPtr::setIsInstanceData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareVertexBufferSharedPtr
的用法示例。
在下文中一共展示了HardwareVertexBufferSharedPtr::setIsInstanceData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupVertices
//-----------------------------------------------------------------------
void InstanceBatchHW::setupVertices( const SubMesh* baseSubMesh )
{
mRenderOperation.vertexData = baseSubMesh->vertexData->clone();
mRemoveOwnVertexData = true; //Raise flag to remove our own vertex data in the end (not always needed)
VertexData *thisVertexData = mRenderOperation.vertexData;
//No skeletal animation support in this technique, sorry
removeBlendData();
//Modify the declaration so it contains an extra source, where we can put the per instance data
size_t offset = 0;
unsigned short nextTexCoord = thisVertexData->vertexDeclaration->getNextFreeTextureCoordinate();
const unsigned short newSource = thisVertexData->vertexDeclaration->getMaxSource() + 1;
for( unsigned char i=0; i<3 + mCreator->getNumCustomParams(); ++i )
{
thisVertexData->vertexDeclaration->addElement( newSource, offset, VET_FLOAT4,
VES_TEXTURE_COORDINATES, nextTexCoord++ );
offset = thisVertexData->vertexDeclaration->getVertexSize( newSource );
}
//Create the vertex buffer containing per instance data
HardwareVertexBufferSharedPtr vertexBuffer =
HardwareBufferManager::getSingleton().createVertexBuffer(
thisVertexData->vertexDeclaration->getVertexSize(newSource),
mInstancesPerBatch,
HardwareBuffer::HBU_STATIC_WRITE_ONLY );
thisVertexData->vertexBufferBinding->setBinding( newSource, vertexBuffer );
vertexBuffer->setIsInstanceData( true );
vertexBuffer->setInstanceDataStepRate( 1 );
}
示例2: buildFrom
//-----------------------------------------------------------------------
void LightInstanceBatchHW::buildFrom( const SubMesh *baseSubMesh, const RenderOperation &renderOperation )
{
InstanceBatch::buildFrom( baseSubMesh, renderOperation );
//We need to clone the VertexData (but just reference all buffers, except the last one)
//because last buffer contains data specific to this batch, we need a different binding
mRenderOperation.vertexData = mRenderOperation.vertexData->clone( false );
VertexData *thisVertexData = mRenderOperation.vertexData;
const unsigned short lastSource = thisVertexData->vertexDeclaration->getMaxSource();
HardwareVertexBufferSharedPtr vertexBuffer =
HardwareBufferManager::getSingleton().createVertexBuffer(
thisVertexData->vertexDeclaration->getVertexSize(lastSource),
mInstancesPerBatch,
HardwareBuffer::HBU_STATIC_WRITE_ONLY );
thisVertexData->vertexBufferBinding->setBinding( lastSource, vertexBuffer );
vertexBuffer->setIsInstanceData( true );
vertexBuffer->setInstanceDataStepRate( 1 );
}