Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

   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

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted
The same 'seethrough' effect happens to all mesh files that I have tried to load. All from the DirectX SDK; however, the one above shows the best representation of the problem I am having.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

I figured out the problem, it was Z-Buffering. Resolution:

 

       'Add to present params these lines....
       PresentParams.EnableAutoDepthStencil = True
       PresentParams.AutoDepthStencilFormat = DepthFormat.D16

 

You need to use ClearFlags.zbuffer in your Device.Clear(). Does anyone know how to pass multiple flags to a function? Right now what I use works, but I think could be much more effecient.

 

           Direct3DDevice.Clear(ClearFlags.ZBuffer, Color.Blue, 1.0F, 0)
           Direct3DDevice.Clear(ClearFlags.Target, Color.Blue, 1.0F, 0)
           'I tried 
           Direct3DDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Blue, 1.0F, 0)
           'This gives a snytax error about no function matches these parameters

 

Any ideas about that would be great.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • Leaders
Posted
'Try
           Direct3DDevice.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.Blue, 1.0F, 0)
'The C#/C++ | operator is just a binary OR operator. The "Or" keywords doubles 
'as a logical and binary OR operator in VB.

[sIGPIC]e[/sIGPIC]
Posted

Works like a charm, I thought I tried it before, but I must've had some other setting wrong to make it not work. Thanks

 

 

--Issue Resolved--

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

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...