[2.1] sharedVertexData and indexData are size-2 arrays now?
-
- Gnoblar
- Posts: 14
- Joined: Tue Mar 22, 2011 10:06 pm
[2.1] sharedVertexData and indexData are size-2 arrays now?
I am referring to Ogre::v1::Mesh::sharedVertexData and Ogre::v1::SubMesh::indexData. They used to be pointers but now they are size-2 arrays of pointers. As I understand it, this has something to do with using a separate mesh for calculating shadows, but if I just want to get my old code (which creates a mesh programatically by populating vertex and index buffers) working with the newest Ogre, what do I do?
-
- Halfling
- Posts: 64
- Joined: Mon Sep 12, 2011 7:35 pm
- x 13
Re: [2.1] sharedVertexData and indexData are size-2 arrays n
If you don't have any particular reason to create it as v1 meshes, I would recommend you to take a look at the DynamicGeometry Sample (Samples/2.0/ApiUsage/DynamicGeometry). You'll see that it's very easy to do what you want using Ogre::VaoManager.ArbitraryValue wrote:if I just want to get my old code (which creates a mesh programatically by populating vertex and index buffers) working with the newest Ogre, what do I do?
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: [2.1] sharedVertexData and indexData are size-2 arrays n
You can just use the same data for both and will work
-
- Gnoblar
- Posts: 14
- Joined: Tue Mar 22, 2011 10:06 pm
Re: [2.1] sharedVertexData and indexData are size-2 arrays n
This did work, thank you. For other people's reference, the following code appears to work:xrgo wrote:You can just use the same data for both and will work
Code: Select all
Ogre::v1::MeshPtr currentMesh = Ogre::v1::MeshManager::getSingleton().createManual(nameGenerator.generate(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
Ogre::v1::SubMesh* currentSubmesh = currentMesh->createSubMesh();
Ogre::v1::VertexData* vertexData = new Ogre::v1::VertexData();
currentMesh->sharedVertexData[0] = vertexData;
// no seperate shadow mesh
currentMesh->sharedVertexData[1] = currentMesh->sharedVertexData[0];
currentSubmesh->indexData[1] = currentSubmesh->indexData[0];
I intend to follow your advice (after all, why switch to 2.1 unstable but keep using v1 objects) but I just wanted to get the old code running before I started improving it.farrer wrote:If you don't have any particular reason to create it as v1 meshes, I would recommend you to take a look at the DynamicGeometry Sample (Samples/2.0/ApiUsage/DynamicGeometry). You'll see that it's very easy to do what you want using Ogre::VaoManager.
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: [2.1] sharedVertexData and indexData are size-2 arrays n
Having a nullptr for the shadow vertex buffer is not valid (unless the mesh is being initialized of course).ArbitraryValue wrote: I looked in the ogre code and the shadow mesh appears to be processed only if its address is not the same as that of the normal (not in the normal vector sense) mesh. IMO there should be a null check there too but there isn't.
During render Ogre expects the shadow vertex buffer to either be the same pointer as the regular vertex buffer (i.e. share same geometry & buffers); or have its own buffer.
If trying to render with a nullptr in the shadow vertex buffer and shadow mapping is used, Ogre will crash.