Applying color to shapes

hi everyone…

i have been doing jme for past two weeks and have learned much…

i have rendered a box…and by default it is gray in color…so i used PointLight to make it red…

and it worked…



now i want to ask "Is there any alternate to apply color to shapes without using light sources…as in java3d we could simply apply colours to triangles using color3f classes…"///…

Yes… you can use the colorbuffer to give each vertice a different color, make sure you use NO lighting on your object though. (eg in SimpleGame there is always a light so that won't work). You can search through the tests for an example.

thanks for the advice…could you please tell me where could i find the sample code using colorbuffer…

You can use a simple MaterialState with a diffuse color (but with lights). Examples are in wiki and jme tests

padam said:

thanks for the advice....could you please tell me where could i find the sample code using colorbuffer.......


Setting a solid color is pretty easy as you can call setSolidColor(ColorRGBA) on any Geometry object.

Check out TestRenderQueue for an example that uses Materials.

One other note that may help... If you are building off SimpleGame and don't see color, hit L to toggle lights and see if that helps.  Vertex coloring is overridden by lighting (unless you use a special setting in MaterialState)