code to set RotateBy
If tempnode = Null Then tempnode = MainSceneManager.createSceneNode() 'Tempnode is global to this type- most objects here will be, to prevent repeated creation of local objects.
tempnode.setOrientation(node.getworldOrientation()) 'set tempnodes orientation to that of the "parent" node.
tempnode.getOrientation().ToRotationMatrix(startrot) 'insert its rotation matrix into StartRot.
tempnode.rotate(yaw, pitch, roll, 1, space) 'Rotate it.
Local tempquat:TQuaternion = tempnode.getOrientation() 'Lets normalise it. stops wierd scaling/stretching
tempquat.normalise() 'continue normalise.
tempnode.setOrientation(tempquat) 'set the normalised rotation.
tempnode.getOrientation().ToRotationMatrix(endrot) 'Store its new rotation matrix into EndRot
rotateby = endrot.sub(startrot) 'RotateBy matrix now contains the difference between StartRot and Endrot. It (SHOULD BE?) world space, even if Space is Local. THIS IS THE ONLY THING I THINK COULD BE INVOLVED???
OK this code is now execuded for ALL nodes in the list. Main node or not.
thisnode.getworldOrientation().ToRotationMatrix(thisnoderotmatrix) 'get the nodes rotation matrix and put it in thisnoderotmatrix.
Local newrot:TMatrix3 = thisnoderotmatrix.add(rotateby) 'multiply thisnoderotmatrix with the matrix we want to ratate with.
neworientation.FromRotationMatrix(newrot) 'convert this matrix to a quat.
neworientation.normalise() 'Normalise the orientation quat to prevent floating issues that end up breaking the objects matrix.
thisnode.setOrientation(neworientation) 'Set the orientation.