getChild from j3o questions

I’ve seen this many times at the forums, but it is not working for me.

I want to Scroll a texture from a material.

First get the geometry from the j3o, so i open scene editor and find geometry name:

Geometry geom = j3o_Model.getChild("Geometry_Name");

I saw this a lot of times and people says it works… For me “getchild” shows red underline and I can’t use this.

This is the Model in scene editor:

Can somebody tell me what’s wrong? maybe i’m making a syntax mistakes as i’m a complete noob in java and Jmonkey engine.

Once I get the geometry, I could use this to move vertex positions (I hope):

    public void MoveTextureUV(Mesh meshload, float moveUOffset){
         VertexBuffer uv = meshload.getBuffer(Type.TexCoord);
         float[] uvArray = BufferUtils.getFloatArray((FloatBuffer) uv.getData());
         for (int i = 0; i < uvArray.length; i += 2)
             uvArray[i] += moveUOffset; //moves u.
         uv.updateData(BufferUtils.createFloatBuffer(uvArray));
    }

Thanks.

j3o_Model is probably a Spatial. I’m only guessing because I can’t see that code. If it’s a node then you need to cast it to Node… because only Nodes have children, thus only Nodes have getChild().

javadoc is your friend. As you get better at Java you will find it speeds the process.

I found you can access geometries from models (imported from blender) very easy. For example, this gets the first child geometry “getchild(0)”:

MyModel = assetManager.loadModel("Models/Model.j3o");
Geometry MyGeometry = (Geometry) (((Node)MyModel).getChild(0));

Well the Geometry isn’t necessarily child(0)

Just the way the model happens to have turned out. You can also use the .getGeometry() method. Or use a self running method to iterate over spatials in a node to pull out geometry.