Clone a Mesh with different HardwareBuffer Usage?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
KingLeonid
Gnoblar
Posts: 15
Joined: Wed Apr 13, 2005 12:57 pm
Location: St.Petersburg, Russia
Contact:

Clone a Mesh with different HardwareBuffer Usage?

Post by KingLeonid »

Hi!

Imagine that I have a mesh (pre-loaded or created manually somewhere) and I want
to clone this mesh for tweaking its vertices and add my own data to them. But original mesh has HBU_STATIC_WRITE_ONLY buffer usage. And I need a copy of such mesh but with HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE buffer usage (or any other).

How can I do such clonning?

My first idea was to do:

Code: Select all

newmesh = oldmesh->clone();
for every submesh in newmesh
{
  submesh = newmesh->getSubMesh(i);
  submesh->vertexData->reorganizeBuffers(submesh->vertexData->vertexDeclaration, MyHBUlist);
}
But this method has at least two drawbacks:
  • Double copy of vertex data - firstly they are copied in Mesh::clone in STATIC hardware buffer and then to my DYNAMIC one.
  • reogranizeBuffers(...) doesn't allow to add extra fields into vertexDeclaration
So, the only way to clone a Mesh into DYNAMIC hardware buffer is to do MANUAL copy of all inner Mesh and SubMesh parameters, but I'm not sure that I can get them all from class object due to protection.
And doing such copy is a wrong way because Mesh declaration could change in future
releases.

Any ideas?
Best regards,
Leo.

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 65
Contact:

Post by sinbad »

You might want to look at the implementation of software skinning, which does pretty much what you're asking here. See HardwareBufferManager::allocateVertexBufferCopy and the various usages of TempBlendedBufferInfo in the code.

User avatar
KingLeonid
Gnoblar
Posts: 15
Joined: Wed Apr 13, 2005 12:57 pm
Location: St.Petersburg, Russia
Contact:

Post by KingLeonid »

sinbad wrote:You might want to look at the implementation of software skinning, which does pretty much what you're asking here. See HardwareBufferManager::allocateVertexBufferCopy and the various usages of TempBlendedBufferInfo in the code.
Thank you for the reference, I'll take a look.
Best regards,
Leo.

Post Reply