--- include/ISceneNode.h 2005-11-06 09:35:12.000000000 +0100 +++ include/ISceneNode.h 2005-12-20 14:33:56.000000000 +0100 @@ -370,6 +368,36 @@ RelativeScale = scale; } + //! Rotate the node around an arbitrary axis + //! \param angle: Angle in degree + //! \param axis: Axis to rotate around + //! \param global: Rotate around local or parents axis (global if no parent) + //! \param aroundParent: Rotate around parent node (or origin if no parent) + virtual void rotate(float angle, const core::vector3df& axis, bool local=true, bool aroundParent=false) { + core::matrix4 currentRotation; + currentRotation.setRotationDegrees(getRotation()); + core::matrix4 rot; + rot.buildAxisRotationMatrix(angle*(f32)core::GRAD_PI2, axis); + rot = (local) ? (currentRotation*rot) : (rot*currentRotation); + setRotation(rot.getRotationDegrees()); + + if (aroundParent) { + core::vector3df pos = getPosition(); + currentRotation.getTransposed().transformVect(pos); + rot.transformVect(pos); + setPosition(pos); + } + } + + //! Translate the node + //! \param vector: The vector to translate along + //! \param local: Translate locally or use parents coord system (global if no parent) + virtual void translate(core::vector3df& vector, bool local=true) { + core::matrix4 mat; + mat.setRotationDegrees(getRotation()); + if (local) mat.transformVect(vector); + setPosition(getPosition() + vector); + } //! Sets the rotation of the node. Note that this is //! the relative rotation of the node.