Sylither Posted November 15, 2004 Posted November 15, 2004 I want to make a game that has spheres going around the screen. They will be moving only horizontal and vertical but I'm thinking it might look better if they were 3D spheres. I also have anothere question how do we use meshes and .X files? Quote
Ming_Lei Posted November 15, 2004 Posted November 15, 2004 Code to load and draw a DirectX .X model The following code is from book source MDX Kick Start to load a .X mesh file: ====================================== private void LoadMesh(string file) { ExtendedMaterial[] mtrl; // Load our mesh mesh = Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl); // If we have any materials, store them if ((mtrl != null) && (mtrl.Length > 0)) { meshMaterials = new Material[mtrl.Length]; meshTextures = new Texture[mtrl.Length]; // Store each material and texture for (int i = 0; i < mtrl.Length; i++) { meshMaterials = mtrl.Material3D; if ((mtrl.TextureFilename != null) && (mtrl.TextureFilename != string.Empty)) { // We have a texture, try to load it meshTextures = TextureLoader.FromFile(device, @"..\..\" + mtrl.TextureFilename); } } } } ============================================ You also need to have declared the following: Mesh mesh = null; Material[] meshMaterials; Texture[] meshTextures; The 'mesh' can be drawn using the following code: ============================================ for (int i = 0; i < meshMaterials.Length; i++) { device.Material = meshMaterials; device.SetTexture(0, meshTextures); mesh.DrawSubset(i); } Quote
Sylither Posted November 16, 2004 Author Posted November 16, 2004 thanx a lot but I can't use it. I forget to say that I use VB.net not C# which I know very little for but I'll try to translate it it's not that diffcult Quote
ThePentiumGuy Posted November 17, 2004 Posted November 17, 2004 Check out my last post here: http://www.xtremedotnettalk.com/showthread.php?t=89586 ALso view the tutorials in the Tutor's corner :P Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.