[NOOB] Simple rotation and scaling?

Hi,



I'm new to jME and also to 3D worlds. I am trying to do some simple rotation, scaling and transformation stuff. I have a TriMesh which I rotate 90

By your description, it should be something like



triMesh.setLocalScale(new Vector3f(2.0f, 2.0.f, 5.0f));



which should scale up 2 on x and y and 5 on z.  If you are seeing only a 2 up on x, y, and z then most likely you are using the overload method that only takes a float for an argument and scales x,y,z accordingly.



If that isn't it, post your scaling code so that a closer look can be taken at it.


Hi,



what I do is this:


/* back */
      box[0].setLocalTranslation(new Vector3f(-.5f, -.5f, -.5f));
      
      /* front */
      box[1].setLocalTranslation(new Vector3f(-.5f, -.5f, .5f));
      
      /* left */
      box[2].setLocalRotation(roll90);
      rot = JMEHelper.rotation(0, -FastMath.PI/2, 0);
      box[2].setLocalRotation(rot);
      box[2].setLocalTranslation(new Vector3f(-.5f, -.5f, -.5f));
      
      /* right */
      rot = JMEHelper.rotation(0, -FastMath.PI/2, 0);
      box[3].setLocalRotation(rot);
      box[3].setLocalTranslation(new Vector3f(.5f, -.5f, -.5f));
      
      /* top */
      rot = JMEHelper.rotation(FastMath.PI/2, 0, 0);
      box[4].setLocalRotation(rot);
      box[4].setLocalTranslation(new Vector3f(-.5f, .5f, -.5f));
      
      /* bottom */
      rot = JMEHelper.rotation(FastMath.PI/2, 0, 0);
      box[5].setLocalRotation(rot);
      box[5].setLocalTranslation(new Vector3f(-.5f, -.5f, -.5f));



In the box array there are a couple of TriMeshs which are a square which goes from (0,0,0) to (1,1,0). The JMEHelper.rotation(); gives me a rotation Matrix. It is the right one as I can see on the screen. It creates a cube from (-.5,-.5,-.5) to (.5,.5,.5).

But after this creation I put this box array in a Node and then I do this:


myNode.setLocalTranslation(new Vector3f(5f, 5f, 5f));
myNode.setLocalScale(new Vector3f(2, 4, 6));



And this leads to this result:


What I expect is a cube that is 2 times as big in x direction, 4 times in y directions and 6 times in z direction. What am I missing here?

I know I can do a cube more easy, but I want to understand the way TriMesh, Node and transformations work.

Best regards,
Michael

Yeah, this seems a bit much for a cube made out of individual walls/boxes.



I take it that you move your boxes from the array directly into the node by iterating through it and attaching them individually.  If not, then try that.  If you do, then remove the scaling part of your code.  Do you get the same sort of weird results?  If so, then you've got some other problem.  If you don't, then try to scale up the boxes individually by iterating over the children of the node and applying the scaling.  Basically, just start to troubleshoot by a process of elimination.  Also, did you write the JMEHelper class?  Did you check in there to make sure that nothing unexpected is happening?

Ok I got it! I tried all that and nothing helped. Now I noticed, that rotatePoints() is the method I have to use, instead of setLocalRotation()!



Thanks for your help,

Michael

madboy said:

Ok I got it! I tried all that and nothing helped. Now I noticed, that rotatePoints() is the method I have to use, instead of setLocalRotation()!

Thanks for your help,
Michael


Glad to hear it.

Just out of curiosity, what is the origin of your JMEHelper class?  Can you make it available?  It sounds like something that might help new users of jME out a bit.