summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-06-19 20:11:47 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-06-19 20:11:47 +0200
commit9f784e81f81651bed087902f9f3afee113e56148 (patch)
treeae89f6dabe2443b39aba292673027d197fc120e6 /src/common
parentb8027ce9a7f050b95846a668a02f5801331e127f (diff)
downloadcolobot-9f784e81f81651bed087902f9f3afee113e56148.tar.gz
colobot-9f784e81f81651bed087902f9f3afee113e56148.tar.bz2
colobot-9f784e81f81651bed087902f9f3afee113e56148.zip
Switched to new implementation of the rest of math module
- changed structs from D3DVECTOR to Math::Vector and from D3DMATRIX to Math::Matrix - changed functions to new Math namespace functions - moved mainmovie module from graphics to object - added Get and Set to Math::Matrix
Diffstat (limited to 'src/common')
-rw-r--r--src/common/modfile.cpp15
-rw-r--r--src/common/modfile.h5
-rw-r--r--src/common/struct.h4
3 files changed, 14 insertions, 10 deletions
diff --git a/src/common/modfile.cpp b/src/common/modfile.cpp
index 79d6612..eb11065 100644
--- a/src/common/modfile.cpp
+++ b/src/common/modfile.cpp
@@ -22,6 +22,7 @@
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/language.h"
@@ -62,10 +63,10 @@ CModFile::~CModFile()
// Creates a triangle in the internal structure.
-bool CModFile::CreateTriangle(D3DVECTOR p1, D3DVECTOR p2, D3DVECTOR p3,
+bool CModFile::CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3,
float min, float max)
{
- D3DVECTOR n;
+ Math::Vector n;
int i;
if ( m_triangleUsed >= MAX_VERTICES )
@@ -81,7 +82,7 @@ bool CModFile::CreateTriangle(D3DVECTOR p1, D3DVECTOR p2, D3DVECTOR p3,
m_triangleTable[i].bUsed = true;
m_triangleTable[i].bSelect = false;
- n = ComputeNormal(p3, p2, p1);
+ n = Math::NormalToPlane(p3, p2, p1);
m_triangleTable[i].p1 = D3DVERTEX2( p1, n);
m_triangleTable[i].p2 = D3DVERTEX2( p2, n);
m_triangleTable[i].p3 = D3DVERTEX2( p3, n);
@@ -106,7 +107,7 @@ bool CModFile::ReadDXF(char *filename, float min, float max)
FILE* file = NULL;
char line[100];
int command, rankSommet, nbSommet, nbFace;
- D3DVECTOR table[MAX_VERTICES];
+ Math::Vector table[MAX_VERTICES];
bool bWaitNbSommet;
bool bWaitNbFace;
bool bWaitSommetX;
@@ -187,7 +188,7 @@ bool CModFile::ReadDXF(char *filename, float min, float max)
nbSommet --;
if ( nbSommet >= 0 )
{
- D3DVECTOR p(x,z,y); // permutation of Y and Z!
+ Math::Vector p(x,z,y); // permutation of Y and Z!
table[rankSommet++] = p;
bWaitSommetX = true;
@@ -657,9 +658,9 @@ ModelTriangle* CModFile::RetTriangleList()
// Returns the height according to a position (x - z);
-float CModFile::RetHeight(D3DVECTOR pos)
+float CModFile::RetHeight(Math::Vector pos)
{
- D3DVECTOR p1, p2, p3;
+ Math::Vector p1, p2, p3;
float limit;
int i;
diff --git a/src/common/modfile.h b/src/common/modfile.h
index 8095a91..fb85118 100644
--- a/src/common/modfile.h
+++ b/src/common/modfile.h
@@ -19,6 +19,7 @@
#pragma once
+#include "math/vector.h"
#include "graphics/d3d/d3dengine.h"
@@ -98,10 +99,10 @@ public:
int RetTriangleMax();
ModelTriangle* RetTriangleList();
- float RetHeight(D3DVECTOR pos);
+ float RetHeight(Math::Vector pos);
protected:
- bool CreateTriangle(D3DVECTOR p1, D3DVECTOR p2, D3DVECTOR p3, float min, float max);
+ bool CreateTriangle(Math::Vector p1, Math::Vector p2, Math::Vector p3, float min, float max);
protected:
CInstanceManager* m_iMan;
diff --git a/src/common/struct.h b/src/common/struct.h
index 76594fe..cf62743 100644
--- a/src/common/struct.h
+++ b/src/common/struct.h
@@ -21,6 +21,8 @@
#include <d3d.h>
+#include <math/vector.h>
+
#define D3DFVF_VERTEX2 (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
@@ -32,7 +34,7 @@ struct D3DVERTEX2
float tu2, tv2;
D3DVERTEX2() { }
- D3DVERTEX2(const D3DVECTOR& _v, const D3DVECTOR& _n, float _tu=0.0f, float _tv=0.0f, float _tu2=0.0f, float _tv2=0.0f)
+ D3DVERTEX2(const Math::Vector& _v, const Math::Vector& _n, float _tu=0.0f, float _tv=0.0f, float _tu2=0.0f, float _tv2=0.0f)
{
x = _v.x;
y = _v.y;