Skip to main content
GameDev.net gamedev.net
🔒 Locked

load an x file in a c# program

Started by Link Jul 13, 2005 at 4:51 PM 7 replies 2.1k views
Original Post
Link
Link
How? Some easy tuts online?
Instruo
Instruo
MSDN / DirectX SDK has tons of information for you. Specifically, try Mesh and look at the "FromFile" static method.
"Game Programming" in an of itself does not exist. We learn to program and then use that knowledge to make games.
Etherstar
Etherstar
    // Begin loading a mesh    ExtendedMaterial[] mtrl;    private Material[] meshMat;    private Texture[] meshTex;    Mesh sysMesh = Mesh.FromFile("fileName.x", MeshFlags.Managed, device, out           mtrl);   //store mesh materials   if ((mtrl != null) && (mtrl.Length > 0))   {        meshMat = new Material[mtrl.Length];        meshTex = new Texture[mtrl.Length];        for (int i = 0; i < mtrl.Length; i++)        {             meshMat = mtrl.Material3D;             if ((mtrl.TextureFilename != null) && (mtrl.TextureFilename                 != string.Empty))             {                 //There's a texture, load it                 meshTex = TextureLoader.FromFile(device,                       mtrl.TextureFilename);             }         }    }


Basically you need to not only load the mesh, but also keep all your textures and materials stored for your drawSubset calls when you render the mesh. Hope this helps.
Link
Link
if it is a skinned mesh .x file?
Bosh
Bosh
I just had to run through a skinned me myself. The problem is that you have to have an derived classes for about everything you will use when you animate (Frame, AllocateHeirarchy, MeshContainer, etc...). You then have to override all of the functions in the AllocateHeirarchy derived class so that you can load the frames, meshes, and textures. It's a long drawn out process, and there is something in the SDK about it. I believe it's called simple animation. It came with the June SDK, and if I remember, pretty much everyone since summer 2004. Elsewise, just load it like it says. AnimtionRoot = Mesh.LoadHierarchyFromFile(string for file, meshflags, device, (the derived heirarchy), null(don't know what it's for));
Link
Link
I've the old version of sdk 9.0
how can i update also the help files?
Saruman
Saruman
Get the latest SDK version.
Link
Link
Ok, tnx.
Now i would try to load my mesh inside a panel of my windows c# form.
How could i do?

i use this code:
		public void OnResetDevice(object sender, EventArgs e)		{			ExtendedMaterial[] materials = null;			Directory.SetCurrentDirectory(Application.StartupPath + @"\");			Device dev = (Device) sender;			dev.RenderState.ZBufferEnable = true;			dev.RenderState.Ambient = System.Drawing.Color.White;			mesh = Mesh.FromFile("tiger.x", MeshFlags.SystemMemory, device, out materials);			if(meshTextures == null)			{				meshTextures = new Texture[materials.Length];				meshMaterials = new Direct3D.Material[materials.Length];				for(int i=0; i<materials.Length; i++)				{					meshMaterials = materials.Material3D;					meshMaterials.Ambient = meshMaterials.Diffuse;					meshTextures = TextureLoader.FromFile(dev, materials.TextureFilename);				}			}		}


It should be cool convert panel to device...
Device dev = (Device) sender;
Device dev = (Device) mypanel; // ERROR
Link
Link
up

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.