Sign in to follow this  
Carbon_PhD

Quickly Modifying Direct Meshes

Recommended Posts

Carbon_PhD    100
Hello everyone,

So I tried a number of combinations to resolve my issue and i think my brain has now gone dead.

I basically have a mesh where the indices and vertices are continuously changing. When i use the following code the mesh appears once and then whne createmesh() method is executed again it disappears. I have attached an image of the wire frame which shows the vertices and indices are different between each call of the createmesh() method.

Now if i create a new instance of _catmullShellMesh in the createmesh() i dont have a problem but that means i have to dipose of the mesh each time the method is called which leads to memory corruption problems.

I believe problem stems from the cloning and computing of the normals because if i bypass this code i get the correct wireframe but obviously no colour.

A fresh set of eyes would be much appreciated.

Thanks in advance...


[color=blue][code]public class DynamicShell
{
private Mesh _catmullShellMesh;
public DynamicShell(...)
{
_catmullShellMesh = new Mesh(1500, _maxMeshVertices, MeshFlags.Managed, CustomVertex.PositionColored.Format, _DXDevice);

}

private void CreateMesh()
{
_catmullShellMesh.VertexBuffer.SetData(_catmullVertexData, 0, LockFlags.Discard);
_catmullShellMesh.IndexBuffer.SetData(_catmullIndexArray.ToArray(), 0, LockFlags.Discard);

Mesh temp = _catmullShellMesh.Clone(_catmullShellMesh.Options.Value, CustomVertex.PositionNormal.Format, _DXDevice);

temp.ComputeNormals();

_catmullShellMesh.Dispose();
_catmullShellMesh = temp;

}
}[/code][/color]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this