Textures from .x files

Lazlo

Newcomer
Joined
Mar 2, 2005
Messages
3
I´m using the code below to load a .x file, but can´t figure out how to load the textures from the X file. :confused:
Plz help me with som code snippets showing how to do this.


Code:
        Mesh = Mesh.FromFile(Application.StartupPath & "/Map.X", MeshFlags.Dynamic, obj3DDevice)
        MeshMaterials = New Material
        MeshMaterials.Ambient = Color.White
        obj3DDevice.Material = MeshMaterials

        MeshTextures = TextureLoader.FromFile(obj3DDevice, Application.StartupPath & "/texture.bmp")
 
I didn't even know that .x files would come WITH textures... Odd
I know that there's something called Mesh.TextureFileName.

This is what I use to load meshes with textures (not within the mesh, but seperately)

<Edit: Please ignore. The code I pasted ended up being one HUGE (wide) line. See next post>
 
Argh. iNet.

Code:
		Public Sub LoadMesh(ByVal FileName As String, ByVal TextureFileName As String)
			Dim intX As Integer
			objMesh = Mesh.FromFile(FileName, MeshFlags.SystemMemory, d3ddev, extMaterials)
			ReDim MeshTexture(extMaterials.Length)
			ReDim Mat(extMaterials.Length)
			For intX = 0 To extMaterials.Length - 1
				Mat(intX) = extMaterials(intX).Material3D
				Mat(intX).Ambient = Mat(intX).Diffuse
				extMaterials(intX).TextureFilename = TextureFileName
				MeshTexture(intX) = TextureLoader.FromFile(d3ddev, extMaterials(intX).TextureFilename)
			Next
		End Sub
 
ThePentiumGuy said:
So... .x files come with textures?
They can embed the texture name. A common problem is that the texture filename may have a complete or partial path in the .x file (it all depends on the modeler and exporter) and that path will rarely match up with where your loading app expects them to be.
 
Simple process, the good thing about this is you load .fx shaders the same way given you add some extra code to handle the rendering passes.

The reference information is in the .X File.

If your mesh has been saved with the appropriate references then when you load it it will automatically load this information for you in arrays, all you need to do is setup a simple render loop for the object and apply your textures, etc..

:D :rolleyes: :p :cool:
 
Back
Top