Jump to content
  • Advertisement
Sign in to follow this  
AHussain

How to Render Mesh Included in Sample of DirectX 9 SDK Update August 2005

This topic is 4505 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

Create a Mesh Object This example shows how to create a Mesh object. In the following C# code example, device is assumed to be the rendering Device.

Share this post


Link to post
Share on other sites
Advertisement
I have to admit you've got me confused.

Which sample in the SDK are you referring to? Have you found some code you dont understand (and want to use), or is your post outlining the code you want to find/write?

I dont know what the MDX/C# equivalent is, but there is a D3DXCreateMesh() function that you can use to allocate an empty mesh - and then fill it manually as you see appropriate.

hth
Jack

Share this post


Link to post
Share on other sites
this is a code included in DirectX help file.

[C#]

int numberVerts = 8;
short[] indices = {
0,1,2, // Front Face
1,3,2, // Front Face
4,5,6, // Back Face
6,5,7, // Back Face
0,5,4, // Top Face
0,2,5, // Top Face
1,6,7, // Bottom Face
1,7,3, // Bottom Face
0,6,1, // Left Face
4,6,0, // Left Face
2,3,7, // Right Face
5,2,7 // Right Face
};

Mesh mesh = new Mesh(numberVerts * 3, numberVerts, MeshFlags.Managed,
CustomVertex.PositionColored.Format, device);

using(VertexBuffer vb = mesh.VertexBuffer)
{
GraphicsStream data = vb.Lock(0, 0, LockFlags.None);

data.Write(new CustomVertex.PositionColored(-1.0f, 1.0f, 1.0f, 0x00ff00ff));
data.Write(new CustomVertex.PositionColored(-1.0f, -1.0f, 1.0f, 0x00ff00ff));
data.Write(new CustomVertex.PositionColored(1.0f, 1.0f, 1.0f, 0x00ff00ff));
data.Write(new CustomVertex.PositionColored(1.0f, -1.0f, 1.0f, 0x00ff00ff));
data.Write(new CustomVertex.PositionColored(-1.0f, 1.0f, -1.0f, 0x00ff00ff));
data.Write(new CustomVertex.PositionColored(1.0f, 1.0f, -1.0f, 0x00ff00ff));
data.Write(new CustomVertex.PositionColored(-1.0f, -1.0f, -1.0f, 0x00ff00ff));
data.Write(new CustomVertex.PositionColored(1.0f, -1.0f, -1.0f, 0x00ff00ff));

vb.Unlock();
}

using (IndexBuffer ib = mesh.IndexBuffer)
{
ib.SetData(indices, 0, LockFlags.None);
}




how can i render the above code in

device.BeginScene();


device.EndScene();


EDIT: These forums use 'source' and 'code' tags....

[Edited by - jollyjeffers on May 23, 2006 5:03:26 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!