2009-05-26 14:22:57 +00:00
|
|
|
/* Residual - A 3D game interpreter
|
2008-06-13 14:57:47 +00:00
|
|
|
*
|
|
|
|
* Residual is the legal property of its developers, whose names
|
2011-04-16 14:12:44 +02:00
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
2008-06-13 14:57:47 +00:00
|
|
|
* file distributed with this source distribution.
|
2006-04-02 14:20:45 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*/
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2009-05-25 12:28:16 +00:00
|
|
|
#ifndef GRAPHICS_MATRIX3_H
|
|
|
|
#define GRAPHICS_MATRIX3_H
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2009-05-25 10:41:21 +00:00
|
|
|
#include "graphics/vector3d.h"
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2009-05-25 12:13:35 +00:00
|
|
|
namespace Graphics {
|
|
|
|
|
2003-08-28 01:55:48 +00:00
|
|
|
// matrix 3 is a rotation matrix
|
2009-05-25 06:49:57 +00:00
|
|
|
class Matrix3 {
|
2003-08-28 01:55:48 +00:00
|
|
|
public:
|
2004-12-09 23:55:43 +00:00
|
|
|
Vector3d _right;
|
|
|
|
Vector3d _up;
|
|
|
|
Vector3d _at;
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2004-12-09 23:55:43 +00:00
|
|
|
void buildFromPitchYawRoll(float pitch, float yaw, float roll);
|
|
|
|
void setAsIdentity();
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2004-12-09 23:55:43 +00:00
|
|
|
void constructAroundPitch(float pitch);
|
2011-05-07 22:59:11 +08:00
|
|
|
void constructAroundYaw(float yaw);
|
|
|
|
void constructAroundRoll(float roll);
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2011-05-07 22:59:11 +08:00
|
|
|
void getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll) const;
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2011-05-07 22:59:11 +08:00
|
|
|
float getPitch() const;
|
|
|
|
float getYaw() const;
|
|
|
|
float getRoll() const;
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2011-05-07 22:59:11 +08:00
|
|
|
void transform(Vector3d* v) const;
|
2003-08-28 01:55:48 +00:00
|
|
|
|
|
|
|
// operators
|
2004-02-25 08:21:31 +00:00
|
|
|
Matrix3& operator *=(const Matrix3& s) {
|
2011-05-07 22:59:11 +08:00
|
|
|
float rx = s._right.dotProduct(_right.x(), _up.x(), _at.x());
|
|
|
|
float ry = s._right.dotProduct(_right.y(), _up.y(), _at.y());
|
|
|
|
float rz = s._right.dotProduct(_right.z(), _up.z(), _at.z());
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2011-05-07 22:59:11 +08:00
|
|
|
float ux = s._up.dotProduct(_right.x(), _up.x(), _at.x());
|
|
|
|
float uy = s._up.dotProduct(_right.y(), _up.y(), _at.y());
|
|
|
|
float uz = s._up.dotProduct(_right.z(), _up.z(), _at.z());
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2011-05-07 22:59:11 +08:00
|
|
|
float ax = s._at.dotProduct(_right.x(), _up.x(), _at.x());
|
|
|
|
float ay = s._at.dotProduct(_right.y(), _up.y(), _at.y());
|
|
|
|
float az = s._at.dotProduct(_right.z(), _up.z(), _at.z());
|
2003-08-28 01:55:48 +00:00
|
|
|
|
2011-05-07 22:59:11 +08:00
|
|
|
_right.set(rx,ry,rz);
|
|
|
|
_up.set(ux,uy,uz);
|
|
|
|
_at.set(ax,ay,az);
|
2003-08-28 01:55:48 +00:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
2004-02-25 08:21:31 +00:00
|
|
|
Matrix3& operator =(const Matrix3& s) {
|
2004-12-09 23:55:43 +00:00
|
|
|
_right = s._right;
|
|
|
|
_up = s._up;
|
|
|
|
_at = s._at;
|
2003-08-28 01:55:48 +00:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
2009-05-25 12:13:35 +00:00
|
|
|
} // end of namespace Graphics
|
|
|
|
|
|
|
|
#endif
|
2003-08-28 02:01:48 +00:00
|
|
|
|