Nate Bross
Contributor
I worked out the following code and it works great with one exception. When I am looking at them, (I am using the wall_with_pillars.x mesh that comes with the DirectX August SDK Update) they are see through. You can easily see the object, but it is see through. You can see clearly with a screenshot I took. If you look at the pillers they are all see through. Any advice anyone has would be greatly appreciated.
Visual Basic:
Private Mesh As Mesh
Private Materials() As Material
Private Textures() As Texture
Private Sub DrawMesh()
Dim i As Long
For i = 0 To Materials.Length - 1
If Not Textures(i) Is System.DBNull.Value Then
Direct3DDevice.SetTexture(0, Textures(i))
End If
Direct3DDevice.Material = Materials(i)
Mesh.DrawSubset(i)
Next i
End Sub
Private Sub CreateMesh(ByVal path As String)
Dim exMaterials() As ExtendedMaterial
Mesh = Mesh.FromFile(path, MeshFlags.SystemMemory, Direct3DDevice, exMaterials)
If Not Textures Is System.DBNull.Value Then
'DisposeTextures()
End If
Textures = New Texture(exMaterials.Length) {}
Materials = New Material(exMaterials.Length) {}
Dim i As Long
For i = 0 To exMaterials.Length - 1
If exMaterials(i).TextureFilename <> "" Then
Dim texturePath As String
texturePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(path), exMaterials(i).TextureFilename)
Textures(i) = TextureLoader.FromFile(Direct3DDevice, texturePath)
End If
Materials(i) = exMaterials(i).Material3D
Materials(i).Ambient = Materials(i).Diffuse
Next i
End Sub