Coloring Spatials

hi… I recognized that setDefaultColor and setSolidColor are only available for TriMeshes… how can I color spatials and nodes, most especially that the model that MaxtoJme importer cannot be cast with a TriMesh since it only returns a Node…

How could you colour a Node?

If you check the Node's children, you would most probably find a Geometry there (probably a TriMesh).

Geometry has the setDefaultColor method.

Hello,



Try to ad a MaterialState to your node, setting the ambient, diffuse and specular color. If you have light in your scene, they will be affected by light.



Regards

hi again… thanks for the reply equilibrium… could you teach me how to apply light and material states? I tried this…

MaterialState mhelz = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
               mhelz.setAmbient(ColorRGBA.blue);
               mhelz.setDiffuse(ColorRGBA.blue);
               mhelz.apply();
               r1.setRenderState(mhelz);


but was not succesful on adding colors on my spatial.... I do not have any background on light and material states whatsoever...so please help.... anyway this wouldn't be a problem if only my models does not appear uncolored when imported to JME's scenegraph.... there appears no error when I try to open my models in blender, it appears colored with materials.... but when I try to import it to JME using MaxToJME importer... the color is gone.... I've enclosed one of my models in this reply... could any of you folks try to import it using the MaxToJME importer and diagnose what the problem is...?

Is your model completely white without and shades? Then its because you have no lights in your scene.

:D… that may be the problem… although can you point me to an example in the jme package that tackles about lighting?

have a look at jmetest.util.TestLightStateController.java

LightStateController / LightManagement are Deprecated.

For more than 8 Lights in a Scene, Node.sortLights() can be used.



Any of the jmetest.renderer.state.* should be interesting.



A good new test where one can play with the various light / material settings would be quite nice also.

Hi there… I was able to put ligthing into my scene by reviewing the flagrushtutorial… I've put a directional light pointed to Vector3f(0,-1,1) and it works like a charm… although, I still have my materialstate problem… because even though I now see the shadings of my model… the color isn't visible still… by the way, I've changed back to ColladaImporter… seems to me its more easier than maxtojme… do you think my collada model has any problems with its material? can any of you try to import this model in your scene and look at what it would return?.. I've attached one of my models in this post…thanks in advance

try to use SceneMonitor to see if and how your MatrialStates have been applied to your scene:

http://www.jmonkeyengine.com/forum/index.php?topic=8159.0