Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

 

 

       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")

Posted

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>

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

Posted

Argh. iNet.

 


	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

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

  • 3 months later...
Posted
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.

  • 1 month later...
Posted

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:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...