Jump to content
  • Advertisement
Sign in to follow this  
Kranar

Managed DirectX Scaling a Mesh

This topic is 4832 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've decided to give Managed DirectX in C# a try but can not think of a way to resize a mesh. In C++ you could lock the mesh's VertexBuffer and then directly multiply each vertex by your a scaling factor, but in C# there seems to be no way to do this. Anyone have any suggestions or advice?

Share this post


Link to post
Share on other sites
Advertisement
Actually, I think I found a similar way to directly access the vertices of a mesh doing something like this in C#


private void ScaleObject(float scale) {
Mesh scaledMesh = mesh.Clone((MeshFlags)(0),
VertexFormats.Position,
device);

Array ar = scaledMesh.LockVertexBuffer(...);

foreach(Vector3 i in ar) {
i.Scale(scale);
}
scaledMesh.UnlockVertexBuffer();
mesh = scaledMesh;
}



The problem is that I don't know what I'm supposed to pass into scaledMesh.LockVertexBuffer() in order for it to properly return an array of vertices.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!