Code: Select all
Index: include/matrix4.h
===================================================================
--- include/matrix4.h (revision 1286)
+++ include/matrix4.h (working copy)
@@ -124,6 +124,9 @@
//! Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
void setRotationDegrees( const vector3d<T>& rotation );
+ //! Make a rotation matrix from a direction vector (e.g. a plane normal)
+ void createRotationFromVector(const vector3d<T>& vector);
+
//! Returns the rotation, as set by setRotation(). This code was orginally written by by Chev.
core::vector3d<T> getRotationDegrees() const;
@@ -632,6 +635,13 @@
}
template <class T>
+ inline void CMatrix4<T>::createRotationFromVector(const vector3d<T>& vector)
+ {
+ setRotationDegrees(vector.getHorizontalAngle());
+ }
+
+
+ template <class T>
inline void CMatrix4<T>::setInverseRotationDegrees( const vector3d<T>& rotation )
{
setInverseRotationRadians( rotation * core::DEGTORAD );
Index: include/vector3d.h
===================================================================
--- include/vector3d.h (revision 1286)
+++ include/vector3d.h (working copy)
@@ -232,7 +232,7 @@
/** Thanks to Arras on the Irrlicht forums to add this method.
\return A vector representing the rotation in degrees of
this vector. The Z component of the vector will always be 0. */
- vector3d<T> getHorizontalAngle()
+ vector3d<T> getHorizontalAngle() const
{
vector3d<T> angle;