Spatial.rotate(f, f, f) - Center of Rotation & Tutorial Exercise Issue

I'm not sure if I posted this in the right place, if not, feel free to move it  :)



I'm slowly working my way through the tutorials on the wiki, and I've noticed an issue with an exercise in the second tutorial:

1.  How is the outcome different if you attach the boxes to the rootNode instead, and then rotate them individually around their own center?


If you attach the two boxes directly to the rootNode, and then rotate them both in the same way the pivot was rotated, they end up in exactly the same place. I'm guessing this happens because the center of rotation for Spatial.rotate(float, float, float) is the origin; this results in a different outcome from what, I'm assuming, the exercise was written to show.

Am I correct in assuming that the center of rotation for Spatial.rotate(float, float, float) is the origin? If so, the Javadoc should probably be updated to reflect that.

Yeah, correct. Its because the meshes (and not the geometrys) have that 1,-1,1 / 1,3,1 location. The demo should set the location for the geoms instead. We gotta fix that :slight_smile: Thanks for mentioning!

Cheers,

Normen

Ok, cool; was getting a bit worried that I was doing something stupid :stuck_out_tongue:



Also, the second exercise on that page

2.  Load two models (e.g. a driver and a car). Position the car at the origin, and the driver in the car. Create a node at the origin and attach them to it. Translate the node, or rotate it around the y axis.

seems a bit premature as the following page explains how to load 3d models. Without that information, it's a bit difficult to work out from scratch...

True. I am happy to see that somebody actually uses the tutorials instead of asking questions on the forum right away that could have been answered by working through the tutorials :wink:

More feedback is always welcome.



Cheers,

Normen

I can't imagine learning jME by diving in at the deep end; I'm a big fan of tutorials though :stuck_out_tongue:


normen said:

I am happy to see that somebody actually uses the tutorials instead of asking questions on the forum right away that could have been answered by working through the tutorials ;)

Perhaps having a more prominent "Getting Started" link outside of the wiki might help increase the number of users who follow the tutorials...

Thanks for the feedback, I'll improve that!

They really should all have a big DRAFT stamp and a feedback link on them. :wink: I'm making stuff up as I go along, and am still changing the order of docs, as you noticed. 

How would you rotate it about the spatial’s center? I just ran into the problem that one box is at the origin and rotating about its center, while the other is orbiting it. Do I set the local translation to the origin, rotate, then move it back? That seems like a bit of work.



Edit: I understand now. The BOX has to be created at 0, 0, 0 but after you move it, you can rotate it all you want.



But then… another question. I know you can multiply matrices and cause a Spatial to rotate around a point. I would do translationMatrice.multiply(rotationMatrix). How would I go about getting these two matrices and multiplying them?

You mean rotation using Quaternions ?

I mean, rotate an object on a different axis than 0, 0, 0. Sorry for not making that clear.

Sorry, I don’t understand what you mean by 000 axis – The x axis is 1/0/0, y is 0/1/0, and z is 0/0/1, and you pick one, and rotate aroudn this axis. The value you specify is in radians (0 - 6.28), not in degrees.



Can you give me an example of what you want, and what you don’t want? Which rotation method did you use?



thing.getLocalRotation()

thing.setLocalRotation(…)

thing.rotate(x,y,z) – try this method maybe?



(here are two orbiting spheres, don’t know whther that helps http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/test/jme3test/model/TestOgreLoading.java)

Test