Jump to content
  • Advertisement
Sign in to follow this  
tuvd

Directx9 Vb.net Change Mesh color

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to change the color of a d3dmesh sphere, but it dont seem to work, and i cant see anything wrong with my code?? here is my code it seems to be right but when i run it it dosent change the color it just screws up the shape of the object.
         
    Public Structure MeshVertex
        Public p As Vector3
        Public n As Vector3
        Public tu, tv As Single
        Public Color As Integer
        Public Const Format As VertexFormats = VertexFormats.Position Or    VertexFormats.Normal Or VertexFormats.Texture1 Or VertexFormats.Diffuse
    End Structure 'MeshVertex


Dim TmpVertexBuffer As VertexBuffer
        Dim numOfVerts As Integer
        Dim I As Integer

        'Dim vb As VertexBuffer = CType(sender, TmpVertexBuffer)
        'TmpVertexBuffer = CType(EarthMesh.VertexBuffer, VertexBuffer)
        Dim v As MeshVertex()

        numOfVerts = SunMesh.NumberVertices
        TmpVertexBuffer = SunMesh.VertexBuffer
        v = CType(TmpVertexBuffer.Lock(0, GetType(MeshVertex), 0, numOfVerts), MeshVertex())


        For I = 0 To numOfVerts - 1
            v(I).Color = System.Drawing.Color.Yellow.ToArgb
        Next

        'EarthMesh.LockVertexBuffer(0, 0, p_vertices(), 0)
        TmpVertexBuffer.Unlock()
        TmpVertexBuffer.Dispose()

Share this post


Link to post
Share on other sites
Advertisement
What are your render states configured as?

You're specifying VertexFormats.Normal, so if you're using the FF pipeline it'll get fed into the lighting processor. I'm pretty sure that, by default, this'll override your diffuse component.

I don't know what the name is in MDX, but there is a render state you can set so that it uses vertex colour as well (or instead of?) computed "light" colour.

hth
Jack

Share this post


Link to post
Share on other sites
ok now ive got rid of the normals, and it solved my prob with da polygon lookin wierd. But its still not changing the color of the object..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!