scummvm/graphics/matrix3.h

94 lines
2.4 KiB
C
Raw Normal View History

2006-04-02 14:20:45 +00:00
/* Residual - Virtual machine to run LucasArts' 3D adventure games
*
* Residual is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* 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$
*
*/
#ifndef ENGINE_MATRIX3_H
#define ENGINE_MATRIX3_H
2009-05-25 10:41:21 +00:00
#include "graphics/vector3d.h"
namespace Graphics {
// matrix 3 is a rotation matrix
2009-05-25 06:49:57 +00:00
class Matrix3 {
public:
2004-12-09 23:55:43 +00:00
Vector3d _right;
Vector3d _up;
Vector3d _at;
2004-12-09 23:55:43 +00:00
void buildFromPitchYawRoll(float pitch, float yaw, float roll);
void setAsIdentity();
2004-12-09 23:55:43 +00:00
void constructAroundPitch(float pitch);
void constructAroundYaw(float pitch);
void constructAroundRoll(float pitch);
2004-12-09 23:55:43 +00:00
void getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll);
float getPitch();
float getYaw();
float getRoll();
2004-12-09 23:55:43 +00:00
void transform(Vector3d* v);
// operators
Matrix3& operator *=(const Matrix3& s) {
float x, y, z;
2004-12-09 23:55:43 +00:00
x = _right.dotProduct(s._right.x(), s._up.x(), s._at.x());
y = _right.dotProduct(s._right.y(), s._up.y(), s._at.y());
z = _right.dotProduct(s._right.z(), s._up.z(), s._at.z());
2004-12-09 23:55:43 +00:00
_right.set(x, y, z);
2004-12-09 23:55:43 +00:00
x = _up.dotProduct(s._right.x(), s._up.x(), s._at.x());
y = _up.dotProduct(s._right.y(), s._up.y(), s._at.y());
z = _up.dotProduct(s._right.z(), s._up.z(), s._at.z());
2004-12-09 23:55:43 +00:00
_up.set( x, y, z );
2004-12-09 23:55:43 +00:00
x = _at.dotProduct(s._right.x(), s._up.x(), s._at.x());
y = _at.dotProduct(s._right.y(), s._up.y(), s._at.y());
z = _at.dotProduct(s._right.z(), s._up.z(), s._at.z());
2004-12-09 23:55:43 +00:00
_at.set(x, y, z);
return *this;
}
Matrix3& operator =(const Matrix3& s) {
2004-12-09 23:55:43 +00:00
_right = s._right;
_up = s._up;
_at = s._at;
return *this;
}
private:
};
} // end of namespace Graphics
#endif
2003-08-28 02:01:48 +00:00