Cloning a Mesh/submesh


25-11-2006 11:14:09

I'm having problems cloning submeshes. What I want to do is take some submeshes from a existing mesh and clone them into a manual created mesh. But it always ends up crashing the program with a "Attempted to read or write protected memory" exception.

To try to find out what the problem was, I copied the code from the Clone method of Ogre::Mesh and converted it into c#. But this gives the exact same problem. Apart from a few attributes that I couldn't copy because they are either not public members in Mogre.SubMesh or are read only (While in ogre I don't think there are. The three main ones I mean are: blendIndexToBoneIndexMap, mLodFaceList, isMatInitialised).

Anyway as the code is doing the same thing as it does in Ogre::Mesh.clone, so I'm wondering if it is something to do with Mogre? Or if there is something else I need to do.

Basically I'm just going through the submeshes and cloning their Vertexdata (with the Vertexdata.clone() method) and then copying the other data from the old submesh to the new one.


25-11-2006 13:07:35

Can you post a small example that demonstrates the problem so I can check it out?


27-11-2006 11:22:11

I think it might have been a mistake I was making. I need to do more testing to be sure but it is looking that way.

Thanks for taking the time to reply though.