getWorldCoords method

Hi,



I am an absolute beginner with the jme, so I have some dumb questions:

What does getWorldCoords Return?

In the description of the method it says:

getWorldCoords(java.nio.FloatBuffer store)

          getWorldCoords translates/rotates and scales the coordinates of this Geometry (from the first batch) to world coordinates based on its world settings.

but I don't understand this. For example, if I have a box as a node and I use box.getWorldCoords(tmp) what am I getting. Ideally I would like to have the world coordinates of the 8 vertices of the box, but avoid doing all the transformations manually.



thanks

Every spatial (like TriMesh, Node, etc.) has a local coordinate system in which the contained data is laid out. World coordinates speak about a way to obtain the chained (remember everything in jME is in a Scenegraph) transformations from the root to the spatial. In this sense, it will tell you the overall coordinate reference of your object.



Welcome to jME!  :smiley:

Thank you duenez,

:smiley:

I am still a bit unclear though. Remeber, I am the absoluteNoob  :smiley:

I am not sure how to interpret the "overall coordinate reference" though. Is this just one point, the center of the box? What exactly is contained in the float buffer returned by cube.getWorldCoords().

I understand that computeVertices() returns the coordinates of the 8 vertices of the box in local reference. I would like to have them in the world (root) reference coordinates though. I think I can achieve it by getting and applying the transformations of each parent all the way down to the root, but ideally I would like to avoid this since my understanding of linear algebra is somewhat feeble. Can I use getWorldCoords() to achieve this?



thanks a lot

yeah, getworldcoords is what you are looking for… it's like doing a getVertexBuffer but with the added world transforms on each vert…

Hi all,



i  also habe a problem understanding getVertexBuffer() the right way.



I would like to extract the coordinates after construction of the scene inside simpleInigGame().



But they are not set at this time and my code throws Nullpointer.  So how can i read worldcoordinates at runtime? and by whom are they set?



At the end of my post is a pseudocode version of my nullpoiniter throwing class.



Thanks in advance

Mx







myclass extends SimpleGame(){
simpleInitGame(){
                  box = new Box(..);

                   // my Scene
                  ....  
                 translate and rotate the box
                attach box to a node, which is attached to rootnode
      node.updateWorldVectors(false);
               
                 ///Nullpointer throwing comand
                for(float f: getVertexBuffer().array()){ 
                      System.out.prinltnI(f);
                 }

main() {
     starts jme....
     calls simpleinitGame
}
}


Ok I solved it.



If i initialize of FloatBuffer: FloatBuffer f = null  or  FloatBuffer f = FloatBuffer.allocate(0);

but it works with f = FloatBuffer.allocate(>1);



Maybe that issues is helpful inside of javadocs.



cu Mx