Color gradient on .j3o object

Hi all,



I am not sure if I am just looking in the wrong places or what but would anyone happen to know how to apply a two-color gradient as a material for a .j3o model (has a .material and .mesh.xml and everything)? So far I have the following:



Spatial walls = assetManager.loadModel("Models/Walls.j3o);

Material new_mat = new Material(assetManager, “Common/MatDefs/Misc/VertexColor.j3md”);



I have looked over the VertexColor.j3md tutorial on applying a color gradient to a simple 4-vertex square, however, now that I have loaded a model file it has become more complicated. Part of the problem has also been because when I casted walls into Geometry there was no material defined for it and I received a cast exception error (was under the impression Geometry was a subclass of Spatial and ‘walls’ in the example would have some superfluous information above that of its Geometry subclass, but perhaps I was mistaken). Any help on getting up a simple two-color gradient on opposite sides when you’re left with only a Spatial would be greatly appreciated. Thanks! :slight_smile:

search “wall” for its children, one child should be geometry.

as @tralala said, a lot of the models using loadModel actually return a Node, even if there is only 1 child. If you are sure there is only 1 mesh in your model, then you should be able to do:



[java]Node walls = (Node) assetManager.loadModel(“Models/Walls.j3o”);

Geometry wall = (Geometry) walls.getChild(0);[/java]



I’ve never used vertexColor, so idk if this actually helps, but maybe it needs a geometry reference to work.

Alright I’ll give that a try when I get back to that stage again. As it turns out I am trying to start a little simpler with applying VertexColor to a Dome object. Is there any documentation online that anyone would know of specifying the order in which the vertices are laid out? I have been able to create a color array whose size is num_vertices*4 and apply a gradient from the bottom of the dome to the top. However, I need to “split the Dome” essentially by coloring each half a different color. I cannot find any documentation anywhere on the ordering of vertices for the Dome in order to structure my float[] color_array correctly. Anyone seen documentation on this site before?