Kbessa,
This is the code I came up with in the end. Seems to work well.
Shared Sub MakeTeapot(ByVal ObjNo As Integer)
Dim res As SlimDX.Result
Dim strTempObject As String = Path.GetTempFileName.Replace(".tmp", ".x")
g_Mesh3D = SlimDX.Direct3D9.Mesh.CreateTeapot(d3dDev)
g_Mesh3D.SetMaterials(SetDefaultTextures)
g_Mesh3D.SetEffects(SetDefaultEffects)
res = SlimDX.Direct3D9.Mesh.ToXFile(g_Mesh3D, strTempObject, Direct3D9.XFileFormat.Text)
DGDKPlugins.CDarkGDK.oDB3D.LoadObject(strTempObject, ObjNo)
File.Delete(strTempObject)
End Sub
Friend Shared Function SetDefaultTextures() As SlimDX.Direct3D9.ExtendedMaterial()
Dim extMat As New SlimDX.Direct3D9.ExtendedMaterial
Dim defMaterial As New SlimDX.Direct3D9.Material
Dim mats(0) As SlimDX.Direct3D9.ExtendedMaterial
defMaterial.Ambient = New SlimDX.Color4(1, 0, 0, 0)
defMaterial.Diffuse = New SlimDX.Color4(0, 0.5, 0.5, 0.5)
defMaterial.Emissive = New SlimDX.Color4(1, 0, 0, 0)
defMaterial.Specular = New SlimDX.Color4(1, 0.5, 0.5, 0.5)
extMat.MaterialD3D = defMaterial
extMat.TextureFileName = ""
mats(0) = extMat
Return mats
End Function
Friend Shared Function SetDefaultEffects() As SlimDX.Direct3D9.EffectInstance()
Dim myEffect(0) As SlimDX.Direct3D9.EffectInstance
Dim Effects(3) As SlimDX.Direct3D9.EffectDefault
Effects(0).ParameterName = "Diffuse"
Effects(0).Type = Direct3D9.EffectDefaultType.Floats
Effects(0).Value = New SlimDX.DataStream(16, True, True)
Effects(1).ParameterName = "Power"
Effects(1).Type = Direct3D9.EffectDefaultType.Floats
Effects(1).Value = New SlimDX.DataStream(4, True, True)
Effects(2).ParameterName = "Specular"
Effects(2).Type = Direct3D9.EffectDefaultType.Floats
Effects(2).Value = New SlimDX.DataStream(16, True, True)
Effects(3).ParameterName = "Emissive"
Effects(3).Type = Direct3D9.EffectDefaultType.Floats
Effects(3).Value = New SlimDX.DataStream(16, True, True)
myEffect(0).Defaults = Effects
Return myEffect
End Function