friggityfraggity

I'm currently using a simple mesh created in 3ds. I changed the color and exported several times until I had a rainbow of colored objects. This seems silly to me, but it got me moving along at the time. I would like to progress beyond this and be able to be able to change the color in code. I realize the answer to this might involve textures and/or lighting, so if the answer is not straightforward, could you at least tell me where to begin Do I need to create multiple textures and swap between them

Thanks!
Greg


Re: XNA Game Studio Express Change the color of a mesh?

luggage

I guess you'd use a vertex shader for this. Texture your mesh greyscale and make sure you're using vertex colours. Then in the vertex shaderset the vertex colour to whatever you want it to be. This should tint your mesh.



Re: XNA Game Studio Express Change the color of a mesh?

dczraptor

If you are not using textures, a simple way is just to use the BasicEffect class.

BasicEffect effect = (BasicEffect)model.Meshes[0].Effects[0];

then enable default lighting, and change the diffuse and ambient colors to whatever combos you need to color your object. However, this method only works with simple non-textured models (which i think you are using), and not with textured models.

effect.EnabledDefaultLighting();

effect.DiffuseColor = Color.Blue.ToVector3();

effect.AmbientColor = Color.Gray.ToVector3();






Re: XNA Game Studio Express Change the color of a mesh?

friggityfraggity

That should work for now. Thanks!