[Scummvm-cvs-logs] SF.net SVN: scummvm:[33964] residual/trunk
aquadran at users.sourceforge.net
aquadran at users.sourceforge.net
Sun Aug 17 10:02:01 CEST 2008
Revision: 33964
http://scummvm.svn.sourceforge.net/scummvm/?rev=33964&view=rev
Author: aquadran
Date: 2008-08-17 08:01:59 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
moved vector and matrix from common into engine dir
Modified Paths:
--------------
residual/trunk/common/module.mk
residual/trunk/dists/msvc7/residual.vcproj
residual/trunk/dists/msvc71/residual.vcproj
residual/trunk/dists/msvc8/residual.vcproj
residual/trunk/dists/msvc9/residual.vcproj
residual/trunk/engine/actor.h
residual/trunk/engine/backend/platform/driver.h
residual/trunk/engine/backend/platform/sdl/driver_gl.h
residual/trunk/engine/backend/platform/sdl/driver_sdl.h
residual/trunk/engine/backend/platform/sdl/driver_tinygl.cpp
residual/trunk/engine/backend/platform/sdl/driver_tinygl.h
residual/trunk/engine/costume.h
residual/trunk/engine/keyframe.h
residual/trunk/engine/lua.h
residual/trunk/engine/model.h
residual/trunk/engine/module.mk
residual/trunk/engine/objectstate.h
residual/trunk/engine/scene.cpp
residual/trunk/engine/scene.h
residual/trunk/engine/walkplane.h
Added Paths:
-----------
residual/trunk/engine/matrix3.cpp
residual/trunk/engine/matrix3.h
residual/trunk/engine/matrix4.cpp
residual/trunk/engine/matrix4.h
residual/trunk/engine/vector3d.h
Removed Paths:
-------------
residual/trunk/common/matrix3.cpp
residual/trunk/common/matrix3.h
residual/trunk/common/matrix4.cpp
residual/trunk/common/matrix4.h
residual/trunk/common/vector3d.h
Deleted: residual/trunk/common/matrix3.cpp
===================================================================
--- residual/trunk/common/matrix3.cpp 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/common/matrix3.cpp 2008-08-17 08:01:59 UTC (rev 33964)
@@ -1,188 +0,0 @@
-/* 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.
- *
- * 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$
- *
- */
-
-#include "common/matrix3.h"
-
-#include <math.h>
-
-void Matrix3::setAsIdentity() {
- _right.set(1.f, 0.f, 0.f);
- _up.set(0.f, 1.f, 0.f);
- _at.set(0.f, 0.f, 0.f);
-}
-
-void Matrix3::buildFromPitchYawRoll(float pitch, float yaw, float roll) {
- Matrix3 temp1, temp2;
-
- temp1.constructAroundPitch(pitch);
- constructAroundRoll(roll);
-
- (*this) *= temp1;
-
- temp2.constructAroundYaw(yaw);
-
- (*this) *= temp2;
-}
-
-#define DEGTORAD(a) (a * LOCAL_PI / 180.0)
-#define RADTODEG(a) (a * 180.0 / LOCAL_PI)
-
-float RadianToDegree(float rad) {
- return (float)RADTODEG(rad);
-}
-
-float DegreeToRadian(float degrees) {
- return (float)DEGTORAD(degrees);
-}
-
-// right
-void Matrix3::constructAroundPitch(float pitch) {
- float cosa;
- float sina;
-
- cosa = (float)cos(DegreeToRadian(pitch));
- sina = (float)sin(DegreeToRadian(pitch));
-
- _right.set(1.f, 0.f, 0.f);
- _up.set(0.f, cosa, -sina);
- _at.set(0.f, sina, cosa);
-}
-
-// up
-void Matrix3::constructAroundYaw(float yaw) {
- float cosa;
- float sina;
-
- cosa = (float)cos(DegreeToRadian(yaw));
- sina = (float)sin(DegreeToRadian(yaw));
-
- _right.set(cosa, 0.f, sina);
- _up.set(0.f, 1.f, 0.f);
- _at.set(-sina, 0.f, cosa);
-}
-
-// at
-void Matrix3::constructAroundRoll(float roll) {
- float cosa;
- float sina;
-
- cosa = (float)cos(DegreeToRadian(roll));
- sina = (float)sin(DegreeToRadian(roll));
-
- _right.set(cosa, -sina, 0.f);
- _up.set(sina, cosa, 0.f);
- _at.set(0.f, 0.f, 1.f);
-}
-
-/*
-0 1 2 3
-4 5 6 7
-8 9 10 11
-*/
-
-// WARNING: Still buggy in some occasions.
-void Matrix3::getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll) {
- float D;
- float C;
- float ftrx;
- float ftry;
- float angle_x;
- float angle_y;
- float angle_z;
-
- angle_y = D = asin(_right.z()); /* Calculate Y-axis angle */
- C = cos(angle_y);
- angle_y = RadianToDegree(angle_y);
-
- if (fabs( C ) > 0.005) { /* Gimball lock? */
- ftrx = _at.z() / C; /* No, so get X-axis angle */
- ftry = -_up.z() / C;
-
- angle_x = RadianToDegree(atan2(ftry, ftrx));
-
- ftrx = _right.x() / C; /* Get Z-axis angle */
- ftry = -_right.y() / C;
-
- angle_z = RadianToDegree(atan2(ftry, ftrx));
- } else { /* Gimball lock has occurred */
- angle_x = 0; /* Set X-axis angle to zqero */
-
- ftrx = _up.y(); /* And calculate Z-axis angle */
- ftry = _up.x();
-
- angle_z = RadianToDegree(atan2(ftry, ftrx));
- }
-
- /* return only positive angles in [0,360] */
- if (angle_x < 0) angle_x += 360;
- if (angle_y < 0) angle_y += 360;
- if (angle_z < 0) angle_z += 360;
-
- if (pPitch)
- *pPitch = angle_x;
-
- if (pYaw)
- *pYaw = angle_y;
-
- if (pRoll)
- *pRoll = angle_z;
-}
-
-float Matrix3::getPitch() {
- float pitch;
-
- getPitchYawRoll(&pitch, 0, 0);
-
- return pitch;
-}
-
-float Matrix3::getYaw() {
- float yaw;
-
- getPitchYawRoll(0, &yaw, 0);
-
- return yaw;
-}
-
-float Matrix3::getRoll() {
- float roll;
-
- getPitchYawRoll(0, 0, &roll);
-
- return roll;
-}
-
-void Matrix3::transform(Vector3d* v) {
- float x;
- float y;
- float z;
-
- x = v->dotProduct(_right.x(), _up.x(), _at.x());
- y = v->dotProduct(_right.x(), _up.x(), _at.x());
- z = v->dotProduct(_right.x(), _up.x(), _at.x());
-
- v->set(x, y, z);
-}
-
Deleted: residual/trunk/common/matrix3.h
===================================================================
--- residual/trunk/common/matrix3.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/common/matrix3.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -1,89 +0,0 @@
-/* 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.
- *
- * 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 COMMON_MATRIX3_H
-#define COMMON_MATRIX3_H
-
-#include "common/vector3d.h"
-
-// matrix 3 is a rotation matrix
-class Matrix3{
-public:
- Vector3d _right;
- Vector3d _up;
- Vector3d _at;
-
- void buildFromPitchYawRoll(float pitch, float yaw, float roll);
- void setAsIdentity();
-
- void constructAroundPitch(float pitch);
- void constructAroundYaw(float pitch);
- void constructAroundRoll(float pitch);
-
- void getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll);
-
- float getPitch();
- float getYaw();
- float getRoll();
-
- void transform(Vector3d* v);
-
- // operators
- Matrix3& operator *=(const Matrix3& s) {
- float x, y, z;
-
- 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());
-
- _right.set(x, y, z);
-
- 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());
-
- _up.set( x, y, z );
-
- 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());
-
- _at.set(x, y, z);
-
- return *this;
- }
- Matrix3& operator =(const Matrix3& s) {
- _right = s._right;
- _up = s._up;
- _at = s._at;
-
- return *this;
- }
-
-private:
-};
-
-#endif // MATRIX_HH
-
Deleted: residual/trunk/common/matrix4.cpp
===================================================================
--- residual/trunk/common/matrix4.cpp 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/common/matrix4.cpp 2008-08-17 08:01:59 UTC (rev 33964)
@@ -1,40 +0,0 @@
-/* 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.
- *
- * 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$
- *
- */
-
-#include "common/matrix4.h"
-
-Matrix4::Matrix4() {
- _pos.set(0.f, 0.f, 0.f);
- _rot.setAsIdentity();
-}
-
-void Matrix4::translate(float x, float y, float z) {
- Vector3d v;
-
- v.set(x, y, z);
- _rot.transform(&v);
- _pos += v;
-}
-
Deleted: residual/trunk/common/matrix4.h
===================================================================
--- residual/trunk/common/matrix4.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/common/matrix4.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -1,64 +0,0 @@
-/* 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.
- *
- * 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 COMMON_MATRIX4_H
-#define COMMON_MATRIX4_H
-
-#include "common/vector3d.h"
-#include "common/matrix3.h"
-
-// matrix 4 is a rotation matrix + position
-class Matrix4 {
-public:
- Matrix3 _rot;
- Vector3d _pos;
-
- Matrix4();
-
- Matrix4& operator =(const Matrix4& s) {
- _pos = s._pos;
- _rot = s._rot;
-
- return *this;
- }
-
- Matrix4& operator *=(const Matrix4& s) {
- Vector3d v;
-
- v = s._pos;
- _rot.transform(&v);
- _pos += v;
- _rot *= s._rot;
-
- return *this;
- }
-
- void translate(float x, float y, float z);
-
-private:
-};
-
-#endif // MATRIX_HH
-
Modified: residual/trunk/common/module.mk
===================================================================
--- residual/trunk/common/module.mk 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/common/module.mk 2008-08-17 08:01:59 UTC (rev 33964)
@@ -7,8 +7,6 @@
file.o \
fs.o \
hashmap.o \
- matrix3.o \
- matrix4.o \
memorypool.o \
mutex.o \
str.o \
Deleted: residual/trunk/common/vector3d.h
===================================================================
--- residual/trunk/common/vector3d.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/common/vector3d.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -1,196 +0,0 @@
-/* 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.
- *
- * 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 COMMON_VECTOR3D_H
-#define COMMON_VECTOR3D_H
-
-#include <cmath>
-#include <common/sys.h>
-
-class Vector3d {
-public:
- float _coords[3]; // Make sure this stays as an array so
-
- float& x() { return _coords[0]; }
- float x() const { return _coords[0]; }
- float& y() { return _coords[1]; }
- float y() const { return _coords[1]; }
- float& z() { return _coords[2]; }
- float z() const { return _coords[2]; }
-
- Vector3d() { x() = 0; y() = 0; z() = 0; }
-
- Vector3d(float lx, float ly, float lz) {
- x() = lx; y() = ly; z() = lz;
- }
-
- Vector3d(const Vector3d &v) {
- x() = v.x(); y() = v.y(); z() = v.z();
- }
-
- void set(float lx, float ly, float lz) {
- x() = lx; y() = ly; z() = lz;
- }
-
- Vector3d& operator =(const Vector3d &v) {
- x() = v.x(); y() = v.y(); z() = v.z();
- return *this;
- }
-
- bool operator ==(const Vector3d &v) {
- return ( (x() == v.x()) && (y() == v.y()) && (z() == v.z()) );
- }
-
- bool operator !=(const Vector3d &v) {
- return ( (x() != v.x()) || (y() != v.y()) || (z() != v.z()) );
- }
-
- Vector3d& operator +=(const Vector3d &v) {
- x() += v.x(); y() += v.y(); z() += v.z();
- return *this;
- }
-
- Vector3d& operator -=(const Vector3d &v) {
- x() -= v.x(); y() -= v.y(); z() -= v.z();
- return *this;
- }
-
- Vector3d& operator *=(float s) {
- x() *= s; y() *= s; z() *= s;
- return *this;
- }
-
- Vector3d& operator /=(float s) {
- x() /= s; y() /= s; z() /= s;
- return *this;
- }
-
- float magnitude() const {
- return std::sqrt(x() * x() + y() * y() + z() * z());
- }
-
- // Get the angle a vector is around the unit circle
- // (ignores z-component)
- float unitCircleAngle() const {
- float a = x() / magnitude();
- float b = y() / magnitude();
- float yaw;
-
- // find the angle on the upper half of the unit circle
- yaw = std::acos(a) * (180.0f / LOCAL_PI);
- if (b < 0.0f)
- // adjust for the lower half of the unit circle
- return 360.0f - yaw;
- else
- // no adjustment, angle is on the upper half
- return yaw;
- }
-
- float dotProduct( float sx, float sy, float sz ) {
- return x() * sx + y() * sy + z()*sz;
- }
-
- bool isZero() {
- if(x() == 0.f && y() == 0.f && z() == 0.f)
- return true;
- return false;
- }
-};
-
-inline float dot(const Vector3d& v1, const Vector3d& v2) {
- return v1.x() * v2.x() + v1.y() * v2.y() + v1.z() * v2.z();
-}
-
-inline Vector3d cross(const Vector3d& v1, const Vector3d& v2) {
- return Vector3d(v1.y() * v2.z() - v1.z() * v2.y(),
- v1.z() * v2.x() - v1.x() * v2.z(),
- v1.x() * v2.y() - v1.y() * v2.x());
-}
-
-inline float angle(const Vector3d& v1, const Vector3d& v2) {
- return std::acos(dot(v1, v2) / (v1.magnitude() * v2.magnitude()));
-}
-
-inline Vector3d operator +(const Vector3d& v1, const Vector3d& v2) {
- Vector3d result = v1;
- result += v2;
- return result;
-}
-
-inline Vector3d operator -(const Vector3d& v1, const Vector3d& v2) {
- Vector3d result = v1;
- result -= v2;
- return result;
-}
-
-inline Vector3d operator *(float s, const Vector3d& v) {
- Vector3d result = v;
- result *= s;
- return result;
-}
-
-inline Vector3d operator -(const Vector3d& v) {
- return (-1.0f) * v;
-}
-
-inline Vector3d operator *(const Vector3d& v, float s) {
- return s * v;
-}
-
-inline Vector3d operator /(const Vector3d& v, float s) {
- Vector3d result = v;
- result /= s;
- return result;
-}
-
-inline bool operator ==(const Vector3d& v1, const Vector3d& v2) {
- return v1.x() == v2.x() && v1.y() == v2.y() && v1.z() == v2.z();
-}
-
-#if defined(SYSTEM_BIG_ENDIAN)
-
-inline float get_float(const char *data) {
- const unsigned char *udata = reinterpret_cast<const unsigned char *>(data);
- unsigned char fdata[4];
- fdata[0] = udata[3];
- fdata[1] = udata[2];
- fdata[2] = udata[1];
- fdata[3] = udata[0];
- return *(reinterpret_cast<const float *>(fdata));
-}
-
-#else
-
-inline float get_float(const char *data) {
- return *(reinterpret_cast<const float *>(data));
-}
-#endif
-
-inline Vector3d get_vector3d(const char *data) {
- return Vector3d(get_float(data), get_float(data + 4), get_float(data + 8));
-}
-
-
-#endif
Modified: residual/trunk/dists/msvc7/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc7/residual.vcproj 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/dists/msvc7/residual.vcproj 2008-08-17 08:01:59 UTC (rev 33964)
@@ -178,18 +178,6 @@
RelativePath="..\..\common\list.h">
</File>
<File
- RelativePath="..\..\common\matrix3.cpp">
- </File>
- <File
- RelativePath="..\..\common\matrix3.h">
- </File>
- <File
- RelativePath="..\..\common\matrix4.cpp">
- </File>
- <File
- RelativePath="..\..\common\matrix4.h">
- </File>
- <File
RelativePath="..\..\common\memorypool.cpp">
</File>
<File
@@ -240,9 +228,6 @@
<File
RelativePath="..\..\common\util.h">
</File>
- <File
- RelativePath="..\..\common\vector3d.h">
- </File>
</Filter>
<Filter
Name="dists">
@@ -337,6 +322,18 @@
RelativePath="..\..\engine\material.h">
</File>
<File
+ RelativePath="..\..\engine\matrix3.cpp">
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix3.h">
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.cpp">
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.h">
+ </File>
+ <File
RelativePath="..\..\engine\model.cpp">
</File>
<File
@@ -391,6 +388,9 @@
RelativePath="..\..\engine\textsplit.h">
</File>
<File
+ RelativePath="..\..\engine\vector3d.h">
+ </File>
+ <File
RelativePath="..\..\engine\version.cpp">
</File>
<File
Modified: residual/trunk/dists/msvc71/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc71/residual.vcproj 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/dists/msvc71/residual.vcproj 2008-08-17 08:01:59 UTC (rev 33964)
@@ -192,18 +192,6 @@
RelativePath="..\..\common\list.h">
</File>
<File
- RelativePath="..\..\common\matrix3.cpp">
- </File>
- <File
- RelativePath="..\..\common\matrix3.h">
- </File>
- <File
- RelativePath="..\..\common\matrix4.cpp">
- </File>
- <File
- RelativePath="..\..\common\matrix4.h">
- </File>
- <File
RelativePath="..\..\common\memorypool.cpp">
</File>
<File
@@ -254,9 +242,6 @@
<File
RelativePath="..\..\common\util.h">
</File>
- <File
- RelativePath="..\..\common\vector3d.h">
- </File>
</Filter>
<Filter
Name="dists">
@@ -351,6 +336,18 @@
RelativePath="..\..\engine\material.h">
</File>
<File
+ RelativePath="..\..\engine\matrix3.cpp">
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix3.h">
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.cpp">
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.h">
+ </File>
+ <File
RelativePath="..\..\engine\model.cpp">
</File>
<File
@@ -405,6 +402,9 @@
RelativePath="..\..\engine\textsplit.h">
</File>
<File
+ RelativePath="..\..\engine\vector3d.h">
+ </File>
+ <File
RelativePath="..\..\engine\version.cpp">
</File>
<File
Modified: residual/trunk/dists/msvc8/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc8/residual.vcproj 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/dists/msvc8/residual.vcproj 2008-08-17 08:01:59 UTC (rev 33964)
@@ -276,22 +276,6 @@
>
</File>
<File
- RelativePath="..\..\common\matrix3.cpp"
- >
- </File>
- <File
- RelativePath="..\..\common\matrix3.h"
- >
- </File>
- <File
- RelativePath="..\..\common\matrix4.cpp"
- >
- </File>
- <File
- RelativePath="..\..\common\matrix4.h"
- >
- </File>
- <File
RelativePath="..\..\common\memorypool.cpp"
>
</File>
@@ -359,10 +343,6 @@
RelativePath="..\..\common\util.h"
>
</File>
- <File
- RelativePath="..\..\common\vector3d.h"
- >
- </File>
</Filter>
<Filter
Name="dists"
@@ -488,6 +468,22 @@
>
</File>
<File
+ RelativePath="..\..\engine\matrix3.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix3.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.h"
+ >
+ </File>
+ <File
RelativePath="..\..\engine\model.cpp"
>
</File>
@@ -560,6 +556,10 @@
>
</File>
<File
+ RelativePath="..\..\engine\vector3d.h"
+ >
+ </File>
+ <File
RelativePath="..\..\engine\version.cpp"
>
</File>
Modified: residual/trunk/dists/msvc9/residual.vcproj
===================================================================
--- residual/trunk/dists/msvc9/residual.vcproj 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/dists/msvc9/residual.vcproj 2008-08-17 08:01:59 UTC (rev 33964)
@@ -281,22 +281,6 @@
>
</File>
<File
- RelativePath="..\..\common\matrix3.cpp"
- >
- </File>
- <File
- RelativePath="..\..\common\matrix3.h"
- >
- </File>
- <File
- RelativePath="..\..\common\matrix4.cpp"
- >
- </File>
- <File
- RelativePath="..\..\common\matrix4.h"
- >
- </File>
- <File
RelativePath="..\..\common\memorypool.cpp"
>
</File>
@@ -364,10 +348,6 @@
RelativePath="..\..\common\util.h"
>
</File>
- <File
- RelativePath="..\..\common\vector3d.h"
- >
- </File>
</Filter>
<Filter
Name="dists"
@@ -493,6 +473,22 @@
>
</File>
<File
+ RelativePath="..\..\engine\matrix3.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix3.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\engine\matrix4.h"
+ >
+ </File>
+ <File
RelativePath="..\..\engine\model.cpp"
>
</File>
@@ -565,6 +561,10 @@
>
</File>
<File
+ RelativePath="..\..\engine\vector3d.h"
+ >
+ </File>
+ <File
RelativePath="..\..\engine\version.cpp"
>
</File>
Modified: residual/trunk/engine/actor.h
===================================================================
--- residual/trunk/engine/actor.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/actor.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,11 +26,10 @@
#ifndef ACTOR_H
#define ACTOR_H
-#include "common/vector3d.h"
-
#include "engine/color.h"
#include "engine/resource.h"
#include "engine/font.h"
+#include "engine/vector3d.h"
#include <string>
#include <list>
Modified: residual/trunk/engine/backend/platform/driver.h
===================================================================
--- residual/trunk/engine/backend/platform/driver.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/backend/platform/driver.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -27,12 +27,12 @@
#define BACKEND_DRIVER_H
#include "common/sys.h"
-#include "common/vector3d.h"
#include "common/mutex.h"
#include "engine/color.h"
#include "engine/model.h"
#include "engine/scene.h"
+#include "engine/vector3d.h"
#include "engine/colormap.h"
#include "engine/font.h"
#include "engine/primitives.h"
Modified: residual/trunk/engine/backend/platform/sdl/driver_gl.h
===================================================================
--- residual/trunk/engine/backend/platform/sdl/driver_gl.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/backend/platform/sdl/driver_gl.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -27,12 +27,12 @@
#define BACKEND_DRIVER_GL_H
#include "common/sys.h"
-#include "common/vector3d.h"
#include "engine/color.h"
#include "engine/model.h"
#include "engine/colormap.h"
#include "engine/bitmap.h"
+#include "engine/vector3d.h"
#include "engine/backend/platform/driver.h"
#include "engine/backend/platform/sdl/driver_sdl.h"
Modified: residual/trunk/engine/backend/platform/sdl/driver_sdl.h
===================================================================
--- residual/trunk/engine/backend/platform/sdl/driver_sdl.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/backend/platform/sdl/driver_sdl.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -27,12 +27,12 @@
#define BACKEND_DRIVER_SDL_H
#include "common/sys.h"
-#include "common/vector3d.h"
#include "engine/color.h"
#include "engine/model.h"
#include "engine/colormap.h"
#include "engine/bitmap.h"
+#include "engine/vector3d.h"
#include "engine/backend/platform/driver.h"
#include <SDL.h>
Modified: residual/trunk/engine/backend/platform/sdl/driver_tinygl.cpp
===================================================================
--- residual/trunk/engine/backend/platform/sdl/driver_tinygl.cpp 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/backend/platform/sdl/driver_tinygl.cpp 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,11 +26,11 @@
#include "common/sys.h"
#include "common/endian.h"
#include "common/debug.h"
-#include "common/vector3d.h"
#include "engine/colormap.h"
#include "engine/material.h"
#include "engine/font.h"
+#include "engine/vector3d.h"
#include "engine/backend/platform/sdl/driver_tinygl.h"
#include "engine/tinygl/gl.h"
Modified: residual/trunk/engine/backend/platform/sdl/driver_tinygl.h
===================================================================
--- residual/trunk/engine/backend/platform/sdl/driver_tinygl.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/backend/platform/sdl/driver_tinygl.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -27,12 +27,12 @@
#define BACKEND_DRIVER_TINYGL_H
#include "common/sys.h"
-#include "common/vector3d.h"
#include "engine/color.h"
#include "engine/model.h"
#include "engine/colormap.h"
#include "engine/bitmap.h"
+#include "engine/vector3d.h"
#include "engine/backend/platform/driver.h"
#include "engine/backend/platform/sdl/driver_sdl.h"
Modified: residual/trunk/engine/costume.h
===================================================================
--- residual/trunk/engine/costume.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/costume.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,9 +26,8 @@
#ifndef COSTUME_H
#define COSTUME_H
-#include "common/matrix4.h"
-
#include "engine/model.h"
+#include "engine/vector3d.h"
#include <string>
Modified: residual/trunk/engine/keyframe.h
===================================================================
--- residual/trunk/engine/keyframe.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/keyframe.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,10 +26,9 @@
#ifndef KEYFRAME_H
#define KEYFRAME_H
-#include "common/vector3d.h"
-
#include "engine/resource.h"
#include "engine/model.h"
+#include "engine/vector3d.h"
class TextSplitter;
Modified: residual/trunk/engine/lua.h
===================================================================
--- residual/trunk/engine/lua.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/lua.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,8 +26,7 @@
#ifndef LUA_HH
#define LUA_HH
-#include "common/vector3d.h"
-
+#include "engine/vector3d.h"
#include "engine/lua/lua.h"
#include "engine/lua/lualib.h"
#include "engine/lua/luadebug.h"
Copied: residual/trunk/engine/matrix3.cpp (from rev 33956, residual/trunk/common/matrix3.cpp)
===================================================================
--- residual/trunk/engine/matrix3.cpp (rev 0)
+++ residual/trunk/engine/matrix3.cpp 2008-08-17 08:01:59 UTC (rev 33964)
@@ -0,0 +1,188 @@
+/* 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.
+ *
+ * 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$
+ *
+ */
+
+#include "engine/matrix3.h"
+
+#include <math.h>
+
+void Matrix3::setAsIdentity() {
+ _right.set(1.f, 0.f, 0.f);
+ _up.set(0.f, 1.f, 0.f);
+ _at.set(0.f, 0.f, 0.f);
+}
+
+void Matrix3::buildFromPitchYawRoll(float pitch, float yaw, float roll) {
+ Matrix3 temp1, temp2;
+
+ temp1.constructAroundPitch(pitch);
+ constructAroundRoll(roll);
+
+ (*this) *= temp1;
+
+ temp2.constructAroundYaw(yaw);
+
+ (*this) *= temp2;
+}
+
+#define DEGTORAD(a) (a * LOCAL_PI / 180.0)
+#define RADTODEG(a) (a * 180.0 / LOCAL_PI)
+
+float RadianToDegree(float rad) {
+ return (float)RADTODEG(rad);
+}
+
+float DegreeToRadian(float degrees) {
+ return (float)DEGTORAD(degrees);
+}
+
+// right
+void Matrix3::constructAroundPitch(float pitch) {
+ float cosa;
+ float sina;
+
+ cosa = (float)cos(DegreeToRadian(pitch));
+ sina = (float)sin(DegreeToRadian(pitch));
+
+ _right.set(1.f, 0.f, 0.f);
+ _up.set(0.f, cosa, -sina);
+ _at.set(0.f, sina, cosa);
+}
+
+// up
+void Matrix3::constructAroundYaw(float yaw) {
+ float cosa;
+ float sina;
+
+ cosa = (float)cos(DegreeToRadian(yaw));
+ sina = (float)sin(DegreeToRadian(yaw));
+
+ _right.set(cosa, 0.f, sina);
+ _up.set(0.f, 1.f, 0.f);
+ _at.set(-sina, 0.f, cosa);
+}
+
+// at
+void Matrix3::constructAroundRoll(float roll) {
+ float cosa;
+ float sina;
+
+ cosa = (float)cos(DegreeToRadian(roll));
+ sina = (float)sin(DegreeToRadian(roll));
+
+ _right.set(cosa, -sina, 0.f);
+ _up.set(sina, cosa, 0.f);
+ _at.set(0.f, 0.f, 1.f);
+}
+
+/*
+0 1 2 3
+4 5 6 7
+8 9 10 11
+*/
+
+// WARNING: Still buggy in some occasions.
+void Matrix3::getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll) {
+ float D;
+ float C;
+ float ftrx;
+ float ftry;
+ float angle_x;
+ float angle_y;
+ float angle_z;
+
+ angle_y = D = asin(_right.z()); /* Calculate Y-axis angle */
+ C = cos(angle_y);
+ angle_y = RadianToDegree(angle_y);
+
+ if (fabs( C ) > 0.005) { /* Gimball lock? */
+ ftrx = _at.z() / C; /* No, so get X-axis angle */
+ ftry = -_up.z() / C;
+
+ angle_x = RadianToDegree(atan2(ftry, ftrx));
+
+ ftrx = _right.x() / C; /* Get Z-axis angle */
+ ftry = -_right.y() / C;
+
+ angle_z = RadianToDegree(atan2(ftry, ftrx));
+ } else { /* Gimball lock has occurred */
+ angle_x = 0; /* Set X-axis angle to zqero */
+
+ ftrx = _up.y(); /* And calculate Z-axis angle */
+ ftry = _up.x();
+
+ angle_z = RadianToDegree(atan2(ftry, ftrx));
+ }
+
+ /* return only positive angles in [0,360] */
+ if (angle_x < 0) angle_x += 360;
+ if (angle_y < 0) angle_y += 360;
+ if (angle_z < 0) angle_z += 360;
+
+ if (pPitch)
+ *pPitch = angle_x;
+
+ if (pYaw)
+ *pYaw = angle_y;
+
+ if (pRoll)
+ *pRoll = angle_z;
+}
+
+float Matrix3::getPitch() {
+ float pitch;
+
+ getPitchYawRoll(&pitch, 0, 0);
+
+ return pitch;
+}
+
+float Matrix3::getYaw() {
+ float yaw;
+
+ getPitchYawRoll(0, &yaw, 0);
+
+ return yaw;
+}
+
+float Matrix3::getRoll() {
+ float roll;
+
+ getPitchYawRoll(0, 0, &roll);
+
+ return roll;
+}
+
+void Matrix3::transform(Vector3d* v) {
+ float x;
+ float y;
+ float z;
+
+ x = v->dotProduct(_right.x(), _up.x(), _at.x());
+ y = v->dotProduct(_right.x(), _up.x(), _at.x());
+ z = v->dotProduct(_right.x(), _up.x(), _at.x());
+
+ v->set(x, y, z);
+}
+
Property changes on: residual/trunk/engine/matrix3.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: residual/trunk/engine/matrix3.h (from rev 33956, residual/trunk/common/matrix3.h)
===================================================================
--- residual/trunk/engine/matrix3.h (rev 0)
+++ residual/trunk/engine/matrix3.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -0,0 +1,89 @@
+/* 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.
+ *
+ * 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
+
+#include "engine/vector3d.h"
+
+// matrix 3 is a rotation matrix
+class Matrix3{
+public:
+ Vector3d _right;
+ Vector3d _up;
+ Vector3d _at;
+
+ void buildFromPitchYawRoll(float pitch, float yaw, float roll);
+ void setAsIdentity();
+
+ void constructAroundPitch(float pitch);
+ void constructAroundYaw(float pitch);
+ void constructAroundRoll(float pitch);
+
+ void getPitchYawRoll(float* pPitch, float* pYaw, float* pRoll);
+
+ float getPitch();
+ float getYaw();
+ float getRoll();
+
+ void transform(Vector3d* v);
+
+ // operators
+ Matrix3& operator *=(const Matrix3& s) {
+ float x, y, z;
+
+ 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());
+
+ _right.set(x, y, z);
+
+ 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());
+
+ _up.set( x, y, z );
+
+ 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());
+
+ _at.set(x, y, z);
+
+ return *this;
+ }
+ Matrix3& operator =(const Matrix3& s) {
+ _right = s._right;
+ _up = s._up;
+ _at = s._at;
+
+ return *this;
+ }
+
+private:
+};
+
+#endif // MATRIX_HH
+
Property changes on: residual/trunk/engine/matrix3.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: residual/trunk/engine/matrix4.cpp (from rev 33956, residual/trunk/common/matrix4.cpp)
===================================================================
--- residual/trunk/engine/matrix4.cpp (rev 0)
+++ residual/trunk/engine/matrix4.cpp 2008-08-17 08:01:59 UTC (rev 33964)
@@ -0,0 +1,40 @@
+/* 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.
+ *
+ * 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$
+ *
+ */
+
+#include "engine/matrix4.h"
+
+Matrix4::Matrix4() {
+ _pos.set(0.f, 0.f, 0.f);
+ _rot.setAsIdentity();
+}
+
+void Matrix4::translate(float x, float y, float z) {
+ Vector3d v;
+
+ v.set(x, y, z);
+ _rot.transform(&v);
+ _pos += v;
+}
+
Property changes on: residual/trunk/engine/matrix4.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: residual/trunk/engine/matrix4.h (from rev 33956, residual/trunk/common/matrix4.h)
===================================================================
--- residual/trunk/engine/matrix4.h (rev 0)
+++ residual/trunk/engine/matrix4.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -0,0 +1,64 @@
+/* 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.
+ *
+ * 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_MATRIX4_H
+#define ENGINE_MATRIX4_H
+
+#include "engine/vector3d.h"
+#include "engine/matrix3.h"
+
+// matrix 4 is a rotation matrix + position
+class Matrix4 {
+public:
+ Matrix3 _rot;
+ Vector3d _pos;
+
+ Matrix4();
+
+ Matrix4& operator =(const Matrix4& s) {
+ _pos = s._pos;
+ _rot = s._rot;
+
+ return *this;
+ }
+
+ Matrix4& operator *=(const Matrix4& s) {
+ Vector3d v;
+
+ v = s._pos;
+ _rot.transform(&v);
+ _pos += v;
+ _rot *= s._rot;
+
+ return *this;
+ }
+
+ void translate(float x, float y, float z);
+
+private:
+};
+
+#endif // MATRIX_HH
+
Property changes on: residual/trunk/engine/matrix4.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: residual/trunk/engine/model.h
===================================================================
--- residual/trunk/engine/model.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/model.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,10 +26,9 @@
#ifndef MODEL_H
#define MODEL_H
-#include "common/vector3d.h"
-#include "common/matrix4.h"
-
#include "engine/resource.h"
+#include "engine/vector3d.h"
+#include "engine/matrix4.h"
#include <cstring>
Modified: residual/trunk/engine/module.mk
===================================================================
--- residual/trunk/engine/module.mk 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/module.mk 2008-08-17 08:01:59 UTC (rev 33964)
@@ -14,6 +14,8 @@
lua.o \
main.o \
material.o \
+ matrix3.o \
+ matrix4.o \
model.o \
objectstate.o \
primitives.o \
Modified: residual/trunk/engine/objectstate.h
===================================================================
--- residual/trunk/engine/objectstate.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/objectstate.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,10 +26,9 @@
#ifndef OSTATE_H
#define OSTATE_H
-#include "common/vector3d.h"
-
#include "engine/resource.h"
#include "engine/bitmap.h"
+#include "engine/vector3d.h"
#include <string>
#include <list>
Modified: residual/trunk/engine/scene.cpp
===================================================================
--- residual/trunk/engine/scene.cpp 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/scene.cpp 2008-08-17 08:01:59 UTC (rev 33964)
@@ -25,7 +25,6 @@
#include "common/sys.h"
#include "common/debug.h"
-#include "common/vector3d.h"
#include "engine/scene.h"
#include "engine/textsplit.h"
@@ -34,6 +33,7 @@
#include "engine/colormap.h"
#include "engine/backend/platform/driver.h"
#include "engine/engine.h"
+#include "engine/vector3d.h"
#include "engine/imuse/imuse.h"
Modified: residual/trunk/engine/scene.h
===================================================================
--- residual/trunk/engine/scene.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/scene.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -26,13 +26,13 @@
#ifndef SCENE_H
#define SCENE_H
-#include "common/vector3d.h"
#include "common/debug.h"
#include "engine/bitmap.h"
#include "engine/color.h"
#include "engine/walkplane.h"
#include "engine/objectstate.h"
+#include "engine/vector3d.h"
#include <string>
Copied: residual/trunk/engine/vector3d.h (from rev 33956, residual/trunk/common/vector3d.h)
===================================================================
--- residual/trunk/engine/vector3d.h (rev 0)
+++ residual/trunk/engine/vector3d.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -0,0 +1,196 @@
+/* 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.
+ *
+ * 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_VECTOR3D_H
+#define ENGINE_VECTOR3D_H
+
+#include <cmath>
+#include <common/sys.h>
+
+class Vector3d {
+public:
+ float _coords[3]; // Make sure this stays as an array so
+
+ float& x() { return _coords[0]; }
+ float x() const { return _coords[0]; }
+ float& y() { return _coords[1]; }
+ float y() const { return _coords[1]; }
+ float& z() { return _coords[2]; }
+ float z() const { return _coords[2]; }
+
+ Vector3d() { x() = 0; y() = 0; z() = 0; }
+
+ Vector3d(float lx, float ly, float lz) {
+ x() = lx; y() = ly; z() = lz;
+ }
+
+ Vector3d(const Vector3d &v) {
+ x() = v.x(); y() = v.y(); z() = v.z();
+ }
+
+ void set(float lx, float ly, float lz) {
+ x() = lx; y() = ly; z() = lz;
+ }
+
+ Vector3d& operator =(const Vector3d &v) {
+ x() = v.x(); y() = v.y(); z() = v.z();
+ return *this;
+ }
+
+ bool operator ==(const Vector3d &v) {
+ return ( (x() == v.x()) && (y() == v.y()) && (z() == v.z()) );
+ }
+
+ bool operator !=(const Vector3d &v) {
+ return ( (x() != v.x()) || (y() != v.y()) || (z() != v.z()) );
+ }
+
+ Vector3d& operator +=(const Vector3d &v) {
+ x() += v.x(); y() += v.y(); z() += v.z();
+ return *this;
+ }
+
+ Vector3d& operator -=(const Vector3d &v) {
+ x() -= v.x(); y() -= v.y(); z() -= v.z();
+ return *this;
+ }
+
+ Vector3d& operator *=(float s) {
+ x() *= s; y() *= s; z() *= s;
+ return *this;
+ }
+
+ Vector3d& operator /=(float s) {
+ x() /= s; y() /= s; z() /= s;
+ return *this;
+ }
+
+ float magnitude() const {
+ return std::sqrt(x() * x() + y() * y() + z() * z());
+ }
+
+ // Get the angle a vector is around the unit circle
+ // (ignores z-component)
+ float unitCircleAngle() const {
+ float a = x() / magnitude();
+ float b = y() / magnitude();
+ float yaw;
+
+ // find the angle on the upper half of the unit circle
+ yaw = std::acos(a) * (180.0f / LOCAL_PI);
+ if (b < 0.0f)
+ // adjust for the lower half of the unit circle
+ return 360.0f - yaw;
+ else
+ // no adjustment, angle is on the upper half
+ return yaw;
+ }
+
+ float dotProduct( float sx, float sy, float sz ) {
+ return x() * sx + y() * sy + z()*sz;
+ }
+
+ bool isZero() {
+ if(x() == 0.f && y() == 0.f && z() == 0.f)
+ return true;
+ return false;
+ }
+};
+
+inline float dot(const Vector3d& v1, const Vector3d& v2) {
+ return v1.x() * v2.x() + v1.y() * v2.y() + v1.z() * v2.z();
+}
+
+inline Vector3d cross(const Vector3d& v1, const Vector3d& v2) {
+ return Vector3d(v1.y() * v2.z() - v1.z() * v2.y(),
+ v1.z() * v2.x() - v1.x() * v2.z(),
+ v1.x() * v2.y() - v1.y() * v2.x());
+}
+
+inline float angle(const Vector3d& v1, const Vector3d& v2) {
+ return std::acos(dot(v1, v2) / (v1.magnitude() * v2.magnitude()));
+}
+
+inline Vector3d operator +(const Vector3d& v1, const Vector3d& v2) {
+ Vector3d result = v1;
+ result += v2;
+ return result;
+}
+
+inline Vector3d operator -(const Vector3d& v1, const Vector3d& v2) {
+ Vector3d result = v1;
+ result -= v2;
+ return result;
+}
+
+inline Vector3d operator *(float s, const Vector3d& v) {
+ Vector3d result = v;
+ result *= s;
+ return result;
+}
+
+inline Vector3d operator -(const Vector3d& v) {
+ return (-1.0f) * v;
+}
+
+inline Vector3d operator *(const Vector3d& v, float s) {
+ return s * v;
+}
+
+inline Vector3d operator /(const Vector3d& v, float s) {
+ Vector3d result = v;
+ result /= s;
+ return result;
+}
+
+inline bool operator ==(const Vector3d& v1, const Vector3d& v2) {
+ return v1.x() == v2.x() && v1.y() == v2.y() && v1.z() == v2.z();
+}
+
+#if defined(SYSTEM_BIG_ENDIAN)
+
+inline float get_float(const char *data) {
+ const unsigned char *udata = reinterpret_cast<const unsigned char *>(data);
+ unsigned char fdata[4];
+ fdata[0] = udata[3];
+ fdata[1] = udata[2];
+ fdata[2] = udata[1];
+ fdata[3] = udata[0];
+ return *(reinterpret_cast<const float *>(fdata));
+}
+
+#else
+
+inline float get_float(const char *data) {
+ return *(reinterpret_cast<const float *>(data));
+}
+#endif
+
+inline Vector3d get_vector3d(const char *data) {
+ return Vector3d(get_float(data), get_float(data + 4), get_float(data + 8));
+}
+
+
+#endif
Property changes on: residual/trunk/engine/vector3d.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: residual/trunk/engine/walkplane.h
===================================================================
--- residual/trunk/engine/walkplane.h 2008-08-17 07:50:38 UTC (rev 33963)
+++ residual/trunk/engine/walkplane.h 2008-08-17 08:01:59 UTC (rev 33964)
@@ -27,8 +27,9 @@
#define WALKPLANE_H
#include "common/debug.h"
-#include "common/vector3d.h"
+#include "engine/vector3d.h"
+
#include <string>
class TextSplitter;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list