Totaly Simple, Totaly Impossable

Here goes my pride as a coder. I am TOTALY rubbish at this 3d molarky! Any help is totaly appreciated, i am attempting what i beleve should be terrably simple:



i have a box… i want to rotate it in a single plain around it’s center. If i run a getCenter i do indeed get the point at it’s dead center. However when i do:




            Box body = new Box("Body Of Dancer " + danceNumber, new Vector3f(), 2,.5f,2);
      body.setModelBound(new BoundingSphere());
      body.updateModelBound();
      CompleteDancer.attachChild(body);
      System.out.println(body.getCenter());
      
      
      
      Quaternion x90=new Quaternion();
      
      x90.fromAngleAxis(FastMath.DEG_TO_RAD*90,new Vector3f(0,1,0));
      CompleteDancer.setLocalRotation(x90);



i end up with a box which has rotated around it's source vector (that of position 0,0,0). Am i being an utter retard and doing somthing daft? If so i TOTALY appologise but if you would be so kind as to point it out i will be eternaly greatfull.

Many thanks
Roja

I had this same problem, and I can assure you, I’m not retarded :wink:

Use one of the other constructors that Box has (one that doesn’t set the center), rotate it, and then set its position using setLocalTranslation. That way jME will first rotate it about the center point, and then move the rotated box.

Thank goodness it wasnt just me… I think i have worked out how the transformes actually work… they appear to work arrount the local 0,0,0… if ya get my drift, basically you have to align the center of the center item of your node-tree with the center point of that tree… (that sounds complecated :()… umm… if ya make a box, make sure it’s center is at 0,0,0 and then you can rotate it around it’s centerpoint :slight_smile:



Anyway… Cheers!

Roja.



P.S. about to write another topic!

Hello,



I'm writing because i have the same problem. If you are still here, could you explain the "centering" thing?

i’m not sure if hes still there, the post was 3 years ago :slight_smile:



look into the jmetest examples: TestRotateAboutPoint

it will help you getting started

Things are usually rotated around the origin. Sometimes you want a thing to rotate about its center (eg. a ball), but sometimes you don't (eg. a bone rotating with a joint).



So you just make sure that the origin is where you want the center of rotation to be.

Core-Dump said:

i'm not sure if hes still there, the post was 3 years ago :)

look into the jmetest examples: TestRotateAboutPoint
it will help you getting started


Thank you for the intel, it seems to be working. I put my box in the middle, attached it to a pivot node, and it was rotating.
However i did the same exact thing in my own class, and the box didn't move with the node. I dont know the problem yet, but its getting late, and i'm too tired to think... If you dont see a new post in 24 hours, then its alright :)
Thanks again, and good night.