“Is there a mechanism that does simple Rotation behaviors like Java3D? If on each frame I want an object to rotate on its Y axis by a specified amount, how do I do that? SpatialTransformer, suggested in another thread, seems more complicated than I would think necessary for a replacement to RotationBehavior.”
SpatialTransformer is more complicated because it does more than RotationBehavior for Java3d. You can use it for a simple rotation if you want. If you want help, I can show you how to make a basic rotation behavior Controller from scratch.
“I’m looking at SpatialTransformer and I have some basic questions about why it works the way it does. If I have geometry attached to a node, I would want to attach a SpatialTransformer to it. Not sure why I have to tell it the number of objects it would be transforming - it would be all of the nodes that are the children of the node that the Transformer is attached to.”
Currently, Controllers and what they are attached to have no significance. You could attach the controller to the root node and it would do the same thing if setup the same way. Controllers are being removed for another animation system this release of jME. Currently, there is no way to say “do this on all the children” without writting your own update function, which isn’t very difficult in itself. I can help with this if you want. Controllers aren’t objects in the scene graph. They are a seperate property of the objects themselves. This seems to be one point of confusion.
Root Node
|_ Transformer
|_ Node
|_ Planet
|_ Node
|_ Moon
“By Attaching the transformer to the ‘root node’ I expect I should be transforming everything underneath.”
The controller won’t animate what it’s not been specificly told to animate. ControllerNode type behavior is planned for the next jME release. I agree this system isn’t best and that’s why it will be gone on the next release.
“Similarly, why would I be attaching objects to the transformer? setObject just seems awkward in this sense. I have to attach the transformer to the rootNode (which IS my pivot point) and then attach all of its children to the Transformer as well?”
setObject is the way you tell the Controller what you want to animate. The current way is to
- Tell the controller everything you want to animate and how.
- add things to your scene graph.
- Attach controller to the scene graph.
“The other sets (position, rotation, scale) make sense to me. But I should be able to set a rotation based off a Vector3f as well (0,1,0) -> rotate along the y axis.”
To do that you would have to create a Quat that represents that rotation. There should be some functions that can do that for you in jME. If not, I can post the math required.
“I guess what I’m saying here is that this use case is very complex when it really should be obvious and simple but in this case appears to be neither and will be harder to learn.”
Modeling a solar system with sun->earth->moon is more complex than it seems at first. You can’t just attach them as children and rotate the moon around the earth because the earth is actually doing two rotations: rotating around the sun (year) and rotating around its core (days). So if you rotate the earth to represent days and the moon is a child you end up with the moon rotating around the earth really fast. You have to setup a center of rotation type system with a center of mass that the earth and moon can rotate around. I’ve actually coded this exact thing before and posted the code on the jME forum. I’ll check my home computer and see if I still have it.