There’s probably a straightforward solution to this, but I’m not seeing it.
I am trying to apply rotations to some small parts of a larger model. Can anybody tell me what’s wrong with my reasoning here?
Let the big model origin be O, and the small parts center of mass origin be o. When extracting smaller parts of the model, these will have the same origin O initially, so applying a rotation simply by calling Spatial.rotate() will not work - the spatial will rotate about O, not it’s center of mass o.
I know the vector describing the center of mass o related to O - let this be p.
In order to rotate about o, I make myself a rotationNode, then translate the rotationNode by p. It is now located in o.
My unit rotations are simply defined by these quaternions:
[java]Quaternion xRotation = new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_X);
Quaternion yRotation = new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y);
Quaternion zRotation = new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Z);
[/java]
How do I go from here to making the spatial rotate around its center of mass by these unit rotations? Note that I cannot apply a translation to the Spatial first, as this would move it out of place (it does not have any information on it’s location relative to the parent model). I need to make the spatial rotate around the new origin o, as defined by the rotationNode, rather than its “actual” origin O.
Basically, I want a way to rotate the spatial around an arbitrary point [x,y,z] without moving the spatial.