Sign in to follow this  
IronDonut

Texturing A Mesh (Managed)

Recommended Posts

I have a Mesh object I've created and am rendering into my DirectX scene. I'd like to add a texture to it real time. Does anyone have any example code? int numVertex = targetMesh.SystemMesh.NumberVertices; CustomVertex.PositionNormalTextured[] verts =(CustomVertex.PositionNormalTextured[]) targetMesh.SystemVertexBuffer.Lock( 0, typeof( CustomVertex.PositionNormalTextured ), 0, targetMesh.SystemMesh.NumberVertices ); VertexBuffer vertexBuffer = new VertexBuffer( typeof( CustomVertex.PositionNormalTextured ), numVertex, device, Usage.WriteOnly, CustomVertex.PositionNormalTextured.Format, Pool.Default ); device.SetTexture( 0, texture ); device.SetStreamSource( 0, vertexBuffer, 0 ); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, numVertex); targetMesh.SystemVertexBuffer.Unlock(); This is what I'm doing now and it's not working. Thank you.

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