Sign in to follow this  
Wrathnut

[XNA] Rendering Model from modTool using Vertex color

Recommended Posts

Hi, I am relatively new to 3d and was getting started with rendering a model using it's vertex colors instead of using textures on the model. I am using XSI modTool to generate a model in the DirectX .x file format. Currently it does not seem to be rendering the model with the correct vertex colors. I am using the Vertex color painting tool in modTool to set the color data on the vertex's of the mesh. When I render the model I am using the effect parameter VertexColorEnabled = true. This sort of works, where I will start seeing some of the colors that I painted being rendered on the model but it isn't painting it correctly. I was wondering if the is something more that needs to be done in XNA for you to render a model using vertex color data or if I am not exporting the model file from modTool. At this point I am unsure how to tell if I am getting the error from modTool or from my rendering. Here is the code used for rendering:
private void DrawModel( Model m )
{
    Matrix[] transforms = new Matrix[m.Bones.Count];
    float aspectRatio = graphics.GraphicsDevice.Viewport.Width / graphics.GraphicsDevice.Viewport.Height;
    m.CopyAbsoluteBoneTransformsTo( transforms );
    Matrix projection = Matrix.CreatePerspectiveFieldOfView( MathHelper.ToRadians( 45.0f ),
        aspectRatio, 1.0f, 10000.0f );
    Matrix view = Matrix.CreateLookAt( new Vector3( 0.0f, 50.0f, Zoom ), Vector3.Zero, Vector3.Up );

    foreach (ModelMesh mesh in m.Meshes)
    {
        foreach (BasicEffect effect in mesh.Effects)
        {
            effect.EnableDefaultLighting();
            effect.VertexColorEnabled = true;
            effect.View = view;
            effect.Projection = projection;
            effect.World = MyWorldRotation * transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation( Position );
        }
        mesh.Draw();
    }
}
Thanks in advance

Share this post


Link to post
Share on other sites

I haven't used vertex colors myself before, but you could try disabling the texture and the lighting on the effect to see if the colors do show up correctly then. Perhaps this may already solve the problem (if it's something with the textures/lighting), but at least it should help narrow down what's going wrong. Also a screenshot of how it "sort of works" might be useful [wink]

Hope this helps :)

Share this post


Link to post
Share on other sites

Hi, Thanks for the reply! Ya I tried disabling the lighting. There is no texturing being done on the model. None of that did anything really. I am using a global lighting. That is what the EnableDefaultLighting() does. But like I said that didn't do anything. Unfortunately I won't be able to post a screen shot today.

I was looking around last night and I saw some code were someone literally rendered their model by using drawPrimitives() and then passing the vertex data from the model into the method. I was wondering if this might work. I haven't figured out how to pass the data from my model into that method yet so I am unsure. Although I would really think that to render a model using the vertex colors you wouldn't have to do that. :(

Share this post


Link to post
Share on other sites
So I downloaded a model from Riemers tutorial that uses vertex coloring instead of texturing and it appears that my problem is modTool didn't export the vertex colors properly to the DirectX .x file format. So the problem is either modTool of my understanding of how modTool paints the vertex data.

So my next question is this, what Free tools are available to either paint vertex data on a .x File model or free modeling tools? I am going to give blender a try but I am curious if they are some other tools you guys have used that you find easier/better.

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this