Jump to content
  • Advertisement
Sign in to follow this  

Directx9 Vb.net Change Mesh color

This topic is 4823 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

        'EarthMesh.LockVertexBuffer(0, 0, p_vertices(), 0)

Share this post

Link to post
Share on other sites
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.


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!