summaryrefslogtreecommitdiffstats
path: root/src/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphics')
-rw-r--r--src/graphics/common/blitz.cpp34
-rw-r--r--src/graphics/common/blitz.h6
-rw-r--r--src/graphics/common/camera.cpp138
-rw-r--r--src/graphics/common/camera.h13
-rw-r--r--src/graphics/common/cloud.cpp6
-rw-r--r--src/graphics/common/cloud.h8
-rw-r--r--src/graphics/common/color.cpp10
-rw-r--r--src/graphics/common/light.cpp15
-rw-r--r--src/graphics/common/mainmovie.cpp2
-rw-r--r--src/graphics/common/mainmovie.h3
-rw-r--r--src/graphics/common/model.cpp198
-rw-r--r--src/graphics/common/model.h16
-rw-r--r--src/graphics/common/particule.cpp226
-rw-r--r--src/graphics/common/particule.h17
-rw-r--r--src/graphics/common/planet.cpp15
-rw-r--r--src/graphics/common/planet.h11
-rw-r--r--src/graphics/common/pyro.cpp474
-rw-r--r--src/graphics/common/terrain.cpp40
-rw-r--r--src/graphics/common/terrain.h7
-rw-r--r--src/graphics/common/text.cpp44
-rw-r--r--src/graphics/common/text.h25
-rw-r--r--src/graphics/common/water.cpp62
-rw-r--r--src/graphics/common/water.h3
-rw-r--r--src/graphics/d3d/d3dengine.cpp208
-rw-r--r--src/graphics/d3d/d3dengine.h29
-rw-r--r--src/graphics/d3d/d3denum.cpp1
-rw-r--r--src/graphics/d3d/d3dframe.cpp1
-rw-r--r--src/graphics/d3d/d3dtextr.cpp3
-rw-r--r--src/graphics/d3d/d3dutil.cpp2
29 files changed, 809 insertions, 808 deletions
diff --git a/src/graphics/common/blitz.cpp b/src/graphics/common/blitz.cpp
index 43f4fed..9bf5a93 100644
--- a/src/graphics/common/blitz.cpp
+++ b/src/graphics/common/blitz.cpp
@@ -14,14 +14,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "graphics/d3d/d3dutil.h"
@@ -75,7 +75,7 @@ void CBlitz::Flush()
for ( i=0 ; i<BLITZMAX ; i++ )
{
- m_shift[i] = FPOINT(0.0f, 0.0f);
+ m_shift[i] = Math::Point(0.0f, 0.0f);
m_width[i] = 1.0f;
}
}
@@ -114,11 +114,11 @@ bool CBlitz::EventFrame(const Event &event)
if ( m_progress >= 1.0f )
{
#if 1
- m_pos.x = (Rand()-0.5f)*(3200.0f-200.0f);
- m_pos.z = (Rand()-0.5f)*(3200.0f-200.0f);
+ m_pos.x = (Math::Rand()-0.5f)*(3200.0f-200.0f);
+ m_pos.z = (Math::Rand()-0.5f)*(3200.0f-200.0f);
#else
- m_pos.x = (Rand()-0.5f)*(3200.0f-2800.0f);
- m_pos.z = (Rand()-0.5f)*(3200.0f-2800.0f);
+ m_pos.x = (Math::Rand()-0.5f)*(3200.0f-2800.0f);
+ m_pos.z = (Math::Rand()-0.5f)*(3200.0f-2800.0f);
#endif
m_pos.y = 0.0f;
@@ -179,15 +179,15 @@ bool CBlitz::EventFrame(const Event &event)
{
max += 0.4f;
- m_shift[i].x += (Rand()-0.5f)*max*2.0f;
+ m_shift[i].x += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].x < -max ) m_shift[i].x = -max;
if ( m_shift[i].x > max ) m_shift[i].x = max;
- m_shift[i].y += (Rand()-0.5f)*max*2.0f;
+ m_shift[i].y += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].y < -max ) m_shift[i].y = -max;
if ( m_shift[i].y > max ) m_shift[i].y = max;
- m_width[i] += (Rand()-0.5f)*2.0f;
+ m_width[i] += (Math::Rand()-0.5f)*2.0f;
if ( m_width[i] < 1.0f ) m_width[i] = 1.0f;
if ( m_width[i] > 6.0f ) m_width[i] = 6.0f;
}
@@ -199,7 +199,7 @@ bool CBlitz::EventFrame(const Event &event)
{
m_phase = BPH_WAIT;
m_progress = 0.0f;
- m_speed = 1.0f/(1.0f+Rand()*m_delay);
+ m_speed = 1.0f/(1.0f+Math::Rand()*m_delay);
}
}
@@ -215,7 +215,7 @@ void CBlitz::Draw()
D3DVERTEX2 vertex[4]; // 2 triangles
D3DVECTOR corner[4], eye, n, p, p1, p2;
D3DMATRIX matrix;
- FPOINT texInf, texSup, rot;
+ Math::Point texInf, texSup, rot;
float a;
int i;
@@ -237,7 +237,7 @@ void CBlitz::Draw()
p1 = m_pos;
eye = m_engine->RetEyePt();
- a = RotateAngle(eye.x-p1.x, eye.z-p1.z);
+ a = Math::RotateAngle(eye.x-p1.x, eye.z-p1.z);
n = Normalize(p1-eye);
for ( i=0 ; i<BLITZMAX-1 ; i++ )
@@ -247,22 +247,22 @@ void CBlitz::Draw()
p = p1;
p.x += m_width[i];
- rot = RotatePoint(FPOINT(p1.x, p1.z), a+PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[0].x = rot.x+m_shift[i].x;
corner[0].y = p1.y;
corner[0].z = rot.y+m_shift[i].y;
- rot = RotatePoint(FPOINT(p1.x, p1.z), a-PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[1].x = rot.x+m_shift[i].x;
corner[1].y = p1.y;
corner[1].z = rot.y+m_shift[i].y;
p = p2;
p.x += m_width[i+1];
- rot = RotatePoint(FPOINT(p2.x, p2.z), a+PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[2].x = rot.x+m_shift[i+1].x;
corner[2].y = p2.y;
corner[2].z = rot.y+m_shift[i+1].y;
- rot = RotatePoint(FPOINT(p2.x, p2.z), a-PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[3].x = rot.x+m_shift[i+1].x;
corner[3].y = p2.y;
corner[3].z = rot.y+m_shift[i+1].y;
diff --git a/src/graphics/common/blitz.h b/src/graphics/common/blitz.h
index d492654..a4e47a6 100644
--- a/src/graphics/common/blitz.h
+++ b/src/graphics/common/blitz.h
@@ -20,9 +20,11 @@
#include "common/misc.h"
-#include "common/struct.h"
+#include "math/point.h"
+#include "graphics/d3d/d3dengine.h"
+class CObject;
class CInstanceManager;
class CD3DEngine;
class CTerrain;
@@ -75,7 +77,7 @@ protected:
float m_speed;
float m_progress;
D3DVECTOR m_pos;
- FPOINT m_shift[BLITZMAX];
+ Math::Point m_shift[BLITZMAX];
float m_width[BLITZMAX];
};
diff --git a/src/graphics/common/camera.cpp b/src/graphics/common/camera.cpp
index f3b7d39..1298c3c 100644
--- a/src/graphics/common/camera.cpp
+++ b/src/graphics/common/camera.cpp
@@ -14,14 +14,14 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/language.h"
@@ -65,9 +65,9 @@ CCamera::CCamera(CInstanceManager* iMan)
m_focus = 1.0f;
m_bRightDown = false;
- m_rightPosInit = FPOINT(0.5f, 0.5f);
- m_rightPosCenter = FPOINT(0.5f, 0.5f);
- m_rightPosMove = FPOINT(0.5f, 0.5f);
+ m_rightPosInit = Math::Point(0.5f, 0.5f);
+ m_rightPosCenter = Math::Point(0.5f, 0.5f);
+ m_rightPosMove = Math::Point(0.5f, 0.5f);
m_eyePt = D3DVECTOR(0.0f, 0.0f, 0.0f);
m_directionH = 0.0f;
@@ -180,18 +180,18 @@ void CCamera::Init(D3DVECTOR eye, D3DVECTOR lookat, float delay)
m_type = CAMERA_FREE;
m_eyePt = eye;
- m_directionH = RotateAngle(eye.x-lookat.x, eye.z-lookat.z)+PI/2.0f;
- m_directionV = -RotateAngle(Length2d(eye, lookat), eye.y-lookat.y);
+ m_directionH = Math::RotateAngle(eye.x-lookat.x, eye.z-lookat.z)+Math::PI/2.0f;
+ m_directionV = -Math::RotateAngle(Length2d(eye, lookat), eye.y-lookat.y);
m_eyeDistance = 10.0f;
m_heightLookat = 10.0f;
m_backDist = 30.0f;
m_backMin = 10.0f;
m_addDirectionH = 0.0f;
- m_addDirectionV = -PI*0.05f;
+ m_addDirectionV = -Math::PI*0.05f;
m_fixDist = 50.0f;
- m_fixDirectionH = PI*0.25f;
- m_fixDirectionV = -PI*0.10f;
+ m_fixDirectionH = Math::PI*0.25f;
+ m_fixDirectionV = -Math::PI*0.10f;
m_centeringPhase = CP_NULL;
m_actualEye = m_eyePt;
m_actualLookat = LookatPoint(m_eyePt, m_directionH, m_directionV, 50.0f);
@@ -338,7 +338,7 @@ void CCamera::SetType(CameraType type)
{
AbortCentering(); // Special stops framing
m_addDirectionH = 0.0f;
- m_addDirectionV = -PI*0.05f;
+ m_addDirectionV = -Math::PI*0.05f;
if ( m_cameraObj == 0 ) oType = OBJECT_NULL;
else oType = m_cameraObj->RetType();
@@ -450,7 +450,7 @@ float CCamera::RetRemotePan()
void CCamera::SetRemoteZoom(float value)
{
- value = Norm(value);
+ value = Math::Norm(value);
if ( m_type == CAMERA_BACK )
{
@@ -491,7 +491,7 @@ void CCamera::StartVisit(D3DVECTOR goal, float dist)
m_visitDist = dist;
m_visitTime = 0.0f;
m_visitDirectionH = 0.0f;
- m_visitDirectionV = -PI*0.10f;
+ m_visitDirectionV = -Math::PI*0.10f;
}
// Circular end of a visit with the camera.
@@ -521,9 +521,9 @@ bool CCamera::StartCentering(CObject *object, float angleH, float angleV,
if ( m_centeringPhase != CP_NULL ) return false;
- if ( m_addDirectionH > PI )
+ if ( m_addDirectionH > Math::PI )
{
- angleH = PI*2.0f-angleH;
+ angleH = Math::PI*2.0f-angleH;
}
m_centeringPhase = CP_START;
@@ -627,9 +627,9 @@ void CCamera::EffectFrame(const Event &event)
if ( m_effectType == CE_TERRAFORM )
{
m_effectProgress += event.rTime*0.7f;
- m_effectOffset.x = (Rand()-0.5f)*10.0f;
- m_effectOffset.y = (Rand()-0.5f)*10.0f;
- m_effectOffset.z = (Rand()-0.5f)*10.0f;
+ m_effectOffset.x = (Math::Rand()-0.5f)*10.0f;
+ m_effectOffset.y = (Math::Rand()-0.5f)*10.0f;
+ m_effectOffset.z = (Math::Rand()-0.5f)*10.0f;
force *= 1.0f-m_effectProgress;
}
@@ -637,9 +637,9 @@ void CCamera::EffectFrame(const Event &event)
if ( m_effectType == CE_EXPLO )
{
m_effectProgress += event.rTime*1.0f;
- m_effectOffset.x = (Rand()-0.5f)*5.0f;
- m_effectOffset.y = (Rand()-0.5f)*5.0f;
- m_effectOffset.z = (Rand()-0.5f)*5.0f;
+ m_effectOffset.x = (Math::Rand()-0.5f)*5.0f;
+ m_effectOffset.y = (Math::Rand()-0.5f)*5.0f;
+ m_effectOffset.z = (Math::Rand()-0.5f)*5.0f;
force *= 1.0f-m_effectProgress;
}
@@ -647,9 +647,9 @@ void CCamera::EffectFrame(const Event &event)
if ( m_effectType == CE_SHOT )
{
m_effectProgress += event.rTime*1.0f;
- m_effectOffset.x = (Rand()-0.5f)*2.0f;
- m_effectOffset.y = (Rand()-0.5f)*2.0f;
- m_effectOffset.z = (Rand()-0.5f)*2.0f;
+ m_effectOffset.x = (Math::Rand()-0.5f)*2.0f;
+ m_effectOffset.y = (Math::Rand()-0.5f)*2.0f;
+ m_effectOffset.z = (Math::Rand()-0.5f)*2.0f;
force *= 1.0f-m_effectProgress;
}
@@ -657,29 +657,29 @@ void CCamera::EffectFrame(const Event &event)
if ( m_effectType == CE_CRASH )
{
m_effectProgress += event.rTime*5.0f;
- m_effectOffset.y = sinf(m_effectProgress*PI)*1.5f;
- m_effectOffset.x = (Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
- m_effectOffset.z = (Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
+ m_effectOffset.y = sinf(m_effectProgress*Math::PI)*1.5f;
+ m_effectOffset.x = (Math::Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
+ m_effectOffset.z = (Math::Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
}
if ( m_effectType == CE_VIBRATION )
{
m_effectProgress += event.rTime*0.1f;
- m_effectOffset.y = (Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
- m_effectOffset.x = (Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
- m_effectOffset.z = (Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
+ m_effectOffset.y = (Math::Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
+ m_effectOffset.x = (Math::Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
+ m_effectOffset.z = (Math::Rand()-0.5f)*1.0f*(1.0f-m_effectProgress);
}
if ( m_effectType == CE_PET )
{
m_effectProgress += event.rTime*5.0f;
- m_effectOffset.x = (Rand()-0.5f)*0.2f;
- m_effectOffset.y = (Rand()-0.5f)*2.0f;
- m_effectOffset.z = (Rand()-0.5f)*0.2f;
+ m_effectOffset.x = (Math::Rand()-0.5f)*0.2f;
+ m_effectOffset.y = (Math::Rand()-0.5f)*2.0f;
+ m_effectOffset.z = (Math::Rand()-0.5f)*0.2f;
}
dist = Length(m_eyePt, m_effectPos);
- dist = Norm((dist-100.f)/100.0f);
+ dist = Math::Norm((dist-100.f)/100.0f);
force *= 1.0f-dist;
#if _TEEN
@@ -1004,13 +1004,13 @@ bool CCamera::IsCollisionBack(D3DVECTOR &eye, D3DVECTOR lookat)
iType = m_cameraObj->RetType();
}
- min.x = Min(eye.x, lookat.x);
- min.y = Min(eye.y, lookat.y);
- min.z = Min(eye.z, lookat.z);
+ min.x = Math::Min(eye.x, lookat.x);
+ min.y = Math::Min(eye.y, lookat.y);
+ min.z = Math::Min(eye.z, lookat.z);
- max.x = Max(eye.x, lookat.x);
- max.y = Max(eye.y, lookat.y);
- max.z = Max(eye.z, lookat.z);
+ max.x = Math::Max(eye.x, lookat.x);
+ max.y = Math::Max(eye.y, lookat.y);
+ max.z = Math::Max(eye.z, lookat.z);
prox = 8.0f; // maximum proximity of the vehicle
@@ -1108,13 +1108,13 @@ bool CCamera::IsCollisionBack(D3DVECTOR &eye, D3DVECTOR lookat)
iType = m_cameraObj->RetType();
}
- min.x = Min(m_actualEye.x, m_actualLookat.x);
- min.y = Min(m_actualEye.y, m_actualLookat.y);
- min.z = Min(m_actualEye.z, m_actualLookat.z);
+ min.x = Math::Min(m_actualEye.x, m_actualLookat.x);
+ min.y = Math::Min(m_actualEye.y, m_actualLookat.y);
+ min.z = Math::Min(m_actualEye.z, m_actualLookat.z);
- max.x = Max(m_actualEye.x, m_actualLookat.x);
- max.y = Max(m_actualEye.y, m_actualLookat.y);
- max.z = Max(m_actualEye.z, m_actualLookat.z);
+ max.x = Math::Max(m_actualEye.x, m_actualLookat.x);
+ max.y = Math::Max(m_actualEye.y, m_actualLookat.y);
+ max.z = Math::Max(m_actualEye.z, m_actualLookat.z);
m_bTransparency = false;
@@ -1173,9 +1173,9 @@ bool CCamera::IsCollisionBack(D3DVECTOR &eye, D3DVECTOR lookat)
if ( oType == OBJECT_FACTORY )
{
- angle = RotateAngle(m_actualEye.x-oPos.x, oPos.z-m_actualEye.z); // CW !
- angle = Direction(angle, pObj->RetAngleY(0));
- if ( Abs(angle) < 30.0f*PI/180.0f ) continue; // in the gate?
+ angle = Math::RotateAngle(m_actualEye.x-oPos.x, oPos.z-m_actualEye.z); // CW !
+ angle = Math::Direction(angle, pObj->RetAngleY(0));
+ if ( fabs(angle) < 30.0f*Math::PI/180.0f ) continue; // in the gate?
}
del = Length(m_actualEye, m_actualLookat);
@@ -1260,7 +1260,7 @@ bool CCamera::EventProcess(const Event &event)
case EVENT_RBUTTONDOWN:
m_bRightDown = true;
m_rightPosInit = event.pos;
- m_rightPosCenter = FPOINT(0.5f, 0.5f);
+ m_rightPosCenter = Math::Point(0.5f, 0.5f);
m_engine->MoveMousePos(m_rightPosCenter);
//? m_engine->SetMouseHide(true); // cache la souris
break;
@@ -1270,7 +1270,7 @@ bool CCamera::EventProcess(const Event &event)
m_engine->MoveMousePos(m_rightPosInit);
//? m_engine->SetMouseHide(false); // remontre la souris
m_addDirectionH = 0.0f;
- m_addDirectionV = -PI*0.05f;
+ m_addDirectionV = -Math::PI*0.05f;
break;
#endif
@@ -1397,7 +1397,7 @@ bool CCamera::EventFrame(const Event &event)
// Returns the default sprite to use for the mouse.
-D3DMouse CCamera::RetMouseDef(FPOINT pos)
+D3DMouse CCamera::RetMouseDef(Math::Point pos)
{
D3DMouse type;
@@ -1506,11 +1506,11 @@ bool CCamera::EventFrameFree(const Event &event)
{
if ( event.axeX < 0.0f )
{
- m_eyePt = LookatPoint(m_eyePt, m_directionH+PI/2.0f, m_directionV, -event.axeX*event.rTime*factor*m_speed);
+ m_eyePt = LookatPoint(m_eyePt, m_directionH+Math::PI/2.0f, m_directionV, -event.axeX*event.rTime*factor*m_speed);
}
if ( event.axeX > 0.0f )
{
- m_eyePt = LookatPoint(m_eyePt, m_directionH-PI/2.0f, m_directionV, event.axeX*event.rTime*factor*m_speed);
+ m_eyePt = LookatPoint(m_eyePt, m_directionH-Math::PI/2.0f, m_directionV, event.axeX*event.rTime*factor*m_speed);
}
}
else
@@ -1586,12 +1586,12 @@ bool CCamera::EventFrameEdit(const Event &event)
{
// Left/Right.
m_fixDirectionH += m_mouseDirH*event.rTime*1.0f*m_speed;
- m_fixDirectionH = NormAngle(m_fixDirectionH);
+ m_fixDirectionH = Math::NormAngle(m_fixDirectionH);
// Up/Down.
//? m_fixDirectionV -= m_mouseDirV*event.rTime*0.5f*m_speed;
-//? if ( m_fixDirectionV < -PI*0.40f ) m_fixDirectionV = -PI*0.40f;
-//? if ( m_fixDirectionV > PI*0.20f ) m_fixDirectionV = PI*0.20f;
+//? if ( m_fixDirectionV < -Math::PI*0.40f ) m_fixDirectionV = -Math::PI*0.40f;
+//? if ( m_fixDirectionV > Math::PI*0.20f ) m_fixDirectionV = Math::PI*0.20f;
}
m_terrain->ValidPosition(m_eyePt, 10.0f);
@@ -1638,7 +1638,7 @@ bool CCamera::EventFrameBack(const Event &event)
CPhysics* physics;
ObjectType type;
D3DVECTOR pos, vLookatPt;
- FPOINT mouse;
+ Math::Point mouse;
float centeringH, centeringV, centeringD, h, v, d, floor;
if ( m_cameraObj == 0 )
@@ -1676,7 +1676,7 @@ bool CCamera::EventFrameBack(const Event &event)
#if 1
// Left/Right.
m_addDirectionH += m_mouseDirH*event.rTime*1.0f*m_speed;
- m_addDirectionH = NormAngle(m_addDirectionH);
+ m_addDirectionH = Math::NormAngle(m_addDirectionH);
// Up/Down.
//? m_backDist -= m_mouseDirV*event.rTime*30.0f*m_speed;
@@ -1782,18 +1782,18 @@ bool CCamera::EventFrameBack(const Event &event)
type == OBJECT_START ||
type == OBJECT_END ) // building?
{
- h += PI*0.20f; // nearly face
+ h += Math::PI*0.20f; // nearly face
}
else // vehicle?
{
- h += PI; // back
+ h += Math::PI; // back
}
- h = NormAngle(h)+m_remotePan;
+ h = Math::NormAngle(h)+m_remotePan;
v = 0.0f; //?
h += m_centeringCurrentH;
h += m_addDirectionH*(1.0f-centeringH);
- h = NormAngle(h);
+ h = Math::NormAngle(h);
if ( type == OBJECT_MOBILEdr ) // designer?
{
@@ -1827,7 +1827,7 @@ bool CCamera::EventFrameBack(const Event &event)
SetViewTime(m_eyePt, vLookatPt, event.rTime);
- m_directionH = h+PI/2.0f;
+ m_directionH = h+Math::PI/2.0f;
m_directionV = v;
}
@@ -1857,7 +1857,7 @@ bool CCamera::EventFrameFix(const Event &event)
{
// Left/Right.
m_fixDirectionH += m_mouseDirH*event.rTime*1.0f*m_speed;
- m_fixDirectionH = NormAngle(m_fixDirectionH);
+ m_fixDirectionH = Math::NormAngle(m_fixDirectionH);
// Up/Down.
//? m_fixDist -= m_mouseDirV*event.rTime*30.0f*m_speed;
@@ -1887,7 +1887,7 @@ bool CCamera::EventFrameFix(const Event &event)
SetViewTime(m_eyePt, vLookatPt, event.rTime);
- m_directionH = h+PI/2.0f;
+ m_directionH = h+Math::PI/2.0f;
m_directionV = v;
}
@@ -1993,7 +1993,7 @@ bool CCamera::EventFrameVisit(const Event &event)
if ( event.keyState & KS_PAGEUP )
{
m_visitDirectionV -= event.rTime*1.0f*m_speed;
- if ( m_visitDirectionV < -PI*0.40f ) m_visitDirectionV = -PI*0.40f;
+ if ( m_visitDirectionV < -Math::PI*0.40f ) m_visitDirectionV = -Math::PI*0.40f;
}
if ( event.keyState & KS_PAGEDOWN )
{
@@ -2008,7 +2008,7 @@ bool CCamera::EventFrameVisit(const Event &event)
if ( m_visitDist > 200.0f ) m_visitDist = 200.0f;
}
- angleH = (m_visitTime/10.0f)*(PI*2.0f);
+ angleH = (m_visitTime/10.0f)*(Math::PI*2.0f);
angleV = m_visitDirectionV;
eye = RotateView(m_visitGoal, angleH, angleV, m_visitDist);
eye = ExcludeTerrain(eye, m_visitGoal, angleH, angleV);
@@ -2068,7 +2068,7 @@ D3DVECTOR CCamera::ExcludeTerrain(D3DVECTOR eye, D3DVECTOR lookat,
pos.y += 2.0f+dist*0.1f;
if ( pos.y > eye.y )
{
- angleV = -RotateAngle(dist, pos.y-lookat.y);
+ angleV = -Math::RotateAngle(dist, pos.y-lookat.y);
eye = RotateView(lookat, angleH, angleV, dist);
}
}
diff --git a/src/graphics/common/camera.h b/src/graphics/common/camera.h
index 407d522..433a458 100644
--- a/src/graphics/common/camera.h
+++ b/src/graphics/common/camera.h
@@ -19,8 +19,9 @@
#pragma once
+#include "common/event.h"
+#include "math/point.h"
#include "graphics/d3d/d3dengine.h"
-#include "common/struct.h"
class CInstanceManager;
@@ -142,7 +143,7 @@ public:
void SetCameraInvertY(bool bInvert);
float RetMotorTurn();
- D3DMouse RetMouseDef(FPOINT pos);
+ D3DMouse RetMouseDef(Math::Point pos);
protected:
bool EventMouseMove(const Event &event);
@@ -193,9 +194,9 @@ protected:
float m_focus;
bool m_bRightDown;
- FPOINT m_rightPosInit;
- FPOINT m_rightPosCenter;
- FPOINT m_rightPosMove;
+ Math::Point m_rightPosInit;
+ Math::Point m_rightPosCenter;
+ Math::Point m_rightPosMove;
D3DVECTOR m_eyePt; // CAMERA_FREE: eye
float m_directionH; // CAMERA_FREE: horizontal direction
@@ -226,7 +227,7 @@ protected:
float m_remotePan;
float m_remoteZoom;
- FPOINT m_mousePos;
+ Math::Point m_mousePos;
float m_mouseDirH;
float m_mouseDirV;
float m_mouseMarging;
diff --git a/src/graphics/common/cloud.cpp b/src/graphics/common/cloud.cpp
index 1d4f6d9..507da66 100644
--- a/src/graphics/common/cloud.cpp
+++ b/src/graphics/common/cloud.cpp
@@ -14,8 +14,6 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -94,7 +92,7 @@ bool CCloud::EventFrame(const Event &event)
// at movement.
void CCloud::AdjustLevel(D3DVECTOR &pos, D3DVECTOR &eye, float deep,
- FPOINT &uv1, FPOINT &uv2)
+ Math::Point &uv1, Math::Point &uv2)
{
float dist, factor;
@@ -126,7 +124,7 @@ void CCloud::Draw()
D3DMATERIAL7 material;
D3DMATRIX matrix;
D3DVECTOR n, pos, p, eye;
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
float iDeep, deep, size, fogStart, fogEnd;
int i, j, u;
diff --git a/src/graphics/common/cloud.h b/src/graphics/common/cloud.h
index cf97bc7..d806c03 100644
--- a/src/graphics/common/cloud.h
+++ b/src/graphics/common/cloud.h
@@ -19,7 +19,9 @@
#pragma once
-#include "common/struct.h"
+#include "common/event.h"
+#include "math/point.h"
+#include "graphics/d3d/d3dengine.h"
class CInstanceManager;
@@ -57,7 +59,7 @@ public:
protected:
bool EventFrame(const Event &event);
- void AdjustLevel(D3DVECTOR &pos, D3DVECTOR &eye, float deep, FPOINT &uv1, FPOINT &uv2);
+ void AdjustLevel(D3DVECTOR &pos, D3DVECTOR &eye, float deep, Math::Point &uv1, Math::Point &uv2);
bool CreateLine(int x, int y, int len);
protected:
@@ -67,7 +69,7 @@ protected:
char m_filename[100];
float m_level; // overall level
- FPOINT m_speed; // feedrate (wind)
+ Math::Point m_speed; // feedrate (wind)
D3DCOLORVALUE m_diffuse; // diffuse color
D3DCOLORVALUE m_ambient; // ambient color
float m_time;
diff --git a/src/graphics/common/color.cpp b/src/graphics/common/color.cpp
index bc5cf5d..6bffba4 100644
--- a/src/graphics/common/color.cpp
+++ b/src/graphics/common/color.cpp
@@ -73,8 +73,8 @@ void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest)
{
float min, max, delta;
- min = Min(src.r, src.g, src.b);
- max = Max(src.r, src.g, src.b);
+ min = Math::Min(src.r, src.g, src.b);
+ max = Math::Max(src.r, src.g, src.b);
dest.v = max; // intensity
@@ -114,9 +114,9 @@ void HSV2RGB(ColorHSV src, D3DCOLORVALUE &dest)
int i;
float f,v,p,q,t;
- src.h = Norm(src.h)*360.0f;
- src.s = Norm(src.s);
- src.v = Norm(src.v);
+ src.h = Math::Norm(src.h)*360.0f;
+ src.s = Math::Norm(src.s);
+ src.v = Math::Norm(src.v);
if ( src.s == 0.0f ) // zero saturation?
{
diff --git a/src/graphics/common/light.cpp b/src/graphics/common/light.cpp
index 29cd1d6..3077c27 100644
--- a/src/graphics/common/light.cpp
+++ b/src/graphics/common/light.cpp
@@ -16,15 +16,14 @@
// light.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
-#include "math/const.h"
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "common/event.h"
#include "common/misc.h"
@@ -417,16 +416,16 @@ void CLight::FrameLight(float rTime)
if ( m_lightTable[i].incluType == TYPEQUARTZ )
{
- m_lightTable[i].light.dvDirection.x = sinf((m_time+i*PI*0.5f)*1.0f);
- m_lightTable[i].light.dvDirection.z = cosf((m_time+i*PI*0.5f)*1.1f);
- m_lightTable[i].light.dvDirection.y = -1.0f+cosf((m_time+i*PI*0.5f)*2.7f)*0.5f;
+ m_lightTable[i].light.dvDirection.x = sinf((m_time+i*Math::PI*0.5f)*1.0f);
+ m_lightTable[i].light.dvDirection.z = cosf((m_time+i*Math::PI*0.5f)*1.1f);
+ m_lightTable[i].light.dvDirection.y = -1.0f+cosf((m_time+i*Math::PI*0.5f)*2.7f)*0.5f;
}
if ( m_lightTable[i].incluType == TYPEMETAL )
{
dir = m_engine->RetEyePt()-m_engine->RetLookatPt();
- angle = RotateAngle(dir.x, dir.z);
- angle += PI*0.5f*i;
+ angle = Math::RotateAngle(dir.x, dir.z);
+ angle += Math::PI*0.5f*i;
m_lightTable[i].light.dvDirection.x = sinf(angle*2.0f);
m_lightTable[i].light.dvDirection.z = cosf(angle*2.0f);
}
diff --git a/src/graphics/common/mainmovie.cpp b/src/graphics/common/mainmovie.cpp
index 23c3652..e890ae7 100644
--- a/src/graphics/common/mainmovie.cpp
+++ b/src/graphics/common/mainmovie.cpp
@@ -16,8 +16,6 @@
// mainmovie.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/graphics/common/mainmovie.h b/src/graphics/common/mainmovie.h
index f02f0f1..ddc1b96 100644
--- a/src/graphics/common/mainmovie.h
+++ b/src/graphics/common/mainmovie.h
@@ -19,6 +19,9 @@
#pragma once
+#include "common/event.h"
+#include "graphics/d3d/d3dengine.h"
+
class CInstanceManager;
class CEvent;
class CD3DEngine;
diff --git a/src/graphics/common/model.cpp b/src/graphics/common/model.cpp
index fa1fe1c..8fc6be3 100644
--- a/src/graphics/common/model.cpp
+++ b/src/graphics/common/model.cpp
@@ -16,14 +16,14 @@
// model.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/event.h"
@@ -134,7 +134,7 @@ CModel::~CModel()
void CModel::StartUserAction()
{
Event event;
- FPOINT pos, dim;
+ Math::Point pos, dim;
CButton* pb;
dim.x = 105.0f/640.0f;
@@ -607,7 +607,7 @@ bool CModel::EventProcess(const Event &event)
}
if ( event.param == 'E' )
{
- FPOINT ti, ts;
+ Math::Point ti, ts;
ti.x = 0.00f;
ti.y = 0.00f;
ts.x = 0.00f;
@@ -1099,19 +1099,19 @@ void CModel::MoveSelect(D3DVECTOR move)
if ( m_oper == 'R' )
{
#if 0
- if ( move.x == +1 ) move.x = 5.0f*PI/180.0f;
- else if ( move.x == -1 ) move.x = -5.0f*PI/180.0f;
- if ( move.y == +1 ) move.y = 5.0f*PI/180.0f;
- else if ( move.y == -1 ) move.y = -5.0f*PI/180.0f;
- if ( move.z == +1 ) move.z = 5.0f*PI/180.0f;
- else if ( move.z == -1 ) move.z = -5.0f*PI/180.0f;
+ if ( move.x == +1 ) move.x = 5.0f*Math::PI/180.0f;
+ else if ( move.x == -1 ) move.x = -5.0f*Math::PI/180.0f;
+ if ( move.y == +1 ) move.y = 5.0f*Math::PI/180.0f;
+ else if ( move.y == -1 ) move.y = -5.0f*Math::PI/180.0f;
+ if ( move.z == +1 ) move.z = 5.0f*Math::PI/180.0f;
+ else if ( move.z == -1 ) move.z = -5.0f*Math::PI/180.0f;
#else
- if ( move.x == +1 ) move.x = 45.0f*PI/180.0f;
- else if ( move.x == -1 ) move.x = -45.0f*PI/180.0f;
- if ( move.y == +1 ) move.y = 45.0f*PI/180.0f;
- else if ( move.y == -1 ) move.y = -45.0f*PI/180.0f;
- if ( move.z == +1 ) move.z = 45.0f*PI/180.0f;
- else if ( move.z == -1 ) move.z = -45.0f*PI/180.0f;
+ if ( move.x == +1 ) move.x = 45.0f*Math::PI/180.0f;
+ else if ( move.x == -1 ) move.x = -45.0f*Math::PI/180.0f;
+ if ( move.y == +1 ) move.y = 45.0f*Math::PI/180.0f;
+ else if ( move.y == -1 ) move.y = -45.0f*Math::PI/180.0f;
+ if ( move.z == +1 ) move.z = 45.0f*Math::PI/180.0f;
+ else if ( move.z == -1 ) move.z = -45.0f*Math::PI/180.0f;
#endif
}
@@ -1122,7 +1122,7 @@ void CModel::MoveSelect(D3DVECTOR move)
void CModel::OperSelect(D3DVECTOR move, char oper)
{
- FPOINT rot;
+ Math::Point rot;
int used, i;
DefaultSelect();
@@ -1162,19 +1162,19 @@ void CModel::OperSelect(D3DVECTOR move, char oper)
{
rot.x = m_triangleTable[i].p1.z;
rot.y = m_triangleTable[i].p1.y;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.x, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.x, rot);
m_triangleTable[i].p1.z = rot.x;
m_triangleTable[i].p1.y = rot.y;
rot.x = m_triangleTable[i].p2.z;
rot.y = m_triangleTable[i].p2.y;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.x, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.x, rot);
m_triangleTable[i].p2.z = rot.x;
m_triangleTable[i].p2.y = rot.y;
rot.x = m_triangleTable[i].p3.z;
rot.y = m_triangleTable[i].p3.y;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.x, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.x, rot);
m_triangleTable[i].p3.z = rot.x;
m_triangleTable[i].p3.y = rot.y;
}
@@ -1182,19 +1182,19 @@ void CModel::OperSelect(D3DVECTOR move, char oper)
{
rot.x = m_triangleTable[i].p1.x;
rot.y = m_triangleTable[i].p1.z;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.y, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.y, rot);
m_triangleTable[i].p1.x = rot.x;
m_triangleTable[i].p1.z = rot.y;
rot.x = m_triangleTable[i].p2.x;
rot.y = m_triangleTable[i].p2.z;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.y, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.y, rot);
m_triangleTable[i].p2.x = rot.x;
m_triangleTable[i].p2.z = rot.y;
rot.x = m_triangleTable[i].p3.x;
rot.y = m_triangleTable[i].p3.z;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.y, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.y, rot);
m_triangleTable[i].p3.x = rot.x;
m_triangleTable[i].p3.z = rot.y;
}
@@ -1202,19 +1202,19 @@ void CModel::OperSelect(D3DVECTOR move, char oper)
{
rot.x = m_triangleTable[i].p1.x;
rot.y = m_triangleTable[i].p1.y;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.z, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.z, rot);
m_triangleTable[i].p1.x = rot.x;
m_triangleTable[i].p1.y = rot.y;
rot.x = m_triangleTable[i].p2.x;
rot.y = m_triangleTable[i].p2.y;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.z, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.z, rot);
m_triangleTable[i].p2.x = rot.x;
m_triangleTable[i].p2.y = rot.y;
rot.x = m_triangleTable[i].p3.x;
rot.y = m_triangleTable[i].p3.y;
- rot = RotatePoint(FPOINT(0.0f, 0.0f), move.z, rot);
+ rot = Math::RotatePoint(Math::Point(0.0f, 0.0f), move.z, rot);
m_triangleTable[i].p3.x = rot.x;
m_triangleTable[i].p3.y = rot.y;
}
@@ -1275,7 +1275,7 @@ void CModel::ReadScript(char *filename)
OperSelect(move, 'Z');
move = OpDir(line, "rot");
- move *= PI/180.0f; // degrees -> radians
+ move *= Math::PI/180.0f; // degrees -> radians
OperSelect(move, 'R');
move = OpDir(line, "pos");
@@ -1362,7 +1362,7 @@ bool CModel::IsMappingSelectPlausible(D3DMaping D3Dmode)
{
D3DVERTEX2 vertex[3];
D3DVECTOR min, max;
- FPOINT a, b, ti, ts;
+ Math::Point a, b, ti, ts;
float au, bu, av, bv;
int used, i, j;
@@ -1440,11 +1440,11 @@ bool CModel::IsMappingSelectPlausible(D3DMaping D3Dmode)
// Maps a texture onto the selected triangles.
void CModel::MappingSelect(int mode, int rotate, bool bMirrorX, bool bMirrorY,
- FPOINT ti, FPOINT ts, char *texName)
+ Math::Point ti, Math::Point ts, char *texName)
{
D3DVERTEX2 vertex;
D3DVECTOR min, max;
- FPOINT a, b;
+ Math::Point a, b;
D3DMaping D3Dmode;
float au, bu, av, bv;
int used, i;
@@ -1516,12 +1516,12 @@ void CModel::MappingSelect(int mode, int rotate, bool bMirrorX, bool bMirrorY,
if ( bMirrorX )
{
- Swap(ti.x, ts.x);
+ Math::Swap(ti.x, ts.x);
}
if ( !bMirrorY ) // reverse test!
{
- Swap(ti.y, ts.y);
+ Math::Swap(ti.y, ts.y);
}
au = (ts.x-ti.x)/(b.x-a.x);
@@ -1559,7 +1559,7 @@ void CModel::MappingSelect(int mode, int rotate, bool bMirrorX, bool bMirrorY,
// Maps a texture onto the selected triangles.
void CModel::MappingSelectSpherical(int mode, int rotate, bool bMirrorX, bool bMirrorY,
- FPOINT ti, FPOINT ts, char *texName)
+ Math::Point ti, Math::Point ts, char *texName)
{
D3DVERTEX2 vertex;
D3DVECTOR min, max, center, dim, p;
@@ -1569,16 +1569,16 @@ void CModel::MappingSelectSpherical(int mode, int rotate, bool bMirrorX, bool bM
BBoxCompute(min, max);
center = (min+max)/2.0f;
dim = (max-min)/2.0f;
- radius = Min(dim.x, dim.y, dim.z);
+ radius = Math::Min(dim.x, dim.y, dim.z);
if ( bMirrorX )
{
- Swap(ti.x, ts.x);
+ Math::Swap(ti.x, ts.x);
}
if ( !bMirrorY ) // reverse test!
{
- Swap(ti.y, ts.y);
+ Math::Swap(ti.y, ts.y);
}
used = m_modFile->RetTriangleUsed();
@@ -1627,9 +1627,9 @@ D3DVECTOR CModel::RetMappingCenter(D3DVECTOR pos, D3DVECTOR min)
p.y = vertex.y;
p.z = vertex.z;
- if ( Abs(p.x-pos.x) <= min.x &&
- Abs(p.y-pos.y) <= min.y &&
- Abs(p.z-pos.z) <= min.z )
+ if ( fabs(p.x-pos.x) <= min.x &&
+ fabs(p.y-pos.y) <= min.y &&
+ fabs(p.z-pos.z) <= min.z )
{
center.x += p.x;
center.y += p.y;
@@ -1650,7 +1650,7 @@ D3DVECTOR CModel::RetMappingCenter(D3DVECTOR pos, D3DVECTOR min)
// Maps a texture onto the selected triangles.
void CModel::MappingSelectCylindrical(int mode, int rotate, bool bMirrorX, bool bMirrorY,
- FPOINT ti, FPOINT ts, char *texName)
+ Math::Point ti, Math::Point ts, char *texName)
{
D3DVERTEX2 vertex;
D3DVECTOR min, max, center, local, dim, p, pp, box;
@@ -1660,16 +1660,16 @@ void CModel::MappingSelectCylindrical(int mode, int rotate, bool bMirrorX, bool
BBoxCompute(min, max);
center = (min+max)/2.0f;
dim = (max-min)/2.0f;
- radius = Min(dim.x, dim.y, dim.z);
+ radius = Math::Min(dim.x, dim.y, dim.z);
if ( bMirrorX )
{
- Swap(ti.x, ts.x);
+ Math::Swap(ti.x, ts.x);
}
if ( !bMirrorY ) // reverse test!
{
- Swap(ti.y, ts.y);
+ Math::Swap(ti.y, ts.y);
}
if ( rotate == 0 )
@@ -1721,23 +1721,23 @@ void CModel::MappingSelectCylindrical(int mode, int rotate, bool bMirrorX, bool
if ( rotate == 0 )
{
- u = RotateAngle(pp.y, pp.z);
+ u = Math::RotateAngle(pp.y, pp.z);
v = p.x/dim.x/2.0f + 0.5f;
}
if ( rotate == 1 )
{
- u = RotateAngle(pp.x, pp.z);
+ u = Math::RotateAngle(pp.x, pp.z);
v = p.y/dim.y/2.0f + 0.5f;
}
if ( rotate == 2 )
{
- u = RotateAngle(pp.x, pp.y);
+ u = Math::RotateAngle(pp.x, pp.y);
v = p.z/dim.z/2.0f + 0.5f;
}
-//? if ( u < PI ) u = u/PI;
-//? else u = 2.0f-u/PI;
- u = u/(PI*2.0f);
+//? if ( u < Math::PI ) u = u/Math::PI;
+//? else u = 2.0f-u/Math::PI;
+ u = u/(Math::PI*2.0f);
vertex.tu = ti.x+(ts.x-ti.x)*u;
vertex.tv = ti.y+(ts.y-ti.y)*v;
@@ -1752,7 +1752,7 @@ void CModel::MappingSelectCylindrical(int mode, int rotate, bool bMirrorX, bool
// Maps a texture onto the selected triangles.
void CModel::MappingSelectFace(int mode, int rotate, bool bMirrorX, bool bMirrorY,
- FPOINT ti, FPOINT ts, char *texName)
+ Math::Point ti, Math::Point ts, char *texName)
{
D3DVERTEX2 vertex[3];
D3DVECTOR min, max, center, local, dim, p;
@@ -1762,16 +1762,16 @@ void CModel::MappingSelectFace(int mode, int rotate, bool bMirrorX, bool bMirror
BBoxCompute(min, max);
center = (min+max)/2.0f;
dim = (max-min)/2.0f;
- radius = Min(dim.x, dim.y, dim.z);
+ radius = Math::Min(dim.x, dim.y, dim.z);
if ( bMirrorX )
{
- Swap(ti.x, ts.x);
+ Math::Swap(ti.x, ts.x);
}
if ( !bMirrorY ) // reverse test!
{
- Swap(ti.y, ts.y);
+ Math::Swap(ti.y, ts.y);
}
used = m_modFile->RetTriangleUsed();
@@ -1786,10 +1786,10 @@ void CModel::MappingSelectFace(int mode, int rotate, bool bMirrorX, bool bMirror
p.z = vertex[j].z - center.z;
#if 0
- u[j] = RotateAngle(p.x, p.z)/(PI*2.0f)+0.5f;
+ u[j] = Math::RotateAngle(p.x, p.z)/(Math::PI*2.0f)+0.5f;
if ( u[j] > 1.0f ) u[j] -= 1.0f;
#else
- u[j] = RotateAngle(p.x, p.z)/PI;
+ u[j] = Math::RotateAngle(p.x, p.z)/Math::PI;
//? if ( u[j] > 1.0f ) u[j] = 2.0f-u[j];
if ( u[j] > 1.0f ) u[j] -= 1.0f;
#endif
@@ -1870,24 +1870,24 @@ void CModel::MappingSelect2(int texNum2, int subdiv,
p.y = vertex.y-center.y;
p.z = vertex.z-center.z;
- u = RotateAngle(p.x, p.z);
- v = RotateAngle(Length(p.x, p.z), p.y);
- if ( p.x < 0.0f ) v += PI;
+ u = Math::RotateAngle(p.x, p.z);
+ v = Math::RotateAngle(Length(p.x, p.z), p.y);
+ if ( p.x < 0.0f ) v += Math::PI;
- u = NormAngle(u+(float)offsetU*PI/180.0f);
- v = NormAngle(v+(float)offsetV*PI/180.0f);
+ u = Math::NormAngle(u+(float)offsetU*Math::PI/180.0f);
+ v = Math::NormAngle(v+(float)offsetV*Math::PI/180.0f);
if ( subdiv == 1 )
{
- u = u/(PI*2.0f);
- v = v/(PI*2.0f);
+ u = u/(Math::PI*2.0f);
+ v = v/(Math::PI*2.0f);
}
if ( subdiv == 2 )
{
- if ( u < PI ) u = u/PI;
- else u = (PI*2.0f-u)/PI;
- if ( v < PI ) v = v/PI;
- else v = (PI*2.0f-v)/PI;
+ if ( u < Math::PI ) u = u/Math::PI;
+ else u = (Math::PI*2.0f-u)/Math::PI;
+ if ( v < Math::PI ) v = v/Math::PI;
+ else v = (Math::PI*2.0f-v)/Math::PI;
}
vertex.tu2 = u;
@@ -1905,12 +1905,12 @@ void CModel::MappingSelectPlane2(int mode, bool bMirrorX, bool bMirrorY)
{
D3DVERTEX2 vertex;
D3DVECTOR min, max;
- FPOINT ti, ts, a, b;
+ Math::Point ti, ts, a, b;
float au, bu, av, bv;
int used, i;
- ti = FPOINT(0.0f, 0.0f);
- ts = FPOINT(1.0f, 1.0f);
+ ti = Math::Point(0.0f, 0.0f);
+ ts = Math::Point(1.0f, 1.0f);
BBoxCompute(min, max);
@@ -1938,12 +1938,12 @@ void CModel::MappingSelectPlane2(int mode, bool bMirrorX, bool bMirrorY)
if ( bMirrorX )
{
- Swap(ti.x, ts.x);
+ Math::Swap(ti.x, ts.x);
}
if ( !bMirrorY ) // reverse test!
{
- Swap(ti.y, ts.y);
+ Math::Swap(ti.y, ts.y);
}
au = (ts.x-ti.x)/(b.x-a.x);
@@ -1985,26 +1985,26 @@ void CModel::MappingSelectSpherical2(bool bMirrorX, bool bMirrorY)
{
D3DVERTEX2 vertex;
D3DVECTOR min, max, center, dim, p;
- FPOINT ti, ts;
+ Math::Point ti, ts;
float radius, k, u, v;
int used, i;
BBoxCompute(min, max);
center = (min+max)/2.0f;
dim = (max-min)/2.0f;
- radius = Min(dim.x, dim.y, dim.z);
+ radius = Math::Min(dim.x, dim.y, dim.z);
- ti = FPOINT(0.0f, 0.0f);
- ts = FPOINT(1.0f, 1.0f);
+ ti = Math::Point(0.0f, 0.0f);
+ ts = Math::Point(1.0f, 1.0f);
if ( bMirrorX )
{
- Swap(ti.x, ts.x);
+ Math::Swap(ti.x, ts.x);
}
if ( !bMirrorY ) // reverse test!
{
- Swap(ti.y, ts.y);
+ Math::Swap(ti.y, ts.y);
}
used = m_modFile->RetTriangleUsed();
@@ -2037,22 +2037,22 @@ void CModel::MappingSelectMagic2(bool bMirrorX, bool bMirrorY)
{
D3DVERTEX2 vertex, v[3];
D3DVECTOR min, max, au, bu, av, bv, n;
- FPOINT ti, ts;
+ Math::Point ti, ts;
int used, i, mode;
- ti = FPOINT(0.0f, 0.0f);
- ts = FPOINT(1.0f, 1.0f);
+ ti = Math::Point(0.0f, 0.0f);
+ ts = Math::Point(1.0f, 1.0f);
BBoxCompute(min, max);
if ( bMirrorX )
{
- Swap(ti.x, ts.x);
+ Math::Swap(ti.x, ts.x);
}
if ( !bMirrorY ) // reverse test!
{
- Swap(ti.y, ts.y);
+ Math::Swap(ti.y, ts.y);
}
au.x = (ts.x-ti.x)/(max.x-min.x);
@@ -2082,13 +2082,13 @@ void CModel::MappingSelectMagic2(bool bMirrorX, bool bMirrorY)
D3DVECTOR(v[1].x, v[1].y, v[1].z),
D3DVECTOR(v[2].x, v[2].y, v[2].z));
- n.x = Abs(n.x);
- n.y = Abs(n.y);
- n.z = Abs(n.z);
+ n.x = fabs(n.x);
+ n.y = fabs(n.y);
+ n.z = fabs(n.z);
- if ( n.x >= Max(n.y, n.z) ) mode = 0;
- if ( n.y >= Max(n.x, n.z) ) mode = 1;
- if ( n.z >= Max(n.x, n.y) ) mode = 2;
+ if ( n.x >= Math::Max(n.y, n.z) ) mode = 0;
+ if ( n.y >= Math::Max(n.x, n.z) ) mode = 1;
+ if ( n.z >= Math::Max(n.x, n.y) ) mode = 2;
}
if ( !GetVertex(i, vertex) ) continue;
@@ -2429,20 +2429,20 @@ void CModel::InitViewFromSelect()
n = RetSelectNormal();
- m_viewAngleH = RotateAngle(n.x, n.z)+PI;
- m_viewAngleV = RotateAngle(sqrtf(n.x*n.x+n.z*n.z), n.y)+PI;
+ m_viewAngleH = Math::RotateAngle(n.x, n.z)+Math::PI;
+ m_viewAngleV = Math::RotateAngle(sqrtf(n.x*n.x+n.z*n.z), n.y)+Math::PI;
h = m_viewAngleH;
v = m_viewAngleV;
- while ( m_viewAngleV <= -PI )
+ while ( m_viewAngleV <= -Math::PI )
{
- m_viewAngleV += PI;
- m_viewAngleH += PI;
+ m_viewAngleV += Math::PI;
+ m_viewAngleH += Math::PI;
}
- while ( m_viewAngleV >= PI )
+ while ( m_viewAngleV >= Math::PI )
{
- m_viewAngleV -= PI;
- m_viewAngleH -= PI;
+ m_viewAngleV -= Math::PI;
+ m_viewAngleH -= Math::PI;
}
m_viewAngleV *= 0.75f;
@@ -2484,7 +2484,7 @@ void CModel::ViewMove(const Event &event, float speed)
else
{
m_viewAngleV -= event.rTime*1.0f*speed;
- if ( m_viewAngleV < -PI*0.49f ) m_viewAngleV = -PI*0.49f;
+ if ( m_viewAngleV < -Math::PI*0.49f ) m_viewAngleV = -Math::PI*0.49f;
}
}
if ( event.axeY < -0.5f )
@@ -2497,7 +2497,7 @@ void CModel::ViewMove(const Event &event, float speed)
else
{
m_viewAngleV += event.rTime*1.0f*speed;
- if ( m_viewAngleV > PI*0.49f ) m_viewAngleV = PI*0.49f;
+ if ( m_viewAngleV > Math::PI*0.49f ) m_viewAngleV = Math::PI*0.49f;
}
}
@@ -2564,7 +2564,7 @@ void CModel::UpdateInfoText()
if ( m_mode == 3 )
{
- sprintf(info, "[3] LOD Min/max=%d..%d Sel=%d..%d (T=%d)",
+ sprintf(info, "[3] LOD Math::Min/max=%d..%d Sel=%d..%d (T=%d)",
(int)m_min, (int)m_max,
m_triangleSel1, m_triangleSel2,
m_triangleSel2-m_triangleSel1+1);
diff --git a/src/graphics/common/model.h b/src/graphics/common/model.h
index 30daf24..385f4e1 100644
--- a/src/graphics/common/model.h
+++ b/src/graphics/common/model.h
@@ -19,7 +19,9 @@
#pragma once
-#include "common/struct.h"
+#include "common/event.h"
+#include "common/modfile.h"
+#include "math/point.h"
class CInstanceManager;
@@ -60,11 +62,11 @@ protected:
void ReadScript(char *filename);
void BBoxCompute(D3DVECTOR &min, D3DVECTOR &max);
bool IsMappingSelectPlausible(D3DMaping D3Dmode);
- void MappingSelect(int mode, int rotate, bool bMirrorX, bool bMirrorY, FPOINT ti, FPOINT ts, char *texName);
- void MappingSelectSpherical(int mode, int rotate, bool bMirrorX, bool bMirrorY, FPOINT ti, FPOINT ts, char *texName);
+ void MappingSelect(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
+ void MappingSelectSpherical(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
D3DVECTOR RetMappingCenter(D3DVECTOR pos, D3DVECTOR min);
- void MappingSelectCylindrical(int mode, int rotate, bool bMirrorX, bool bMirrorY, FPOINT ti, FPOINT ts, char *texName);
- void MappingSelectFace(int mode, int rotate, bool bMirrorX, bool bMirrorY, FPOINT ti, FPOINT ts, char *texName);
+ void MappingSelectCylindrical(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
+ void MappingSelectFace(int mode, int rotate, bool bMirrorX, bool bMirrorY, Math::Point ti, Math::Point ts, char *texName);
void MappingSelect2(int texNum2, int subdiv, int offsetU, int offsetV, bool bMirrorX, bool bMirrorY);
void MappingSelectPlane2(int mode, bool bMirrorX, bool bMirrorY);
void MappingSelectSpherical2(bool bMirrorX, bool bMirrorY);
@@ -110,8 +112,8 @@ protected:
int m_textureRotate;
bool m_bTextureMirrorX;
bool m_bTextureMirrorY;
- FPOINT m_textureInf;
- FPOINT m_textureSup;
+ Math::Point m_textureInf;
+ Math::Point m_textureSup;
int m_texturePart;
int m_textureRank;
char m_textureName[20];
diff --git a/src/graphics/common/particule.cpp b/src/graphics/common/particule.cpp
index edf9c3d..6359ddf 100644
--- a/src/graphics/common/particule.cpp
+++ b/src/graphics/common/particule.cpp
@@ -16,14 +16,14 @@
// particule.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "math/old/d3dmath.h"
#include "graphics/d3d/d3dtextr.h"
#include "graphics/d3d/d3dengine.h"
@@ -249,7 +249,7 @@ void NameParticule(char *buffer, int num)
// Creates a new particle.
// Returns the channel of the particle created or -1 on error.
-int CParticule::CreateParticule(D3DVECTOR pos, D3DVECTOR speed, FPOINT dim,
+int CParticule::CreateParticule(D3DVECTOR pos, D3DVECTOR speed, Math::Point dim,
ParticuleType type,
float duration, float mass,
float windSensitivity, int sheet)
@@ -428,7 +428,7 @@ int CParticule::CreateParticule(D3DVECTOR pos, D3DVECTOR speed, FPOINT dim,
if ( type == PARTIEXPLOT ||
type == PARTIEXPLOO )
{
- m_particule[i].angle = Rand()*PI*2.0f;
+ m_particule[i].angle = Math::Rand()*Math::PI*2.0f;
}
if ( type == PARTIGUN1 ||
@@ -516,8 +516,8 @@ int CParticule::CreateFrag(D3DVECTOR pos, D3DVECTOR speed,
l1 = Length(p1, p2);
l2 = Length(p2, p3);
l3 = Length(p3, p1);
- dx = Abs(Min(l1, l2, l3))*0.5f;
- dy = Abs(Max(l1, l2, l3))*0.5f;
+ dx = fabs(Math::Min(l1, l2, l3))*0.5f;
+ dy = fabs(Math::Max(l1, l2, l3))*0.5f;
p1 = D3DVECTOR(-dx, dy, 0.0f);
p2 = D3DVECTOR( dx, dy, 0.0f);
p3 = D3DVECTOR(-dx, -dy, 0.0f);
@@ -550,7 +550,7 @@ int CParticule::CreateFrag(D3DVECTOR pos, D3DVECTOR speed,
if ( type == PARTIFRAG )
{
- m_particule[i].angle = Rand()*PI*2.0f;
+ m_particule[i].angle = Math::Rand()*Math::PI*2.0f;
}
return i | ((m_particule[i].uniqueStamp&0xffff)<<16);
}
@@ -615,7 +615,7 @@ int CParticule::CreatePart(D3DVECTOR pos, D3DVECTOR speed,
// Returns the channel of the particle created or -1 on error.
int CParticule::CreateRay(D3DVECTOR pos, D3DVECTOR goal,
- ParticuleType type, FPOINT dim,
+ ParticuleType type, Math::Point dim,
float duration, int sheet)
{
int i, j, t;
@@ -677,7 +677,7 @@ int CParticule::CreateRay(D3DVECTOR pos, D3DVECTOR goal,
// Creates a particle with a trail.
// "length" is the length of the tail of drag (in seconds)!
-int CParticule::CreateTrack(D3DVECTOR pos, D3DVECTOR speed, FPOINT dim,
+int CParticule::CreateTrack(D3DVECTOR pos, D3DVECTOR speed, Math::Point dim,
ParticuleType type, float duration, float mass,
float length, float width)
{
@@ -872,7 +872,7 @@ void CParticule::SetPosition(int channel, D3DVECTOR pos)
m_particule[channel].pos = pos;
}
-void CParticule::SetDimension(int channel, FPOINT dim)
+void CParticule::SetDimension(int channel, Math::Point dim)
{
if ( !CheckChannel(channel) ) return;
m_particule[channel].dim = dim;
@@ -896,7 +896,7 @@ void CParticule::SetIntensity(int channel, float intensity)
m_particule[channel].intensity = intensity;
}
-void CParticule::SetParam(int channel, D3DVECTOR pos, FPOINT dim, float zoom,
+void CParticule::SetParam(int channel, D3DVECTOR pos, Math::Point dim, float zoom,
float angle, float intensity)
{
if ( !CheckChannel(channel) ) return;
@@ -938,7 +938,7 @@ void CParticule::FrameParticule(float rTime)
{
CObject* object;
D3DVECTOR eye, pos, speed, wind;
- FPOINT ts, ti, dim;
+ Math::Point ts, ti, dim;
bool bPause;
float progress, dp, h, duration, mass, amplitude;
int i, j, r, total;
@@ -985,7 +985,7 @@ void CParticule::FrameParticule(float rTime)
if ( m_particule[i].sheet == SH_WORLD )
{
- h = rTime*m_particule[i].windSensitivity*Rand()*2.0f;
+ h = rTime*m_particule[i].windSensitivity*Math::Rand()*2.0f;
m_particule[i].pos += wind*h;
}
@@ -1185,7 +1185,7 @@ void CParticule::FrameParticule(float rTime)
}
m_particule[i].zoom = 1.0f-progress;
- m_particule[i].angle = Rand()*PI*2.0f;
+ m_particule[i].angle = Math::Rand()*Math::PI*2.0f;
ts.x = 0.125f;
ts.y = 0.750f;
@@ -1316,9 +1316,9 @@ void CParticule::FrameParticule(float rTime)
speed.x = 0.0f;
speed.z = 0.0f;
speed.y = 0.0f;
- dim.x = Rand()*6.0f+6.0f;
+ dim.x = Math::Rand()*6.0f+6.0f;
dim.y = dim.x;
- duration = Rand()*1.0f+1.0f;
+ duration = Math::Rand()*1.0f+1.0f;
mass = 0.0f;
CreateParticule(pos, speed, dim, PARTIEXPLOG1, duration, mass, 1.0f);
@@ -1326,13 +1326,13 @@ void CParticule::FrameParticule(float rTime)
total = (int)(2.0f*m_engine->RetParticuleDensity());
for ( j=0 ; j<total ; j++ )
{
- speed.x = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
- speed.y = Rand()*20.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
+ speed.y = Math::Rand()*20.0f;
dim.x = 1.0f;
dim.y = dim.x;
- duration = Rand()*1.0f+1.0f;
- mass = Rand()*10.0f+15.0f;
+ duration = Math::Rand()*1.0f+1.0f;
+ mass = Math::Rand()*10.0f+15.0f;
CreateParticule(pos, speed, dim, PARTIEXPLOG1, duration, mass, 1.0f);
}
}
@@ -1360,9 +1360,9 @@ void CParticule::FrameParticule(float rTime)
speed.x = 0.0f;
speed.z = 0.0f;
speed.y = 0.0f;
- dim.x = Rand()*6.0f+6.0f;
+ dim.x = Math::Rand()*6.0f+6.0f;
dim.y = dim.x;
- duration = Rand()*1.0f+1.0f;
+ duration = Math::Rand()*1.0f+1.0f;
mass = 0.0f;
CreateParticule(pos, speed, dim, PARTIEXPLOG1, duration, mass, 1.0f);
@@ -1370,13 +1370,13 @@ void CParticule::FrameParticule(float rTime)
total = (int)(2.0f*m_engine->RetParticuleDensity());
for ( j=0 ; j<total ; j++ )
{
- speed.x = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
- speed.y = Rand()*20.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
+ speed.y = Math::Rand()*20.0f;
dim.x = 1.0f;
dim.y = dim.x;
- duration = Rand()*1.0f+1.0f;
- mass = Rand()*10.0f+15.0f;
+ duration = Math::Rand()*1.0f+1.0f;
+ mass = Math::Rand()*10.0f+15.0f;
CreateParticule(pos, speed, dim, PARTIEXPLOG1, duration, mass, 1.0f);
}
}
@@ -1391,7 +1391,7 @@ void CParticule::FrameParticule(float rTime)
}
}
- m_particule[i].angle -= rTime*PI*8.0f;
+ m_particule[i].angle -= rTime*Math::PI*8.0f;
m_particule[i].zoom = 1.0f-progress;
ts.x = 0.00f;
@@ -1417,7 +1417,7 @@ void CParticule::FrameParticule(float rTime)
{
if ( object->RetShieldRadius() > 0.0f ) // protected by shield?
{
- CreateParticule(m_particule[i].pos, D3DVECTOR(0.0f, 0.0f, 0.0f), FPOINT(6.0f, 6.0f), PARTIGUNDEL, 2.0f);
+ CreateParticule(m_particule[i].pos, D3DVECTOR(0.0f, 0.0f, 0.0f), Math::Point(6.0f, 6.0f), PARTIGUNDEL, 2.0f);
if ( m_lastTimeGunDel > 0.2f )
{
m_lastTimeGunDel = 0.0f;
@@ -1437,7 +1437,7 @@ void CParticule::FrameParticule(float rTime)
}
}
- m_particule[i].angle = Rand()*PI*2.0f;
+ m_particule[i].angle = Math::Rand()*Math::PI*2.0f;
m_particule[i].zoom = 1.0f-progress;
ts.x = 0.125f;
@@ -1463,7 +1463,7 @@ void CParticule::FrameParticule(float rTime)
{
if ( object->RetShieldRadius() > 0.0f )
{
- CreateParticule(m_particule[i].pos, D3DVECTOR(0.0f, 0.0f, 0.0f), FPOINT(6.0f, 6.0f), PARTIGUNDEL, 2.0f);
+ CreateParticule(m_particule[i].pos, D3DVECTOR(0.0f, 0.0f, 0.0f), Math::Point(6.0f, 6.0f), PARTIGUNDEL, 2.0f);
if ( m_lastTimeGunDel > 0.2f )
{
m_lastTimeGunDel = 0.0f;
@@ -1510,9 +1510,9 @@ void CParticule::FrameParticule(float rTime)
speed.x = 0.0f;
speed.z = 0.0f;
speed.y = 0.0f;
- dim.x = Rand()*4.0f+2.0f;
+ dim.x = Math::Rand()*4.0f+2.0f;
dim.y = dim.x;
- duration = Rand()*0.7f+0.7f;
+ duration = Math::Rand()*0.7f+0.7f;
mass = 0.0f;
CreateParticule(pos, speed, dim, PARTIEXPLOG2, duration, mass, 1.0f);
}
@@ -1540,9 +1540,9 @@ void CParticule::FrameParticule(float rTime)
speed.x = 0.0f;
speed.z = 0.0f;
speed.y = 0.0f;
- dim.x = Rand()*4.0f+2.0f;
+ dim.x = Math::Rand()*4.0f+2.0f;
dim.y = dim.x;
- duration = Rand()*0.7f+0.7f;
+ duration = Math::Rand()*0.7f+0.7f;
mass = 0.0f;
CreateParticule(pos, speed, dim, PARTIEXPLOG2, duration, mass, 1.0f);
}
@@ -1557,7 +1557,7 @@ void CParticule::FrameParticule(float rTime)
}
}
- m_particule[i].angle = Rand()*PI*2.0f;
+ m_particule[i].angle = Math::Rand()*Math::PI*2.0f;
m_particule[i].zoom = 1.0f-progress;
ts.x = 0.125f;
@@ -1594,7 +1594,7 @@ void CParticule::FrameParticule(float rTime)
if ( progress < 0.5f ) m_particule[i].intensity = progress/0.5f;
else m_particule[i].intensity = 2.0f-progress/0.5f;
m_particule[i].zoom = 1.0f-progress*0.8f;
- m_particule[i].angle -= rTime*PI*0.5f;
+ m_particule[i].angle -= rTime*Math::PI*0.5f;
ts.x = 0.50f;
ts.y = 0.00f;
@@ -1629,7 +1629,7 @@ void CParticule::FrameParticule(float rTime)
m_particule[i].zoom = 0.1f+progress;
m_particule[i].intensity = 1.0f-progress;
- m_particule[i].angle -= rTime*PI*2.0f;
+ m_particule[i].angle -= rTime*Math::PI*2.0f;
ts.x = 0.00f;
ts.y = 0.50f;
@@ -1971,7 +1971,7 @@ void CParticule::FrameParticule(float rTime)
{
m_particule[i].intensity = 1.0f-(progress-0.25f)/0.75f;
}
- m_particule[i].angle += rTime*PI*1.0f;
+ m_particule[i].angle += rTime*Math::PI*1.0f;
if ( m_particule[i].type == PARTIVIRUS1 ) // A ?
{
@@ -2122,7 +2122,7 @@ void CParticule::FrameParticule(float rTime)
if ( m_particule[i].type == PARTIFRAG )
{
- m_particule[i].angle += rTime*PI*0.5f;
+ m_particule[i].angle += rTime*Math::PI*0.5f;
ts.x = 0.0f;
ts.y = 0.0f;
@@ -2145,12 +2145,12 @@ void CParticule::FrameParticule(float rTime)
m_particule[i].testTime = 0.0f;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
pos = m_particule[i].pos;
//? speed = -m_particule[i].speed*0.5f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = 1.0f*(Rand()*0.8f+0.6f);
+ dim.x = 1.0f*(Math::Rand()*0.8f+0.6f);
dim.y = dim.x;
CreateParticule(pos, speed, dim, PARTIGAS, 0.5f);
}
@@ -2175,18 +2175,18 @@ void CParticule::FrameParticule(float rTime)
total = (int)(10.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<total ; i++ )
{
- speed.x = (Rand()-0.5f)*20.0f;
- speed.y = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.y = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
CreateParticule(pos, speed, dim, PARTIORGANIC2, duration, mass);
}
total = (int)(5.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<total ; i++ )
{
- speed.x = (Rand()-0.5f)*20.0f;
- speed.y = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
- duration *= Rand()+0.8f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.y = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
+ duration *= Math::Rand()+0.8f;
CreateTrack(pos, speed, dim, PARTITRACK4, duration, mass, duration*0.2f, dim.x*2.0f);
}
continue;
@@ -2229,7 +2229,7 @@ void CParticule::FrameParticule(float rTime)
//? m_particule[i].zoom = 1.0f-(m_particule[i].time-m_particule[i].duration/2.0f);
m_particule[i].zoom = 1.0f-(progress-0.5f)*2.0f;
}
- m_particule[i].angle = m_particule[i].time*PI;
+ m_particule[i].angle = m_particule[i].time*Math::PI;
ts.x = 0.75f;
ts.y = 0.25f;
@@ -2249,7 +2249,7 @@ void CParticule::FrameParticule(float rTime)
{
m_particule[i].zoom = 1.0f-(progress-0.5f)*2.0f;
}
- m_particule[i].angle = m_particule[i].time*PI;
+ m_particule[i].angle = m_particule[i].time*Math::PI;
ts.x = 0.75f;
ts.y = 0.50f;
@@ -2269,7 +2269,7 @@ void CParticule::FrameParticule(float rTime)
{
m_particule[i].zoom = 1.0f-(progress-0.5f)*2.0f;
}
- m_particule[i].angle = m_particule[i].time*PI;
+ m_particule[i].angle = m_particule[i].time*Math::PI;
ts.x = 0.75f;
ts.y = 0.00f;
@@ -2294,7 +2294,7 @@ void CParticule::FrameParticule(float rTime)
{
m_particule[i].intensity = 1.0f-(progress-0.5f)*2.0f;
}
-//? m_particule[i].angle = m_particule[i].time*PI;
+//? m_particule[i].angle = m_particule[i].time*Math::PI;
ts.x = 0.25f*(m_particule[i].type-PARTILENS1);
ts.y = 0.25f;
@@ -2338,7 +2338,7 @@ void CParticule::FrameParticule(float rTime)
{
m_particule[i].zoom = 1.0f-(m_particule[i].time-m_particule[i].duration/2.0f);
}
- m_particule[i].angle = m_particule[i].time*PI;
+ m_particule[i].angle = m_particule[i].time*Math::PI;
ts.x = 0.75f;
ts.y = 0.50f;
@@ -2351,11 +2351,11 @@ void CParticule::FrameParticule(float rTime)
if ( progress >= 1.0f )
{
m_particule[i].time = 0.0f;
- m_particule[i].duration = 0.5f+Rand()*2.0f;
- m_particule[i].pos.x = m_particule[i].speed.x + (Rand()-0.5f)*m_particule[i].mass;
- m_particule[i].pos.y = m_particule[i].speed.y + (Rand()-0.5f)*m_particule[i].mass;
- m_particule[i].pos.z = m_particule[i].speed.z + (Rand()-0.5f)*m_particule[i].mass;
- m_particule[i].dim.x = 0.5f+Rand()*1.5f;
+ m_particule[i].duration = 0.5f+Math::Rand()*2.0f;
+ m_particule[i].pos.x = m_particule[i].speed.x + (Math::Rand()-0.5f)*m_particule[i].mass;
+ m_particule[i].pos.y = m_particule[i].speed.y + (Math::Rand()-0.5f)*m_particule[i].mass;
+ m_particule[i].pos.z = m_particule[i].speed.z + (Math::Rand()-0.5f)*m_particule[i].mass;
+ m_particule[i].dim.x = 0.5f+Math::Rand()*1.5f;
m_particule[i].dim.y = m_particule[i].dim.x;
progress = 0.0f;
}
@@ -2511,7 +2511,7 @@ void CParticule::FrameParticule(float rTime)
m_particule[i].intensity = 1.0f-(progress-0.30f)/0.70f;
}
m_particule[i].zoom = progress*m_particule[i].dim.x;
- m_particule[i].angle = m_particule[i].time*PI*2.0f;
+ m_particule[i].angle = m_particule[i].time*Math::PI*2.0f;
ts.x = 0.000f;
ts.y = 0.000f;
@@ -2536,7 +2536,7 @@ void CParticule::FrameParticule(float rTime)
m_particule[i].intensity = 1.0f-(progress-0.20f)/0.80f;
}
m_particule[i].zoom = progress*m_particule[i].dim.x;
- m_particule[i].angle = m_particule[i].time*PI*2.0f;
+ m_particule[i].angle = m_particule[i].time*Math::PI*2.0f;
ts.x = 0.125f;
ts.y = 0.000f;
@@ -2568,7 +2568,7 @@ void CParticule::FrameParticule(float rTime)
}
m_particule[i].zoom = m_particule[i].dim.x;
- m_particule[i].angle = m_particule[i].time*PI*0.2f;
+ m_particule[i].angle = m_particule[i].time*Math::PI*0.2f;
ts.x = 0.25f;
ts.y = 0.75f;
@@ -2605,7 +2605,7 @@ void CParticule::FrameParticule(float rTime)
{
m_particule[i].intensity = 0.7f+sinf(progress)*0.3f;
m_particule[i].zoom = m_particule[i].dim.x*(1.0f+sinf(progress*0.7f)*0.01f);
- m_particule[i].angle = m_particule[i].time*PI*0.2f;
+ m_particule[i].angle = m_particule[i].time*Math::PI*0.2f;
ts.x = 0.25f;
ts.y = 0.50f;
@@ -2799,7 +2799,7 @@ void CParticule::TrackDraw(int i, ParticuleType type)
D3DVERTEX2 vertex[4]; // 2 triangles
D3DVECTOR corner[4], p1, p2, p, n, eye;
D3DMATRIX matrix;
- FPOINT texInf, texSup, rot;
+ Math::Point texInf, texSup, rot;
float lTotal, f1, f2, a;
int counter, h;
@@ -2905,7 +2905,7 @@ void CParticule::TrackDraw(int i, ParticuleType type)
f1 = m_track[i].intensity;
eye = m_engine->RetEyePt();
- a = RotateAngle(eye.x-p1.x, eye.z-p1.z);
+ a = Math::RotateAngle(eye.x-p1.x, eye.z-p1.z);
for ( counter=0 ; counter<m_track[i].used-1 ; counter++ )
{
@@ -2918,22 +2918,22 @@ void CParticule::TrackDraw(int i, ParticuleType type)
p = p1;
p.x += f1*m_track[i].width;
- rot = RotatePoint(FPOINT(p1.x, p1.z), a+PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[0].x = rot.x;
corner[0].y = p1.y;
corner[0].z = rot.y;
- rot = RotatePoint(FPOINT(p1.x, p1.z), a-PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[1].x = rot.x;
corner[1].y = p1.y;
corner[1].z = rot.y;
p = p2;
p.x += f2*m_track[i].width;
- rot = RotatePoint(FPOINT(p2.x, p2.z), a+PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[2].x = rot.x;
corner[2].y = p2.y;
corner[2].z = rot.y;
- rot = RotatePoint(FPOINT(p2.x, p2.z), a-PI/2.0f, FPOINT(p.x, p.z));
+ rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[3].x = rot.x;
corner[3].y = p2.y;
corner[3].z = rot.y;
@@ -2981,8 +2981,8 @@ void CParticule::DrawParticuleTriangle(int i)
pos += object->RetPosition(0);
}
- angle.x = -RotateAngle(Length2d(pos, eye), pos.y-eye.y);
- angle.y = RotateAngle(pos.z-eye.z, pos.x-eye.x);
+ angle.x = -Math::RotateAngle(Length2d(pos, eye), pos.y-eye.y);
+ angle.y = Math::RotateAngle(pos.z-eye.z, pos.x-eye.x);
angle.z = m_particule[i].angle;
MatRotateXZY(matrix, angle);
@@ -3004,7 +3004,7 @@ void CParticule::DrawParticuleNorm(int i)
D3DVERTEX2 vertex[4]; // 2 triangles
D3DMATRIX matrix;
D3DVECTOR corner[4], eye, pos, n, angle;
- FPOINT dim;
+ Math::Point dim;
float zoom;
zoom = m_particule[i].zoom;
@@ -3060,8 +3060,8 @@ void CParticule::DrawParticuleNorm(int i)
pos += object->RetPosition(0);
}
- angle.x = -RotateAngle(Length2d(pos, eye), pos.y-eye.y);
- angle.y = RotateAngle(pos.z-eye.z, pos.x-eye.x);
+ angle.x = -Math::RotateAngle(Length2d(pos, eye), pos.y-eye.y);
+ angle.y = Math::RotateAngle(pos.z-eye.z, pos.x-eye.x);
angle.z = m_particule[i].angle;
MatRotateXZY(matrix, angle);
@@ -3109,7 +3109,7 @@ void CParticule::DrawParticuleFlat(int i)
D3DVERTEX2 vertex[4]; // 2 triangles
D3DMATRIX matrix;
D3DVECTOR corner[4], pos, n, angle, eye;
- FPOINT dim;
+ Math::Point dim;
if ( m_particule[i].zoom == 0.0f ) return;
if ( m_particule[i].intensity == 0.0f ) return;
@@ -3122,14 +3122,14 @@ void CParticule::DrawParticuleFlat(int i)
pos += object->RetPosition(0);
}
- angle.x = PI/2.0f;
+ angle.x = Math::PI/2.0f;
angle.y = 0.0f;
angle.z = m_particule[i].angle;
#if 0
if ( m_engine->RetRankView() == 1 ) // underwater?
{
- angle.x = -PI/2.0f;
+ angle.x = -Math::PI/2.0f;
pos.y -= 1.0f;
}
#else
@@ -3141,7 +3141,7 @@ void CParticule::DrawParticuleFlat(int i)
eye = m_engine->RetEyePt();
if ( pos.y > eye.y ) // seen from below?
{
- angle.x = -PI/2.0f;
+ angle.x = -Math::PI/2.0f;
}
#endif
@@ -3189,7 +3189,7 @@ void CParticule::DrawParticuleFog(int i)
D3DVERTEX2 vertex[4]; // 2 triangles
D3DMATRIX matrix;
D3DVECTOR corner[4], pos, n, angle, eye;
- FPOINT dim, zoom;
+ Math::Point dim, zoom;
if ( !m_engine->RetFog() ) return;
if ( m_particule[i].intensity == 0.0f ) return;
@@ -3229,7 +3229,7 @@ void CParticule::DrawParticuleFog(int i)
pos += object->RetPosition(0);
}
- angle.x = PI/2.0f;
+ angle.x = Math::PI/2.0f;
angle.y = 0.0f;
angle.z = m_particule[i].angle;
@@ -3241,7 +3241,7 @@ void CParticule::DrawParticuleFog(int i)
eye = m_engine->RetEyePt();
if ( pos.y > eye.y ) // seen from below?
{
- angle.x = -PI/2.0f;
+ angle.x = -Math::PI/2.0f;
}
MatRotateXZY(matrix, angle);
@@ -3285,7 +3285,7 @@ void CParticule::DrawParticuleRay(int i)
D3DVERTEX2 vertex[4]; // 2 triangles
D3DMATRIX matrix;
D3DVECTOR corner[4], eye, pos, goal, n, angle, proj;
- FPOINT dim, texInf, texSup;
+ Math::Point dim, texInf, texSup;
bool bLeft;
float a, len, adv, prop, vario1, vario2;
int r, rank, step, first, last;
@@ -3303,13 +3303,13 @@ void CParticule::DrawParticuleRay(int i)
pos += object->RetPosition(0);
}
- a = RotateAngle(FPOINT(pos.x,pos.z), FPOINT(goal.x,goal.z), FPOINT(eye.x,eye.z));
- bLeft = (a < PI);
+ a = Math::RotateAngle(Math::Point(pos.x,pos.z), Math::Point(goal.x,goal.z), Math::Point(eye.x,eye.z));
+ bLeft = (a < Math::PI);
proj = Projection(pos, goal, eye);
- angle.x = -RotateAngle(Length2d(proj, eye), proj.y-eye.y);
- angle.y = RotateAngle(pos.z-goal.z, pos.x-goal.x)+PI/2.0f;
- angle.z = -RotateAngle(Length2d(pos, goal), pos.y-goal.y);
+ angle.x = -Math::RotateAngle(Length2d(proj, eye), proj.y-eye.y);
+ angle.y = Math::RotateAngle(pos.z-goal.z, pos.x-goal.x)+Math::PI/2.0f;
+ angle.z = -Math::RotateAngle(Length2d(pos, goal), pos.y-goal.y);
if ( bLeft ) angle.x = -angle.x;
MatRotateZXY(matrix, angle);
@@ -3393,22 +3393,22 @@ void CParticule::DrawParticuleRay(int i)
corner[2].x = adv;
corner[0].y = dim.y;
corner[2].y = -dim.y;
- corner[0].z = (Rand()-0.5f)*vario1;
- corner[1].z = (Rand()-0.5f)*vario1;
- corner[2].z = (Rand()-0.5f)*vario1;
- corner[3].z = (Rand()-0.5f)*vario1;
+ corner[0].z = (Math::Rand()-0.5f)*vario1;
+ corner[1].z = (Math::Rand()-0.5f)*vario1;
+ corner[2].z = (Math::Rand()-0.5f)*vario1;
+ corner[3].z = (Math::Rand()-0.5f)*vario1;
for ( rank=0 ; rank<step ; rank++ )
{
corner[1].x = corner[0].x;
corner[3].x = corner[2].x;
- corner[0].x = adv+dim.x*2.0f+(Rand()-0.5f)*vario2;
- corner[2].x = adv+dim.x*2.0f+(Rand()-0.5f)*vario2;
+ corner[0].x = adv+dim.x*2.0f+(Math::Rand()-0.5f)*vario2;
+ corner[2].x = adv+dim.x*2.0f+(Math::Rand()-0.5f)*vario2;
corner[1].y = corner[0].y;
corner[3].y = corner[2].y;
- corner[0].y = dim.y+(Rand()-0.5f)*vario2;
- corner[2].y = -dim.y+(Rand()-0.5f)*vario2;
+ corner[0].y = dim.y+(Math::Rand()-0.5f)*vario2;
+ corner[2].y = -dim.y+(Math::Rand()-0.5f)*vario2;
if ( rank >= first && rank <= last )
{
@@ -3421,15 +3421,15 @@ void CParticule::DrawParticuleRay(int i)
texSup.x += 0.25f*(r/4);
if ( r%2 < 1 && adv > 0.0f && m_particule[i].type != PARTIRAY1 )
{
- Swap(texInf.x, texSup.x);
+ Math::Swap(texInf.x, texSup.x);
}
if ( r%4 < 2 )
{
- Swap(texInf.y, texSup.y);
+ Math::Swap(texInf.y, texSup.y);
}
#else
- texInf.x = Mod(texInf.x+0.25f, 1.0f);
- texSup.x = Mod(texSup.x+0.25f, 1.0f);
+ texInf.x = Math::Mod(texInf.x+0.25f, 1.0f);
+ texSup.x = Math::Mod(texSup.x+0.25f, 1.0f);
#endif
vertex[0] = D3DVERTEX2(corner[1], n, texSup.x, texSup.y);
@@ -3451,7 +3451,7 @@ void CParticule::DrawParticuleSphere(int i)
D3DVERTEX2 vertex[2*16*(16+1)]; // triangles
D3DMATRIX matrix, rot;
D3DVECTOR angle, v0, v1;
- FPOINT ts, ti;
+ Math::Point ts, ti;
float zoom, deltaRingAngle, deltaSegAngle;
float r0,r1, tu0,tv0, tu1,tv1;
int j, ring, seg, numRings, numSegments;
@@ -3506,8 +3506,8 @@ void CParticule::DrawParticuleSphere(int i)
}
// Establish constants used in sphere generation.
- deltaRingAngle = PI/numRings;
- deltaSegAngle = 2.0f*PI/numSegments;
+ deltaRingAngle = Math::PI/numRings;
+ deltaSegAngle = 2.0f*Math::PI/numSegments;
// Generate the group of rings for the sphere.
j = 0;
@@ -3568,7 +3568,7 @@ void CParticule::DrawParticuleCylinder(int i)
D3DVERTEX2 vertex[2*5*(10+1)]; // triangles
D3DMATRIX matrix, rot;
D3DVECTOR angle, v0, v1;
- FPOINT ts, ti;
+ Math::Point ts, ti;
float progress, zoom, diam, deltaSegAngle, h[6], d[6];
float r0,r1, tu0,tv0, tu1,tv1, p1, p2, pp;
int j, ring, seg, numRings, numSegments;
@@ -3597,7 +3597,7 @@ void CParticule::DrawParticuleCylinder(int i)
numRings = 5;
numSegments = 10;
- deltaSegAngle = 2.0f*PI/numSegments;
+ deltaSegAngle = 2.0f*Math::PI/numSegments;
if ( m_particule[i].type == PARTIPLOUF0 )
{
@@ -3669,7 +3669,7 @@ void CParticule::DrawParticuleWheel(int i)
D3DVECTOR pos[4], center;
D3DVERTEX2 vertex[4]; // 2 triangles
D3DVECTOR n;
- FPOINT ts, ti;
+ Math::Point ts, ti;
float dist, dp;
dist = Length2d(m_engine->RetEyePt(), m_wheelTrace[i].pos[0]);
@@ -3960,9 +3960,9 @@ CObject* CParticule::SearchObjectGun(D3DVECTOR old, D3DVECTOR pos,
box1 = old;
box2 = pos;
- if ( box1.x > box2.x ) Swap(box1.x, box2.x); // box1 < box2
- if ( box1.y > box2.y ) Swap(box1.y, box2.y);
- if ( box1.z > box2.z ) Swap(box1.z, box2.z);
+ if ( box1.x > box2.x ) Math::Swap(box1.x, box2.x); // box1 < box2
+ if ( box1.y > box2.y ) Math::Swap(box1.y, box2.y);
+ if ( box1.z > box2.z ) Math::Swap(box1.z, box2.z);
box1.x -= min;
box1.y -= min;
box1.z -= min;
@@ -4099,9 +4099,9 @@ CObject* CParticule::SearchObjectRay(D3DVECTOR pos, D3DVECTOR goal,
box1 = pos;
box2 = goal;
- if ( box1.x > box2.x ) Swap(box1.x, box2.x); // box1 < box2
- if ( box1.y > box2.y ) Swap(box1.y, box2.y);
- if ( box1.z > box2.z ) Swap(box1.z, box2.z);
+ if ( box1.x > box2.x ) Math::Swap(box1.x, box2.x); // box1 < box2
+ if ( box1.y > box2.y ) Math::Swap(box1.y, box2.y);
+ if ( box1.z > box2.z ) Math::Swap(box1.z, box2.z);
box1.x -= min;
box1.y -= min;
box1.z -= min;
@@ -4262,7 +4262,7 @@ bool CParticule::WriteWheelTrace(char *filename, int width, int height,
HGDIOBJ old;
RECT rect;
COLORREF color;
- FPOINT pos[4];
+ Math::Point pos[4];
POINT list[4];
int i;
diff --git a/src/graphics/common/particule.h b/src/graphics/common/particule.h
index 4014060..19e4053 100644
--- a/src/graphics/common/particule.h
+++ b/src/graphics/common/particule.h
@@ -19,6 +19,7 @@
#pragma once
+#include "math/point.h"
#include "graphics/d3d/d3dengine.h"
#include "sound/sound.h"
@@ -217,12 +218,12 @@ struct Particule
D3DVECTOR speed; // speed of displacement
float windSensitivity;
short bounce; // number of rebounds
- FPOINT dim; // dimensions of the rectangle
+ Math::Point dim; // dimensions of the rectangle
float zoom; // zoom (0..1)
float angle; // angle of rotation
float intensity; // intensity
- FPOINT texSup; // coordinated upper texture
- FPOINT texInf; // coordinated lower texture
+ Math::Point texSup; // coordinated upper texture
+ Math::Point texInf; // coordinated lower texture
float time; // age of the particle (0..n)
float phaseTime; // age at the beginning of phase
float testTime; // time since last test
@@ -265,22 +266,22 @@ public:
void FlushParticule();
void FlushParticule(int sheet);
- int CreateParticule(D3DVECTOR pos, D3DVECTOR speed, FPOINT dim, ParticuleType type, float duration=1.0f, float mass=0.0f, float windSensitivity=1.0f, int sheet=0);
+ int CreateParticule(D3DVECTOR pos, D3DVECTOR speed, Math::Point dim, ParticuleType type, float duration=1.0f, float mass=0.0f, float windSensitivity=1.0f, int sheet=0);
int CreateFrag(D3DVECTOR pos, D3DVECTOR speed, D3DTriangle *triangle, ParticuleType type, float duration=1.0f, float mass=0.0f, float windSensitivity=1.0f, int sheet=0);
int CreatePart(D3DVECTOR pos, D3DVECTOR speed, ParticuleType type, float duration=1.0f, float mass=0.0f, float weight=0.0f, float windSensitivity=1.0f, int sheet=0);
- int CreateRay(D3DVECTOR pos, D3DVECTOR goal, ParticuleType type, FPOINT dim, float duration=1.0f, int sheet=0);
- int CreateTrack(D3DVECTOR pos, D3DVECTOR speed, FPOINT dim, ParticuleType type, float duration=1.0f, float mass=0.0f, float length=10.0f, float width=1.0f);
+ int CreateRay(D3DVECTOR pos, D3DVECTOR goal, ParticuleType type, Math::Point dim, float duration=1.0f, int sheet=0);
+ int CreateTrack(D3DVECTOR pos, D3DVECTOR speed, Math::Point dim, ParticuleType type, float duration=1.0f, float mass=0.0f, float length=10.0f, float width=1.0f);
void CreateWheelTrace(const D3DVECTOR &p1, const D3DVECTOR &p2, const D3DVECTOR &p3, const D3DVECTOR &p4, ParticuleType type);
void DeleteParticule(ParticuleType type);
void DeleteParticule(int channel);
void SetObjectLink(int channel, CObject *object);
void SetObjectFather(int channel, CObject *object);
void SetPosition(int channel, D3DVECTOR pos);
- void SetDimension(int channel, FPOINT dim);
+ void SetDimension(int channel, Math::Point dim);
void SetZoom(int channel, float zoom);
void SetAngle(int channel, float angle);
void SetIntensity(int channel, float intensity);
- void SetParam(int channel, D3DVECTOR pos, FPOINT dim, float zoom, float angle, float intensity);
+ void SetParam(int channel, D3DVECTOR pos, Math::Point dim, float zoom, float angle, float intensity);
void SetPhase(int channel, ParticulePhase phase, float duration);
bool GetPosition(int channel, D3DVECTOR &pos);
diff --git a/src/graphics/common/planet.cpp b/src/graphics/common/planet.cpp
index 68a5a64..5353c54 100644
--- a/src/graphics/common/planet.cpp
+++ b/src/graphics/common/planet.cpp
@@ -16,14 +16,13 @@
// planet.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/const.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/event.h"
@@ -103,7 +102,7 @@ bool CPlanet::EventFrame(const Event &event)
a = m_time*m_planet[m_mode][i].speed;
if ( a < 0.0f )
{
- a += PI*1000.0f;
+ a += Math::PI*1000.0f;
}
m_planet[m_mode][i].angle.x = a+m_planet[m_mode][i].start.x;
m_planet[m_mode][i].angle.y = sinf(a)*sinf(m_planet[m_mode][i].dir)+m_planet[m_mode][i].start.y;
@@ -137,7 +136,7 @@ void CPlanet::Draw()
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
D3DVECTOR n;
- FPOINT p1, p2;
+ Math::Point p1, p2;
float eyeDirH, eyeDirV, dp, u1, u2, v1, v2, a;
int i;
@@ -164,10 +163,10 @@ void CPlanet::Draw()
}
a = eyeDirH + m_planet[m_mode][i].angle.x;
- p1.x = Mod(a, PI*2.0f)-0.5f;
+ p1.x = Math::Mod(a, Math::PI*2.0f)-0.5f;
a = eyeDirV + m_planet[m_mode][i].angle.y;
- p1.y = 0.4f+(Mod(a+PI, PI*2.0f)-PI)*(2.0f/PI);
+ p1.y = 0.4f+(Math::Mod(a+Math::PI, Math::PI*2.0f)-Math::PI)*(2.0f/Math::PI);
p1.x -= m_planet[m_mode][i].dim/2.0f*0.75f;
p1.y -= m_planet[m_mode][i].dim/2.0f;
@@ -192,8 +191,8 @@ void CPlanet::Draw()
// Creates a new planet.
-bool CPlanet::Create(int mode, FPOINT start, float dim, float speed,
- float dir, char *name, FPOINT uv1, FPOINT uv2)
+bool CPlanet::Create(int mode, Math::Point start, float dim, float speed,
+ float dir, char *name, Math::Point uv1, Math::Point uv2)
{
int i;
diff --git a/src/graphics/common/planet.h b/src/graphics/common/planet.h
index fd2f0f2..14c8111 100644
--- a/src/graphics/common/planet.h
+++ b/src/graphics/common/planet.h
@@ -19,7 +19,8 @@
#pragma once
-#include "common/struct.h"
+#include "common/event.h"
+#include "math/point.h"
class CInstanceManager;
@@ -32,13 +33,13 @@ const int MAXPLANET = 10;
struct Planet
{
char bUsed; // true -> planet exists
- FPOINT start; // initial position in degrees
- FPOINT angle; // current position in degrees
+ Math::Point start; // initial position in degrees
+ Math::Point angle; // current position in degrees
float dim; // dimensions (0..1)
float speed; // speed
float dir; // direction in the sky
char name[20]; // name of the texture
- FPOINT uv1, uv2; // texture mapping
+ Math::Point uv1, uv2; // texture mapping
char bTGA; // texture .TGA
};
@@ -53,7 +54,7 @@ public:
void Flush();
bool EventProcess(const Event &event);
- bool Create(int mode, FPOINT start, float dim, float speed, float dir, char *name, FPOINT uv1, FPOINT uv2);
+ bool Create(int mode, Math::Point start, float dim, float speed, float dir, char *name, Math::Point uv1, Math::Point uv2);
bool PlanetExist();
void LoadTexture();
void Draw();
diff --git a/src/graphics/common/pyro.cpp b/src/graphics/common/pyro.cpp
index 6ba09c5..0f187c8 100644
--- a/src/graphics/common/pyro.cpp
+++ b/src/graphics/common/pyro.cpp
@@ -16,15 +16,13 @@
// pyro.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
-#include "math/const.h"
#include "common/struct.h"
+#include "math/const.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/event.h"
@@ -98,7 +96,7 @@ bool CPyro::Create(PyroType type, CObject* pObj, float force)
CObject* power;
CMotion* motion;
D3DVECTOR min, max, pos, speed;
- FPOINT dim;
+ Math::Point dim;
ObjectType oType;
Sound sound;
float duration, mass, h, limit;
@@ -310,7 +308,7 @@ bool CPyro::Create(PyroType type, CObject* pObj, float force)
{
motion->SetAction(MHS_DEADg, 1.0f);
}
- m_camera->StartCentering(m_object, PI*0.5f, 99.9f, 0.0f, 1.5f);
+ m_camera->StartCentering(m_object, Math::PI*0.5f, 99.9f, 0.0f, 1.5f);
m_camera->StartOver(OE_FADEOUTw, m_pos, 1.0f);
m_speed = 1.0f/10.0f;
return true;
@@ -324,7 +322,7 @@ bool CPyro::Create(PyroType type, CObject* pObj, float force)
{
motion->SetAction(MHS_DEADw, 4.0f);
}
- m_camera->StartCentering(m_object, PI*0.5f, 99.9f, 0.0f, 3.0f);
+ m_camera->StartCentering(m_object, Math::PI*0.5f, 99.9f, 0.0f, 3.0f);
m_camera->StartOver(OE_FADEOUTb, m_pos, 1.0f);
m_speed = 1.0f/10.0f;
return true;
@@ -517,15 +515,15 @@ bool CPyro::Create(PyroType type, CObject* pObj, float force)
for ( i=0 ; i<total ; i++ )
{
pos = m_posPower;
- speed.x = (Rand()-0.5f)*30.0f;
- speed.z = (Rand()-0.5f)*30.0f;
- speed.y = Rand()*30.0f;
+ speed.x = (Math::Rand()-0.5f)*30.0f;
+ speed.z = (Math::Rand()-0.5f)*30.0f;
+ speed.y = Math::Rand()*30.0f;
dim.x = 1.0f;
dim.y = dim.x;
- duration = Rand()*3.0f+2.0f;
- mass = Rand()*10.0f+15.0f;
+ duration = Math::Rand()*3.0f+2.0f;
+ mass = Math::Rand()*10.0f+15.0f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK1,
- duration, mass, Rand()+0.7f, 1.0f);
+ duration, mass, Math::Rand()+0.7f, 1.0f);
}
}
@@ -554,13 +552,13 @@ bool CPyro::Create(PyroType type, CObject* pObj, float force)
for ( i=0 ; i<total ; i++ )
{
pos = m_pos;
- speed.x = (Rand()-0.5f)*30.0f;
- speed.z = (Rand()-0.5f)*30.0f;
- speed.y = Rand()*50.0f;
+ speed.x = (Math::Rand()-0.5f)*30.0f;
+ speed.z = (Math::Rand()-0.5f)*30.0f;
+ speed.y = Math::Rand()*50.0f;
dim.x = 1.0f;
dim.y = dim.x;
- duration = Rand()*1.0f+0.8f;
- mass = Rand()*10.0f+15.0f;
+ duration = Math::Rand()*1.0f+0.8f;
+ mass = Math::Rand()*10.0f+15.0f;
m_particule->CreateParticule(pos, speed, dim, PARTIORGANIC1,
duration, mass);
}
@@ -568,13 +566,13 @@ bool CPyro::Create(PyroType type, CObject* pObj, float force)
for ( i=0 ; i<total ; i++ )
{
pos = m_pos;
- speed.x = (Rand()-0.5f)*30.0f;
- speed.z = (Rand()-0.5f)*30.0f;
- speed.y = Rand()*50.0f;
+ speed.x = (Math::Rand()-0.5f)*30.0f;
+ speed.z = (Math::Rand()-0.5f)*30.0f;
+ speed.y = Math::Rand()*50.0f;
dim.x = 1.0f;
dim.y = dim.x;
- duration = Rand()*2.0f+1.4f;
- mass = Rand()*10.0f+15.0f;
+ duration = Math::Rand()*2.0f+1.4f;
+ mass = Math::Rand()*10.0f+15.0f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK4,
duration, mass, duration*0.5f, dim.x*2.0f);
}
@@ -585,31 +583,31 @@ bool CPyro::Create(PyroType type, CObject* pObj, float force)
for ( i=0 ; i<50 ; i++ )
{
pos = m_pos;
- pos.x += (Rand()-0.5f)*3.0f;
- pos.z += (Rand()-0.5f)*3.0f;
- pos.y += (Rand()-0.5f)*2.0f;
- speed.x = (Rand()-0.5f)*24.0f;
- speed.z = (Rand()-0.5f)*24.0f;
- speed.y = 10.0f+Rand()*10.0f;
+ pos.x += (Math::Rand()-0.5f)*3.0f;
+ pos.z += (Math::Rand()-0.5f)*3.0f;
+ pos.y += (Math::Rand()-0.5f)*2.0f;
+ speed.x = (Math::Rand()-0.5f)*24.0f;
+ speed.z = (Math::Rand()-0.5f)*24.0f;
+ speed.y = 10.0f+Math::Rand()*10.0f;
dim.x = 1.0f;
dim.y = dim.x;
- channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN3, 2.0f+Rand()*2.0f, 10.0f);
+ channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN3, 2.0f+Math::Rand()*2.0f, 10.0f);
m_particule->SetObjectFather(channel, pObj);
}
total = (int)(10.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<total ; i++ )
{
pos = m_pos;
- pos.x += (Rand()-0.5f)*3.0f;
- pos.z += (Rand()-0.5f)*3.0f;
- pos.y += (Rand()-0.5f)*2.0f;
- speed.x = (Rand()-0.5f)*24.0f;
- speed.z = (Rand()-0.5f)*24.0f;
- speed.y = 7.0f+Rand()*7.0f;
+ pos.x += (Math::Rand()-0.5f)*3.0f;
+ pos.z += (Math::Rand()-0.5f)*3.0f;
+ pos.y += (Math::Rand()-0.5f)*2.0f;
+ speed.x = (Math::Rand()-0.5f)*24.0f;
+ speed.z = (Math::Rand()-0.5f)*24.0f;
+ speed.y = 7.0f+Math::Rand()*7.0f;
dim.x = 1.0f;
dim.y = dim.x;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK3,
- 2.0f+Rand()*2.0f, 10.0f, 2.0f, 0.6f);
+ 2.0f+Math::Rand()*2.0f, 10.0f, 2.0f, 0.6f);
}
}
@@ -733,28 +731,28 @@ void CPyro::CreateTriangle(CObject* pObj, ObjectType oType, int part)
pos = Transform(*mat, offset);
if ( m_type == PT_EGG )
{
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*15.0f;
- mass = Rand()*20.0f+20.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*15.0f;
+ mass = Math::Rand()*20.0f+20.0f;
}
else if ( m_type == PT_SPIDER )
{
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*20.0f;
- mass = Rand()*10.0f+15.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*20.0f;
+ mass = Math::Rand()*10.0f+15.0f;
}
else
{
- speed.x = (Rand()-0.5f)*30.0f;
- speed.z = (Rand()-0.5f)*30.0f;
- speed.y = Rand()*30.0f;
- mass = Rand()*10.0f+15.0f;
+ speed.x = (Math::Rand()-0.5f)*30.0f;
+ speed.z = (Math::Rand()-0.5f)*30.0f;
+ speed.y = Math::Rand()*30.0f;
+ mass = Math::Rand()*10.0f+15.0f;
}
if ( oType == OBJECT_STONE ) speed *= 0.5f;
if ( oType == OBJECT_URANIUM ) speed *= 0.4f;
- duration = Rand()*3.0f+3.0f;
+ duration = Math::Rand()*3.0f+3.0f;
m_particule->CreateFrag(pos, speed, &buffer[i], PARTIFRAG,
duration, mass, 0.5f);
}
@@ -854,7 +852,7 @@ bool CPyro::EventProcess(const Event &event)
{
ParticuleType type;
D3DVECTOR pos, speed, angle;
- FPOINT dim;
+ Math::Point dim;
float prog, factor, duration;
int i, r;
@@ -885,24 +883,24 @@ bool CPyro::EventProcess(const Event &event)
{
i = rand()%m_crashSphereUsed;
pos = m_crashSpherePos[i];
- pos.x += (Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
- pos.z += (Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
- speed.x = (Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
- speed.z = (Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
- speed.y = Rand()*m_crashSphereRadius[i]*1.0f;
- dim.x = Rand()*m_crashSphereRadius[i]*0.5f+m_crashSphereRadius[i]*0.75f*m_force;
+ pos.x += (Math::Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
+ pos.z += (Math::Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
+ speed.x = (Math::Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
+ speed.z = (Math::Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
+ speed.y = Math::Rand()*m_crashSphereRadius[i]*1.0f;
+ dim.x = Math::Rand()*m_crashSphereRadius[i]*0.5f+m_crashSphereRadius[i]*0.75f*m_force;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 3.0f);
}
else
{
pos = m_pos;
- pos.x += (Rand()-0.5f)*m_size*0.3f;
- pos.z += (Rand()-0.5f)*m_size*0.3f;
- speed.x = (Rand()-0.5f)*m_size*0.1f;
- speed.z = (Rand()-0.5f)*m_size*0.1f;
- speed.y = Rand()*m_size*0.2f;
- dim.x = Rand()*m_size/10.0f+m_size/10.0f*m_force;
+ pos.x += (Math::Rand()-0.5f)*m_size*0.3f;
+ pos.z += (Math::Rand()-0.5f)*m_size*0.3f;
+ speed.x = (Math::Rand()-0.5f)*m_size*0.1f;
+ speed.z = (Math::Rand()-0.5f)*m_size*0.1f;
+ speed.y = Math::Rand()*m_size*0.2f;
+ dim.x = Math::Rand()*m_size/10.0f+m_size/10.0f*m_force;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 3.0f);
}
@@ -916,15 +914,15 @@ bool CPyro::EventProcess(const Event &event)
for ( i=0 ; i<10 ; i++ )
{
pos = m_pos;
- pos.x += (Rand()-0.5f)*m_size*0.2f;
- pos.z += (Rand()-0.5f)*m_size*0.2f;
- pos.y += (Rand()-0.5f)*m_size*0.5f;
- speed.x = (Rand()-0.5f)*5.0f;
- speed.z = (Rand()-0.5f)*5.0f;
- speed.y = Rand()*1.0f;
+ pos.x += (Math::Rand()-0.5f)*m_size*0.2f;
+ pos.z += (Math::Rand()-0.5f)*m_size*0.2f;
+ pos.y += (Math::Rand()-0.5f)*m_size*0.5f;
+ speed.x = (Math::Rand()-0.5f)*5.0f;
+ speed.z = (Math::Rand()-0.5f)*5.0f;
+ speed.y = Math::Rand()*1.0f;
dim.x = 1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLOOD, Rand()*3.0f+3.0f, Rand()*10.0f+15.0f, 0.5f);
+ m_particule->CreateParticule(pos, speed, dim, PARTIBLOOD, Math::Rand()*3.0f+3.0f, Math::Rand()*10.0f+15.0f, 0.5f);
}
}
@@ -937,13 +935,13 @@ bool CPyro::EventProcess(const Event &event)
for ( i=0 ; i<r ; i++ )
{
pos = m_pos;
- pos.x += (Rand()-0.5f)*20.0f;
- pos.z += (Rand()-0.5f)*20.0f;
+ pos.x += (Math::Rand()-0.5f)*20.0f;
+ pos.z += (Math::Rand()-0.5f)*20.0f;
pos.y += 8.0f;
- speed.x = (Rand()-0.5f)*40.0f;
- speed.z = (Rand()-0.5f)*40.0f;
- speed.y = Rand()*40.0f;
- dim.x = Rand()*8.0f+8.0f*m_force;
+ speed.x = (Math::Rand()-0.5f)*40.0f;
+ speed.z = (Math::Rand()-0.5f)*40.0f;
+ speed.y = Math::Rand()*40.0f;
+ dim.x = Math::Rand()*8.0f+8.0f*m_force;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLOODM, 2.0f, 50.0f, 0.0f);
@@ -959,11 +957,11 @@ bool CPyro::EventProcess(const Event &event)
{
i = rand()%m_crashSphereUsed;
pos = m_crashSpherePos[i];
- pos.x += (Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
- pos.z += (Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
- speed.x = (Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
- speed.z = (Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
- speed.y = Rand()*m_crashSphereRadius[i]*1.0f;
+ pos.x += (Math::Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
+ pos.z += (Math::Rand()-0.5f)*m_crashSphereRadius[i]*2.0f;
+ speed.x = (Math::Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
+ speed.z = (Math::Rand()-0.5f)*m_crashSphereRadius[i]*0.5f;
+ speed.y = Math::Rand()*m_crashSphereRadius[i]*1.0f;
dim.x = 1.0f*m_force;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 0.5f, 0.0f, 0.0f);
@@ -971,11 +969,11 @@ bool CPyro::EventProcess(const Event &event)
else
{
pos = m_pos;
- pos.x += (Rand()-0.5f)*m_size*0.3f;
- pos.z += (Rand()-0.5f)*m_size*0.3f;
- speed.x = (Rand()-0.5f)*m_size*0.1f;
- speed.z = (Rand()-0.5f)*m_size*0.1f;
- speed.y = Rand()*m_size*0.2f;
+ pos.x += (Math::Rand()-0.5f)*m_size*0.3f;
+ pos.z += (Math::Rand()-0.5f)*m_size*0.3f;
+ speed.x = (Math::Rand()-0.5f)*m_size*0.1f;
+ speed.z = (Math::Rand()-0.5f)*m_size*0.1f;
+ speed.y = Math::Rand()*m_size*0.2f;
dim.x = 1.0f*m_force;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 0.5f, 0.0f, 0.0f);
@@ -989,12 +987,12 @@ bool CPyro::EventProcess(const Event &event)
pos = m_pos;
pos.y -= 2.0f;
- pos.x += (Rand()-0.5f)*4.0f;
- pos.z += (Rand()-0.5f)*4.0f;
+ pos.x += (Math::Rand()-0.5f)*4.0f;
+ pos.z += (Math::Rand()-0.5f)*4.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 10.0f+Rand()*10.0f;
- dim.x = Rand()*2.5f+2.0f*m_force;
+ speed.y = 10.0f+Math::Rand()*10.0f;
+ dim.x = Math::Rand()*2.5f+2.0f*m_force;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 4.0f);
}
@@ -1006,10 +1004,10 @@ bool CPyro::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_pos;
- speed.x = (Rand()-0.5f)*m_size*1.0f;
- speed.z = (Rand()-0.5f)*m_size*1.0f;
- speed.y = Rand()*m_size*0.50f;
- dim.x = Rand()*m_size/5.0f+m_size/5.0f;
+ speed.x = (Math::Rand()-0.5f)*m_size*1.0f;
+ speed.z = (Math::Rand()-0.5f)*m_size*1.0f;
+ speed.y = Math::Rand()*m_size*0.50f;
+ dim.x = Math::Rand()*m_size/5.0f+m_size/5.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIEXPLOT);
@@ -1021,11 +1019,11 @@ bool CPyro::EventProcess(const Event &event)
{
m_lastParticuleSmoke = m_time;
- dim.x = Rand()*m_size/3.0f+m_size/3.0f;
+ dim.x = Math::Rand()*m_size/3.0f+m_size/3.0f;
dim.y = dim.x;
pos = m_pos;
- pos.x += (Rand()-0.5f)*m_size*0.5f;
- pos.z += (Rand()-0.5f)*m_size*0.5f;
+ pos.x += (Math::Rand()-0.5f)*m_size*0.5f;
+ pos.z += (Math::Rand()-0.5f)*m_size*0.5f;
m_terrain->MoveOnFloor(pos);
speed.x = 0.0f;
speed.z = 0.0f;
@@ -1045,10 +1043,10 @@ bool CPyro::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_pos;
- speed.x = (Rand()-0.5f)*m_size*2.0f;
- speed.z = (Rand()-0.5f)*m_size*2.0f;
- speed.y = Rand()*m_size*1.0f;
- dim.x = Rand()*m_size/2.0f+m_size/2.0f;
+ speed.x = (Math::Rand()-0.5f)*m_size*2.0f;
+ speed.z = (Math::Rand()-0.5f)*m_size*2.0f;
+ speed.y = Math::Rand()*m_size*1.0f;
+ dim.x = Math::Rand()*m_size/2.0f+m_size/2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIEXPLOO);
@@ -1061,9 +1059,9 @@ bool CPyro::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_pos;
- speed.x = (Rand()-0.5f)*m_size*1.0f;
- speed.z = (Rand()-0.5f)*m_size*1.0f;
- speed.y = Rand()*m_size*0.50f;
+ speed.x = (Math::Rand()-0.5f)*m_size*1.0f;
+ speed.z = (Math::Rand()-0.5f)*m_size*1.0f;
+ speed.y = Math::Rand()*m_size*0.50f;
dim.x = 1.0f;
dim.y = dim.x;
@@ -1078,12 +1076,12 @@ bool CPyro::EventProcess(const Event &event)
pos = m_pos;
pos.y -= 2.0f;
- pos.x += (Rand()-0.5f)*4.0f;
- pos.z += (Rand()-0.5f)*4.0f;
+ pos.x += (Math::Rand()-0.5f)*4.0f;
+ pos.z += (Math::Rand()-0.5f)*4.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 4.0f+Rand()*4.0f;
- dim.x = Rand()*2.5f+2.0f;
+ speed.y = 4.0f+Math::Rand()*4.0f;
+ dim.x = Math::Rand()*2.5f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 4.0f);
}
@@ -1106,12 +1104,12 @@ bool CPyro::EventProcess(const Event &event)
pos = m_pos;
pos.y += factor;
- pos.x += (Rand()-0.5f)*3.0f;
- pos.z += (Rand()-0.5f)*3.0f;
+ pos.x += (Math::Rand()-0.5f)*3.0f;
+ pos.z += (Math::Rand()-0.5f)*3.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 5.0f+Rand()*5.0f;
- dim.x = Rand()*1.5f+1.5f;
+ speed.y = 5.0f+Math::Rand()*5.0f;
+ dim.x = Math::Rand()*1.5f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 2.0f);
//? m_particule->CreateParticule(pos, speed, dim, (ParticuleType)(PARTILENS1+rand()%4), 2.0f);
@@ -1141,12 +1139,12 @@ bool CPyro::EventProcess(const Event &event)
pos = m_pos;
m_terrain->MoveOnFloor(pos);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = 2.0f+Rand()*2.0f;
- dim.x = (Rand()*1.0f+1.0f)*(0.2f+m_progress*0.8f);
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = 2.0f+Math::Rand()*2.0f;
+ dim.x = (Math::Rand()*1.0f+1.0f)*(0.2f+m_progress*0.8f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 2.0f, 0.0f, 0.0f);
}
@@ -1168,12 +1166,12 @@ bool CPyro::EventProcess(const Event &event)
pos = m_pos;
m_terrain->MoveOnFloor(pos);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = 2.0f+Rand()*2.0f;
- dim.x = (Rand()*1.0f+1.0f)*(0.2f+m_progress*0.8f);
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = 2.0f+Math::Rand()*2.0f;
+ dim.x = (Math::Rand()*1.0f+1.0f)*(0.2f+m_progress*0.8f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 2.0f, 0.0f, 0.5f);
}
@@ -1195,16 +1193,16 @@ bool CPyro::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_pos;
- speed.x = (Rand()-0.5f)*6.0f;
- speed.z = (Rand()-0.5f)*6.0f;
- speed.y = Rand()*12.0f;
- dim.x = (Rand()*2.5f+2.5f)*(1.0f-m_progress*0.9f);
+ speed.x = (Math::Rand()-0.5f)*6.0f;
+ speed.z = (Math::Rand()-0.5f)*6.0f;
+ speed.y = Math::Rand()*12.0f;
+ dim.x = (Math::Rand()*2.5f+2.5f)*(1.0f-m_progress*0.9f);
dim.y = dim.x;
pos.y += dim.y;
m_particule->CreateParticule(pos, speed, dim,
(ParticuleType)(PARTILENS1+rand()%4),
- Rand()*2.5f+2.5f,
- Rand()*5.0f+5.0f, 0.0f);
+ Math::Rand()*2.5f+2.5f,
+ Math::Rand()*5.0f+5.0f, 0.0f);
}
#else
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
@@ -1212,24 +1210,24 @@ bool CPyro::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_pos;
- pos.x += (Rand()-0.5f)*5.0f;
- pos.z += (Rand()-0.5f)*5.0f;
+ pos.x += (Math::Rand()-0.5f)*5.0f;
+ pos.z += (Math::Rand()-0.5f)*5.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 5.0f+Rand()*5.0f;
- dim.x = Rand()*2.0f+2.0f;
+ speed.y = 5.0f+Math::Rand()*5.0f;
+ dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
pos = m_pos;
- speed.x = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
- speed.y = Rand()*10.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
+ speed.y = Math::Rand()*10.0f;
speed *= 0.5f+m_progress*0.5f;
dim.x = 0.6f;
dim.y = dim.x;
pos.y += dim.y;
- duration = Rand()*1.5f+1.5f;
+ duration = Math::Rand()*1.5f+1.5f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
@@ -1253,12 +1251,12 @@ bool CPyro::EventProcess(const Event &event)
if ( factor > 40.0f ) factor = 40.0f;
pos = m_pos;
m_terrain->MoveOnFloor(pos);
- pos.x += (Rand()-0.5f)*factor;
- pos.z += (Rand()-0.5f)*factor;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = 4.0f+Rand()*4.0f;
- dim.x = (Rand()*3.0f+3.0f)*(1.0f-m_progress*0.9f);
+ pos.x += (Math::Rand()-0.5f)*factor;
+ pos.z += (Math::Rand()-0.5f)*factor;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = 4.0f+Math::Rand()*4.0f;
+ dim.x = (Math::Rand()*3.0f+3.0f)*(1.0f-m_progress*0.9f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 2.0f, 0.0f, 0.5f);
}
@@ -1275,34 +1273,34 @@ bool CPyro::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y -= m_object->RetCharacter()->height;
- pos.x += (Rand()-0.5f)*(4.0f+8.0f*m_progress)*factor;
- pos.z += (Rand()-0.5f)*(4.0f+8.0f*m_progress)*factor;
+ pos.x += (Math::Rand()-0.5f)*(4.0f+8.0f*m_progress)*factor;
+ pos.z += (Math::Rand()-0.5f)*(4.0f+8.0f*m_progress)*factor;
speed.x = 0.0f;
speed.z = 0.0f;
speed.y = 0.0f;
- dim.x = (Rand()*2.5f+1.0f)*factor;
+ dim.x = (Math::Rand()*2.5f+1.0f)*factor;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFLAME, 2.0f, 0.0f, 0.2f);
pos = m_object->RetPosition(0);
pos.y -= m_object->RetCharacter()->height;
- pos.x += (Rand()-0.5f)*(2.0f+4.0f*m_progress)*factor;
- pos.z += (Rand()-0.5f)*(2.0f+4.0f*m_progress)*factor;
+ pos.x += (Math::Rand()-0.5f)*(2.0f+4.0f*m_progress)*factor;
+ pos.z += (Math::Rand()-0.5f)*(2.0f+4.0f*m_progress)*factor;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = (Rand()*5.0f*m_progress+3.0f)*factor;
- dim.x = (Rand()*2.0f+1.0f)*factor;
+ speed.y = (Math::Rand()*5.0f*m_progress+3.0f)*factor;
+ dim.x = (Math::Rand()*2.0f+1.0f)*factor;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFLAME, 2.0f, 0.0f, 0.2f);
pos = m_object->RetPosition(0);
pos.y -= 2.0f;
- pos.x += (Rand()-0.5f)*5.0f*factor;
- pos.z += (Rand()-0.5f)*5.0f*factor;
+ pos.x += (Math::Rand()-0.5f)*5.0f*factor;
+ pos.z += (Math::Rand()-0.5f)*5.0f*factor;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = (6.0f+Rand()*6.0f+m_progress*6.0f)*factor;
- dim.x = (Rand()*1.5f+1.0f+m_progress*3.0f)*factor;
+ speed.y = (6.0f+Math::Rand()*6.0f+m_progress*6.0f)*factor;
+ dim.x = (Math::Rand()*1.5f+1.0f+m_progress*3.0f)*factor;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
}
@@ -1314,8 +1312,8 @@ bool CPyro::EventProcess(const Event &event)
else
{
speed.y = 0.0f;
- speed.x = (Rand()-0.5f)*m_progress*1.0f;
- speed.z = (Rand()-0.5f)*m_progress*1.0f;
+ speed.x = (Math::Rand()-0.5f)*m_progress*1.0f;
+ speed.z = (Math::Rand()-0.5f)*m_progress*1.0f;
if ( m_progress > 0.8f )
{
prog = (m_progress-0.8f)/0.2f; // 0..1
@@ -1334,10 +1332,10 @@ bool CPyro::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y += 1.5f;
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = 8.0f+Rand()*8.0f;
- dim.x = Rand()*0.2f+0.2f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = 8.0f+Math::Rand()*8.0f;
+ dim.x = Math::Rand()*0.2f+0.2f;
dim.y = dim.x;
m_particule->CreateTrack(pos, speed, dim,
(ParticuleType)(PARTITRACK7+rand()%4),
@@ -1353,12 +1351,12 @@ bool CPyro::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y -= 2.0f;
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 1.0f+Rand()*1.0f;
- dim.x = Rand()*1.0f+1.0f;
+ speed.y = 1.0f+Math::Rand()*1.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 8.0f, 0.0f, 0.0f);
}
@@ -1603,7 +1601,7 @@ bool CPyro::CreateLight(D3DVECTOR pos, float height)
light.dvAttenuation1 = 0.0f;
light.dvAttenuation2 = 0.0f;
light.dvTheta = 0.0f;
- light.dvPhi = PI/4.0f;
+ light.dvPhi = Math::PI/4.0f;
m_lightRank = m_light->CreateLight();
if ( m_lightRank == -1 ) return false;
@@ -1665,9 +1663,9 @@ void CPyro::ExploStart()
m_engine->GetBBox(objRank, min, max);
weight = Length(min, max); // weight according to size!
- speed.y = 10.0f+Rand()*20.0f;
- speed.x = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
+ speed.y = 10.0f+Math::Rand()*20.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
}
channel = m_particule->CreatePart(pos, speed, PARTIPART, 10.0f, 20.0f, weight, 0.5f);
@@ -1733,58 +1731,58 @@ void CPyro::BurnStart()
m_burnType == OBJECT_LABO )
{
pos.x = 0.0f;
- pos.y = -(4.0f+Rand()*4.0f);
+ pos.y = -(4.0f+Math::Rand()*4.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.4f;
+ angle.z = (Math::Rand()-0.5f)*0.4f;
}
else if ( m_burnType == OBJECT_STATION ||
m_burnType == OBJECT_RADAR ||
m_burnType == OBJECT_INFO )
{
pos.x = 0.0f;
- pos.y = -(1.0f+Rand()*1.0f);
+ pos.y = -(1.0f+Math::Rand()*1.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.2f;
+ angle.z = (Math::Rand()-0.5f)*0.2f;
}
else if ( m_burnType == OBJECT_NUCLEAR )
{
pos.x = 0.0f;
- pos.y = -(10.0f+Rand()*10.0f);
+ pos.y = -(10.0f+Math::Rand()*10.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.4f;
+ angle.z = (Math::Rand()-0.5f)*0.4f;
}
else if ( m_burnType == OBJECT_PARA )
{
pos.x = 0.0f;
- pos.y = -(10.0f+Rand()*10.0f);
+ pos.y = -(10.0f+Math::Rand()*10.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.4f;
+ angle.z = (Math::Rand()-0.5f)*0.4f;
}
else if ( m_burnType == OBJECT_SAFE )
{
pos.x = 0.0f;
- pos.y = -(10.0f+Rand()*10.0f);
+ pos.y = -(10.0f+Math::Rand()*10.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.4f;
+ angle.z = (Math::Rand()-0.5f)*0.4f;
}
else if ( m_burnType == OBJECT_HUSTON )
{
pos.x = 0.0f;
- pos.y = -(10.0f+Rand()*10.0f);
+ pos.y = -(10.0f+Math::Rand()*10.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.4f;
+ angle.z = (Math::Rand()-0.5f)*0.4f;
}
else if ( m_burnType == OBJECT_MOBILEwa ||
m_burnType == OBJECT_MOBILEwc ||
@@ -1793,29 +1791,29 @@ void CPyro::BurnStart()
m_burnType == OBJECT_MOBILEwt )
{
pos.x = 0.0f;
- pos.y = -(0.5f+Rand()*1.0f);
+ pos.y = -(0.5f+Math::Rand()*1.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.8f;
+ angle.x = (Math::Rand()-0.5f)*0.8f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.4f;
+ angle.z = (Math::Rand()-0.5f)*0.4f;
}
else if ( m_burnType == OBJECT_TEEN31 ) // basket?
{
pos.x = 0.0f;
pos.y = 0.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.8f;
+ angle.x = (Math::Rand()-0.5f)*0.8f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.2f;
+ angle.z = (Math::Rand()-0.5f)*0.2f;
}
else
{
pos.x = 0.0f;
- pos.y = -(2.0f+Rand()*2.0f);
+ pos.y = -(2.0f+Math::Rand()*2.0f);
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.8f;
+ angle.x = (Math::Rand()-0.5f)*0.8f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*0.8f;
+ angle.z = (Math::Rand()-0.5f)*0.8f;
}
BurnAddPart(0, pos, angle); // movement of the main part
@@ -1837,9 +1835,9 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -12.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
- angle.y = (Rand()-0.5f)*0.2f;
- angle.z = -90.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
+ angle.y = (Math::Rand()-0.5f)*0.2f;
+ angle.z = -90.0f*Math::PI/180.0f;
BurnAddPart(1, pos, angle); // down the sensor
}
@@ -1848,9 +1846,9 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -12.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
- angle.y = (Rand()-0.5f)*0.2f;
- angle.z = -90.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
+ angle.y = (Math::Rand()-0.5f)*0.2f;
+ angle.z = -90.0f*Math::PI/180.0f;
BurnAddPart(1, pos, angle); // down the sensor
}
@@ -1859,8 +1857,8 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -200.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.5f;
- angle.y = (Rand()-0.5f)*0.5f;
+ angle.x = (Math::Rand()-0.5f)*0.5f;
+ angle.y = (Math::Rand()-0.5f)*0.5f;
angle.z = 0.0f;
BurnAddPart(1, pos, angle); // down the cover
BurnAddPart(2, pos, angle);
@@ -1872,8 +1870,8 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -7.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
- angle.y = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
+ angle.y = (Math::Rand()-0.5f)*0.4f;
angle.z = 0.0f;
BurnAddPart(1, pos, angle); // down the cannon
}
@@ -1883,8 +1881,8 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -7.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
- angle.y = (Rand()-0.5f)*0.2f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
+ angle.y = (Math::Rand()-0.5f)*0.2f;
angle.z = 0.0f;
BurnAddPart(1, pos, angle); // down the anemometer
}
@@ -1894,8 +1892,8 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -14.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
- angle.y = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
+ angle.y = (Math::Rand()-0.5f)*0.4f;
angle.z = 0.0f;
BurnAddPart(1, pos, angle); // down the radar
BurnAddPart(2, pos, angle);
@@ -1906,8 +1904,8 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -14.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.4f;
- angle.y = (Rand()-0.5f)*0.4f;
+ angle.x = (Math::Rand()-0.5f)*0.4f;
+ angle.y = (Math::Rand()-0.5f)*0.4f;
angle.z = 0.0f;
BurnAddPart(1, pos, angle); // down the information terminal
BurnAddPart(2, pos, angle);
@@ -1931,7 +1929,7 @@ void CPyro::BurnStart()
pos.z = 0.0f;
angle.x = 0.0f;
angle.y = 0.0f;
- angle.z = -135.0f*PI/180.0f;
+ angle.z = -135.0f*Math::PI/180.0f;
BurnAddPart(1, pos, angle); // down the cover
}
@@ -1943,9 +1941,9 @@ void CPyro::BurnStart()
pos.x = 2.0f;
pos.y = -5.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
- angle.y = (Rand()-0.5f)*0.2f;
- angle.z = 40.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
+ angle.y = (Math::Rand()-0.5f)*0.2f;
+ angle.z = 40.0f*Math::PI/180.0f;
BurnAddPart(1, pos, angle); // down the arm
}
@@ -1957,9 +1955,9 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -7.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
- angle.y = (Rand()-0.5f)*0.2f;
- angle.z = 50.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
+ angle.y = (Math::Rand()-0.5f)*0.2f;
+ angle.z = 50.0f*Math::PI/180.0f;
BurnAddPart(1, pos, angle); // down the sensor
}
@@ -1971,9 +1969,9 @@ void CPyro::BurnStart()
pos.x = -1.5f;
pos.y = -5.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
- angle.y = (Rand()-0.5f)*0.2f;
- angle.z = -25.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
+ angle.y = (Math::Rand()-0.5f)*0.2f;
+ angle.z = -25.0f*Math::PI/180.0f;
BurnAddPart(1, pos, angle); // down the cannon
}
@@ -1985,9 +1983,9 @@ void CPyro::BurnStart()
pos.x = -1.5f;
pos.y = -5.0f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*0.2f;
- angle.y = (Rand()-0.5f)*0.2f;
- angle.z = -25.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*0.2f;
+ angle.y = (Math::Rand()-0.5f)*0.2f;
+ angle.z = -25.0f*Math::PI/180.0f;
BurnAddPart(1, pos, angle); // down the insect-cannon
}
@@ -2026,7 +2024,7 @@ void CPyro::BurnStart()
pos.z = 0.0f;
angle.x = 0.0f;
angle.y = 0.0f;
- angle.z = -PI/2.0f;
+ angle.z = -Math::PI/2.0f;
BurnAddPart(4, pos, angle);
pos.x = 0.0f;
@@ -2034,7 +2032,7 @@ void CPyro::BurnStart()
pos.z = 0.0f;
angle.x = 0.0f;
angle.y = 0.0f;
- angle.z = PI/2.5f;
+ angle.z = Math::PI/2.5f;
BurnAddPart(2, pos, angle);
}
@@ -2085,10 +2083,10 @@ void CPyro::BurnStart()
for ( i=0 ; i<4 ; i++ )
{
pos.x = 0.0f;
- pos.y = Rand()*0.5f;
+ pos.y = Math::Rand()*0.5f;
pos.z = 0.0f;
- angle.x = (Rand()-0.5f)*PI/2.0f;
- angle.y = (Rand()-0.5f)*PI/2.0f;
+ angle.x = (Math::Rand()-0.5f)*Math::PI/2.0f;
+ angle.y = (Math::Rand()-0.5f)*Math::PI/2.0f;
angle.z = 0.0f;
BurnAddPart(6+i, pos, angle); // wheel
@@ -2111,17 +2109,17 @@ void CPyro::BurnStart()
pos.x = 0.0f;
pos.y = -4.0f;
pos.z = 2.0f;
- angle.x = (Rand()-0.5f)*20.0f*PI/180.0f;
- angle.y = (Rand()-0.5f)*10.0f*PI/180.0f;
- angle.z = (Rand()-0.5f)*30.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*20.0f*Math::PI/180.0f;
+ angle.y = (Math::Rand()-0.5f)*10.0f*Math::PI/180.0f;
+ angle.z = (Math::Rand()-0.5f)*30.0f*Math::PI/180.0f;
BurnAddPart(6, pos, angle); // down the right caterpillar
pos.x = 0.0f;
pos.y = -4.0f;
pos.z = -2.0f;
- angle.x = (Rand()-0.5f)*20.0f*PI/180.0f;
- angle.y = (Rand()-0.5f)*10.0f*PI/180.0f;
- angle.z = (Rand()-0.5f)*30.0f*PI/180.0f;
+ angle.x = (Math::Rand()-0.5f)*20.0f*Math::PI/180.0f;
+ angle.y = (Math::Rand()-0.5f)*10.0f*Math::PI/180.0f;
+ angle.z = (Math::Rand()-0.5f)*30.0f*Math::PI/180.0f;
BurnAddPart(7, pos, angle); // down the left caterpillar
}
@@ -2138,7 +2136,7 @@ void CPyro::BurnStart()
pos.z = 0.0f;
angle.x = 0.0f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*PI/2.0f;
+ angle.z = (Math::Rand()-0.5f)*Math::PI/2.0f;
BurnAddPart(6+i, pos, angle); // foot
}
m_burnKeepPart[i] = -1;
@@ -2155,8 +2153,8 @@ void CPyro::BurnStart()
pos.y = -3.0f;
pos.z = 0.0f;
angle.x = 0.0f;
- angle.y = (Rand()-0.5f)*PI/4.0f;
- angle.z = (Rand()-0.5f)*PI/4.0f;
+ angle.y = (Math::Rand()-0.5f)*Math::PI/4.0f;
+ angle.z = (Math::Rand()-0.5f)*Math::PI/4.0f;
BurnAddPart(6+i, pos, angle); // leg
}
}
@@ -2442,7 +2440,7 @@ void CPyro::FallProgress(float rTime)
{
if ( pObj->RetShieldRadius() > 0.0f ) // protected by shield?
{
- m_particule->CreateParticule(pos, D3DVECTOR(0.0f, 0.0f, 0.0f), FPOINT(6.0f, 6.0f), PARTIGUNDEL, 2.0f, 0.0f, 0.0f);
+ m_particule->CreateParticule(pos, D3DVECTOR(0.0f, 0.0f, 0.0f), Math::Point(6.0f, 6.0f), PARTIGUNDEL, 2.0f, 0.0f, 0.0f);
m_sound->Play(SOUND_GUNDEL);
DeleteObject(true, true); // removes the ball
diff --git a/src/graphics/common/terrain.cpp b/src/graphics/common/terrain.cpp
index af0bb6e..dbf92c3 100644
--- a/src/graphics/common/terrain.cpp
+++ b/src/graphics/common/terrain.cpp
@@ -16,14 +16,14 @@
// terrain.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "graphics/d3d/d3dutil.h"
@@ -384,13 +384,13 @@ bool CTerrain::ReliefFromBMP(const char* filename, float scaleRelief,
level = (255-buffer[BMPHEAD+x+sizem*y])*scaleRelief;
//? dist = Length((float)(x-size/2), (float)(y-size/2));
- dist = Max(Abs((float)(x-size/2)), Abs((float)(y-size/2)));
+ dist = Math::Max(fabs((float)(x-size/2)), fabs((float)(y-size/2)));
dist = dist/(float)(size/2);
if ( dist > limit && adjustBorder )
{
dist = (dist-limit)/(1.0f-limit); // 0..1
if ( dist > 1.0f ) dist = 1.0f;
- border = 300.0f+Rand()*20.0f;
+ border = 300.0f+Math::Rand()*20.0f;
level = level+dist*(border-level);
}
@@ -766,7 +766,7 @@ bool CTerrain::CreateMosaic(int ox, int oy, int step, int objRank,
D3DMATRIX transform;
D3DVERTEX2 o, p1, p2;
D3DObjLevel6* buffer;
- FPOINT uv;
+ Math::Point uv;
int brick, total, size, mx, my, x, y, xx, yy, i;
char texName1[20];
char texName2[20];
@@ -955,7 +955,7 @@ TerrainMaterial* CTerrain::LevelSearchMat(int id)
// Chooses texture to use for a given square.
-void CTerrain::LevelTextureName(int x, int y, char *name, FPOINT &uv)
+void CTerrain::LevelTextureName(int x, int y, char *name, Math::Point &uv)
{
TerrainMaterial* tm;
@@ -1019,7 +1019,7 @@ bool CTerrain::LevelGetDot(int x, int y, float min, float max, float slope)
{
for ( i=0 ; i<4 ; i++ )
{
- if ( Abs(hc-h[i]) >= slope )
+ if ( fabs(hc-h[i]) >= slope )
{
return false;
}
@@ -1031,7 +1031,7 @@ bool CTerrain::LevelGetDot(int x, int y, float min, float max, float slope)
{
for ( i=0 ; i<4 ; i++ )
{
- if ( Abs(hc-h[i]) < -slope )
+ if ( fabs(hc-h[i]) < -slope )
{
return false;
}
@@ -1689,7 +1689,7 @@ float CTerrain::RetFineSlope(const D3DVECTOR &pos)
D3DVECTOR n;
if ( !GetNormal(n, pos) ) return 0.0f;
- return Abs(RotateAngle(Length(n.x, n.z), n.y)-PI/2.0f);
+ return fabs(Math::RotateAngle(Length(n.x, n.z), n.y)-Math::PI/2.0f);
}
// Gives the approximate slope of the terrain of a specific location.
@@ -1714,8 +1714,8 @@ float CTerrain::RetCoarseSlope(const D3DVECTOR &pos)
level[2] = m_relief[(x+0)+(y+1)*(m_mosaic*m_brick+1)];
level[3] = m_relief[(x+1)+(y+1)*(m_mosaic*m_brick+1)];
- min = Min(level[0], level[1], level[2], level[3]);
- max = Max(level[0], level[1], level[2], level[3]);
+ min = Math::Min(level[0], level[1], level[2], level[3]);
+ max = Math::Max(level[0], level[1], level[2], level[3]);
return atanf((max-min)/m_size);
}
@@ -1741,7 +1741,7 @@ bool CTerrain::GetNormal(D3DVECTOR &n, const D3DVECTOR &p)
p3 = RetVector(x+0, y+1);
p4 = RetVector(x+1, y+1);
- if ( Abs(p.z-p2.z) < Abs(p.x-p2.x) )
+ if ( fabs(p.z-p2.z) < fabs(p.x-p2.x) )
{
n = ComputeNormal(p1,p2,p3);
}
@@ -1774,7 +1774,7 @@ float CTerrain::RetFloorLevel(const D3DVECTOR &p, bool bBrut, bool bWater)
p4 = RetVector(x+1, y+1);
ps = p;
- if ( Abs(p.z-p2.z) < Abs(p.x-p2.x) )
+ if ( fabs(p.z-p2.z) < fabs(p.x-p2.x) )
{
if ( !IntersectY(p1, p2, p3, ps) ) return 0.0f;
}
@@ -1817,7 +1817,7 @@ float CTerrain::RetFloorHeight(const D3DVECTOR &p, bool bBrut, bool bWater)
p4 = RetVector(x+1, y+1);
ps = p;
- if ( Abs(p.z-p2.z) < Abs(p.x-p2.x) )
+ if ( fabs(p.z-p2.z) < fabs(p.x-p2.x) )
{
if ( !IntersectY(p1, p2, p3, ps) ) return 0.0f;
}
@@ -1858,7 +1858,7 @@ bool CTerrain::MoveOnFloor(D3DVECTOR &p, bool bBrut, bool bWater)
p3 = RetVector(x+0, y+1);
p4 = RetVector(x+1, y+1);
- if ( Abs(p.z-p2.z) < Abs(p.x-p2.x) )
+ if ( fabs(p.z-p2.z) < fabs(p.x-p2.x) )
{
if ( !IntersectY(p1, p2, p3, p) ) return false;
}
@@ -2157,7 +2157,7 @@ void CTerrain::GroundFlat(D3DVECTOR pos)
float CTerrain::RetFlatZoneRadius(D3DVECTOR center, float max)
{
D3DVECTOR pos;
- FPOINT c, p;
+ Math::Point c, p;
float ref, radius, angle, h;
int i, nb;
@@ -2170,7 +2170,7 @@ float CTerrain::RetFlatZoneRadius(D3DVECTOR center, float max)
while ( radius <= max )
{
angle = 0.0f;
- nb = (int)(2.0f*PI*radius);
+ nb = (int)(2.0f*Math::PI*radius);
if ( nb < 8 ) nb = 8;
for ( i=0 ; i<nb ; i++ )
{
@@ -2178,13 +2178,13 @@ float CTerrain::RetFlatZoneRadius(D3DVECTOR center, float max)
c.y = center.z;
p.x = center.x+radius;
p.y = center.z;
- p = RotatePoint(c, angle, p);
+ p = Math::RotatePoint(c, angle, p);
pos.x = p.x;
pos.z = p.y;
h = RetFloorLevel(pos, true);
- if ( Abs(h-ref) > 1.0f ) return radius;
+ if ( fabs(h-ref) > 1.0f ) return radius;
- angle += PI*2.0f/8.0f;
+ angle += Math::PI*2.0f/8.0f;
}
radius += 1.0f;
}
diff --git a/src/graphics/common/terrain.h b/src/graphics/common/terrain.h
index 1ea5a6a..dd04377 100644
--- a/src/graphics/common/terrain.h
+++ b/src/graphics/common/terrain.h
@@ -19,7 +19,8 @@
#pragma once
-#include "math/old/math3d.h"
+#include "common/struct.h"
+#include "math/point.h"
#include "graphics/d3d/d3dengine.h"
@@ -29,7 +30,7 @@ class CWater;
-const float FLATLIMIT = (5.0f*PI/180.0f);
+const float FLATLIMIT = (5.0f*Math::PI/180.0f);
enum TerrainRes
@@ -154,7 +155,7 @@ protected:
bool CreateSquare(bool bMultiRes, int x, int y);
TerrainMaterial* LevelSearchMat(int id);
- void LevelTextureName(int x, int y, char *name, FPOINT &uv);
+ void LevelTextureName(int x, int y, char *name, Math::Point &uv);
float LevelRetHeight(int x, int y);
bool LevelGetDot(int x, int y, float min, float max, float slope);
int LevelTestMat(char *mat);
diff --git a/src/graphics/common/text.cpp b/src/graphics/common/text.cpp
index 948ac7d..2bee6f4 100644
--- a/src/graphics/common/text.cpp
+++ b/src/graphics/common/text.cpp
@@ -16,8 +16,6 @@
// text.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -1133,7 +1131,7 @@ void CText::SetD3DDevice(LPDIRECT3DDEVICE7 device)
// Displays multi-font text.
// The vertical position is at the bottom of the box of the character.
-void CText::DrawText(char *string, char *format, int len, FPOINT pos,
+void CText::DrawText(char *string, char *format, int len, Math::Point pos,
float width, int justif, float size, float stretch,
int eol)
{
@@ -1157,7 +1155,7 @@ void CText::DrawText(char *string, char *format, int len, FPOINT pos,
// Displays multi-font text.
// The vertical position is at the bottom of the box of the character.
-void CText::DrawText(char *string, char *format, FPOINT pos, float width,
+void CText::DrawText(char *string, char *format, Math::Point pos, float width,
int justif, float size, float stretch,
int eol)
{
@@ -1167,7 +1165,7 @@ void CText::DrawText(char *string, char *format, FPOINT pos, float width,
// Displays text.
// The vertical position is at the bottom of the box of the character.
-void CText::DrawText(char *string, int len, FPOINT pos, float width,
+void CText::DrawText(char *string, int len, Math::Point pos, float width,
int justif, float size, float stretch, FontType font,
int eol)
{
@@ -1191,7 +1189,7 @@ void CText::DrawText(char *string, int len, FPOINT pos, float width,
// Displays text.
// The vertical position is at the bottom of the box of the character.
-void CText::DrawText(char *string, FPOINT pos, float width,
+void CText::DrawText(char *string, Math::Point pos, float width,
int justif, float size, float stretch, FontType font,
int eol)
{
@@ -1201,9 +1199,9 @@ void CText::DrawText(char *string, FPOINT pos, float width,
// Returns the size of a multi-font text.
-void CText::DimText(char *string, char *format, int len, FPOINT pos,
+void CText::DimText(char *string, char *format, int len, Math::Point pos,
int justif, float size, float stretch,
- FPOINT &start, FPOINT &end)
+ Math::Point &start, Math::Point &end)
{
float sw;
@@ -1228,18 +1226,18 @@ void CText::DimText(char *string, char *format, int len, FPOINT pos,
// Returns the size of a multi-font text.
-void CText::DimText(char *string, char *format, FPOINT pos, int justif,
+void CText::DimText(char *string, char *format, Math::Point pos, int justif,
float size, float stretch,
- FPOINT &start, FPOINT &end)
+ Math::Point &start, Math::Point &end)
{
DimText(string, format, strlen(string), pos, justif, size, stretch, start, end);
}
// Returns the size of a text.
-void CText::DimText(char *string, int len, FPOINT pos, int justif,
+void CText::DimText(char *string, int len, Math::Point pos, int justif,
float size, float stretch, FontType font,
- FPOINT &start, FPOINT &end)
+ Math::Point &start, Math::Point &end)
{
float sw;
@@ -1264,9 +1262,9 @@ void CText::DimText(char *string, int len, FPOINT pos, int justif,
// Returns the size of a text.
-void CText::DimText(char *string, FPOINT pos, int justif,
+void CText::DimText(char *string, Math::Point pos, int justif,
float size, float stretch, FontType font,
- FPOINT &start, FPOINT &end)
+ Math::Point &start, Math::Point &end)
{
DimText(string, strlen(string), pos, justif, size, stretch, font, start, end);
}
@@ -1320,7 +1318,7 @@ float CText::RetStringWidth(char *string, char *format, int len,
{
pt = table+' '*4;
tab = (float)(pt[2]-pt[0])/256.0f*(size/20.0f)*stretch*m_engine->RetEditIndentValue();
- w = tab-Mod(width, tab);
+ w = tab-Math::Mod(width, tab);
if ( w < tab*0.1f ) w += tab;
width += w;
continue;
@@ -1356,7 +1354,7 @@ float CText::RetStringWidth(char *string, int len,
{
pt = table+' '*4;
tab = (float)(pt[2]-pt[0])/256.0f*(size/20.0f)*stretch*m_engine->RetEditIndentValue();
- w = tab-Mod(width, tab);
+ w = tab-Math::Mod(width, tab);
if ( w < tab*0.1f ) w += tab;
width += w;
continue;
@@ -1388,7 +1386,7 @@ float CText::RetCharWidth(int character, float offset,
{
pt = RetTable(font)+' '*4;
tab = (float)(pt[2]-pt[0])/256.0f*(size/20.0f)*stretch*m_engine->RetEditIndentValue();
- w = tab-Mod(offset, tab);
+ w = tab-Math::Mod(offset, tab);
if ( w < tab*0.1f ) w += tab;
return w;
}
@@ -1554,7 +1552,7 @@ int CText::Detect(char *string, int len, float offset,
// Displays multi-font text.
-void CText::DrawString(char *string, char *format, int len, FPOINT pos,
+void CText::DrawString(char *string, char *format, int len, Math::Point pos,
float width, float size, float stretch, int eol)
{
FontType font;
@@ -1603,7 +1601,7 @@ void CText::DrawString(char *string, char *format, int len, FPOINT pos,
// Displays text.
-void CText::DrawString(char *string, int len, FPOINT pos, float width,
+void CText::DrawString(char *string, int len, Math::Point pos, float width,
float size, float stretch, FontType font,
int eol)
{
@@ -1645,10 +1643,10 @@ void CText::DrawString(char *string, int len, FPOINT pos, float width,
// Displays the link to a character.
-void CText::DrawColor(FPOINT pos, float size, float width, int color)
+void CText::DrawColor(Math::Point pos, float size, float width, int color)
{
D3DVERTEX2 vertex[4]; // 2 triangles
- FPOINT p1, p2;
+ Math::Point p1, p2;
POINT dim;
D3DVECTOR n;
float h, u1, u2, v1, v2, dp;
@@ -1727,11 +1725,11 @@ void CText::DrawColor(FPOINT pos, float size, float width, int color)
// Displays a character.
-void CText::DrawChar(int character, FPOINT pos, float size,
+void CText::DrawChar(int character, Math::Point pos, float size,
float stretch, FontType font)
{
D3DVERTEX2 vertex[4]; // 2 triangles
- FPOINT p1, p2;
+ Math::Point p1, p2;
D3DVECTOR n;
float width, height, u1, u2, v1, v2, dp;
short* pt;
diff --git a/src/graphics/common/text.h b/src/graphics/common/text.h
index defa218..976543a 100644
--- a/src/graphics/common/text.h
+++ b/src/graphics/common/text.h
@@ -19,6 +19,7 @@
#pragma once
+#include "math/point.h"
#include "graphics/d3d/d3dengine.h"
@@ -73,14 +74,14 @@ public:
void SetD3DDevice(LPDIRECT3DDEVICE7 device);
- void DrawText(char *string, char *format, int len, FPOINT pos, float width, int justif, float size, float stretch, int eol);
- void DrawText(char *string, char *format, FPOINT pos, float width, int justif, float size, float stretch, int eol);
- void DrawText(char *string, int len, FPOINT pos, float width, int justif, float size, float stretch, FontType font, int eol);
- void DrawText(char *string, FPOINT pos, float width, int justif, float size, float stretch, FontType font, int eol);
- void DimText(char *string, char *format, int len, FPOINT pos, int justif, float size, float stretch, FPOINT &start, FPOINT &end);
- void DimText(char *string, char *format, FPOINT pos, int justif, float size, float stretch, FPOINT &start, FPOINT &end);
- void DimText(char *string, int len, FPOINT pos, int justif, float size, float stretch, FontType font, FPOINT &start, FPOINT &end);
- void DimText(char *string, FPOINT pos, int justif, float size, float stretch, FontType font, FPOINT &start, FPOINT &end);
+ void DrawText(char *string, char *format, int len, Math::Point pos, float width, int justif, float size, float stretch, int eol);
+ void DrawText(char *string, char *format, Math::Point pos, float width, int justif, float size, float stretch, int eol);
+ void DrawText(char *string, int len, Math::Point pos, float width, int justif, float size, float stretch, FontType font, int eol);
+ void DrawText(char *string, Math::Point pos, float width, int justif, float size, float stretch, FontType font, int eol);
+ void DimText(char *string, char *format, int len, Math::Point pos, int justif, float size, float stretch, Math::Point &start, Math::Point &end);
+ void DimText(char *string, char *format, Math::Point pos, int justif, float size, float stretch, Math::Point &start, Math::Point &end);
+ void DimText(char *string, int len, Math::Point pos, int justif, float size, float stretch, FontType font, Math::Point &start, Math::Point &end);
+ void DimText(char *string, Math::Point pos, int justif, float size, float stretch, FontType font, Math::Point &start, Math::Point &end);
float RetAscent(float size, FontType font);
float RetDescent(float size, FontType font);
@@ -96,10 +97,10 @@ public:
int Detect(char *string, int len, float offset, float size, float stretch, FontType font);
protected:
- void DrawString(char *string, char *format, int len, FPOINT pos, float width, float size, float stretch, int eol);
- void DrawString(char *string, int len, FPOINT pos, float width, float size, float stretch, FontType font, int eol);
- void DrawColor(FPOINT pos, float size, float width, int color);
- void DrawChar(int character, FPOINT pos, float size, float stretch, FontType font);
+ void DrawString(char *string, char *format, int len, Math::Point pos, float width, float size, float stretch, int eol);
+ void DrawString(char *string, int len, Math::Point pos, float width, float size, float stretch, FontType font, int eol);
+ void DrawColor(Math::Point pos, float size, float width, int color);
+ void DrawChar(int character, Math::Point pos, float size, float stretch, FontType font);
protected:
CInstanceManager* m_iMan;
diff --git a/src/graphics/common/water.cpp b/src/graphics/common/water.cpp
index 9ea01df..7bd5614 100644
--- a/src/graphics/common/water.cpp
+++ b/src/graphics/common/water.cpp
@@ -16,8 +16,6 @@
// water.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -191,8 +189,8 @@ void CWater::LavaFrame(float rTime)
eye = m_engine->RetEyePt();
lookat = m_engine->RetLookatPt();
- distance = Rand()*200.0f;
- shift = (Rand()-0.5f)*200.0f;
+ distance = Math::Rand()*200.0f;
+ shift = (Math::Rand()-0.5f)*200.0f;
dir = Normalize(lookat-eye);
pos = eye + dir*distance;
@@ -207,24 +205,24 @@ void CWater::LavaFrame(float rTime)
{
pos.y = m_level;
- level = Rand();
+ level = Math::Rand();
if ( level < 0.8f )
{
- if ( VaporCreate(PARTIFIRE, pos, 0.02f+Rand()*0.06f) )
+ if ( VaporCreate(PARTIFIRE, pos, 0.02f+Math::Rand()*0.06f) )
{
m_lastLava = m_time;
}
}
else if ( level < 0.9f )
{
- if ( VaporCreate(PARTIFLAME, pos, 0.5f+Rand()*3.0f) )
+ if ( VaporCreate(PARTIFLAME, pos, 0.5f+Math::Rand()*3.0f) )
{
m_lastLava = m_time;
}
}
else
{
- if ( VaporCreate(PARTIVAPOR, pos, 0.2f+Rand()*2.0f) )
+ if ( VaporCreate(PARTIVAPOR, pos, 0.2f+Math::Rand()*2.0f) )
{
m_lastLava = m_time;
}
@@ -264,11 +262,11 @@ bool CWater::VaporCreate(ParticuleType type, D3DVECTOR pos, float delay)
if ( m_vapor[i].type == PARTIFIRE )
{
- m_sound->Play(SOUND_BLUP, pos, 1.0f, 1.0f-Rand()*0.5f);
+ m_sound->Play(SOUND_BLUP, pos, 1.0f, 1.0f-Math::Rand()*0.5f);
}
if ( m_vapor[i].type == PARTIFLAME )
{
-//? m_sound->Play(SOUND_SWIM, pos, 1.0f, 1.0f-Rand()*0.5f);
+//? m_sound->Play(SOUND_SWIM, pos, 1.0f, 1.0f-Math::Rand()*0.5f);
}
if ( m_vapor[i].type == PARTIVAPOR )
{
@@ -286,7 +284,7 @@ bool CWater::VaporCreate(ParticuleType type, D3DVECTOR pos, float delay)
void CWater::VaporFrame(int i, float rTime)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int j;
m_vapor[i].time += rTime;
@@ -307,13 +305,13 @@ void CWater::VaporFrame(int i, float rTime)
for ( j=0 ; j<10 ; j++ )
{
pos = m_vapor[i].pos;
- pos.x += (Rand()-0.5f)*2.0f;
- pos.z += (Rand()-0.5f)*2.0f;
+ pos.x += (Math::Rand()-0.5f)*2.0f;
+ pos.z += (Math::Rand()-0.5f)*2.0f;
pos.y -= 1.0f;
- speed.x = (Rand()-0.5f)*6.0f;
- speed.z = (Rand()-0.5f)*6.0f;
- speed.y = 8.0f+Rand()*5.0f;
- dim.x = Rand()*1.5f+1.5f;
+ speed.x = (Math::Rand()-0.5f)*6.0f;
+ speed.z = (Math::Rand()-0.5f)*6.0f;
+ speed.y = 8.0f+Math::Rand()*5.0f;
+ dim.x = Math::Rand()*1.5f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 2.0f, 10.0f);
}
@@ -321,26 +319,26 @@ void CWater::VaporFrame(int i, float rTime)
else if ( m_vapor[i].type == PARTIFLAME )
{
pos = m_vapor[i].pos;
- pos.x += (Rand()-0.5f)*8.0f;
- pos.z += (Rand()-0.5f)*8.0f;
+ pos.x += (Math::Rand()-0.5f)*8.0f;
+ pos.z += (Math::Rand()-0.5f)*8.0f;
pos.y -= 2.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = 4.0f+Rand()*4.0f;
- dim.x = Rand()*2.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = 4.0f+Math::Rand()*4.0f;
+ dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFLAME);
}
else
{
pos = m_vapor[i].pos;
- pos.x += (Rand()-0.5f)*4.0f;
- pos.z += (Rand()-0.5f)*4.0f;
+ pos.x += (Math::Rand()-0.5f)*4.0f;
+ pos.z += (Math::Rand()-0.5f)*4.0f;
pos.y -= 2.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = 8.0f+Rand()*8.0f;
- dim.x = Rand()*1.0f+1.0f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = 8.0f+Math::Rand()*8.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR);
}
@@ -356,7 +354,7 @@ void CWater::VaporFrame(int i, float rTime)
// Adjusts the position to normal, to imitate reflections on an expanse of water at rest.
void CWater::AdjustLevel(D3DVECTOR &pos, D3DVECTOR &norm,
- FPOINT &uv1, FPOINT &uv2)
+ Math::Point &uv1, Math::Point &uv2)
{
#if 0
float t1, t2;
@@ -408,7 +406,7 @@ void CWater::DrawBack()
D3DMATERIAL7 material;
D3DMATRIX matrix;
D3DVECTOR eye, lookat, n, p, p1, p2;
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
float deep, dist;
if ( !m_bDraw ) return;
@@ -486,7 +484,7 @@ void CWater::DrawSurf()
D3DMATERIAL7 material;
D3DMATRIX matrix;
D3DVECTOR eye, lookat, n, pos, p;
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
bool bUnder;
DWORD flags;
float deep, size, sizez, radius;
diff --git a/src/graphics/common/water.h b/src/graphics/common/water.h
index 7a7ffef..c385963 100644
--- a/src/graphics/common/water.h
+++ b/src/graphics/common/water.h
@@ -19,6 +19,7 @@
#pragma once
+#include "common/event.h"
#include "graphics/d3d/d3dengine.h"
#include "graphics/common/particule.h"
@@ -87,7 +88,7 @@ public:
protected:
bool EventFrame(const Event &event);
void LavaFrame(float rTime);
- void AdjustLevel(D3DVECTOR &pos, D3DVECTOR &norm, FPOINT &uv1, FPOINT &uv2);
+ void AdjustLevel(D3DVECTOR &pos, D3DVECTOR &norm, Math::Point &uv1, Math::Point &uv2);
bool RetWater(int x, int y);
bool CreateLine(int x, int y, int len);
diff --git a/src/graphics/d3d/d3dengine.cpp b/src/graphics/d3d/d3dengine.cpp
index 53f651f..8b179ed 100644
--- a/src/graphics/d3d/d3dengine.cpp
+++ b/src/graphics/d3d/d3dengine.cpp
@@ -16,13 +16,13 @@
// d3dengine.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <stdio.h>
#include <math.h>
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "app/d3dapp.h"
#include "graphics/d3d/d3dtextr.h"
#include "graphics/d3d/d3dutil.h"
@@ -158,7 +158,7 @@ CD3DEngine::CD3DEngine(CInstanceManager *iMan, CD3DApplication *app)
m_overMode = D3DSTATETCb;
m_frontsizeName[0] = 0; // no front image
m_hiliteRank[0] = -1; // empty list
- m_mousePos = FPOINT(0.5f, 0.5f);
+ m_mousePos = Math::Point(0.5f, 0.5f);
m_mouseType = D3DMOUSENORM;
m_bMouseHide = false;
m_imageSurface = 0;
@@ -1023,15 +1023,15 @@ bool CD3DEngine::AddTriangle(int objRank, D3DVERTEX2* vertex, int nb,
{
for ( i=0 ; i<nb ; i++ )
{
- m_objectParam[objRank].bboxMin.x = Min(vertex[i].x, m_objectParam[objRank].bboxMin.x);
- m_objectParam[objRank].bboxMin.y = Min(vertex[i].y, m_objectParam[objRank].bboxMin.y);
- m_objectParam[objRank].bboxMin.z = Min(vertex[i].z, m_objectParam[objRank].bboxMin.z);
- m_objectParam[objRank].bboxMax.x = Max(vertex[i].x, m_objectParam[objRank].bboxMax.x);
- m_objectParam[objRank].bboxMax.y = Max(vertex[i].y, m_objectParam[objRank].bboxMax.y);
- m_objectParam[objRank].bboxMax.z = Max(vertex[i].z, m_objectParam[objRank].bboxMax.z);
+ m_objectParam[objRank].bboxMin.x = Math::Min(vertex[i].x, m_objectParam[objRank].bboxMin.x);
+ m_objectParam[objRank].bboxMin.y = Math::Min(vertex[i].y, m_objectParam[objRank].bboxMin.y);
+ m_objectParam[objRank].bboxMin.z = Math::Min(vertex[i].z, m_objectParam[objRank].bboxMin.z);
+ m_objectParam[objRank].bboxMax.x = Math::Max(vertex[i].x, m_objectParam[objRank].bboxMax.x);
+ m_objectParam[objRank].bboxMax.y = Math::Max(vertex[i].y, m_objectParam[objRank].bboxMax.y);
+ m_objectParam[objRank].bboxMax.z = Math::Max(vertex[i].z, m_objectParam[objRank].bboxMax.z);
}
- m_objectParam[objRank].radius = Max(Length(m_objectParam[objRank].bboxMin),
+ m_objectParam[objRank].radius = Math::Max(Length(m_objectParam[objRank].bboxMin),
Length(m_objectParam[objRank].bboxMax));
}
m_objectParam[objRank].totalTriangle += nb/3;
@@ -1070,15 +1070,15 @@ bool CD3DEngine::AddSurface(int objRank, D3DVERTEX2* vertex, int nb,
{
for ( i=0 ; i<nb ; i++ )
{
- m_objectParam[objRank].bboxMin.x = Min(vertex[i].x, m_objectParam[objRank].bboxMin.x);
- m_objectParam[objRank].bboxMin.y = Min(vertex[i].y, m_objectParam[objRank].bboxMin.y);
- m_objectParam[objRank].bboxMin.z = Min(vertex[i].z, m_objectParam[objRank].bboxMin.z);
- m_objectParam[objRank].bboxMax.x = Max(vertex[i].x, m_objectParam[objRank].bboxMax.x);
- m_objectParam[objRank].bboxMax.y = Max(vertex[i].y, m_objectParam[objRank].bboxMax.y);
- m_objectParam[objRank].bboxMax.z = Max(vertex[i].z, m_objectParam[objRank].bboxMax.z);
+ m_objectParam[objRank].bboxMin.x = Math::Min(vertex[i].x, m_objectParam[objRank].bboxMin.x);
+ m_objectParam[objRank].bboxMin.y = Math::Min(vertex[i].y, m_objectParam[objRank].bboxMin.y);
+ m_objectParam[objRank].bboxMin.z = Math::Min(vertex[i].z, m_objectParam[objRank].bboxMin.z);
+ m_objectParam[objRank].bboxMax.x = Math::Max(vertex[i].x, m_objectParam[objRank].bboxMax.x);
+ m_objectParam[objRank].bboxMax.y = Math::Max(vertex[i].y, m_objectParam[objRank].bboxMax.y);
+ m_objectParam[objRank].bboxMax.z = Math::Max(vertex[i].z, m_objectParam[objRank].bboxMax.z);
}
- m_objectParam[objRank].radius = Max(Length(m_objectParam[objRank].bboxMin),
+ m_objectParam[objRank].radius = Math::Max(Length(m_objectParam[objRank].bboxMin),
Length(m_objectParam[objRank].bboxMax));
}
m_objectParam[objRank].totalTriangle += nb-2;
@@ -1116,15 +1116,15 @@ bool CD3DEngine::AddQuick(int objRank, D3DObjLevel6* buffer,
{
for ( i=0 ; i<buffer->totalUsed ; i++ )
{
- m_objectParam[objRank].bboxMin.x = Min(buffer->vertex[i].x, m_objectParam[objRank].bboxMin.x);
- m_objectParam[objRank].bboxMin.y = Min(buffer->vertex[i].y, m_objectParam[objRank].bboxMin.y);
- m_objectParam[objRank].bboxMin.z = Min(buffer->vertex[i].z, m_objectParam[objRank].bboxMin.z);
- m_objectParam[objRank].bboxMax.x = Max(buffer->vertex[i].x, m_objectParam[objRank].bboxMax.x);
- m_objectParam[objRank].bboxMax.y = Max(buffer->vertex[i].y, m_objectParam[objRank].bboxMax.y);
- m_objectParam[objRank].bboxMax.z = Max(buffer->vertex[i].z, m_objectParam[objRank].bboxMax.z);
+ m_objectParam[objRank].bboxMin.x = Math::Min(buffer->vertex[i].x, m_objectParam[objRank].bboxMin.x);
+ m_objectParam[objRank].bboxMin.y = Math::Min(buffer->vertex[i].y, m_objectParam[objRank].bboxMin.y);
+ m_objectParam[objRank].bboxMin.z = Math::Min(buffer->vertex[i].z, m_objectParam[objRank].bboxMin.z);
+ m_objectParam[objRank].bboxMax.x = Math::Max(buffer->vertex[i].x, m_objectParam[objRank].bboxMax.x);
+ m_objectParam[objRank].bboxMax.y = Math::Max(buffer->vertex[i].y, m_objectParam[objRank].bboxMax.y);
+ m_objectParam[objRank].bboxMax.z = Math::Max(buffer->vertex[i].z, m_objectParam[objRank].bboxMax.z);
}
- m_objectParam[objRank].radius = Max(Length(m_objectParam[objRank].bboxMin),
+ m_objectParam[objRank].radius = Math::Max(Length(m_objectParam[objRank].bboxMin),
Length(m_objectParam[objRank].bboxMax));
}
m_objectParam[objRank].totalTriangle += buffer->totalUsed-2;
@@ -1168,24 +1168,24 @@ void CD3DEngine::ChangeLOD()
p4 = p3->table[l3];
if ( p4 == 0 ) continue;
- if ( IsEqual(p4->min, 0.0f ) &&
- IsEqual(p4->max, oldLimit[0]) )
+ if ( Math::IsEqual(p4->min, 0.0f ) &&
+ Math::IsEqual(p4->max, oldLimit[0]) )
{
p4->max = newLimit[0];
}
- else if ( IsEqual(p4->min, oldLimit[0]) &&
- IsEqual(p4->max, oldLimit[1]) )
+ else if ( Math::IsEqual(p4->min, oldLimit[0]) &&
+ Math::IsEqual(p4->max, oldLimit[1]) )
{
p4->min = newLimit[0];
p4->max = newLimit[1];
}
- else if ( IsEqual(p4->min, oldLimit[1]) &&
- IsEqual(p4->max, 1000000.0f ) )
+ else if ( Math::IsEqual(p4->min, oldLimit[1]) &&
+ Math::IsEqual(p4->max, 1000000.0f ) )
{
p4->min = newLimit[1];
}
- else if ( IsEqual(p4->min, 0.0f ) &&
- IsEqual(p4->max, oldTerrain) )
+ else if ( Math::IsEqual(p4->min, 0.0f ) &&
+ Math::IsEqual(p4->max, oldTerrain) )
{
p4->max = newTerrain;
}
@@ -1568,8 +1568,8 @@ bool CD3DEngine::TrackTextureMapping(int objRank,
s = e = 0;
for ( i=0 ; i<6 ; i++ )
{
- if ( Abs(pv[i].x-current.x) < 0.0001f &&
- Abs(pv[i].y-current.y) < 0.0001f )
+ if ( fabs(pv[i].x-current.x) < 0.0001f &&
+ fabs(pv[i].y-current.y) < 0.0001f )
{
ie[e++] = i;
}
@@ -1599,8 +1599,8 @@ bool CD3DEngine::TrackTextureMapping(int objRank,
if ( l6 >= (nb/6)-1 ) break;
for ( i=0 ; i<6 ; i++ )
{
- if ( Abs(pv[i+6].x-current.x) > 0.0001f ||
- Abs(pv[i+6].y-current.y) > 0.0001f )
+ if ( fabs(pv[i+6].x-current.x) > 0.0001f ||
+ fabs(pv[i+6].y-current.y) > 0.0001f )
{
current.x = pv[i+6].x; // end next link
current.y = pv[i+6].y;
@@ -1665,15 +1665,15 @@ void CD3DEngine::UpdateGeometry()
for ( i=0 ; i<p6->totalUsed ; i++ )
{
- m_objectParam[objRank].bboxMin.x = Min(p6->vertex[i].x, m_objectParam[objRank].bboxMin.x);
- m_objectParam[objRank].bboxMin.y = Min(p6->vertex[i].y, m_objectParam[objRank].bboxMin.y);
- m_objectParam[objRank].bboxMin.z = Min(p6->vertex[i].z, m_objectParam[objRank].bboxMin.z);
- m_objectParam[objRank].bboxMax.x = Max(p6->vertex[i].x, m_objectParam[objRank].bboxMax.x);
- m_objectParam[objRank].bboxMax.y = Max(p6->vertex[i].y, m_objectParam[objRank].bboxMax.y);
- m_objectParam[objRank].bboxMax.z = Max(p6->vertex[i].z, m_objectParam[objRank].bboxMax.z);
+ m_objectParam[objRank].bboxMin.x = Math::Min(p6->vertex[i].x, m_objectParam[objRank].bboxMin.x);
+ m_objectParam[objRank].bboxMin.y = Math::Min(p6->vertex[i].y, m_objectParam[objRank].bboxMin.y);
+ m_objectParam[objRank].bboxMin.z = Math::Min(p6->vertex[i].z, m_objectParam[objRank].bboxMin.z);
+ m_objectParam[objRank].bboxMax.x = Math::Max(p6->vertex[i].x, m_objectParam[objRank].bboxMax.x);
+ m_objectParam[objRank].bboxMax.y = Math::Max(p6->vertex[i].y, m_objectParam[objRank].bboxMax.y);
+ m_objectParam[objRank].bboxMax.z = Math::Max(p6->vertex[i].z, m_objectParam[objRank].bboxMax.z);
}
- m_objectParam[objRank].radius = Max(Length(m_objectParam[objRank].bboxMin),
+ m_objectParam[objRank].radius = Math::Max(Length(m_objectParam[objRank].bboxMin),
Length(m_objectParam[objRank].bboxMax));
}
}
@@ -1711,7 +1711,7 @@ bool CD3DEngine::IsVisible(int objRank)
// Detects the target object with the mouse.
// Returns the rank of the object or -1.
-int CD3DEngine::DetectObject(FPOINT mouse)
+int CD3DEngine::DetectObject(Math::Point mouse)
{
D3DObjLevel1* p1;
D3DObjLevel2* p2;
@@ -1790,11 +1790,11 @@ int CD3DEngine::DetectObject(FPOINT mouse)
// Detects whether the mouse is in a triangle.
-bool CD3DEngine::DetectTriangle(FPOINT mouse, D3DVERTEX2 *triangle,
+bool CD3DEngine::DetectTriangle(Math::Point mouse, D3DVERTEX2 *triangle,
int objRank, float &dist)
{
D3DVECTOR p2D[3], p3D;
- FPOINT a, b, c;
+ Math::Point a, b, c;
int i;
for ( i=0 ; i<3 ; i++ )
@@ -1824,7 +1824,7 @@ bool CD3DEngine::DetectTriangle(FPOINT mouse, D3DVERTEX2 *triangle,
b.y = p2D[1].y;
c.x = p2D[2].x;
c.y = p2D[2].y;
- if ( !IsInsideTriangle(a, b, c, mouse) ) return false;
+ if ( !Math::IsInsideTriangle(a, b, c, mouse) ) return false;
dist = (p2D[0].z+p2D[1].z+p2D[2].z)/3.0f;
return true;
@@ -1832,10 +1832,10 @@ bool CD3DEngine::DetectTriangle(FPOINT mouse, D3DVERTEX2 *triangle,
// Detects whether an object is affected by the mouse.
-bool CD3DEngine::DetectBBox(int objRank, FPOINT mouse)
+bool CD3DEngine::DetectBBox(int objRank, Math::Point mouse)
{
D3DVECTOR p, pp;
- FPOINT min, max;
+ Math::Point min, max;
int i;
min.x = 1000000.0f;
@@ -2044,8 +2044,8 @@ void CD3DEngine::SetViewParams(const D3DVECTOR &vEyePt,
#else
m_eyePt = vEyePt;
m_lookatPt = vLookatPt;
- m_eyeDirH = RotateAngle(vEyePt.x-vLookatPt.x, vEyePt.z-vLookatPt.z);
- m_eyeDirV = RotateAngle(Length2d(vEyePt, vLookatPt), vEyePt.y-vLookatPt.y);
+ m_eyeDirH = Math::RotateAngle(vEyePt.x-vLookatPt.x, vEyePt.z-vLookatPt.z);
+ m_eyeDirV = Math::RotateAngle(Length2d(vEyePt, vLookatPt), vEyePt.y-vLookatPt.y);
D3DUtil_SetViewMatrix(m_matView, (D3DVECTOR&)vEyePt, (D3DVECTOR&)vLookatPt, (D3DVECTOR&)vUpVec);
@@ -3639,7 +3639,7 @@ void CD3DEngine::RenderGroundSpot()
WORD* pbSurf;
D3DCOLORVALUE color;
D3DVECTOR pos;
- FPOINT min, max;
+ Math::Point min, max;
int s, i, j, dot, ix, iy, y;
float tu, tv, cx, cy, px, py, ppx, ppy;
float intensity, level;
@@ -3677,8 +3677,8 @@ void CD3DEngine::RenderGroundSpot()
cy += 0.5f;
}
- px = cx-Mod(cx, 1.0f);
- py = cy-Mod(cy, 1.0f); // multiple of 1
+ px = cx-Math::Mod(cx, 1.0f);
+ py = cy-Math::Mod(cy, 1.0f); // multiple of 1
if ( m_bFirstGroundSpot ||
( m_groundMark.drawRadius != 0.0f &&
@@ -3703,8 +3703,8 @@ void CD3DEngine::RenderGroundSpot()
cy += 0.5f;
}
- px = cx-Mod(cx, 1.0f);
- py = cy-Mod(cy, 1.0f); // multiple of 1
+ px = cx-Math::Mod(cx, 1.0f);
+ py = cy-Math::Mod(cy, 1.0f); // multiple of 1
if ( m_groundMark.bUsed &&
px+dot >= min.x && py+dot >= min.y &&
@@ -3758,8 +3758,8 @@ void CD3DEngine::RenderGroundSpot()
cy += 0.5f;
}
- px = cx-Mod(cx, 1.0f);
- py = cy-Mod(cy, 1.0f); // multiple of 1
+ px = cx-Math::Mod(cx, 1.0f);
+ py = cy-Math::Mod(cy, 1.0f); // multiple of 1
if ( px+dot < min.x || py+dot < min.y ||
px-dot > max.x || py-dot > max.y ) continue;
@@ -3843,8 +3843,8 @@ void CD3DEngine::RenderGroundSpot()
cy += 0.5f;
}
- px = cx-Mod(cx, 1.0f);
- py = cy-Mod(cy, 1.0f); // multiple of 1
+ px = cx-Math::Mod(cx, 1.0f);
+ py = cy-Math::Mod(cy, 1.0f); // multiple of 1
for ( iy=-dot ; iy<=dot ; iy++ )
{
@@ -3915,7 +3915,7 @@ void CD3DEngine::DrawShadow()
D3DVECTOR corner[4], n, pos;
D3DMATERIAL7 material;
D3DMATRIX matrix;
- FPOINT ts, ti, rot;
+ Math::Point ts, ti, rot;
float startDeepView, endDeepView;
float intensity, lastIntensity, hFactor, radius, max, height;
float dp, h, d, D;
@@ -4033,22 +4033,22 @@ void CD3DEngine::DrawShadow()
}
else
{
- rot = RotatePoint(-m_shadow[i].angle, FPOINT(radius, radius));
+ rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(radius, radius));
corner[0].x = rot.x;
corner[0].z = rot.y;
corner[0].y = 0.0f;
- rot = RotatePoint(-m_shadow[i].angle, FPOINT(-radius, radius));
+ rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(-radius, radius));
corner[1].x = rot.x;
corner[1].z = rot.y;
corner[1].y = 0.0f;
- rot = RotatePoint(-m_shadow[i].angle, FPOINT(radius, -radius));
+ rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(radius, -radius));
corner[2].x = rot.x;
corner[2].z = rot.y;
corner[2].y = 0.0f;
- rot = RotatePoint(-m_shadow[i].angle, FPOINT(-radius, -radius));
+ rot = Math::RotatePoint(-m_shadow[i].angle, Math::Point(-radius, -radius));
corner[3].x = rot.x;
corner[3].z = rot.y;
corner[3].y = 0.0f;
@@ -4548,7 +4548,7 @@ void CD3DEngine::DrawBackgroundGradient(D3DCOLOR up, D3DCOLOR down)
{
D3DLVERTEX vertex[4]; // 2 triangles
D3DCOLOR color[3];
- FPOINT p1, p2;
+ Math::Point p1, p2;
p1.x = 0.0f;
p1.y = 0.5f;
@@ -4583,7 +4583,7 @@ void CD3DEngine::DrawBackgroundGradient(D3DCOLOR up, D3DCOLOR down)
// Draws a portion of the image background.
-void CD3DEngine::DrawBackgroundImageQuarter(FPOINT p1, FPOINT p2, char *name)
+void CD3DEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, char *name)
{
D3DVERTEX2 vertex[4]; // 2 triangles
D3DVECTOR n;
@@ -4609,17 +4609,17 @@ void CD3DEngine::DrawBackgroundImageQuarter(FPOINT p1, FPOINT p2, char *name)
else
{
h = 0.5f; // visible area vertically (1=all)
- a = m_eyeDirV-PI*0.15f;
- if ( a > PI ) a -= PI*2.0f; // a = -PI..PI
- if ( a > PI/4.0f ) a = PI/4.0f;
- if ( a < -PI/4.0f ) a = -PI/4.0f;
+ a = m_eyeDirV-Math::PI*0.15f;
+ if ( a > Math::PI ) a -= Math::PI*2.0f; // a = -Math::PI..Math::PI
+ if ( a > Math::PI/4.0f ) a = Math::PI/4.0f;
+ if ( a < -Math::PI/4.0f ) a = -Math::PI/4.0f;
- u1 = -m_eyeDirH/PI;
- u2 = u1+1.0f/PI;
-//? u1 = -m_eyeDirH/(PI*2.0f);
-//? u2 = u1+1.0f/(PI*2.0f);
+ u1 = -m_eyeDirH/Math::PI;
+ u2 = u1+1.0f/Math::PI;
+//? u1 = -m_eyeDirH/(Math::PI*2.0f);
+//? u2 = u1+1.0f/(Math::PI*2.0f);
- v1 = (1.0f-h)*(0.5f+a/(2.0f*PI/4.0f))+0.1f;
+ v1 = (1.0f-h)*(0.5f+a/(2.0f*Math::PI/4.0f))+0.1f;
v2 = v1+h;
}
@@ -4649,7 +4649,7 @@ void CD3DEngine::DrawBackgroundImageQuarter(FPOINT p1, FPOINT p2, char *name)
void CD3DEngine::DrawBackgroundImage()
{
- FPOINT p1, p2;
+ Math::Point p1, p2;
char name[50];
if ( m_bBackgroundQuarter )
@@ -4717,7 +4717,7 @@ void CD3DEngine::DrawFrontsize()
{
D3DVERTEX2 vertex[4]; // 2 triangles
D3DVECTOR n;
- FPOINT p1, p2;
+ Math::Point p1, p2;
float u1, u2, v1, v2;
if ( m_frontsizeName[0] == 0 ) return;
@@ -4729,7 +4729,7 @@ void CD3DEngine::DrawFrontsize()
p2.x = 1.0f;
p2.y = 1.0f;
- u1 = -m_eyeDirH/(PI*0.6f)+PI*0.5f;
+ u1 = -m_eyeDirH/(Math::PI*0.6f)+Math::PI*0.5f;
u2 = u1+0.50f;
v1 = 0.2f;
@@ -4769,7 +4769,7 @@ void CD3DEngine::DrawOverColor()
{
D3DLVERTEX vertex[4]; // 2 triangles
D3DCOLOR color[3];
- FPOINT p1, p2;
+ Math::Point p1, p2;
if ( !m_bStateColor ) return;
if ( (m_overColor == 0x00000000 && m_overMode == D3DSTATETCb) ||
@@ -4823,7 +4823,7 @@ void CD3DEngine::SetHiliteRank(int *rankList)
// Give the box in the 2D screen of any object.
-bool CD3DEngine::GetBBox2D(int objRank, FPOINT &min, FPOINT &max)
+bool CD3DEngine::GetBBox2D(int objRank, Math::Point &min, Math::Point &max)
{
D3DVECTOR p, pp;
int i;
@@ -4862,7 +4862,7 @@ bool CD3DEngine::GetBBox2D(int objRank, FPOINT &min, FPOINT &max)
void CD3DEngine::DrawHilite()
{
- FPOINT min, max, omin, omax;
+ Math::Point min, max, omin, omax;
int i;
min.x = 1000000.0f;
@@ -4875,10 +4875,10 @@ void CD3DEngine::DrawHilite()
{
if ( GetBBox2D(m_hiliteRank[i++], omin, omax) )
{
- min.x = Min(min.x, omin.x);
- min.y = Min(min.y, omin.y);
- max.x = Max(max.x, omax.x);
- max.y = Max(max.y, omax.y);
+ min.x = Math::Min(min.x, omin.x);
+ min.y = Math::Min(min.y, omin.y);
+ max.x = Math::Max(max.x, omax.x);
+ max.y = Math::Max(max.y, omax.y);
}
}
@@ -4899,7 +4899,7 @@ void CD3DEngine::DrawHilite()
// Give the rectangle highlighted by drawing CD3DApplication.
-bool CD3DEngine::GetHilite(FPOINT &p1, FPOINT &p2)
+bool CD3DEngine::GetHilite(Math::Point &p1, Math::Point &p2)
{
p1 = m_hiliteP1;
p2 = m_hiliteP2;
@@ -4945,7 +4945,7 @@ bool CD3DEngine::GetSpriteCoord(int &x, int &y)
// Tests whether to exclude a point.
-bool IsExcludeColor(FPOINT *pExclu, int x, int y)
+bool IsExcludeColor(Math::Point *pExclu, int x, int y)
{
int i;
@@ -4970,8 +4970,8 @@ bool CD3DEngine::ChangeColor(char *name,
D3DCOLORVALUE colorRef1, D3DCOLORVALUE colorNew1,
D3DCOLORVALUE colorRef2, D3DCOLORVALUE colorNew2,
float tolerance1, float tolerance2,
- FPOINT ts, FPOINT ti,
- FPOINT *pExclu, float shift, bool bHSV)
+ Math::Point ts, Math::Point ti,
+ Math::Point *pExclu, float shift, bool bHSV)
{
LPDIRECTDRAWSURFACE7 surface;
DDSURFACEDESC2 ddsd;
@@ -5020,7 +5020,7 @@ bool CD3DEngine::ChangeColor(char *name,
if ( bHSV )
{
RGB2HSV(color, c);
- if ( c.s > 0.01f && Abs(c.h-cr1.h) < tolerance1 )
+ if ( c.s > 0.01f && fabs(c.h-cr1.h) < tolerance1 )
{
c.h += cn1.h-cr1.h;
c.s += cn1.s-cr1.s;
@@ -5035,7 +5035,7 @@ bool CD3DEngine::ChangeColor(char *name,
}
else
if ( tolerance2 != -1.0f &&
- c.s > 0.01f && Abs(c.h-cr2.h) < tolerance2 )
+ c.s > 0.01f && fabs(c.h-cr2.h) < tolerance2 )
{
c.h += cn2.h-cr2.h;
c.s += cn2.s-cr2.s;
@@ -5051,9 +5051,9 @@ bool CD3DEngine::ChangeColor(char *name,
}
else
{
- if ( Abs(color.r-colorRef1.r)+
- Abs(color.g-colorRef1.g)+
- Abs(color.b-colorRef1.b) < tolerance1*3.0f )
+ if ( fabs(color.r-colorRef1.r)+
+ fabs(color.g-colorRef1.g)+
+ fabs(color.b-colorRef1.b) < tolerance1*3.0f )
{
color.r = colorNew1.r+color.r-colorRef1.r+shift;
color.g = colorNew1.g+color.g-colorRef1.g+shift;
@@ -5062,9 +5062,9 @@ bool CD3DEngine::ChangeColor(char *name,
}
else
if ( tolerance2 != -1 &&
- Abs(color.r-colorRef2.r)+
- Abs(color.g-colorRef2.g)+
- Abs(color.b-colorRef2.b) < tolerance2*3.0f )
+ fabs(color.r-colorRef2.r)+
+ fabs(color.g-colorRef2.g)+
+ fabs(color.b-colorRef2.b) < tolerance2*3.0f )
{
color.r = colorNew2.r+color.r-colorRef2.r+shift;
color.g = colorNew2.g+color.g-colorRef2.g+shift;
@@ -5539,18 +5539,18 @@ LRESULT CD3DEngine::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
// Mouse control.
-void CD3DEngine::MoveMousePos(FPOINT pos)
+void CD3DEngine::MoveMousePos(Math::Point pos)
{
m_mousePos = pos;
m_app->SetMousePos(pos);
}
-void CD3DEngine::SetMousePos(FPOINT pos)
+void CD3DEngine::SetMousePos(Math::Point pos)
{
m_mousePos = pos;
}
-FPOINT CD3DEngine::RetMousePos()
+Math::Point CD3DEngine::RetMousePos()
{
return m_mousePos;
}
@@ -5613,7 +5613,7 @@ bool CD3DEngine::RetNiceMouseCap()
void CD3DEngine::DrawMouse()
{
D3DMATERIAL7 material;
- FPOINT pos, ppos, dim;
+ Math::Point pos, ppos, dim;
int i;
struct Mouse
@@ -5688,10 +5688,10 @@ void CD3DEngine::DrawMouse()
// Draws the sprite of the mouse.
-void CD3DEngine::DrawSprite(FPOINT pos, FPOINT dim, int icon)
+void CD3DEngine::DrawSprite(Math::Point pos, Math::Point dim, int icon)
{
D3DVERTEX2 vertex[4]; // 2 triangles
- FPOINT p1, p2;
+ Math::Point p1, p2;
D3DVECTOR n;
float u1, u2, v1, v2, dp;
diff --git a/src/graphics/d3d/d3dengine.h b/src/graphics/d3d/d3dengine.h
index 40744a4..8450f91 100644
--- a/src/graphics/d3d/d3dengine.h
+++ b/src/graphics/d3d/d3dengine.h
@@ -19,6 +19,7 @@
#pragma once
+#include "math/point.h"
#include "common/struct.h"
@@ -276,7 +277,7 @@ public:
void AddStatisticTriangle(int nb);
int RetStatisticTriangle();
void SetHiliteRank(int *rankList);
- bool GetHilite(FPOINT &p1, FPOINT &p2);
+ bool GetHilite(Math::Point &p1, Math::Point &p2);
bool GetSpriteCoord(int &x, int &y);
void SetInfoText(int line, char* text);
char* RetInfoText(int line);
@@ -476,14 +477,14 @@ public:
bool IsVisiblePoint(const D3DVECTOR &pos);
- int DetectObject(FPOINT mouse);
+ int DetectObject(Math::Point mouse);
void SetState(int state, D3DCOLOR color=0xffffffff);
void SetTexture(char *name, int stage=0);
void SetMaterial(const D3DMATERIAL7 &mat);
- void MoveMousePos(FPOINT pos);
- void SetMousePos(FPOINT pos);
- FPOINT RetMousePos();
+ void MoveMousePos(Math::Point pos);
+ void SetMousePos(Math::Point pos);
+ Math::Point RetMousePos();
void SetMouseType(D3DMouse type);
D3DMouse RetMouseType();
void SetMouseHide(bool bHide);
@@ -494,7 +495,7 @@ public:
CText* RetText();
- bool ChangeColor(char *name, D3DCOLORVALUE colorRef1, D3DCOLORVALUE colorNew1, D3DCOLORVALUE colorRef2, D3DCOLORVALUE colorNew2, float tolerance1, float tolerance2, FPOINT ts, FPOINT ti, FPOINT *pExclu=0, float shift=0.0f, bool bHSV=false);
+ bool ChangeColor(char *name, D3DCOLORVALUE colorRef1, D3DCOLORVALUE colorNew1, D3DCOLORVALUE colorRef2, D3DCOLORVALUE colorNew2, float tolerance1, float tolerance2, Math::Point ts, Math::Point ti, Math::Point *pExclu=0, float shift=0.0f, bool bHSV=false);
bool OpenImage(char *name);
bool CopyImage();
bool LoadImage();
@@ -522,8 +523,8 @@ protected:
D3DObjLevel6* AddLevel5(D3DObjLevel5 *&p5, D3DTypeTri type, const D3DMATERIAL7 &mat, int state, int nb);
bool IsVisible(int objRank);
- bool DetectBBox(int objRank, FPOINT mouse);
- bool DetectTriangle(FPOINT mouse, D3DVERTEX2 *triangle, int objRank, float &dist);
+ bool DetectBBox(int objRank, Math::Point mouse);
+ bool DetectTriangle(Math::Point mouse, D3DVERTEX2 *triangle, int objRank, float &dist);
bool TransformPoint(D3DVECTOR &p2D, int objRank, D3DVECTOR p3D);
void ComputeDistance();
void UpdateGeometry();
@@ -531,15 +532,15 @@ protected:
void DrawShadow();
void DrawBackground();
void DrawBackgroundGradient(D3DCOLOR up, D3DCOLOR down);
- void DrawBackgroundImageQuarter(FPOINT p1, FPOINT p2, char *name);
+ void DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, char *name);
void DrawBackgroundImage();
void DrawPlanet();
void DrawFrontsize();
void DrawOverColor();
- bool GetBBox2D(int objRank, FPOINT &min, FPOINT &max);
+ bool GetBBox2D(int objRank, Math::Point &min, Math::Point &max);
void DrawHilite();
void DrawMouse();
- void DrawSprite(FPOINT pos, FPOINT dim, int icon);
+ void DrawSprite(Math::Point pos, Math::Point dim, int icon);
protected:
CInstanceManager* m_iMan;
@@ -650,15 +651,15 @@ protected:
int m_hiliteRank[100];
bool m_bHilite;
- FPOINT m_hiliteP1;
- FPOINT m_hiliteP2;
+ Math::Point m_hiliteP1;
+ Math::Point m_hiliteP2;
int m_lastState;
D3DCOLOR m_lastColor;
char m_lastTexture[2][50];
D3DMATERIAL7 m_lastMaterial;
- FPOINT m_mousePos;
+ Math::Point m_mousePos;
D3DMouse m_mouseType;
bool m_bMouseHide;
bool m_bNiceMouse;
diff --git a/src/graphics/d3d/d3denum.cpp b/src/graphics/d3d/d3denum.cpp
index 82d79d9..1081ff5 100644
--- a/src/graphics/d3d/d3denum.cpp
+++ b/src/graphics/d3d/d3denum.cpp
@@ -21,7 +21,6 @@
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
-#define STRICT
#include <windowsx.h>
#include <stdio.h>
#include <tchar.h>
diff --git a/src/graphics/d3d/d3dframe.cpp b/src/graphics/d3d/d3dframe.cpp
index 489e739..e36296a 100644
--- a/src/graphics/d3d/d3dframe.cpp
+++ b/src/graphics/d3d/d3dframe.cpp
@@ -21,7 +21,6 @@
//
// Copyright (c) 1995-1999 by Microsoft, all rights reserved
//-----------------------------------------------------------------------------
-#define STRICT
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
diff --git a/src/graphics/d3d/d3dtextr.cpp b/src/graphics/d3d/d3dtextr.cpp
index 9b82410..4924860 100644
--- a/src/graphics/d3d/d3dtextr.cpp
+++ b/src/graphics/d3d/d3dtextr.cpp
@@ -26,9 +26,10 @@
//
// Copyright (c) 1996-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
-#define STRICT
#include <tchar.h>
#include <stdio.h>
+#include <algorithm>
+using std::min;
#include "graphics/d3d/d3dtextr.h"
#include "graphics/d3d/d3dutil.h"
#include "common/language.h"
diff --git a/src/graphics/d3d/d3dutil.cpp b/src/graphics/d3d/d3dutil.cpp
index 65c3541..5fd46b2 100644
--- a/src/graphics/d3d/d3dutil.cpp
+++ b/src/graphics/d3d/d3dutil.cpp
@@ -22,8 +22,6 @@
//
// Copyright (c) 1997-1999 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
-#define D3D_OVERLOADS
-#define STRICT
#include <math.h>
#include <stdio.h>
#include <tchar.h>