Manual Mesh

mipre100

05-10-2005 14:47:09

I'm planning to use a manual mesh technique to create an ocean mesh with waves, etc. Has anyone been using manual meshes yet? How'd you convert the MeshPtr produced from MeshManager.CreateManualMesh to a Mesh object? Also, are there any other pitfalls I'm likely to come across?

mipre100

05-10-2005 17:28:10

I think I may have answered my "how do you get a Mesh from a MeshPtr" question:

I've added the following to the end of the Mesh.i SWIG file:

%extend Ogre::MeshPtr
{
inline Mesh * get()
{
return self->get();
}
}

Which allows me to get the mesh from the MeshPtr...

fifty1

11-10-2005 03:43:41

mipre100: I'll be using manual meshes in about a week. Do you have any suggestions or warnings?

mipre100

11-10-2005 08:54:30

Right at the moment, you can setup all the buffers, etc, however, there is currently no way to actually write the data to the buffers. You would normally either write an array to the buffer:

positionVertexBuffer.get().WriteData(0,
positionVertexBuffer.get().GetSizeInBytes(), // size
positionVertexArray, // source
true);


or lock the buffer, write to the pointer you are given, and then release the lock:

float[] positionVertexArray;
positionVertexArray = positionVertexBuffer.get().Lock(....)
....
positionVertexBuffer.get().Unlock()


Unfortuantly, both of these methods require use of void pointers and thus are currently unsupported by SWIG. (see http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=60). I have not come accross a work around for this yet, so please let me know if you find a way.

Other things to note, a lot of what is going on here is passing blocks of memory by address (pointers). Remember that in C# the garbage collector does not guarentee the location of your vars, so even if you do get a pointer to a block of memory, when you come to write to it, the GC may have moved that block.

fifty1

11-10-2005 14:14:15

Thanks for the info. I'll be working on this in a week or two. I'll let you know how it goes...