summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/app/d3dapp.cpp22
-rw-r--r--src/app/d3dapp.h6
-rw-r--r--src/app/joystick.cpp1
-rw-r--r--src/common/event.cpp2
-rw-r--r--src/common/event.h4
-rw-r--r--src/common/global.h2
-rw-r--r--src/common/iman.cpp2
-rw-r--r--src/common/metafile.cpp2
-rw-r--r--src/common/misc.cpp2
-rw-r--r--src/common/modfile.cpp14
-rw-r--r--src/common/profile.cpp2
-rw-r--r--src/common/restext.cpp2
-rw-r--r--src/common/restext.h2
-rw-r--r--src/common/struct.h14
-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
-rw-r--r--src/math/conv.h12
-rw-r--r--src/math/func.h6
-rw-r--r--src/math/geometry.h21
-rw-r--r--src/math/old/math3d.cpp158
-rw-r--r--src/math/old/math3d.h99
-rw-r--r--src/object/auto/auto.cpp4
-rw-r--r--src/object/auto/auto.h1
-rw-r--r--src/object/auto/autobase.cpp217
-rw-r--r--src/object/auto/autoconvert.cpp47
-rw-r--r--src/object/auto/autoconvert.h2
-rw-r--r--src/object/auto/autoderrick.cpp60
-rw-r--r--src/object/auto/autodestroyer.cpp10
-rw-r--r--src/object/auto/autodestroyer.h1
-rw-r--r--src/object/auto/autoegg.cpp2
-rw-r--r--src/object/auto/autoenergy.cpp53
-rw-r--r--src/object/auto/autofactory.cpp50
-rw-r--r--src/object/auto/autoflag.cpp9
-rw-r--r--src/object/auto/autohuston.cpp8
-rw-r--r--src/object/auto/autohuston.h1
-rw-r--r--src/object/auto/autoinfo.cpp78
-rw-r--r--src/object/auto/autojostle.cpp6
-rw-r--r--src/object/auto/autokid.cpp20
-rw-r--r--src/object/auto/autolabo.cpp59
-rw-r--r--src/object/auto/automush.cpp26
-rw-r--r--src/object/auto/autonest.cpp2
-rw-r--r--src/object/auto/autonuclear.cpp42
-rw-r--r--src/object/auto/autopara.cpp24
-rw-r--r--src/object/auto/autoportico.cpp16
-rw-r--r--src/object/auto/autoradar.cpp27
-rw-r--r--src/object/auto/autorepair.cpp26
-rw-r--r--src/object/auto/autoresearch.cpp26
-rw-r--r--src/object/auto/autoroot.cpp18
-rw-r--r--src/object/auto/autosafe.cpp81
-rw-r--r--src/object/auto/autostation.cpp34
-rw-r--r--src/object/auto/autotower.cpp31
-rw-r--r--src/object/brain.cpp19
-rw-r--r--src/object/motion/motion.cpp23
-rw-r--r--src/object/motion/motion.h3
-rw-r--r--src/object/motion/motionant.cpp141
-rw-r--r--src/object/motion/motionbee.cpp81
-rw-r--r--src/object/motion/motionhuman.cpp334
-rw-r--r--src/object/motion/motionmother.cpp53
-rw-r--r--src/object/motion/motionspider.cpp137
-rw-r--r--src/object/motion/motiontoto.cpp223
-rw-r--r--src/object/motion/motiontoto.h4
-rw-r--r--src/object/motion/motionvehicle.cpp207
-rw-r--r--src/object/motion/motionworm.cpp25
-rw-r--r--src/object/object.cpp194
-rw-r--r--src/object/robotmain.cpp176
-rw-r--r--src/object/robotmain.h38
-rw-r--r--src/object/task/task.cpp2
-rw-r--r--src/object/task/task.h20
-rw-r--r--src/object/task/taskadvance.cpp4
-rw-r--r--src/object/task/taskadvance.h2
-rw-r--r--src/object/task/taskbuild.cpp67
-rw-r--r--src/object/task/taskbuild.h2
-rw-r--r--src/object/task/taskfire.cpp70
-rw-r--r--src/object/task/taskfire.h2
-rw-r--r--src/object/task/taskfireant.cpp19
-rw-r--r--src/object/task/taskfireant.h1
-rw-r--r--src/object/task/taskflag.cpp13
-rw-r--r--src/object/task/taskflag.h5
-rw-r--r--src/object/task/taskgoto.cpp137
-rw-r--r--src/object/task/taskgoto.h4
-rw-r--r--src/object/task/taskgungoal.cpp8
-rw-r--r--src/object/task/taskgungoal.h2
-rw-r--r--src/object/task/taskinfo.cpp6
-rw-r--r--src/object/task/taskinfo.h2
-rw-r--r--src/object/task/taskmanager.cpp2
-rw-r--r--src/object/task/taskmanager.h2
-rw-r--r--src/object/task/taskmanip.cpp131
-rw-r--r--src/object/task/taskmanip.h2
-rw-r--r--src/object/task/taskpen.cpp42
-rw-r--r--src/object/task/taskpen.h1
-rw-r--r--src/object/task/taskrecover.cpp62
-rw-r--r--src/object/task/taskrecover.h1
-rw-r--r--src/object/task/taskreset.cpp44
-rw-r--r--src/object/task/taskreset.h2
-rw-r--r--src/object/task/tasksearch.cpp24
-rw-r--r--src/object/task/tasksearch.h2
-rw-r--r--src/object/task/taskshield.cpp46
-rw-r--r--src/object/task/taskshield.h2
-rw-r--r--src/object/task/taskspiderexplo.cpp2
-rw-r--r--src/object/task/taskspiderexplo.h2
-rw-r--r--src/object/task/tasktake.cpp55
-rw-r--r--src/object/task/tasktake.h2
-rw-r--r--src/object/task/taskterraform.cpp64
-rw-r--r--src/object/task/taskterraform.h2
-rw-r--r--src/object/task/taskturn.cpp2
-rw-r--r--src/object/task/taskturn.h2
-rw-r--r--src/object/task/taskwait.cpp2
-rw-r--r--src/object/task/taskwait.h2
-rw-r--r--src/physics/physics.cpp448
-rw-r--r--src/physics/physics.h1
-rw-r--r--src/script/cbottoken.cpp2
-rw-r--r--src/script/cmdtoken.cpp2
-rw-r--r--src/script/script.cpp67
-rw-r--r--src/script/script.h2
-rw-r--r--src/sound/sound.cpp9
-rw-r--r--src/ui/button.cpp6
-rw-r--r--src/ui/button.h2
-rw-r--r--src/ui/check.cpp6
-rw-r--r--src/ui/check.h2
-rw-r--r--src/ui/color.cpp6
-rw-r--r--src/ui/color.h2
-rw-r--r--src/ui/compass.cpp13
-rw-r--r--src/ui/compass.h2
-rw-r--r--src/ui/control.cpp56
-rw-r--r--src/ui/control.h34
-rw-r--r--src/ui/displayinfo.cpp16
-rw-r--r--src/ui/displayinfo.h14
-rw-r--r--src/ui/displaytext.cpp4
-rw-r--r--src/ui/displaytext.h2
-rw-r--r--src/ui/edit.cpp60
-rw-r--r--src/ui/edit.h28
-rw-r--r--src/ui/editvalue.cpp10
-rw-r--r--src/ui/editvalue.h6
-rw-r--r--src/ui/gauge.cpp6
-rw-r--r--src/ui/gauge.h2
-rw-r--r--src/ui/group.cpp18
-rw-r--r--src/ui/group.h2
-rw-r--r--src/ui/image.cpp6
-rw-r--r--src/ui/image.h2
-rw-r--r--src/ui/interface.cpp38
-rw-r--r--src/ui/interface.h40
-rw-r--r--src/ui/key.cpp6
-rw-r--r--src/ui/key.h2
-rw-r--r--src/ui/label.cpp6
-rw-r--r--src/ui/label.h2
-rw-r--r--src/ui/list.cpp16
-rw-r--r--src/ui/list.h8
-rw-r--r--src/ui/maindialog.cpp194
-rw-r--r--src/ui/maindialog.h12
-rw-r--r--src/ui/mainmap.cpp8
-rw-r--r--src/ui/mainmap.h6
-rw-r--r--src/ui/mainshort.cpp8
-rw-r--r--src/ui/mainshort.h7
-rw-r--r--src/ui/map.cpp91
-rw-r--r--src/ui/map.h33
-rw-r--r--src/ui/scroll.cpp24
-rw-r--r--src/ui/scroll.h11
-rw-r--r--src/ui/shortcut.cpp12
-rw-r--r--src/ui/shortcut.h2
-rw-r--r--src/ui/slider.cpp24
-rw-r--r--src/ui/slider.h11
-rw-r--r--src/ui/studio.cpp20
-rw-r--r--src/ui/studio.h8
-rw-r--r--src/ui/target.cpp8
-rw-r--r--src/ui/target.h6
-rw-r--r--src/ui/window.cpp76
-rw-r--r--src/ui/window.h62
195 files changed, 3454 insertions, 3618 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 22c5122..4f7275a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -122,6 +122,8 @@ ui/target.cpp
ui/window.cpp
)
+add_definitions(-DSTRICT -DD3D_OVERLOADS)
+
# Change to DirectX SDK directory
set(DXSDK_DIR "c:/dxsdk")
diff --git a/src/app/d3dapp.cpp b/src/app/d3dapp.cpp
index 3d8f798..ed88d6b 100644
--- a/src/app/d3dapp.cpp
+++ b/src/app/d3dapp.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 <winuser.h>
@@ -700,10 +698,10 @@ INT CD3DApplication::Run()
// x: 0=left, 1=right
// y: 0=down, 1=up
-FPOINT CD3DApplication::ConvPosToInterface(HWND hWnd, LPARAM lParam)
+Math::Point CD3DApplication::ConvPosToInterface(HWND hWnd, LPARAM lParam)
{
POINT cpos;
- FPOINT pos;
+ Math::Point pos;
float px, py, w, h;
cpos.x = (short)LOWORD(lParam);
@@ -727,7 +725,7 @@ FPOINT CD3DApplication::ConvPosToInterface(HWND hWnd, LPARAM lParam)
// Physically moves the mouse.
-void CD3DApplication::SetMousePos(FPOINT pos)
+void CD3DApplication::SetMousePos(Math::Point pos)
{
POINT p;
@@ -1259,9 +1257,9 @@ LRESULT CD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
m_axeJoy.y = -js.lY/1000.0f; // avancer
m_axeJoy.z = -js.rglSlider[0]/1000.0f; // monter
- m_axeJoy.x = Neutral(m_axeJoy.x, 0.2f);
- m_axeJoy.y = Neutral(m_axeJoy.y, 0.2f);
- m_axeJoy.z = Neutral(m_axeJoy.z, 0.2f);
+ m_axeJoy.x = Math::Neutral(m_axeJoy.x, 0.2f);
+ m_axeJoy.y = Math::Neutral(m_axeJoy.y, 0.2f);
+ m_axeJoy.z = Math::Neutral(m_axeJoy.z, 0.2f);
//? char s[100];
//? sprintf(s, "x=%d y=%d z=% x=%d y=%d z=%d\n", js.lX,js.lY,js.lZ,js.lRx,js.lRy,js.lRz);
@@ -1859,12 +1857,12 @@ LRESULT CD3DApplication::OnResumeSuspend( DWORD dwData )
void CD3DApplication::DrawSuppl()
{
HDC hDC;
- FPOINT p1, p2;
+ Math::Point p1, p2;
POINT list[3];
RECT rect;
HPEN hPen;
HGDIOBJ old;
- FPOINT pos;
+ Math::Point pos;
float d;
int nbOut;
@@ -1881,12 +1879,12 @@ void CD3DApplication::DrawSuppl()
if ( nbOut <= 2 )
{
#if 0
- time = Mod(m_aTime, 0.5f);
+ time = Math::Mod(m_aTime, 0.5f);
if ( time < 0.25f ) d = time*4.0f;
else d = (2.0f-time*4.0f);
#endif
#if 0
- time = Mod(m_aTime, 0.5f);
+ time = Math::Mod(m_aTime, 0.5f);
if ( time < 0.4f ) d = time/0.4f;
else d = 1.0f-(time-0.4f)/0.1f;
#endif
diff --git a/src/app/d3dapp.h b/src/app/d3dapp.h
index 7cb13b7..db18f5d 100644
--- a/src/app/d3dapp.h
+++ b/src/app/d3dapp.h
@@ -59,8 +59,8 @@ public:
INT Run();
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
VOID Pause( bool bPause );
- FPOINT ConvPosToInterface(HWND hWnd, LPARAM lParam);
- void SetMousePos(FPOINT pos);
+ Math::Point ConvPosToInterface(HWND hWnd, LPARAM lParam);
+ void SetMousePos(Math::Point pos);
void StepSimul(float rTime);
char* RetCDpath();
@@ -155,7 +155,7 @@ public:
D3DVECTOR m_axeKey;
D3DVECTOR m_axeJoy;
bool m_bJoyButton[32];
- FPOINT m_mousePos;
+ Math::Point m_mousePos;
DWORD m_mshMouseWheel;
float m_aTime;
diff --git a/src/app/joystick.cpp b/src/app/joystick.cpp
index 8d617f7..47a0947 100644
--- a/src/app/joystick.cpp
+++ b/src/app/joystick.cpp
@@ -16,7 +16,6 @@
// joystick.cpp
-#define STRICT
#define DIRECTINPUT_VERSION 0x0700
#include <windows.h>
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 1d56e8a..b323e43 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -16,8 +16,6 @@
// event.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/common/event.h b/src/common/event.h
index bf17934..0dc6ced 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/struct.h"
+#include "math/point.h"
#if !defined (WM_XBUTTONDOWN)
@@ -532,7 +532,7 @@ struct Event
{
EventMsg event; // event (EVENT *)
long param; // parameter
- FPOINT pos; // mouse position (0 .. 1)
+ Math::Point pos; // mouse position (0 .. 1)
float axeX; // control the X axis (-1 .. 1)
float axeY; // control of the Y axis (-1 .. 1)
float axeZ; // control the Z axis (-1 .. 1)
diff --git a/src/common/global.h b/src/common/global.h
index 212b8b4..0429cc1 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -16,6 +16,8 @@
// global.h
+#pragma once
+
enum BuildType
{
diff --git a/src/common/iman.cpp b/src/common/iman.cpp
index c6313e0..139f56a 100644
--- a/src/common/iman.cpp
+++ b/src/common/iman.cpp
@@ -16,8 +16,6 @@
// iman.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/common/metafile.cpp b/src/common/metafile.cpp
index 74bcc3d..7a67931 100644
--- a/src/common/metafile.cpp
+++ b/src/common/metafile.cpp
@@ -16,8 +16,6 @@
// metafile.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index f58527f..65b8031 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -16,8 +16,6 @@
// misc.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <math.h>
#include <stdlib.h>
diff --git a/src/common/modfile.cpp b/src/common/modfile.cpp
index ddda0d8..79d6612 100644
--- a/src/common/modfile.cpp
+++ b/src/common/modfile.cpp
@@ -16,8 +16,6 @@
// modfile.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -671,20 +669,20 @@ float CModFile::RetHeight(D3DVECTOR pos)
{
if ( !m_triangleTable[i].bUsed ) continue;
- if ( Abs(pos.x-m_triangleTable[i].p1.x) < limit &&
- Abs(pos.z-m_triangleTable[i].p1.z) < limit )
+ if ( fabs(pos.x-m_triangleTable[i].p1.x) < limit &&
+ fabs(pos.z-m_triangleTable[i].p1.z) < limit )
{
return m_triangleTable[i].p1.y;
}
- if ( Abs(pos.x-m_triangleTable[i].p2.x) < limit &&
- Abs(pos.z-m_triangleTable[i].p2.z) < limit )
+ if ( fabs(pos.x-m_triangleTable[i].p2.x) < limit &&
+ fabs(pos.z-m_triangleTable[i].p2.z) < limit )
{
return m_triangleTable[i].p2.y;
}
- if ( Abs(pos.x-m_triangleTable[i].p3.x) < limit &&
- Abs(pos.z-m_triangleTable[i].p3.z) < limit )
+ if ( fabs(pos.x-m_triangleTable[i].p3.x) < limit &&
+ fabs(pos.z-m_triangleTable[i].p3.z) < limit )
{
return m_triangleTable[i].p3.y;
}
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index ab7904b..9f3de54 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -16,8 +16,6 @@
// profile.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <stdio.h>
#include <d3d.h>
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index 725a96a..d8ac63f 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.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/.// restext.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <stdio.h>
#include "common/struct.h"
diff --git a/src/common/restext.h b/src/common/restext.h
index 481255f..ab48a12 100644
--- a/src/common/restext.h
+++ b/src/common/restext.h
@@ -19,8 +19,6 @@
#pragma once
-#define STRICT
-#define D3D_OVERLOADS
#include "graphics/d3d/d3dengine.h"
diff --git a/src/common/struct.h b/src/common/struct.h
index 901651f..76594fe 100644
--- a/src/common/struct.h
+++ b/src/common/struct.h
@@ -48,20 +48,6 @@ struct D3DVERTEX2
};
-struct FPOINT
-{
- float x;
- float y;
-
- FPOINT() { }
- FPOINT(float _x, float _y)
- {
- x = _x;
- y = _y;
- }
-};
-
-
struct ColorHSV
{
float h,s,v;
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>
diff --git a/src/math/conv.h b/src/math/conv.h
index 8b77db9..8cfdc6b 100644
--- a/src/math/conv.h
+++ b/src/math/conv.h
@@ -8,9 +8,7 @@
#define D3D_OVERLOADS
#include <d3d.h>
-#include "common/struct.h"
#include "vector.h"
-#include "point.h"
inline D3DVECTOR V_TO_D3D(Math::Vector vec)
{
@@ -21,13 +19,3 @@ inline Math::Vector D3D_TO_V(D3DVECTOR vec)
{
return Math::Vector(vec.x, vec.y, vec.z);
}
-
-inline FPOINT P_TO_FP(Math::Point pt)
-{
- return FPOINT(pt.x, pt.y);
-}
-
-inline Math::Point FP_TO_P(FPOINT pt)
-{
- return Math::Point(pt.x, pt.y);
-}
diff --git a/src/math/func.h b/src/math/func.h
index e5e1321..212f7c1 100644
--- a/src/math/func.h
+++ b/src/math/func.h
@@ -151,7 +151,7 @@ inline bool TestAngle(float angle, float min, float max)
}
//! Calculates a value (radians) proportional between a and b (degrees)
-float PropAngle(int a, int b, float p)
+inline float PropAngle(int a, int b, float p)
{
float aa = (float)a * DEG_TO_RAD;
float bb = (float)b * DEG_TO_RAD;
@@ -185,7 +185,7 @@ inline float Direction(float a, float g)
<---->
dead
out: -1 0 0 1\endverbatim */
-float Neutral(float value, float dead)
+inline float Neutral(float value, float dead)
{
if ( fabs(value) <= dead )
{
@@ -200,7 +200,7 @@ float Neutral(float value, float dead)
//! Gently advances a desired value from its current value
/** Over time, the progression is more rapid. */
-float Smooth(float actual, float hope, float time)
+inline float Smooth(float actual, float hope, float time)
{
float future = actual + (hope-actual)*time;
diff --git a/src/math/geometry.h b/src/math/geometry.h
index 580b9da..72584b0 100644
--- a/src/math/geometry.h
+++ b/src/math/geometry.h
@@ -52,25 +52,6 @@ inline float MidPoint(const Point &a, const Point &b, float px)
return (b.y-a.y) * (px-a.x) / (b.x-a.x) + a.y;
}
-//! Calculates the parameters a and b of the linear function passing through \a p1 and \a p2
-/** Returns \c false if the line is vertical.
- \param p1,p2 points
- \param a,b linear function parameters */
-inline bool LinearFunction(const Point &p1, const Point &p2, float &a, float &b)
-{
- if ( IsZero(p1.x-p2.x) )
- {
- a = HUGE;
- b = p2.x;
- return false;
- }
-
- a = (p2.y-p1.y) / (p2.x-p1.x);
- b = p2.y - p2.x*a;
-
- return true;
-}
-
//! Tests whether the point \a p is inside the triangle (\a a,\a b,\a c)
inline bool IsInsideTriangle(Point a, Point b, Point c, Point p)
{
@@ -198,7 +179,7 @@ inline Vector RotatePoint2(const Vector center, float angleH, float angleV, Vect
}
//! Returns the angle between point (x,y) and (0,0)
-float RotateAngle(float x, float y)
+inline float RotateAngle(float x, float y)
{
if ( (x == 0.0f) && (y == 0.0f) )
return 0.0f;
diff --git a/src/math/old/math3d.cpp b/src/math/old/math3d.cpp
index ad380af..c9eb608 100644
--- a/src/math/old/math3d.cpp
+++ b/src/math/old/math3d.cpp
@@ -30,12 +30,116 @@
#include "math/old/math3d.h"
+// Old defines
+#define MATH3D_PI 3.14159265358979323846f
+#define MATH3D_CHOUIA 1e-6f
+#define MATH3D_BEAUCOUP 1e6f
+
+
+// Old FPOINT struct
+struct FPOINT
+{
+ float x;
+ float y;
+
+ FPOINT() { }
+ FPOINT(float _x, float _y)
+ {
+ x = _x;
+ y = _y;
+ }
+};
+
+
+// === Functions already replaced by new implementation ===
+
+//>>> func.h IsEqual()
+bool IsEqual(float a, float b);
+
+//>>> func.h Min()
+float Min(float a, float b);
+float Min(float a, float b, float c);
+float Min(float a, float b, float c, float d);
+float Min(float a, float b, float c, float d, float e);
+
+//>>> func.h Max()
+float Max(float a, float b);
+float Max(float a, float b, float c);
+float Max(float a, float b, float c, float d);
+float Max(float a, float b, float c, float d, float e);
+
+//>>> func.h Norm()
+float Norm(float a);
+//>>> fabs()
+float Abs(float a);
+
+//>>> func.h Swap()
+void Swap(int &a, int &b);
+//>>> func.h Swap()
+void Swap(float &a, float &b);
+//>>> point.h Swap()
+void Swap(FPOINT &a, FPOINT &b);
+
+//>>> func.h Mod()
+float Mod(float a, float m);
+//>>> func.h NormAngle()
+float NormAngle(float angle);
+//>>> func.h TestAngle()
+bool TestAngle(float angle, float min, float max);
+
+//>>> geometry.h RotateAngle()
+float RotateAngle(FPOINT center, FPOINT p1, FPOINT p2);
+
+//>>> func.h Direction()
+float Direction(float a, float g);
+
+//>>> geometry.h RotatePoint()
+FPOINT RotatePoint(FPOINT center, float angle, FPOINT p);
+//>>> geometry.h RotatePoint()
+FPOINT RotatePoint(float angle, FPOINT p);
+//>>> geometry.h RotatePoint()
+FPOINT RotatePoint(float angle, float dist);
+//>>> geometry.h RotateAngle()
+float RotateAngle(float x, float y);
+//>>> geometry.h RotatePoint()
+void RotatePoint(float cx, float cy, float angle, float &px, float &py);
+
+//>>> geometry.h IsInsideTriangle()
+bool IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p);
+
+//>>> point.h Distance()
+float Length(FPOINT a, FPOINT b);
+
+//>>> point.h Point::Length()
+float Length(float x, float y);
+
+//>>> func.h Rand()
+float Rand();
+//>>> func.h Neutral()
+float Neutral(float value, float dead);
+
+//>>> func.h PropAngle()
+float Prop(int a, int b, float p);
+//>>> func.h Smooth()
+float Smooth(float actual, float hope, float time);
+//>>> func.h Bounce()
+float Bounce(float progress, float middle=0.3f, float bounce=0.4f);
+
+
+// UNUSED
+float MidPoint(FPOINT a, FPOINT b, float px);
+
+// UNUSED
+bool LineFunction(FPOINT p1, FPOINT p2, float &a, float &b);
+
+
+
// Returns true if two numbers are nearly equal.
bool IsEqual(float a, float b)
{
- return Abs(a-b) < CHOUIA;
+ return Abs(a-b) < MATH3D_CHOUIA;
}
@@ -147,14 +251,14 @@ float Mod(float a, float m)
return a - ((int)(a/m))*m;
}
-// Returns a normalized angle, that is in other words between 0 and 2 * PI.
+// Returns a normalized angle, that is in other words between 0 and 2 * MATH3D_PI.
float NormAngle(float angle)
{
- angle = Mod(angle, PI*2.0f);
+ angle = Mod(angle, MATH3D_PI*2.0f);
if ( angle < 0.0f )
{
- return PI*2.0f + angle;
+ return MATH3D_PI*2.0f + angle;
}
else
{
@@ -191,11 +295,11 @@ float Direction(float a, float g)
if ( a < g )
{
- if ( a+PI*2.0f-g < g-a ) a += PI*2.0f;
+ if ( a+MATH3D_PI*2.0f-g < g-a ) a += MATH3D_PI*2.0f;
}
else
{
- if ( g+PI*2.0f-a < a-g ) g += PI*2.0f;
+ if ( g+MATH3D_PI*2.0f-a < a-g ) g += MATH3D_PI*2.0f;
}
return (g-a);
}
@@ -249,7 +353,7 @@ FPOINT RotatePoint(float angle, float dist)
}
// Calculates the angle of a right triangle.
-// The angle is counterclockwise (CCW), between 0 and 2 * PI.
+// The angle is counterclockwise (CCW), between 0 and 2 * MATH3D_PI.
// For an angle clockwise (CW), just go ahead.
//
// ^
@@ -271,25 +375,25 @@ float RotateAngle(float x, float y)
if ( y >= 0.0f )
{
if ( x > y ) return atanf(y/x);
- else return PI*0.5f - atanf(x/y);
+ else return MATH3D_PI*0.5f - atanf(x/y);
}
else
{
- if ( x > -y ) return PI*2.0f + atanf(y/x);
- else return PI*1.5f - atanf(x/y);
+ if ( x > -y ) return MATH3D_PI*2.0f + atanf(y/x);
+ else return MATH3D_PI*1.5f - atanf(x/y);
}
}
else
{
if ( y >= 0.0f )
{
- if ( -x > y ) return PI*1.0f + atanf(y/x);
- else return PI*0.5f - atanf(x/y);
+ if ( -x > y ) return MATH3D_PI*1.0f + atanf(y/x);
+ else return MATH3D_PI*0.5f - atanf(x/y);
}
else
{
- if ( -x > -y ) return PI*1.0f + atanf(y/x);
- else return PI*1.5f - atanf(x/y);
+ if ( -x > -y ) return MATH3D_PI*1.0f + atanf(y/x);
+ else return MATH3D_PI*1.5f - atanf(x/y);
}
}
#else
@@ -299,11 +403,11 @@ float RotateAngle(float x, float y)
{
if ( y > 0.0f )
{
- return 90.0f*PI/180.0f;
+ return 90.0f*MATH3D_PI/180.0f;
}
else
{
- return 270.0f*PI/180.0f;
+ return 270.0f*MATH3D_PI/180.0f;
}
}
else
@@ -311,7 +415,7 @@ float RotateAngle(float x, float y)
angle = atanf(y/x);
if ( x < 0.0f )
{
- angle += PI;
+ angle += MATH3D_PI;
}
return angle;
}
@@ -335,11 +439,11 @@ float RotateAngle(FPOINT center, FPOINT p1, FPOINT p2)
a1 = asinf((p1.y-center.y)/Length(p1,center));
a2 = asinf((p2.y-center.y)/Length(p2,center));
- if ( p1.x < center.x ) a1 = PI-a1;
- if ( p2.x < center.x ) a2 = PI-a2;
+ if ( p1.x < center.x ) a1 = MATH3D_PI-a1;
+ if ( p2.x < center.x ) a2 = MATH3D_PI-a2;
a = a2-a1;
- if ( a < 0 ) a += PI*2;
+ if ( a < 0 ) a += MATH3D_PI*2;
return a;
}
@@ -347,10 +451,10 @@ float RotateAngle(FPOINT center, FPOINT p1, FPOINT p2)
float MidPoint(FPOINT a, FPOINT b, float px)
{
- if ( Abs(a.x-b.x) < CHOUIA )
+ if ( Abs(a.x-b.x) < MATH3D_CHOUIA )
{
- if ( a.y < b.y ) return BEAUCOUP;
- else return -BEAUCOUP;
+ if ( a.y < b.y ) return MATH3D_BEAUCOUP;
+ else return -MATH3D_BEAUCOUP;
}
return (b.y-a.y)*(px-a.x)/(b.x-a.x)+a.y;
}
@@ -850,8 +954,8 @@ float Prop(int a, int b, float p)
{
float aa, bb;
- aa = (float)a*PI/180.0f;
- bb = (float)b*PI/180.0f;
+ aa = (float)a*MATH3D_PI/180.0f;
+ bb = (float)b*MATH3D_PI/180.0f;
return aa+p*(bb-aa);
}
@@ -896,12 +1000,12 @@ float Bounce(float progress, float middle, float bounce)
if ( progress < middle )
{
progress = progress/middle; // 0..1
- return 0.5f+sinf(progress*PI-PI/2.0f)/2.0f;
+ return 0.5f+sinf(progress*MATH3D_PI-MATH3D_PI/2.0f)/2.0f;
}
else
{
progress = (progress-middle)/(1.0f-middle); // 0..1
- return (1.0f-bounce/2.0f)+sinf((0.5f+progress*2.0f)*PI)*(bounce/2.0f);
+ return (1.0f-bounce/2.0f)+sinf((0.5f+progress*2.0f)*MATH3D_PI)*(bounce/2.0f);
}
}
diff --git a/src/math/old/math3d.h b/src/math/old/math3d.h
index cb17669..6c09f99 100644
--- a/src/math/old/math3d.h
+++ b/src/math/old/math3d.h
@@ -19,147 +19,92 @@
#pragma once
-#define STRICT
-#define D3D_OVERLOADS
#include <math.h>
-#define PI 3.14159265358979323846f
-#define CHOUIA 1e-6f
-#define BEAUCOUP 1e6f
-
-
-
-//>>> func.h IsEqual()
-bool IsEqual(float a, float b);
-
-//>>> func.h Min()
-float Min(float a, float b);
-float Min(float a, float b, float c);
-float Min(float a, float b, float c, float d);
-float Min(float a, float b, float c, float d, float e);
-
-//>>> func.h Max()
-float Max(float a, float b);
-float Max(float a, float b, float c);
-float Max(float a, float b, float c, float d);
-float Max(float a, float b, float c, float d, float e);
-
-//>>> func.h Norm()
-float Norm(float a);
-//>>> fabs()
-float Abs(float a);
-
-//>>> func.h Swap()
-void Swap(int &a, int &b);
-//>>> func.h Swap()
-void Swap(float &a, float &b);
-//>>> point.h Swap() (FPOINT -> Point)
-void Swap(FPOINT &a, FPOINT &b);
-
-//>>> func.h Mod()
-float Mod(float a, float m);
-//>>> func.h NormAngle()
-float NormAngle(float angle);
-//>>> func.h TestAngle()
-bool TestAngle(float angle, float min, float max);
-
-//>>> func.h Direction()
-float Direction(float a, float g);
-//>>> geometry.h RotatePoint()
-FPOINT RotatePoint(FPOINT center, float angle, FPOINT p);
-//>>> geometry.h RotatePoint()
-FPOINT RotatePoint(float angle, FPOINT p);
-//>>> geometry.h RotatePoint()
-FPOINT RotatePoint(float angle, float dist);
-//>>> geometry.h RotateAngle()
-float RotateAngle(float x, float y);
-//>>> geometry.h RotateAngle()
-float RotateAngle(FPOINT center, FPOINT p1, FPOINT p2);
-//>>> geometry.h MidPoint()
-float MidPoint(FPOINT a, FPOINT b, float px);
//>>> geometry.h SegmentPoint()
D3DVECTOR SegmentDist(const D3DVECTOR &p1, const D3DVECTOR &p2, float dist);
-//>>> geometry.h IsInsideTriangle()
-bool IsInsideTriangle(FPOINT a, FPOINT b, FPOINT c, FPOINT p);
+
//>>> geometry.h Intersect()
bool Intersect(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR d, D3DVECTOR e, D3DVECTOR &i);
+
//>>> geometry.h IntersectY()
bool IntersectY(D3DVECTOR a, D3DVECTOR b, D3DVECTOR c, D3DVECTOR &p);
-//>>> geometry.h RotatePoint()
-void RotatePoint(float cx, float cy, float angle, float &px, float &py);
+
//>>> geometry.h RotatePoint()
void RotatePoint(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
+
//>>> geometry.h RotatePoint2()
void RotatePoint2(D3DVECTOR center, float angleH, float angleV, D3DVECTOR &p);
+
//>>> geometry.h RotateView()
// TODO test & verify
D3DVECTOR RotateView(D3DVECTOR center, float angleH, float angleV, float dist);
+
//>>> geometry.h LookatPoint()
// TODO test & verify
D3DVECTOR LookatPoint( D3DVECTOR eye, float angleH, float angleV, float length );
-//>>> point.h Distance()
-float Length(FPOINT a, FPOINT b);
-//>>> point.h Point::Length()
-float Length(float x, float y);
+
//>>> vector.h Vector::Length()
float Length(const D3DVECTOR &u);
+
//>>> vector.h Distance()
float Length(const D3DVECTOR &a, const D3DVECTOR &b);
+
//>>> geometry.h DistanceProjected()
float Length2d(const D3DVECTOR &a, const D3DVECTOR &b);
+
//>>> vector.h Angle()
// TODO test & verify
float Angle( D3DVECTOR u, D3DVECTOR v );
+
//>>> vector.h CrossProduct()
D3DVECTOR Cross( D3DVECTOR u, D3DVECTOR v );
+
//>>> geometry.h NormalToPlane()
D3DVECTOR ComputeNormal( D3DVECTOR p1, D3DVECTOR p2, D3DVECTOR p3 );
+
//>>> geometry.h Transform()
// TODO test & verify
D3DVECTOR Transform(const D3DMATRIX &m, D3DVECTOR p);
+
//>>> geometry.h Projection()
// TODO test & verify
D3DVECTOR Projection(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &p);
// TODO
void MappingObject( D3DVERTEX2* pVertices, int nb, float scale );
+
// TODO
void SmoothObject( D3DVERTEX2* pVertices, int nb );
-//>>> geometry.h LinearFunction()
-bool LineFunction(FPOINT p1, FPOINT p2, float &a, float &b);
+
//>>> geometry.h DistanceToPlane()
float DistancePlanPoint(const D3DVECTOR &a, const D3DVECTOR &b, const D3DVECTOR &c, const D3DVECTOR &p);
+
//>>> geometry.h IsSamePlane()
bool IsSamePlane(D3DVECTOR *plan1, D3DVECTOR *plan2);
+
//>>> geometry.h LoadRotationXZYMatrix()
// TODO test & verify
void MatRotateXZY(D3DMATRIX &mat, D3DVECTOR angle);
+
//>>> geometry.h LoadRotationZXYMatrix()
// TODO test & verify
void MatRotateZXY(D3DMATRIX &mat, D3DVECTOR angle);
-//>>> func.h Rand()
-float Rand();
-//>>> func.h Neutral()
-float Neutral(float value, float dead);
-
-//>>> func.h PropAngle()
-float Prop(int a, int b, float p);
-//>>> func.h Smooth()
-float Smooth(float actual, float hope, float time);
-//>>> func.h Bounce()
-float Bounce(float progress, float middle=0.3f, float bounce=0.4f);
// TODO
D3DCOLOR RetColor(float intensity);
+
// TODO
D3DCOLOR RetColor(D3DCOLORVALUE intensity);
+
// TODO
D3DCOLORVALUE RetColor(D3DCOLOR intensity);
// TODO
void RGB2HSV(D3DCOLORVALUE src, ColorHSV &dest);
+
// TODO
void HSV2RGB(ColorHSV src, D3DCOLORVALUE &dest);
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index 94a8afa..7440584 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.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>
@@ -176,7 +174,7 @@ bool CAuto::Abort()
bool CAuto::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
char name[100];
diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h
index 5a631ec..68fcacb 100644
--- a/src/object/auto/auto.h
+++ b/src/object/auto/auto.h
@@ -19,6 +19,7 @@
#pragma once
+#include "common/misc.h"
#include "object/object.h"
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index 54bf96f..2091091 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -14,14 +14,13 @@
// * 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/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/language.h"
@@ -132,7 +131,7 @@ bool CAutoBase::EventProcess(const Event &event)
Event newEvent;
CObject* pObj;
D3DVECTOR pos, speed, vibCir, iPos;
- FPOINT dim, p;
+ Math::Point dim, p;
Error err;
float angle, dist, time, h, len, vSpeed;
int i, max;
@@ -160,9 +159,9 @@ begin:
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f-124.0f*PI/180.0f);
- m_object->SetAngleX(10+i, -10.0f*PI/180.0f);
- m_object->SetAngleX(18+i, 10.0f*PI/180.0f);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f-124.0f*Math::PI/180.0f);
+ m_object->SetAngleX(10+i, -10.0f*Math::PI/180.0f);
+ m_object->SetAngleX(18+i, 10.0f*Math::PI/180.0f);
m_object->SetPosition(10+i, D3DVECTOR(23.5f, 0.0f, -11.5f));
m_object->SetPosition(18+i, D3DVECTOR(23.5f, 0.0f, 11.5f));
}
@@ -191,9 +190,9 @@ begin:
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f-124.0f*PI/180.0f);
- m_object->SetAngleX(10+i, -10.0f*PI/180.0f);
- m_object->SetAngleX(18+i, 10.0f*PI/180.0f);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f-124.0f*Math::PI/180.0f);
+ m_object->SetAngleX(10+i, -10.0f*Math::PI/180.0f);
+ m_object->SetAngleX(18+i, 10.0f*Math::PI/180.0f);
m_object->SetPosition(10+i, D3DVECTOR(23.5f, 0.0f, -11.5f));
m_object->SetPosition(18+i, D3DVECTOR(23.5f, 0.0f, 11.5f));
}
@@ -260,7 +259,7 @@ begin:
m_progress = 0.0f;
m_speed = 1.0f/BASE_TRANSIT_TIME;
- m_object->SetAngleZ(0, -PI/2.0f);
+ m_object->SetAngleZ(0, -Math::PI/2.0f);
pos = m_object->RetPosition(0);
pos.y += 10000.0f; // in space
m_finalPos = pos;
@@ -385,14 +384,14 @@ begin:
m_object->SetPosition(0, pos);
MoveCargo(); // all cargo moves
- vibCir.z = sinf(m_time*PI* 2.01f)*(PI/150.0f)+
- sinf(m_time*PI* 2.51f)*(PI/200.0f)+
- sinf(m_time*PI*19.01f)*(PI/400.0f);
- vibCir.x = sinf(m_time*PI* 2.03f)*(PI/150.0f)+
- sinf(m_time*PI* 2.52f)*(PI/200.0f)+
- sinf(m_time*PI*19.53f)*(PI/400.0f);
+ vibCir.z = sinf(m_time*Math::PI* 2.01f)*(Math::PI/150.0f)+
+ sinf(m_time*Math::PI* 2.51f)*(Math::PI/200.0f)+
+ sinf(m_time*Math::PI*19.01f)*(Math::PI/400.0f);
+ vibCir.x = sinf(m_time*Math::PI* 2.03f)*(Math::PI/150.0f)+
+ sinf(m_time*Math::PI* 2.52f)*(Math::PI/200.0f)+
+ sinf(m_time*Math::PI*19.53f)*(Math::PI/400.0f);
vibCir.y = 0.0f;
- vibCir *= Min(1.0f, (1.0f-m_progress)*3.0f);
+ vibCir *= Math::Min(1.0f, (1.0f-m_progress)*3.0f);
m_object->SetCirVibration(vibCir);
pos = m_pos;
@@ -413,15 +412,15 @@ begin:
// Dust thrown to the ground.
pos = m_pos;
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
- angle = Rand()*(PI*2.0f);
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
+ angle = Math::Rand()*(Math::PI*2.0f);
dist = m_progress*50.0f;
- p = RotatePoint(angle, dist);
+ p = Math::RotatePoint(angle, dist);
speed.x = p.x;
speed.z = p.y;
speed.y = 0.0f;
- dim.x = (Rand()*15.0f+15.0f)*m_progress;
+ dim.x = (Math::Rand()*15.0f+15.0f)*m_progress;
dim.y = dim.x;
if ( dim.x >= 1.0f )
{
@@ -432,10 +431,10 @@ begin:
pos = m_object->RetPosition(0);
pos.y += 6.0f;
h = m_terrain->RetFloorHeight(pos)/300.0f;
- speed.x = (Rand()-0.5f)*(80.0f-50.0f*h);
- speed.z = (Rand()-0.5f)*(80.0f-50.0f*h);
- speed.y = -(Rand()*(h+1.0f)*40.0f+(h+1.0f)*40.0f);
- dim.x = Rand()*2.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*(80.0f-50.0f*h);
+ speed.z = (Math::Rand()-0.5f)*(80.0f-50.0f*h);
+ speed.y = -(Math::Rand()*(h+1.0f)*40.0f+(h+1.0f)*40.0f);
+ dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 2.0f, 10.0f, 2.0f);
@@ -443,13 +442,13 @@ begin:
if ( m_progress > 0.8f )
{
pos = m_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 += 3.0f;
- speed.x = (Rand()-0.5f)*8.0f;
- speed.z = (Rand()-0.5f)*8.0f;
+ speed.x = (Math::Rand()-0.5f)*8.0f;
+ speed.z = (Math::Rand()-0.5f)*8.0f;
speed.y = 0.0f;
- dim.x = Rand()*4.0f+4.0f;
+ dim.x = Math::Rand()*4.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 2.0f);
}
@@ -467,15 +466,15 @@ begin:
max = (int)(50.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<max ; i++ )
{
- angle = Rand()*(PI*2.0f);
- p = RotatePoint(angle, 46.0f);
+ angle = Math::Rand()*(Math::PI*2.0f);
+ p = Math::RotatePoint(angle, 46.0f);
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*10.0f+10.0f;
+ dim.x = Math::Rand()*10.0f+10.0f;
dim.y = dim.x;
- time = Rand()*2.0f+1.5f;
+ time = Math::Rand()*2.0f+1.5f;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time, 0.0f, 2.0f);
}
@@ -500,13 +499,13 @@ begin:
// Black smoke from the reactor.
pos = m_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 += 3.0f;
- speed.x = (Rand()-0.5f)*8.0f;
- speed.z = (Rand()-0.5f)*8.0f;
+ speed.x = (Math::Rand()-0.5f)*8.0f;
+ speed.z = (Math::Rand()-0.5f)*8.0f;
speed.y = 0.0f;
- dim.x = Rand()*4.0f+4.0f;
+ dim.x = Math::Rand()*4.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 2.0f);
}
@@ -528,16 +527,16 @@ begin:
{
if ( m_progress < 1.0f )
{
- angle = -m_progress*124.0f*PI/180.0f;
+ angle = -m_progress*124.0f*Math::PI/180.0f;
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f+angle);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f+angle);
}
if ( m_param != PARAM_PORTICO )
{
- angle = m_progress*PI*2.0f;
- p = RotatePoint(angle, -150.0f);
+ angle = m_progress*Math::PI*2.0f;
+ p = Math::RotatePoint(angle, -150.0f);
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
@@ -553,23 +552,23 @@ begin:
{
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f-124.0f*PI/180.0f);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f-124.0f*Math::PI/180.0f);
}
// Clash the doors with the ground.
max = (int)(20.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<max ; i++ )
{
- angle = Rand()*(20.0f*PI/180.0f)-(10.0f*PI/180.0f);
- angle += (PI/4.0f)*(rand()%8);
- p = RotatePoint(angle, 74.0f);
+ angle = Math::Rand()*(20.0f*Math::PI/180.0f)-(10.0f*Math::PI/180.0f);
+ angle += (Math::PI/4.0f)*(rand()%8);
+ p = Math::RotatePoint(angle, 74.0f);
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*8.0f+8.0f;
+ dim.x = Math::Rand()*8.0f+8.0f;
dim.y = dim.x;
- time = Rand()*2.0f+1.5f;
+ time = Math::Rand()*2.0f+1.5f;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time, 0.0f, 2.0f);
}
@@ -592,14 +591,14 @@ begin:
{
m_object->SetPosition(10+i, D3DVECTOR(23.5f, 0.0f, len));
m_object->SetPosition(18+i, D3DVECTOR(23.5f, 0.0f, -len));
- m_object->SetAngleX(10+i, -10.0f*PI/180.0f*m_progress);
- m_object->SetAngleX(18+i, 10.0f*PI/180.0f*m_progress);
+ m_object->SetAngleX(10+i, -10.0f*Math::PI/180.0f*m_progress);
+ m_object->SetAngleX(18+i, 10.0f*Math::PI/180.0f*m_progress);
}
if ( m_param != PARAM_PORTICO )
{
- angle = m_progress*PI/2.0f;
- p = RotatePoint(angle, -150.0f);
+ angle = m_progress*Math::PI/2.0f;
+ p = Math::RotatePoint(angle, -150.0f);
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
@@ -617,8 +616,8 @@ begin:
{
m_object->SetPosition(10+i, D3DVECTOR(23.5f, 0.0f, -11.5f));
m_object->SetPosition(18+i, D3DVECTOR(23.5f, 0.0f, 11.5f));
- m_object->SetAngleX(10+i, -10.0f*PI/180.0f);
- m_object->SetAngleX(18+i, 10.0f*PI/180.0f);
+ m_object->SetAngleX(10+i, -10.0f*Math::PI/180.0f);
+ m_object->SetAngleX(18+i, 10.0f*Math::PI/180.0f);
}
m_phase = ABP_LDWAIT;
@@ -671,8 +670,8 @@ begin:
{
m_object->SetPosition(10+i, D3DVECTOR(23.5f, 0.0f, len));
m_object->SetPosition(18+i, D3DVECTOR(23.5f, 0.0f, -len));
- m_object->SetAngleX(10+i, -10.0f*PI/180.0f*(1.0f-m_progress));
- m_object->SetAngleX(18+i, 10.0f*PI/180.0f*(1.0f-m_progress));
+ m_object->SetAngleX(10+i, -10.0f*Math::PI/180.0f*(1.0f-m_progress));
+ m_object->SetAngleX(18+i, 10.0f*Math::PI/180.0f*(1.0f-m_progress));
}
}
else
@@ -700,17 +699,17 @@ begin:
{
if ( m_progress < 1.0f )
{
- angle = -(1.0f-m_progress)*124.0f*PI/180.0f;
+ angle = -(1.0f-m_progress)*124.0f*Math::PI/180.0f;
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f+angle);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f+angle);
}
}
else
{
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f);
}
m_bMotor = true; // lights the jet engine
@@ -718,16 +717,16 @@ begin:
max = (int)(20.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<max ; i++ )
{
- angle = Rand()*PI*2.0f;
- p = RotatePoint(angle, 32.0f);
+ angle = Math::Rand()*Math::PI*2.0f;
+ p = Math::RotatePoint(angle, 32.0f);
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
pos.y += 85.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*3.0f+3.0f;
+ dim.x = Math::Rand()*3.0f+3.0f;
dim.y = dim.x;
- time = Rand()*1.0f+1.0f;
+ time = Math::Rand()*1.0f+1.0f;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time);
}
m_sound->Play(SOUND_BOUM, m_object->RetPosition(0));
@@ -751,8 +750,8 @@ begin:
m_sound->AddEnvelope(m_soundChannel, 0.3f, 2.0f, BASE_TAKO_TIME, SOPER_STOP);
}
- vibCir.z = sinf(m_time*PI*19.01f)*(PI/400.0f);
- vibCir.x = sinf(m_time*PI*19.53f)*(PI/400.0f);
+ vibCir.z = sinf(m_time*Math::PI*19.01f)*(Math::PI/400.0f);
+ vibCir.x = sinf(m_time*Math::PI*19.53f)*(Math::PI/400.0f);
vibCir.y = 0.0f;
vibCir *= m_progress*1.0f;
m_object->SetCirVibration(vibCir);
@@ -764,10 +763,10 @@ begin:
// Particles are ejected from the reactor.
pos = m_object->RetPosition(0);
pos.y += 6.0f;
- speed.x = (Rand()-0.5f)*160.0f;
- speed.z = (Rand()-0.5f)*160.0f;
- speed.y = -(Rand()*10.0f+10.0f);
- dim.x = Rand()*2.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*160.0f;
+ speed.z = (Math::Rand()-0.5f)*160.0f;
+ speed.y = -(Math::Rand()*10.0f+10.0f);
+ dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 2.0f, 10.0f, 2.0f);
}
@@ -793,8 +792,8 @@ begin:
m_object->SetPosition(0, pos);
MoveCargo(); // all cargo moves
- vibCir.z = sinf(m_time*PI*19.01f)*(PI/400.0f);
- vibCir.x = sinf(m_time*PI*19.53f)*(PI/400.0f);
+ vibCir.z = sinf(m_time*Math::PI*19.01f)*(Math::PI/400.0f);
+ vibCir.x = sinf(m_time*Math::PI*19.53f)*(Math::PI/400.0f);
vibCir.y = 0.0f;
m_object->SetCirVibration(vibCir);
@@ -816,15 +815,15 @@ begin:
// Dust thrown to the ground.
pos = m_pos;
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
- angle = Rand()*(PI*2.0f);
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
+ angle = Math::Rand()*(Math::PI*2.0f);
dist = (1.0f-m_progress)*50.0f;
- p = RotatePoint(angle, dist);
+ p = Math::RotatePoint(angle, dist);
speed.x = p.x;
speed.z = p.y;
speed.y = 0.0f;
- dim.x = (Rand()*10.0f+10.0f)*(1.0f-m_progress);
+ dim.x = (Math::Rand()*10.0f+10.0f)*(1.0f-m_progress);
dim.y = dim.x;
if ( dim.x >= 1.0f )
{
@@ -834,22 +833,22 @@ begin:
// Particles are ejected from the reactor.
pos = m_object->RetPosition(0);
pos.y += 6.0f;
- speed.x = (Rand()-0.5f)*40.0f;
- speed.z = (Rand()-0.5f)*40.0f;
+ speed.x = (Math::Rand()-0.5f)*40.0f;
+ speed.z = (Math::Rand()-0.5f)*40.0f;
time = 5.0f+150.0f*m_progress;
- speed.y = -(Rand()*time+time);
+ speed.y = -(Math::Rand()*time+time);
time = 2.0f+m_progress*12.0f;
- dim.x = Rand()*time+time;
+ dim.x = Math::Rand()*time+time;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 2.0f, 10.0f, 2.0f);
// Black smoke from the reactor.
pos = m_object->RetPosition(0);
pos.y += 3.0f;
- speed.x = (Rand()-0.5f)*10.0f*(4.0f-m_progress*3.0f);
- speed.z = (Rand()-0.5f)*10.0f*(4.0f-m_progress*3.0f);
+ speed.x = (Math::Rand()-0.5f)*10.0f*(4.0f-m_progress*3.0f);
+ speed.z = (Math::Rand()-0.5f)*10.0f*(4.0f-m_progress*3.0f);
speed.y = 0.0f;
- dim.x = Rand()*20.0f+20.0f;
+ dim.x = Math::Rand()*20.0f+20.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 10.0f, 0.0f, 2.0f);
}
@@ -908,15 +907,15 @@ begin:
max = (int)(50.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<max ; i++ )
{
- angle = Rand()*(PI*2.0f);
- p = RotatePoint(angle, 46.0f);
+ angle = Math::Rand()*(Math::PI*2.0f);
+ p = Math::RotatePoint(angle, 46.0f);
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*10.0f+10.0f;
+ dim.x = Math::Rand()*10.0f+10.0f;
dim.y = dim.x;
- time = Rand()*2.0f+1.5f;
+ time = Math::Rand()*2.0f+1.5f;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time, 0.0f, 2.0f);
}
@@ -1007,15 +1006,15 @@ begin:
}
pos = D3DVECTOR(0.0f, 6.0f, 0.0f);
- speed.x = (Rand()-0.5f)*4.0f;
- speed.z = (Rand()-0.5f)*4.0f;
- speed.y = vSpeed*0.8f-(8.0f+Rand()*6.0f);
+ speed.x = (Math::Rand()-0.5f)*4.0f;
+ speed.z = (Math::Rand()-0.5f)*4.0f;
+ speed.y = vSpeed*0.8f-(8.0f+Math::Rand()*6.0f);
speed += pos;
pos = Transform(*mat, pos);
speed = Transform(*mat, speed);
speed -= pos;
- dim.x = 4.0f+Rand()*4.0f;
+ dim.x = 4.0f+Math::Rand()*4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBASE, 3.0f, 0.0f, 0.0f);
@@ -1026,7 +1025,7 @@ begin:
dim.x = 12.0f;
dim.y = dim.x;
pos = D3DVECTOR(0.0f, 7.0f, 0.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 1.0f, 0.0f, 0.0f);
@@ -1034,35 +1033,35 @@ begin:
dim.x = 4.0f;
dim.y = dim.x;
pos = D3DVECTOR(42.0f, 0.0f, 17.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = D3DVECTOR(17.0f, 0.0f, 42.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = D3DVECTOR(42.0f, 0.0f, -17.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = D3DVECTOR(17.0f, 0.0f, -42.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = D3DVECTOR(-42.0f, 0.0f, 17.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = D3DVECTOR(-17.0f, 0.0f, 42.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = D3DVECTOR(-42.0f, 0.0f, -17.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = D3DVECTOR(-17.0f, 0.0f, -42.0f);
- 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 = Transform(*mat, pos);
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
@@ -1138,9 +1137,9 @@ bool CAutoBase::Abort()
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f-124.0f*PI/180.0f);
- m_object->SetAngleX(10+i, -10.0f*PI/180.0f);
- m_object->SetAngleX(18+i, 10.0f*PI/180.0f);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f-124.0f*Math::PI/180.0f);
+ m_object->SetAngleX(10+i, -10.0f*Math::PI/180.0f);
+ m_object->SetAngleX(18+i, 10.0f*Math::PI/180.0f);
m_object->SetPosition(10+i, D3DVECTOR(23.5f, 0.0f, -11.5f));
m_object->SetPosition(18+i, D3DVECTOR(23.5f, 0.0f, 11.5f));
}
@@ -1160,9 +1159,9 @@ bool CAutoBase::Abort()
MoveCargo(); // all cargo moves
for ( i=0 ; i<8 ; i++ )
{
- m_object->SetAngleZ(1+i, PI/2.0f-124.0f*PI/180.0f);
- m_object->SetAngleX(10+i, -10.0f*PI/180.0f);
- m_object->SetAngleX(18+i, 10.0f*PI/180.0f);
+ m_object->SetAngleZ(1+i, Math::PI/2.0f-124.0f*Math::PI/180.0f);
+ m_object->SetAngleX(10+i, -10.0f*Math::PI/180.0f);
+ m_object->SetAngleX(18+i, 10.0f*Math::PI/180.0f);
m_object->SetPosition(10+i, D3DVECTOR(23.5f, 0.0f, -11.5f));
m_object->SetPosition(18+i, D3DVECTOR(23.5f, 0.0f, 11.5f));
}
@@ -1226,7 +1225,7 @@ Error CAutoBase::RetError()
bool CAutoBase::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
float sleep, delay, magnetic, progress;
diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp
index 6cc94e5..75dcc9c 100644
--- a/src/object/auto/autoconvert.cpp
+++ b/src/object/auto/autoconvert.cpp
@@ -14,14 +14,13 @@
// * 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/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/event.h"
@@ -111,7 +110,7 @@ bool CAutoConvert::EventProcess(const Event &event)
{
CObject* fret;
D3DVECTOR pos, speed;
- FPOINT dim, c, p;
+ Math::Point dim, c, p;
float angle;
CAuto::EventProcess(event);
@@ -126,15 +125,15 @@ bool CAutoConvert::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
- angle = (Rand()-0.5f)*0.3f;
+ angle = (Math::Rand()-0.5f)*0.3f;
m_object->SetAngleY(1, angle);
m_object->SetAngleY(2, angle);
- m_object->SetAngleY(3, angle+PI);
+ m_object->SetAngleY(3, angle+Math::PI);
- m_object->SetAngleX(2, -PI*0.35f*(0.8f+Rand()*0.2f));
- m_object->SetAngleX(3, -PI*0.35f*(0.8f+Rand()*0.2f));
+ m_object->SetAngleX(2, -Math::PI*0.35f*(0.8f+Math::Rand()*0.2f));
+ m_object->SetAngleX(3, -Math::PI*0.35f*(0.8f+Math::Rand()*0.2f));
}
return true;
}
@@ -181,7 +180,7 @@ bool CAutoConvert::EventProcess(const Event &event)
m_bSoundClose = true;
m_sound->Play(SOUND_CLOSE, m_object->RetPosition(0), 1.0f, 0.8f);
}
- angle = -PI*0.35f*(1.0f-Bounce(m_progress, 0.85f, 0.05f));
+ angle = -Math::PI*0.35f*(1.0f-Math::Bounce(m_progress, 0.85f, 0.05f));
m_object->SetAngleX(2, angle);
m_object->SetAngleX(3, angle);
}
@@ -216,7 +215,7 @@ bool CAutoConvert::EventProcess(const Event &event)
}
m_object->SetAngleY(1, angle);
m_object->SetAngleY(2, angle);
- m_object->SetAngleY(3, angle+PI);
+ m_object->SetAngleY(3, angle+Math::PI);
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
{
@@ -227,12 +226,12 @@ bool CAutoConvert::EventProcess(const Event &event)
c.y = pos.z;
p.x = c.x;
p.y = c.y+6.0f;
- p = RotatePoint(c, Rand()*PI*2.0f, p);
+ p = Math::RotatePoint(c, Math::Rand()*Math::PI*2.0f, p);
pos.x = p.x;
pos.z = p.y;
pos.y += 1.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*2.0f+1.0f;
+ dim.x = Math::Rand()*2.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 1.0f, 0.0f, 0.0f);
}
@@ -241,7 +240,7 @@ bool CAutoConvert::EventProcess(const Event &event)
{
m_object->SetAngleY(1, 0.0f);
m_object->SetAngleY(2, 0.0f);
- m_object->SetAngleY(3, PI);
+ m_object->SetAngleY(3, Math::PI);
fret = SearchStone(OBJECT_STONE);
if ( fret != 0 )
@@ -264,7 +263,7 @@ bool CAutoConvert::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- angle = -PI*0.35f*Bounce(m_progress, 0.7f, 0.2f);
+ angle = -Math::PI*0.35f*Math::Bounce(m_progress, 0.7f, 0.2f);
m_object->SetAngleX(2, angle);
m_object->SetAngleX(3, angle);
@@ -274,11 +273,11 @@ bool CAutoConvert::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_object->RetPosition(0);
- pos.x += (Rand()-0.5f)*6.0f;
- pos.z += (Rand()-0.5f)*6.0f;
- pos.y += Rand()*4.0f;
+ pos.x += (Math::Rand()-0.5f)*6.0f;
+ pos.z += (Math::Rand()-0.5f)*6.0f;
+ pos.y += Math::Rand()*4.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*4.0f+3.0f;
+ dim.x = Math::Rand()*4.0f+3.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
@@ -286,8 +285,8 @@ bool CAutoConvert::EventProcess(const Event &event)
else
{
m_soundChannel = -1;
- m_object->SetAngleX(2, -PI*0.35f);
- m_object->SetAngleX(3, -PI*0.35f);
+ m_object->SetAngleX(2, -Math::PI*0.35f);
+ m_object->SetAngleX(3, -Math::PI*0.35f);
SetBusy(false);
UpdateInterface();
@@ -327,9 +326,9 @@ bool CAutoConvert::Abort()
m_object->SetAngleY(1, 0.0f);
m_object->SetAngleY(2, 0.0f);
- m_object->SetAngleY(3, PI);
- m_object->SetAngleX(2, -PI*0.35f);
- m_object->SetAngleX(3, -PI*0.35f);
+ m_object->SetAngleY(3, Math::PI);
+ m_object->SetAngleX(2, -Math::PI*0.35f);
+ m_object->SetAngleX(3, -Math::PI*0.35f);
m_phase = ACP_WAIT;
m_progress = 0.0f;
@@ -347,7 +346,7 @@ bool CAutoConvert::Abort()
bool CAutoConvert::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autoconvert.h b/src/object/auto/autoconvert.h
index 5d610eb..10d829c 100644
--- a/src/object/auto/autoconvert.h
+++ b/src/object/auto/autoconvert.h
@@ -16,7 +16,7 @@
// autoconvert.h
-#pragma once_
+#pragma once
#include "object/auto/auto.h"
diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp
index a7d0b5e..7f40da0 100644
--- a/src/object/auto/autoderrick.cpp
+++ b/src/object/auto/autoderrick.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>
@@ -149,7 +147,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
{
CObject* fret;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float angle, duration, factor;
CAuto::EventProcess(event);
@@ -165,14 +163,14 @@ bool CAutoDerrick::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
pos.x = 0.0f;
pos.z = 0.0f;
- pos.y = -2.0f*Rand();
+ pos.y = -2.0f*Math::Rand();
m_object->SetPosition(1, pos); // up / down the drill
- m_object->SetAngleY(1, Rand()*0.5f); // rotates the drill
+ m_object->SetAngleY(1, Math::Rand()*0.5f); // rotates the drill
}
return true;
}
@@ -202,10 +200,10 @@ bool CAutoDerrick::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*5.0f;
- dim.x = Rand()*3.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*5.0f;
+ dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -216,15 +214,15 @@ bool CAutoDerrick::EventProcess(const Event &event)
m_lastTrack = m_time;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*12.0f;
- speed.z = (Rand()-0.5f)*12.0f;
- speed.y = Rand()*10.0f+10.0f;
+ speed.x = (Math::Rand()-0.5f)*12.0f;
+ speed.z = (Math::Rand()-0.5f)*12.0f;
+ speed.y = Math::Rand()*10.0f+10.0f;
dim.x = 0.6f;
dim.y = dim.x;
pos.y += dim.y;
- duration = Rand()*2.0f+2.0f;
+ duration = Math::Rand()*2.0f+2.0f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK5,
- duration, Rand()*10.0f+15.0f,
+ duration, Math::Rand()*10.0f+15.0f,
duration*0.2f, 1.0f);
}
@@ -255,10 +253,10 @@ bool CAutoDerrick::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*5.0f;
- dim.x = Rand()*3.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*5.0f;
+ dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -269,15 +267,15 @@ bool CAutoDerrick::EventProcess(const Event &event)
m_lastTrack = m_time;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*12.0f;
- speed.z = (Rand()-0.5f)*12.0f;
- speed.y = Rand()*10.0f+10.0f;
+ speed.x = (Math::Rand()-0.5f)*12.0f;
+ speed.z = (Math::Rand()-0.5f)*12.0f;
+ speed.y = Math::Rand()*10.0f+10.0f;
dim.x = 0.6f;
dim.y = dim.x;
pos.y += dim.y;
- duration = Rand()*2.0f+2.0f;
+ duration = Math::Rand()*2.0f+2.0f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK5,
- duration, Rand()*10.0f+15.0f,
+ duration, Math::Rand()*10.0f+15.0f,
duration*0.2f, 1.0f);
}
@@ -344,9 +342,9 @@ bool CAutoDerrick::EventProcess(const Event &event)
if ( m_progress < 0.3f )
{
pos = fret->RetPosition(0);
- pos.x += (Rand()-0.5f)*5.0f;
- pos.z += (Rand()-0.5f)*5.0f;
- pos.y += (Rand()-0.5f)*5.0f;
+ pos.x += (Math::Rand()-0.5f)*5.0f;
+ pos.z += (Math::Rand()-0.5f)*5.0f;
+ pos.y += (Math::Rand()-0.5f)*5.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
dim.x = 3.0f;
dim.y = dim.x;
@@ -355,9 +353,9 @@ bool CAutoDerrick::EventProcess(const Event &event)
else
{
pos = fret->RetPosition(0);
- pos.x += (Rand()-0.5f)*5.0f;
- pos.z += (Rand()-0.5f)*5.0f;
- pos.y += Rand()*2.5f;
+ pos.x += (Math::Rand()-0.5f)*5.0f;
+ pos.z += (Math::Rand()-0.5f)*5.0f;
+ pos.y += Math::Rand()*2.5f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
dim.x = 1.0f;
dim.y = dim.x;
@@ -410,7 +408,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
bool CAutoDerrick::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
index 2f999fc..b7c1221 100644
--- a/src/object/auto/autodestroyer.cpp
+++ b/src/object/auto/autodestroyer.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 CAutoDestroyer::EventProcess(const Event &event)
CObject* scrap;
CPyro* pyro;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
CAuto::EventProcess(event);
@@ -108,7 +106,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
@@ -164,7 +162,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
if ( m_progress < 1.0f )
{
pos = D3DVECTOR(0.0f, -10.0f, 0.0f);
- pos.y = -Bounce(m_progress, 0.3f)*10.0f;
+ pos.y = -Math::Bounce(m_progress, 0.3f)*10.0f;
m_object->SetPosition(1, pos);
}
else
@@ -220,7 +218,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
bool CAutoDestroyer::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autodestroyer.h b/src/object/auto/autodestroyer.h
index ececb32..521273f 100644
--- a/src/object/auto/autodestroyer.h
+++ b/src/object/auto/autodestroyer.h
@@ -20,6 +20,7 @@
#include "common/misc.h"
+#include "object/auto/auto.h"
class CInstanceManager;
diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp
index d8620ba..c6400f8 100644
--- a/src/object/auto/autoegg.cpp
+++ b/src/object/auto/autoegg.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>
diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp
index 75ab92a..d4f4ce9 100644
--- a/src/object/auto/autoenergy.cpp
+++ b/src/object/auto/autoenergy.cpp
@@ -14,14 +14,13 @@
// * 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 "math/const.h"
+#include "math/geometry.h"
#include "common/struct.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
@@ -124,7 +123,7 @@ bool CAutoEnergy::EventProcess(const Event &event)
{
CObject* fret;
D3DVECTOR pos, ppos, speed;
- FPOINT dim, c, p;
+ Math::Point dim, c, p;
TerrainRes res;
float big;
bool bGO;
@@ -141,17 +140,17 @@ bool CAutoEnergy::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
{
m_lastParticule = m_time;
pos = m_object->RetPosition(0);
pos.y += 10.0f;
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = -7.0f;
- dim.x = Rand()*0.5f+0.5f;
+ dim.x = Math::Rand()*0.5f+0.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f);
}
@@ -217,7 +216,7 @@ bool CAutoEnergy::EventProcess(const Event &event)
{
m_phase = AENP_BLITZ;
m_progress = 0.0f;
- m_speed = 1.0f/Rand()*1.0f+1.0f;
+ m_speed = 1.0f/Math::Rand()*1.0f+1.0f;
}
else
{
@@ -238,10 +237,10 @@ bool CAutoEnergy::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_object->RetPosition(0);
pos.y += 10.0f;
- speed.x = (Rand()-0.5f)*1.0f;
- speed.z = (Rand()-0.5f)*1.0f;
+ speed.x = (Math::Rand()-0.5f)*1.0f;
+ speed.z = (Math::Rand()-0.5f)*1.0f;
speed.y = -7.0f;
- dim.x = Rand()*0.5f+0.5f;
+ dim.x = Math::Rand()*0.5f+0.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f);
}
@@ -287,35 +286,35 @@ bool CAutoEnergy::EventProcess(const Event &event)
c.y = pos.z;
p.x = c.x;
p.y = c.y+2.0f;
- p = RotatePoint(c, Rand()*PI*2.0f, p);
+ p = Math::RotatePoint(c, Math::Rand()*Math::PI*2.0f, p);
pos.x = p.x;
pos.z = p.y;
- pos.y += 2.5f+Rand()*3.0f;
+ pos.y += 2.5f+Math::Rand()*3.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*2.0f+1.0f;
+ dim.x = Math::Rand()*2.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 1.0f, 0.0f, 0.0f);
pos = m_object->RetPosition(0);
pos.y += 3.0f;
- speed.x = (Rand()-0.5f)*30.0f;
- speed.z = (Rand()-0.5f)*30.0f;
- speed.y = Rand()*20.0f+10.0f;
- dim.x = Rand()*0.4f+0.4f;
+ speed.x = (Math::Rand()-0.5f)*30.0f;
+ speed.z = (Math::Rand()-0.5f)*30.0f;
+ speed.y = Math::Rand()*20.0f+10.0f;
+ dim.x = Math::Rand()*0.4f+0.4f;
dim.y = dim.x;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK2, 2.0f, 50.0f, 1.2f, 1.2f);
pos = m_object->RetPosition(0);
pos.y += 10.0f;
- speed.x = (Rand()-0.5f)*1.5f;
- speed.z = (Rand()-0.5f)*1.5f;
+ speed.x = (Math::Rand()-0.5f)*1.5f;
+ speed.z = (Math::Rand()-0.5f)*1.5f;
speed.y = -6.0f;
- dim.x = Rand()*1.0f+1.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f);
m_sound->Play(SOUND_ENERGY, m_object->RetPosition(0),
- 1.0f, 1.0f+Rand()*1.5f);
+ 1.0f, 1.0f+Math::Rand()*1.5f);
}
}
else
@@ -359,12 +358,12 @@ bool CAutoEnergy::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y += 17.0f;
- 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 = 6.0f+Rand()*6.0f;
- dim.x = Rand()*1.5f+1.0f;
+ speed.y = 6.0f+Math::Rand()*6.0f;
+ dim.x = Math::Rand()*1.5f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
}
@@ -562,7 +561,7 @@ Error CAutoEnergy::RetError()
bool CAutoEnergy::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp
index 89bc399..1fc669f 100644
--- a/src/object/auto/autofactory.cpp
+++ b/src/object/auto/autofactory.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>
@@ -130,7 +128,7 @@ bool CAutoFactory::EventProcess(const Event &event)
D3DMATRIX* mat;
CPhysics* physics;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
ObjectType type;
float zoom, angle, prog;
int i;
@@ -254,7 +252,7 @@ bool CAutoFactory::EventProcess(const Event &event)
{
for ( i=0 ; i<9 ; i++ )
{
- angle = -m_progress*(PI/2.0f)+PI/2.0f;
+ angle = -m_progress*(Math::PI/2.0f)+Math::PI/2.0f;
m_object->SetAngleZ( 1+i, angle);
m_object->SetAngleZ(10+i, -angle);
}
@@ -323,7 +321,7 @@ bool CAutoFactory::EventProcess(const Event &event)
vehicle = SearchVehicle();
if ( vehicle != 0 )
{
- vehicle->SetAngleY(0, angle+PI);
+ vehicle->SetAngleY(0, angle+Math::PI);
vehicle->SetZoom(0, m_progress);
}
@@ -339,13 +337,13 @@ bool CAutoFactory::EventProcess(const Event &event)
#if 0
pos = m_fretPos;
- 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 += 1.0f;
- speed.x = (Rand()-0.5f)*12.0f;
- speed.z = (Rand()-0.5f)*12.0f;
- speed.y = Rand()*12.0f;
- dim.x = Rand()*12.0f+10.0f;
+ speed.x = (Math::Rand()-0.5f)*12.0f;
+ speed.z = (Math::Rand()-0.5f)*12.0f;
+ speed.y = Math::Rand()*12.0f;
+ dim.x = Math::Rand()*12.0f+10.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
#else
@@ -353,12 +351,12 @@ bool CAutoFactory::EventProcess(const Event &event)
pos = D3DVECTOR(-12.0f, 20.0f, -4.0f); // position of chimney
pos = Transform(*mat, pos);
pos.y += 2.0f;
- 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;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 6.0f+Rand()*6.0f;
- dim.x = Rand()*1.5f+1.0f;
+ speed.y = 6.0f+Math::Rand()*6.0f;
+ dim.x = Math::Rand()*1.5f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
#endif
@@ -387,7 +385,7 @@ bool CAutoFactory::EventProcess(const Event &event)
vehicle->SetLock(false); // vehicle useable
//? vehicle->RetPhysics()->RetBrain()->StartTaskAdvance(16.0f);
- vehicle->SetAngleY(0, m_object->RetAngleY(0)+PI);
+ vehicle->SetAngleY(0, m_object->RetAngleY(0)+Math::PI);
vehicle->SetZoom(0, 1.0f);
}
@@ -405,7 +403,7 @@ bool CAutoFactory::EventProcess(const Event &event)
{
for ( i=0 ; i<9 ; i++ )
{
- angle = -(1.0f-m_progress)*(PI/2.0f)+PI/2.0f;
+ angle = -(1.0f-m_progress)*(Math::PI/2.0f)+Math::PI/2.0f;
m_object->SetAngleZ( 1+i, angle);
m_object->SetAngleZ(10+i, -angle);
}
@@ -415,9 +413,9 @@ bool CAutoFactory::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_fretPos;
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
- pos.y += Rand()*10.0f;
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
+ pos.y += Math::Rand()*10.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
dim.x = 2.0f;
dim.y = dim.x;
@@ -428,8 +426,8 @@ bool CAutoFactory::EventProcess(const Event &event)
{
for ( i=0 ; i<9 ; i++ )
{
- m_object->SetAngleZ( 1+i, PI/2.0f);
- m_object->SetAngleZ(10+i, -PI/2.0f);
+ m_object->SetAngleZ( 1+i, Math::PI/2.0f);
+ m_object->SetAngleZ(10+i, -Math::PI/2.0f);
}
SoundManip(3.0f, 1.0f, 0.5f);
@@ -458,9 +456,9 @@ bool CAutoFactory::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_fretPos;
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
- pos.y += Rand()*10.0f;
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
+ pos.y += Math::Rand()*10.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
dim.x = 2.0f;
dim.y = dim.x;
@@ -713,7 +711,7 @@ CObject* CAutoFactory::SearchVehicle()
bool CAutoFactory::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autoflag.cpp b/src/object/auto/autoflag.cpp
index 53792cb..c75f914 100644
--- a/src/object/auto/autoflag.cpp
+++ b/src/object/auto/autoflag.cpp
@@ -14,14 +14,13 @@
// * 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/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/event.h"
@@ -82,7 +81,7 @@ void CAutoFlag::Init()
m_progress = 0.0f;
wind = m_terrain->RetWind();
- angle = RotateAngle(wind.x, -wind.z);
+ angle = Math::RotateAngle(wind.x, -wind.z);
m_object->SetAngleY(0, angle); // directs the flag in the wind
m_strong = Length(wind);
@@ -130,9 +129,9 @@ bool CAutoFlag::EventProcess(const Event &event)
m_progress += event.rTime*(1.0f/2.0f);
if ( m_progress < 1.0f )
{
- angle = sinf(m_progress*PI*8.0f)*0.3f*(1.0f-m_progress);
+ angle = sinf(m_progress*Math::PI*8.0f)*0.3f*(1.0f-m_progress);
m_object->SetAngleX(0, angle);
- angle = sinf(m_progress*PI*4.0f)*0.3f*(1.0f-m_progress);
+ angle = sinf(m_progress*Math::PI*4.0f)*0.3f*(1.0f-m_progress);
m_object->SetAngleZ(0, angle);
}
else
diff --git a/src/object/auto/autohuston.cpp b/src/object/auto/autohuston.cpp
index 6a3202b..9ff5197 100644
--- a/src/object/auto/autohuston.cpp
+++ b/src/object/auto/autohuston.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>
@@ -221,7 +219,7 @@ void CAutoHuston::Start(int param)
bool CAutoHuston::EventProcess(const Event &event)
{
D3DVECTOR speed;
- FPOINT dim;
+ Math::Point dim;
float angle;
int i;
@@ -243,7 +241,7 @@ bool CAutoHuston::EventProcess(const Event &event)
for ( i=0 ; i<m_lensTotal ; i++ )
{
if ( m_lens[i].total != 0.0f &&
- Mod(m_time, m_lens[i].total) < m_lens[i].off )
+ Math::Mod(m_time, m_lens[i].total) < m_lens[i].off )
{
if ( m_lens[i].parti != -1 )
{
@@ -278,7 +276,7 @@ bool CAutoHuston::Abort()
bool CAutoHuston::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autohuston.h b/src/object/auto/autohuston.h
index e17d04e..552def8 100644
--- a/src/object/auto/autohuston.h
+++ b/src/object/auto/autohuston.h
@@ -21,6 +21,7 @@
#include "object/auto/auto.h"
#include "common/misc.h"
+#include "graphics/common/particule.h"
class CInstanceManager;
diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp
index 12dc2de..f96808c 100644
--- a/src/object/auto/autoinfo.cpp
+++ b/src/object/auto/autoinfo.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>
@@ -86,7 +84,7 @@ void CAutoInfo::Init()
void CAutoInfo::Start(int param)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
if ( param == 0 ) // instruction "receive" ?
{
@@ -144,7 +142,7 @@ void CAutoInfo::Start(int param)
bool CAutoInfo::EventProcess(const Event &event)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float duration, angle, rTime;
int i;
@@ -159,19 +157,19 @@ bool CAutoInfo::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
angle = m_object->RetAngleY(1);
- angle += Rand()*0.3f;
+ angle += Math::Rand()*0.3f;
m_object->SetAngleY(1, angle);
- m_object->SetAngleX(2, (Rand()-0.5f)*0.3f);
- m_object->SetAngleX(4, (Rand()-0.5f)*0.3f);
- m_object->SetAngleX(6, (Rand()-0.5f)*0.3f);
+ m_object->SetAngleX(2, (Math::Rand()-0.5f)*0.3f);
+ m_object->SetAngleX(4, (Math::Rand()-0.5f)*0.3f);
+ m_object->SetAngleX(6, (Math::Rand()-0.5f)*0.3f);
- m_object->SetAngleZ(2, (Rand()-0.5f)*0.3f);
- m_object->SetAngleZ(4, (Rand()-0.5f)*0.3f);
- m_object->SetAngleZ(6, (Rand()-0.5f)*0.3f);
+ m_object->SetAngleZ(2, (Math::Rand()-0.5f)*0.3f);
+ m_object->SetAngleZ(4, (Math::Rand()-0.5f)*0.3f);
+ m_object->SetAngleZ(6, (Math::Rand()-0.5f)*0.3f);
UpdateListVirus();
}
@@ -209,13 +207,13 @@ bool CAutoInfo::EventProcess(const Event &event)
{
pos = m_goal;
pos.y += 9.5f;
- speed.x = (Rand()-0.5f)*50.0f;
- speed.z = (Rand()-0.5f)*50.0f;
- speed.y = (Rand()-0.5f)*50.0f;
+ speed.x = (Math::Rand()-0.5f)*50.0f;
+ speed.z = (Math::Rand()-0.5f)*50.0f;
+ speed.y = (Math::Rand()-0.5f)*50.0f;
speed *= 0.5f+m_progress*0.5f;
dim.x = 0.6f;
dim.y = dim.x;
- duration = Rand()*0.5f+0.5f;
+ duration = Math::Rand()*0.5f+0.5f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
@@ -226,9 +224,9 @@ bool CAutoInfo::EventProcess(const Event &event)
{
m_progress += rTime*m_speed;
- m_object->SetAngleZ(2, m_progress*2.0f*PI);
- m_object->SetAngleZ(4, m_progress*2.0f*PI);
- m_object->SetAngleZ(6, m_progress*2.0f*PI);
+ m_object->SetAngleZ(2, m_progress*2.0f*Math::PI);
+ m_object->SetAngleZ(4, m_progress*2.0f*Math::PI);
+ m_object->SetAngleZ(6, m_progress*2.0f*Math::PI);
}
else
{
@@ -256,14 +254,14 @@ bool CAutoInfo::EventProcess(const Event &event)
pos = m_goal;
pos.y += 9.5f;
speed = pos;
- pos.x += (Rand()-0.5f)*40.0f;
- pos.y += (Rand()-0.5f)*40.0f;
- pos.z += (Rand()-0.5f)*40.0f;
+ pos.x += (Math::Rand()-0.5f)*40.0f;
+ pos.y += (Math::Rand()-0.5f)*40.0f;
+ pos.z += (Math::Rand()-0.5f)*40.0f;
speed = (speed-pos)*1.0f;
//? speed *= 0.5f+m_progress*0.5f;
dim.x = 0.6f;
dim.y = dim.x;
- duration = Rand()*0.5f+0.5f;
+ duration = Math::Rand()*0.5f+0.5f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
@@ -274,9 +272,9 @@ bool CAutoInfo::EventProcess(const Event &event)
{
m_progress += rTime*m_speed;
- m_object->SetAngleZ(2, m_progress*2.0f*PI);
- m_object->SetAngleZ(4, m_progress*2.0f*PI);
- m_object->SetAngleZ(6, m_progress*2.0f*PI);
+ m_object->SetAngleZ(2, m_progress*2.0f*Math::PI);
+ m_object->SetAngleZ(4, m_progress*2.0f*Math::PI);
+ m_object->SetAngleZ(6, m_progress*2.0f*Math::PI);
}
else
{
@@ -300,12 +298,12 @@ bool CAutoInfo::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_goal;
- speed.x = (Rand()-0.5f)*5.0f;
- speed.z = (Rand()-0.5f)*5.0f;
- speed.y = 5.0f+Rand()*5.0f;
- dim.x = 5.0f+Rand()*5.0f;
+ speed.x = (Math::Rand()-0.5f)*5.0f;
+ speed.z = (Math::Rand()-0.5f)*5.0f;
+ speed.y = 5.0f+Math::Rand()*5.0f;
+ dim.x = 5.0f+Math::Rand()*5.0f;
dim.y = dim.x;
- duration = Rand()*0.5f+0.5f;
+ duration = Math::Rand()*0.5f+0.5f;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 4.0f);
}
@@ -326,9 +324,9 @@ bool CAutoInfo::EventProcess(const Event &event)
m_object->SetAngleX(4, angle*0.5f);
m_object->SetAngleX(6, angle*0.5f);
- m_object->SetAngleZ(2, (Rand()-0.5f)*0.2f);
- m_object->SetAngleZ(4, (Rand()-0.5f)*0.2f);
- m_object->SetAngleZ(6, (Rand()-0.5f)*0.2f);
+ m_object->SetAngleZ(2, (Math::Rand()-0.5f)*0.2f);
+ m_object->SetAngleZ(4, (Math::Rand()-0.5f)*0.2f);
+ m_object->SetAngleZ(6, (Math::Rand()-0.5f)*0.2f);
}
else
{
@@ -348,9 +346,9 @@ bool CAutoInfo::EventProcess(const Event &event)
angle += rTime*0.5f;
m_object->SetAngleY(1, angle);
- m_object->SetAngleX(3, sinf(m_time*6.0f+PI*0.0f/3.0f)*0.3f);
- m_object->SetAngleX(5, sinf(m_time*6.0f+PI*2.0f/3.0f)*0.3f);
- m_object->SetAngleX(7, sinf(m_time*6.0f+PI*4.0f/3.0f)*0.3f);
+ m_object->SetAngleX(3, sinf(m_time*6.0f+Math::PI*0.0f/3.0f)*0.3f);
+ m_object->SetAngleX(5, sinf(m_time*6.0f+Math::PI*2.0f/3.0f)*0.3f);
+ m_object->SetAngleX(7, sinf(m_time*6.0f+Math::PI*4.0f/3.0f)*0.3f);
return true;
}
@@ -375,7 +373,7 @@ bool CAutoInfo::CreateInterface(bool bSelect)
{
CWindow* pw;
CList* pl;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
@@ -473,12 +471,12 @@ void CAutoInfo::UpdateListVirus()
pl->Flush();
for ( i=0 ; i<4 ; i++ )
{
- max = (int)(2.0f+Rand()*10.0f);
+ max = (int)(2.0f+Math::Rand()*10.0f);
for ( j=0 ; j<max ; j++ )
{
do
{
- text[j] = ' '+(int)(Rand()*94.0f);
+ text[j] = ' '+(int)(Math::Rand()*94.0f);
}
while ( text[j] == '\\' );
}
diff --git a/src/object/auto/autojostle.cpp b/src/object/auto/autojostle.cpp
index 93bdd6b..ee09d93 100644
--- a/src/object/auto/autojostle.cpp
+++ b/src/object/auto/autojostle.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>
@@ -129,8 +127,8 @@ bool CAutoJostle::EventProcess(const Event &event)
}
factor *= m_force;
- dir.x = sinf(m_progress*PI*4.0f);
- dir.z = cosf(m_progress*PI*4.0f);
+ dir.x = sinf(m_progress*Math::PI*4.0f);
+ dir.z = cosf(m_progress*Math::PI*4.0f);
angle = sinf(m_time*10.0f)*factor*0.04f;
m_object->SetAngleX(0, angle*dir.z);
diff --git a/src/object/auto/autokid.cpp b/src/object/auto/autokid.cpp
index 99d4c81..5507d0f 100644
--- a/src/object/auto/autokid.cpp
+++ b/src/object/auto/autokid.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>
@@ -84,15 +82,15 @@ void CAutoKid::Init()
if ( m_type == OBJECT_TEEN36 ) // trunk ?
{
pos = m_object->RetPosition(0);
- m_speed = 1.0f/(1.0f+(Mod(pos.x/10.0f-0.5f, 1.0f)*0.2f));
- m_progress = Mod(pos.x/10.0f, 1.0f);
+ m_speed = 1.0f/(1.0f+(Math::Mod(pos.x/10.0f-0.5f, 1.0f)*0.2f));
+ m_progress = Math::Mod(pos.x/10.0f, 1.0f);
}
if ( m_type == OBJECT_TEEN37 ) // boat?
{
pos = m_object->RetPosition(0);
- m_speed = 1.0f/(1.0f+(Mod(pos.x/10.0f-0.5f, 1.0f)*0.2f))*2.5f;
- m_progress = Mod(pos.x/10.0f, 1.0f);
+ m_speed = 1.0f/(1.0f+(Math::Mod(pos.x/10.0f-0.5f, 1.0f)*0.2f))*2.5f;
+ m_progress = Math::Mod(pos.x/10.0f, 1.0f);
}
if ( m_type == OBJECT_TEEN38 ) // fan?
@@ -111,7 +109,7 @@ void CAutoKid::Init()
bool CAutoKid::EventProcess(const Event &event)
{
D3DVECTOR vib, pos, speed;
- FPOINT dim;
+ Math::Point dim;
CAuto::EventProcess(event);
@@ -158,8 +156,8 @@ bool CAutoKid::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y = m_water->RetLevel()+1.0f;
- pos.x += (Rand()-0.5f)*50.0f;
- pos.z += (Rand()-0.5f)*50.0f;
+ pos.x += (Math::Rand()-0.5f)*50.0f;
+ pos.z += (Math::Rand()-0.5f)*50.0f;
speed.y = 0.0f;
speed.x = 0.0f;
speed.z = 0.0f;
@@ -187,8 +185,8 @@ bool CAutoKid::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y = m_water->RetLevel()+1.0f;
- 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;
speed.y = 0.0f;
speed.x = 0.0f;
speed.z = 0.0f;
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index 7d5c576..7033318 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -14,15 +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 "math/const.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/global.h"
@@ -130,7 +129,7 @@ bool CAutoLabo::EventProcess(const Event &event)
{
CObject* power;
D3DVECTOR pos, goal, speed;
- FPOINT dim, rot;
+ Math::Point dim, rot;
float angle;
int i;
@@ -194,7 +193,7 @@ bool CAutoLabo::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
@@ -216,15 +215,15 @@ bool CAutoLabo::EventProcess(const Event &event)
if ( m_progress < 1.0f )
{
angle = 80.0f-(35.0f*m_progress);
- m_object->SetAngleZ(3, angle*PI/180.0f);
- m_object->SetAngleZ(4, angle*PI/180.0f);
- m_object->SetAngleZ(5, angle*PI/180.0f);
+ m_object->SetAngleZ(3, angle*Math::PI/180.0f);
+ m_object->SetAngleZ(4, angle*Math::PI/180.0f);
+ m_object->SetAngleZ(5, angle*Math::PI/180.0f);
}
else
{
- m_object->SetAngleZ(3, 45.0f*PI/180.0f);
- m_object->SetAngleZ(4, 45.0f*PI/180.0f);
- m_object->SetAngleZ(5, 45.0f*PI/180.0f);
+ m_object->SetAngleZ(3, 45.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(4, 45.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(5, 45.0f*Math::PI/180.0f);
SoundManip(1.5f, 1.0f, 0.7f);
m_phase = ALAP_OPEN2;
@@ -257,7 +256,7 @@ bool CAutoLabo::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- angle = (1.0f-m_progress)*PI/2.0f;
+ angle = (1.0f-m_progress)*Math::PI/2.0f;
m_object->SetAngleZ(1, angle);
}
else
@@ -273,7 +272,7 @@ bool CAutoLabo::EventProcess(const Event &event)
{
m_partiRank[i] = m_particule->CreateRay(pos, goal,
PARTIRAY2,
- FPOINT(2.9f, 2.9f),
+ Math::Point(2.9f, 2.9f),
LABO_DELAY);
}
@@ -320,14 +319,14 @@ bool CAutoLabo::EventProcess(const Event &event)
angle += m_object->RetAngleY(0);
for ( i=0 ; i<3 ; i++ )
{
- rot = RotatePoint(-angle, -4.0f);
+ rot = Math::RotatePoint(-angle, -4.0f);
pos = m_object->RetPosition(0);
pos.x += rot.x;
pos.z += rot.y;
pos.y += 3.0f+4.0f;;
m_particule->SetPosition(m_partiRank[i], pos); // adjusts ray
- angle += PI*2.0f/3.0f;
+ angle += Math::PI*2.0f/3.0f;
}
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
@@ -339,12 +338,12 @@ bool CAutoLabo::EventProcess(const Event &event)
{
pos = m_object->RetPosition(0);
pos.y += 3.0f;
- pos.x += (Rand()-0.5f)*2.0f;
- pos.z += (Rand()-0.5f)*2.0f;
- speed.y = Rand()*5.0f+5.0f;
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- dim.x = Rand()*0.4f*m_progress+1.0f;
+ pos.x += (Math::Rand()-0.5f)*2.0f;
+ pos.z += (Math::Rand()-0.5f)*2.0f;
+ speed.y = Math::Rand()*5.0f+5.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ dim.x = Math::Rand()*0.4f*m_progress+1.0f;
dim.y = dim.x;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK2,
2.0f+2.0f*m_progress, 10.0f, 1.5f, 1.4f);
@@ -376,12 +375,12 @@ bool CAutoLabo::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- angle = m_progress*PI/2.0f;
+ angle = m_progress*Math::PI/2.0f;
m_object->SetAngleZ(1, angle);
}
else
{
- m_object->SetAngleZ(1, PI/2.0f);
+ m_object->SetAngleZ(1, Math::PI/2.0f);
SoundManip(1.5f, 1.0f, 0.7f);
m_phase = ALAP_CLOSE2;
@@ -415,15 +414,15 @@ bool CAutoLabo::EventProcess(const Event &event)
if ( m_progress < 1.0f )
{
angle = 45.0f+(35.0f*m_progress);
- m_object->SetAngleZ(3, angle*PI/180.0f);
- m_object->SetAngleZ(4, angle*PI/180.0f);
- m_object->SetAngleZ(5, angle*PI/180.0f);
+ m_object->SetAngleZ(3, angle*Math::PI/180.0f);
+ m_object->SetAngleZ(4, angle*Math::PI/180.0f);
+ m_object->SetAngleZ(5, angle*Math::PI/180.0f);
}
else
{
- m_object->SetAngleZ(3, 80.0f*PI/180.0f);
- m_object->SetAngleZ(4, 80.0f*PI/180.0f);
- m_object->SetAngleZ(5, 80.0f*PI/180.0f);
+ m_object->SetAngleZ(3, 80.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(4, 80.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(5, 80.0f*Math::PI/180.0f);
SetBusy(false);
UpdateInterface();
@@ -464,7 +463,7 @@ Error CAutoLabo::RetError()
bool CAutoLabo::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp
index 45aa019..44272d0 100644
--- a/src/object/auto/automush.cpp
+++ b/src/object/auto/automush.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>
@@ -82,7 +80,7 @@ void CAutoMush::Init()
bool CAutoMush::EventProcess(const Event &event)
{
D3DVECTOR pos, speed, dir;
- FPOINT dim;
+ Math::Point dim;
float factor, zoom, size, angle;
int i, channel;
@@ -104,7 +102,7 @@ bool CAutoMush::EventProcess(const Event &event)
{
m_phase = AMP_WAIT;
m_progress = 0.0f;
- m_speed = 1.0f/(2.0f+Rand()*2.0f);
+ m_speed = 1.0f/(2.0f+Math::Rand()*2.0f);
}
else
{
@@ -161,9 +159,9 @@ bool CAutoMush::EventProcess(const Event &event)
{
pos = m_object->RetPosition(0);
pos.y += 5.0f;
- speed.x = (Rand()-0.5f)*200.0f;
- speed.z = (Rand()-0.5f)*200.0f;
- speed.y = -(20.0f+Rand()*20.0f);
+ speed.x = (Math::Rand()-0.5f)*200.0f;
+ speed.z = (Math::Rand()-0.5f)*200.0f;
+ speed.y = -(20.0f+Math::Rand()*20.0f);
dim.x = 1.0f;
dim.y = dim.x;
channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN2, 2.0f, 100.0f, 0.0f);
@@ -189,10 +187,10 @@ bool CAutoMush::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y += 5.0f;
- speed.x = (Rand()-0.5f)*4.0f;
- speed.z = (Rand()-0.5f)*4.0f;
- speed.y = -(0.5f+Rand()*0.5f);
- dim.x = Rand()*2.5f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*4.0f;
+ speed.z = (Math::Rand()-0.5f)*4.0f;
+ speed.y = -(0.5f+Math::Rand()*0.5f);
+ dim.x = Math::Rand()*2.5f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 0.0f);
}
@@ -201,14 +199,14 @@ bool CAutoMush::EventProcess(const Event &event)
{
m_phase = AMP_WAIT;
m_progress = 0.0f;
- m_speed = 1.0f/(2.0f+Rand()*2.0f);
+ m_speed = 1.0f/(2.0f+Math::Rand()*2.0f);
}
}
if ( factor != 0.0f || size != 1.0f )
{
- dir.x = sinf(m_time*PI*4.0f);
- dir.z = cosf(m_time*PI*4.0f);
+ dir.x = sinf(m_time*Math::PI*4.0f);
+ dir.z = cosf(m_time*Math::PI*4.0f);
angle = sinf(m_time*10.0f)*factor*0.04f;
m_object->SetAngleX(0, angle*dir.z);
diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp
index a9226ac..a566444 100644
--- a/src/object/auto/autonest.cpp
+++ b/src/object/auto/autonest.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>
diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp
index 5139b9b..49ae0bd 100644
--- a/src/object/auto/autonuclear.cpp
+++ b/src/object/auto/autonuclear.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>
@@ -121,7 +119,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
CObject* fret;
D3DMATRIX* mat;
D3DVECTOR pos, goal, speed;
- FPOINT dim, rot;
+ Math::Point dim, rot;
float angle;
int i, max;
@@ -137,7 +135,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
@@ -176,7 +174,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- angle = (1.0f-m_progress)*(135.0f*PI/180.0f);
+ angle = (1.0f-m_progress)*(135.0f*Math::PI/180.0f);
m_object->SetAngleZ(1, angle);
}
else
@@ -189,12 +187,12 @@ bool CAutoNuclear::EventProcess(const Event &event)
{
pos.x = 27.0f;
pos.y = 0.0f;
- pos.z = (Rand()-0.5f)*8.0f;
+ pos.z = (Math::Rand()-0.5f)*8.0f;
pos = Transform(*mat, pos);
speed.y = 0.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- dim.x = Rand()*1.0f+1.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH);
}
@@ -221,19 +219,19 @@ bool CAutoNuclear::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y += 30.0f;
- pos.x += (Rand()-0.5f)*6.0f;
- pos.z += (Rand()-0.5f)*6.0f;
- speed.y = Rand()*15.0f+15.0f;
+ pos.x += (Math::Rand()-0.5f)*6.0f;
+ pos.z += (Math::Rand()-0.5f)*6.0f;
+ speed.y = Math::Rand()*15.0f+15.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- dim.x = Rand()*8.0f+8.0f;
+ dim.x = Math::Rand()*8.0f+8.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH);
pos = m_pos;
- 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;
dim.x = 2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 1.0f, 0.0f, 0.0f);
@@ -255,15 +253,15 @@ bool CAutoNuclear::EventProcess(const Event &event)
for ( i=0 ; i<max ; i++ )
{
pos = m_pos;
- pos.x += (Rand()-0.5f)*3.0f;
- pos.y += (Rand()-0.5f)*3.0f;
- pos.z += (Rand()-0.5f)*3.0f;
+ pos.x += (Math::Rand()-0.5f)*3.0f;
+ pos.y += (Math::Rand()-0.5f)*3.0f;
+ pos.z += (Math::Rand()-0.5f)*3.0f;
speed.y = 0.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- dim.x = Rand()*2.0f+2.0f;
+ dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, Rand()*5.0f+5.0f, 0.0f, 0.0f);
+ m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, Math::Rand()*5.0f+5.0f, 0.0f, 0.0f);
}
m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 1.4f);
@@ -278,12 +276,12 @@ bool CAutoNuclear::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- angle = m_progress*(135.0f*PI/180.0f);
+ angle = m_progress*(135.0f*Math::PI/180.0f);
m_object->SetAngleZ(1, angle);
}
else
{
- m_object->SetAngleZ(1, 135.0f*PI/180.0f);
+ m_object->SetAngleZ(1, 135.0f*Math::PI/180.0f);
SetBusy(false);
UpdateInterface();
@@ -305,7 +303,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
bool CAutoNuclear::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autopara.cpp b/src/object/auto/autopara.cpp
index 1bc79ac..46a34f9 100644
--- a/src/object/auto/autopara.cpp
+++ b/src/object/auto/autopara.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>
@@ -113,7 +111,7 @@ void CAutoPara::StartBlitz()
bool CAutoPara::EventProcess(const Event &event)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int i;
CAuto::EventProcess(event);
@@ -128,7 +126,7 @@ bool CAutoPara::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
@@ -146,12 +144,12 @@ bool CAutoPara::EventProcess(const Event &event)
for ( i=0 ; i<10 ; i++ )
{
pos = m_object->RetPosition(0);
- pos.x += (Rand()-0.5f)*m_progress*40.0f;
- pos.z += (Rand()-0.5f)*m_progress*40.0f;
+ pos.x += (Math::Rand()-0.5f)*m_progress*40.0f;
+ pos.z += (Math::Rand()-0.5f)*m_progress*40.0f;
pos.y += 50.0f-m_progress*50.0f;
- speed.x = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
- speed.y = 5.0f+Rand()*5.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
+ speed.y = 5.0f+Math::Rand()*5.0f;
dim.x = 2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 1.0f, 20.0f, 0.5f);
@@ -178,9 +176,9 @@ bool CAutoPara::EventProcess(const Event &event)
{
pos = m_object->RetPosition(0);
pos.y += 16.0f;
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = -Rand()*30.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = -Math::Rand()*30.0f;
dim.x = 1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 1.0f, 0.0f, 0.0f);
@@ -206,7 +204,7 @@ bool CAutoPara::EventProcess(const Event &event)
bool CAutoPara::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autoportico.cpp b/src/object/auto/autoportico.cpp
index 5c4a09c..cedb1d7 100644
--- a/src/object/auto/autoportico.cpp
+++ b/src/object/auto/autoportico.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>
@@ -48,12 +46,12 @@ const int PARAM_DEPOSE = 2; // run=2 -> deposits the spaceship
const float PORTICO_POSa = 75.0f;
const float PORTICO_POSb = 65.0f;
-const float PORTICO_ANGLE1a = ( 25.0f*PI/180.0f);
-const float PORTICO_ANGLE1b = ( 70.0f*PI/180.0f);
-const float PORTICO_ANGLE2a = (-37.5f*PI/180.0f);
-const float PORTICO_ANGLE2b = (-62.5f*PI/180.0f);
-const float PORTICO_ANGLE3a = (-77.5f*PI/180.0f);
-const float PORTICO_ANGLE3b = (-30.0f*PI/180.0f);
+const float PORTICO_ANGLE1a = ( 25.0f*Math::PI/180.0f);
+const float PORTICO_ANGLE1b = ( 70.0f*Math::PI/180.0f);
+const float PORTICO_ANGLE2a = (-37.5f*Math::PI/180.0f);
+const float PORTICO_ANGLE2b = (-62.5f*Math::PI/180.0f);
+const float PORTICO_ANGLE3a = (-77.5f*Math::PI/180.0f);
+const float PORTICO_ANGLE3b = (-30.0f*Math::PI/180.0f);
const float PORTICO_TIME_MOVE = 16.0f;
const float PORTICO_TIME_DOWN = 4.0f;
@@ -201,7 +199,7 @@ bool CAutoPortico::EventProcess(const Event &event)
angle = sinf(m_time*4.0f)*0.3f;
m_object->SetAngleX(9, angle);
- angle = -m_time*1.0f+PI/2.3f;
+ angle = -m_time*1.0f+Math::PI/2.3f;
m_object->SetAngleY(10, angle); // turns the left side radar
angle = sinf(m_time*4.0f)*0.3f;
m_object->SetAngleX(11, angle);
diff --git a/src/object/auto/autoradar.cpp b/src/object/auto/autoradar.cpp
index e0567fc..535bfee 100644
--- a/src/object/auto/autoradar.cpp
+++ b/src/object/auto/autoradar.cpp
@@ -14,14 +14,13 @@
// * 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/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/event.h"
@@ -103,19 +102,19 @@ bool CAutoRadar::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
angle = m_object->RetAngleY(1);
- angle += (Rand()-0.2f)*0.5f;
+ angle += (Math::Rand()-0.2f)*0.5f;
m_object->SetAngleY(1, angle);
angle = m_object->RetAngleY(2);
- angle += (Rand()-0.8f)*1.0f;
+ angle += (Math::Rand()-0.8f)*1.0f;
m_object->SetAngleY(2, angle);
- m_object->SetAngleX(3, (Rand()-0.5f)*0.3f);
+ m_object->SetAngleX(3, (Math::Rand()-0.5f)*0.3f);
- m_totalDetect = (int)(Rand()*10.0f);
+ m_totalDetect = (int)(Math::Rand()*10.0f);
UpdateInterface();
}
return true;
@@ -125,7 +124,7 @@ bool CAutoRadar::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- speed = Min(10.0f, m_progress*50.0f);
+ speed = Math::Min(10.0f, m_progress*50.0f);
angle = m_object->RetAngleY(1);
angle += event.rTime*speed;
m_object->SetAngleY(1, angle);
@@ -142,13 +141,13 @@ bool CAutoRadar::EventProcess(const Event &event)
{
pos = m_object->RetPosition(0);
m_start = m_object->RetAngleY(1);
- m_angle = m_start-NormAngle(m_start)+PI*2.0f;
- m_angle += RotateAngle(pos.x-ePos.x, ePos.z-pos.z);
- m_angle += PI-m_object->RetAngleY(0);
+ m_angle = m_start-Math::NormAngle(m_start)+Math::PI*2.0f;
+ m_angle += Math::RotateAngle(pos.x-ePos.x, ePos.z-pos.z);
+ m_angle += Math::PI-m_object->RetAngleY(0);
m_phase = ARAP_SHOW;
m_progress = 0.0f;
- m_speed = 1.0f/(Abs(m_angle-m_start)/10.0f);
+ m_speed = 1.0f/(fabs(m_angle-m_start)/10.0f);
}
}
}
@@ -175,7 +174,7 @@ bool CAutoRadar::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- prog = Min(1.0f, m_progress*2.0f);
+ prog = Math::Min(1.0f, m_progress*2.0f);
freq = 16.0f*(prog+1.0f);
ampl = 0.2f-prog*0.2f;
angle = m_angle + sinf(m_time*freq)*ampl;
@@ -217,7 +216,7 @@ Error CAutoRadar::RetError()
bool CAutoRadar::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp
index 05469c4..79bccc8 100644
--- a/src/object/auto/autorepair.cpp
+++ b/src/object/auto/autorepair.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>
@@ -93,7 +91,7 @@ bool CAutoRepair::EventProcess(const Event &event)
{
CObject* vehicule;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float angle, shield;
CAuto::EventProcess(event);
@@ -108,7 +106,7 @@ bool CAutoRepair::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
@@ -138,7 +136,7 @@ bool CAutoRepair::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- angle = -m_progress*(PI/2.0f)+PI/2.0f;
+ angle = -m_progress*(Math::PI/2.0f)+Math::PI/2.0f;
m_object->SetAngleZ(1, angle);
}
else
@@ -171,13 +169,13 @@ bool CAutoRepair::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_object->RetPosition(0);
- 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;
pos.y += 1.0f;
- speed.x = (Rand()-0.5f)*12.0f;
- speed.z = (Rand()-0.5f)*12.0f;
- speed.y = Rand()*15.0f;
- dim.x = Rand()*6.0f+4.0f;
+ speed.x = (Math::Rand()-0.5f)*12.0f;
+ speed.z = (Math::Rand()-0.5f)*12.0f;
+ speed.y = Math::Rand()*15.0f;
+ dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
@@ -196,12 +194,12 @@ bool CAutoRepair::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- angle = -(1.0f-m_progress)*(PI/2.0f)+PI/2.0f;
+ angle = -(1.0f-m_progress)*(Math::PI/2.0f)+Math::PI/2.0f;
m_object->SetAngleZ(1, angle);
}
else
{
- m_object->SetAngleZ(1, PI/2.0f);
+ m_object->SetAngleZ(1, Math::PI/2.0f);
m_phase = ARP_WAIT;
m_progress = 0.0f;
@@ -218,7 +216,7 @@ bool CAutoRepair::EventProcess(const Event &event)
bool CAutoRepair::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp
index e5305b5..f1602cf 100644
--- a/src/object/auto/autoresearch.cpp
+++ b/src/object/auto/autoresearch.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>
@@ -112,7 +110,7 @@ bool CAutoResearch::EventProcess(const Event &event)
CObject* power;
D3DVECTOR pos, speed;
Error message;
- FPOINT dim;
+ Math::Point dim;
float angle, time;
CAuto::EventProcess(event);
@@ -193,7 +191,7 @@ bool CAutoResearch::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
@@ -204,7 +202,7 @@ bool CAutoResearch::EventProcess(const Event &event)
angle = m_time*0.1f;
m_object->SetAngleY(1, angle); // rotates the antenna
- angle = (30.0f+sinf(m_time*0.3f)*20.0f)*PI/180.0f;
+ angle = (30.0f+sinf(m_time*0.3f)*20.0f)*Math::PI/180.0f;
m_object->SetAngleZ(2, angle); // directs the antenna
if ( m_phase == ALP_WAIT )
@@ -236,13 +234,13 @@ bool CAutoResearch::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_object->RetPosition(0);
- pos.x += (Rand()-0.5f)*6.0f;
- pos.z += (Rand()-0.5f)*6.0f;
+ pos.x += (Math::Rand()-0.5f)*6.0f;
+ pos.z += (Math::Rand()-0.5f)*6.0f;
pos.y += 11.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = Rand()*20.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 = Math::Rand()*20.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR);
}
@@ -318,7 +316,7 @@ Error CAutoResearch::RetError()
bool CAutoResearch::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
@@ -516,7 +514,7 @@ void CAutoResearch::FireStopUpdate(float progress, bool bLightOn)
{
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int i;
static float listpos[12] =
@@ -550,7 +548,7 @@ void CAutoResearch::FireStopUpdate(float progress, bool bLightOn)
for ( i=0 ; i<6 ; i++ )
{
- if ( Mod(progress, 0.025f) < 0.005f )
+ if ( Math::Mod(progress, 0.025f) < 0.005f )
{
if ( m_partiStop[i] != -1 )
{
diff --git a/src/object/auto/autoroot.cpp b/src/object/auto/autoroot.cpp
index 0ab12b8..8b16615 100644
--- a/src/object/auto/autoroot.cpp
+++ b/src/object/auto/autoroot.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>
@@ -67,7 +65,7 @@ void CAutoRoot::Init()
{
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
m_time = 0.0f;
m_lastParticule = 0.0f;
@@ -91,7 +89,7 @@ void CAutoRoot::Init()
bool CAutoRoot::EventProcess(const Event &event)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
CAuto::EventProcess(event);
@@ -107,13 +105,13 @@ bool CAutoRoot::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_center;
- 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 += 0.0f;
- speed.x = (Rand()-0.5f)*12.0f;
- speed.z = (Rand()-0.5f)*12.0f;
- speed.y = Rand()*12.0f;
- dim.x = Rand()*6.0f+4.0f;
+ speed.x = (Math::Rand()-0.5f)*12.0f;
+ speed.z = (Math::Rand()-0.5f)*12.0f;
+ speed.y = Math::Rand()*12.0f;
+ dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIROOT, 1.0f, 0.0f, 0.0f);
}
diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp
index 6565202..6cdccf5 100644
--- a/src/object/auto/autosafe.cpp
+++ b/src/object/auto/autosafe.cpp
@@ -14,14 +14,13 @@
// * 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/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/global.h"
@@ -127,7 +126,7 @@ bool CAutoSafe::EventProcess(const Event &event)
{
CObject* pObj;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int i, count;
CAuto::EventProcess(event);
@@ -142,7 +141,7 @@ bool CAutoSafe::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
}
return true;
}
@@ -169,11 +168,11 @@ bool CAutoSafe::EventProcess(const Event &event)
{
m_countKeys = count;
- if ( count == 0 ) m_finalAngle = 0.0f*PI/180.0f;
- if ( count == 1 ) m_finalAngle = 5.0f*PI/180.0f;
- if ( count == 2 ) m_finalAngle = 10.0f*PI/180.0f;
- if ( count == 3 ) m_finalAngle = 15.0f*PI/180.0f;
- if ( count == 4 ) m_finalAngle = 120.0f*PI/180.0f;
+ if ( count == 0 ) m_finalAngle = 0.0f*Math::PI/180.0f;
+ if ( count == 1 ) m_finalAngle = 5.0f*Math::PI/180.0f;
+ if ( count == 2 ) m_finalAngle = 10.0f*Math::PI/180.0f;
+ if ( count == 3 ) m_finalAngle = 15.0f*Math::PI/180.0f;
+ if ( count == 4 ) m_finalAngle = 120.0f*Math::PI/180.0f;
if ( count == 4 ) // all the keys?
{
@@ -213,33 +212,33 @@ bool CAutoSafe::EventProcess(const Event &event)
for ( i=0 ; i<10 ; i++ )
{
pos = m_object->RetPosition(0);
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
- speed.x = (Rand()-0.5f)*4.0f;
- speed.z = (Rand()-0.5f)*4.0f;
- speed.y = Rand()*15.0f;
- dim.x = Rand()*6.0f+4.0f;
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
+ speed.x = (Math::Rand()-0.5f)*4.0f;
+ speed.z = (Math::Rand()-0.5f)*4.0f;
+ speed.y = Math::Rand()*15.0f;
+ dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
pos = m_object->RetPosition(0);
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
- speed.x = (Rand()-0.5f)*4.0f;
- speed.z = (Rand()-0.5f)*4.0f;
- speed.y = Rand()*10.0f;
- dim.x = Rand()*3.0f+2.0f;
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
+ speed.x = (Math::Rand()-0.5f)*4.0f;
+ speed.z = (Math::Rand()-0.5f)*4.0f;
+ speed.y = Math::Rand()*10.0f;
+ dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 1.0f, 0.0f, 0.0f);
for ( i=0 ; i<4 ; i++ )
{
pos = m_keyPos[i];
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = 1.0f+Rand()*1.0f;
- dim.x = Rand()*1.5f+1.5f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = 1.0f+Math::Rand()*1.0f;
+ dim.x = Math::Rand()*1.5f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 0.0f);
}
@@ -282,12 +281,12 @@ bool CAutoSafe::EventProcess(const Event &event)
{
if ( m_actualAngle < m_finalAngle )
{
- m_actualAngle += (105.0f*PI/180.0f)*event.rTime/OPEN_DELAY;
+ m_actualAngle += (105.0f*Math::PI/180.0f)*event.rTime/OPEN_DELAY;
if ( m_actualAngle > m_finalAngle ) m_actualAngle = m_finalAngle;
}
else
{
- m_actualAngle -= (105.0f*PI/180.0f)*event.rTime/OPEN_DELAY;
+ m_actualAngle -= (105.0f*Math::PI/180.0f)*event.rTime/OPEN_DELAY;
if ( m_actualAngle < m_finalAngle ) m_actualAngle = m_finalAngle;
}
m_object->SetAngleZ(1, m_actualAngle);
@@ -300,7 +299,7 @@ bool CAutoSafe::EventProcess(const Event &event)
dim.y = dim.x;
for ( i=0 ; i<4 ; i++ )
{
- if ( m_phase != ASAP_WAIT || !m_bKey[i] || Mod(m_time, 1.0f) < 0.4f )
+ if ( m_phase != ASAP_WAIT || !m_bKey[i] || Math::Mod(m_time, 1.0f) < 0.4f )
{
if ( m_keyParti[i] != -1 )
{
@@ -328,7 +327,7 @@ bool CAutoSafe::EventProcess(const Event &event)
bool CAutoSafe::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
@@ -414,7 +413,7 @@ int CAutoSafe::CountKeys()
{
CObject* pObj;
D3DVECTOR cPos, oPos;
- FPOINT rot;
+ Math::Point rot;
ObjectType oType;
float dist, angle, limit, cAngle, oAngle;
int i, index;
@@ -447,34 +446,34 @@ int CAutoSafe::CountKeys()
if ( oType == OBJECT_KEYa )
{
- limit = PI*1.0f;
- oAngle = PI*0.0f;
+ limit = Math::PI*1.0f;
+ oAngle = Math::PI*0.0f;
index = 0;
}
if ( oType == OBJECT_KEYb )
{
- limit = PI*0.0f;
- oAngle = PI*1.0f;
+ limit = Math::PI*0.0f;
+ oAngle = Math::PI*1.0f;
index = 1;
}
if ( oType == OBJECT_KEYc )
{
- limit = PI*1.5f;
- oAngle = PI*0.5f;
+ limit = Math::PI*1.5f;
+ oAngle = Math::PI*0.5f;
index = 2;
}
if ( oType == OBJECT_KEYd )
{
- limit = PI*0.5f;
- oAngle = PI*0.0f;
+ limit = Math::PI*0.5f;
+ oAngle = Math::PI*0.0f;
index = 3;
}
- angle = RotateAngle(oPos.x-cPos.x, oPos.z-cPos.z)+cAngle;
- if ( !TestAngle(angle, limit-8.0f*PI/180.0f, limit+8.0f*PI/180.0f) ) continue;
+ angle = Math::RotateAngle(oPos.x-cPos.x, oPos.z-cPos.z)+cAngle;
+ if ( !Math::TestAngle(angle, limit-8.0f*Math::PI/180.0f, limit+8.0f*Math::PI/180.0f) ) continue;
// Key changes the shape of the base.
- rot = RotatePoint(FPOINT(cPos.x, cPos.z), limit-cAngle, FPOINT(cPos.x+16.0f, cPos.z));
+ rot = Math::RotatePoint(Math::Point(cPos.x, cPos.z), limit-cAngle, Math::Point(cPos.x+16.0f, cPos.z));
oPos.x = rot.x;
oPos.z = rot.y;
oPos.y = cPos.y+1.0f;
diff --git a/src/object/auto/autostation.cpp b/src/object/auto/autostation.cpp
index ab26b6d..cc93545 100644
--- a/src/object/auto/autostation.cpp
+++ b/src/object/auto/autostation.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 CAutoStation::EventProcess(const Event &event)
{
D3DMATRIX* mat;
D3DVECTOR pos, ppos, speed;
- FPOINT dim;
+ Math::Point dim;
CObject* vehicule;
CObject* power;
TerrainRes res;
@@ -117,9 +115,9 @@ bool CAutoStation::EventProcess(const Event &event)
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
- m_object->SetEnergy(Rand());
+ m_object->SetEnergy(Math::Rand());
}
return true;
}
@@ -205,11 +203,11 @@ bool CAutoStation::EventProcess(const Event &event)
mat = m_object->RetWorldMatrix(0);
pos = D3DVECTOR(-15.0f, 7.0f, 0.0f); // battery position
pos = Transform(*mat, pos);
- 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;
ppos.x = pos.x;
- ppos.y = pos.y+(Rand()-0.5f)*4.0f;
+ ppos.y = pos.y+(Math::Rand()-0.5f)*4.0f;
ppos.z = pos.z;
dim.x = 1.5f;
dim.y = 1.5f;
@@ -218,23 +216,23 @@ bool CAutoStation::EventProcess(const Event &event)
#if 0
ppos = pos;
ppos.y += 1.0f;
- ppos.x += (Rand()-0.5f)*3.0f;
- ppos.z += (Rand()-0.5f)*3.0f;
+ ppos.x += (Math::Rand()-0.5f)*3.0f;
+ ppos.z += (Math::Rand()-0.5f)*3.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 2.5f+Rand()*6.0f;
- dim.x = Rand()*1.5f+1.0f;
+ speed.y = 2.5f+Math::Rand()*6.0f;
+ dim.x = Math::Rand()*1.5f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(ppos, speed, dim, PARTISMOKE3, 4.0f);
#else
ppos = pos;
ppos.y += 1.0f;
- ppos.x += (Rand()-0.5f)*3.0f;
- ppos.z += (Rand()-0.5f)*3.0f;
+ ppos.x += (Math::Rand()-0.5f)*3.0f;
+ ppos.z += (Math::Rand()-0.5f)*3.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- speed.y = 2.5f+Rand()*5.0f;
- dim.x = Rand()*1.0f+0.6f;
+ speed.y = 2.5f+Math::Rand()*5.0f;
+ dim.x = Math::Rand()*1.0f+0.6f;
dim.y = dim.x;
m_particule->CreateParticule(ppos, speed, dim, PARTIVAPOR, 3.0f);
#endif
@@ -326,7 +324,7 @@ Error CAutoStation::RetError()
bool CAutoStation::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
index 74cc984..a76260e 100644
--- a/src/object/auto/autotower.cpp
+++ b/src/object/auto/autotower.cpp
@@ -14,15 +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 "math/const.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/global.h"
@@ -120,13 +119,13 @@ bool CAutoTower::EventProcess(const Event &event)
{
if ( m_timeVirus <= 0.0f )
{
- m_timeVirus = 0.1f+Rand()*0.3f;
+ m_timeVirus = 0.1f+Math::Rand()*0.3f;
angle = m_object->RetAngleY(1);
- angle += Rand()*0.5f;
+ angle += Math::Rand()*0.5f;
m_object->SetAngleY(1, angle);
- m_object->SetAngleZ(2, Rand()*0.5f);
+ m_object->SetAngleZ(2, Math::Rand()*0.5f);
}
return true;
}
@@ -204,13 +203,13 @@ bool CAutoTower::EventProcess(const Event &event)
{
pos = m_object->RetPosition(0);
pos.y += 24.5f;
- m_angleYfinal = RotateAngle(m_targetPos.x-pos.x, pos.z-m_targetPos.z); // CW !
- m_angleYfinal += PI*2.0f;
+ m_angleYfinal = Math::RotateAngle(m_targetPos.x-pos.x, pos.z-m_targetPos.z); // CW !
+ m_angleYfinal += Math::PI*2.0f;
m_angleYfinal -= m_object->RetAngleY(0);
- m_angleYactual = NormAngle(m_object->RetAngleY(1));
+ m_angleYactual = Math::NormAngle(m_object->RetAngleY(1));
- m_angleZfinal = -PI/2.0f;
- m_angleZfinal -= RotateAngle(Length2d(m_targetPos, pos), pos.y-m_targetPos.y); // CW !
+ m_angleZfinal = -Math::PI/2.0f;
+ m_angleZfinal -= Math::RotateAngle(Length2d(m_targetPos, pos), pos.y-m_targetPos.y); // CW !
m_angleZactual = m_object->RetAngleZ(2);
m_phase = ATP_TURN;
@@ -259,7 +258,7 @@ bool CAutoTower::EventProcess(const Event &event)
pos = m_object->RetPosition(0);
pos.y += 24.5f;
m_particule->CreateRay(pos, m_targetPos, PARTIRAY1,
- FPOINT(5.0f, 5.0f), 1.5f);
+ Math::Point(5.0f, 5.0f), 1.5f);
}
if ( m_progress >= 1.0f )
{
@@ -308,7 +307,7 @@ CObject* CAutoTower::SearchTarget(D3DVECTOR &impact)
physics = pObj->RetPhysics();
if ( physics != 0 )
{
- speed = Abs(physics->RetLinMotionX(MO_REASPEED));
+ speed = fabs(physics->RetLinMotionX(MO_REASPEED));
if ( speed > 20.0f ) continue; // moving too fast?
}
}
@@ -362,7 +361,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
{
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int i;
static float listpos[8] =
@@ -394,7 +393,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
for ( i=0 ; i<4 ; i++ )
{
- if ( Mod(progress+i*0.125f, 0.5f) < 0.2f )
+ if ( Math::Mod(progress+i*0.125f, 0.5f) < 0.2f )
{
if ( m_partiStop[i] != -1 )
{
@@ -424,7 +423,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
bool CAutoTower::CreateInterface(bool bSelect)
{
CWindow* pw;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
float ox, oy, sx, sy;
CAuto::CreateInterface(bSelect);
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index 2984eab..964ab70 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.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>
@@ -23,6 +21,7 @@
#include "CBot/CBotDll.h"
#include "common/struct.h"
+#include "math/const.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/language.h"
@@ -1188,7 +1187,7 @@ Error CBrain::EndedTask()
void CBrain::GroundFlat()
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
Error err;
float level;
@@ -1234,7 +1233,7 @@ bool CBrain::CreateInterface(bool bSelect)
CSlider* ps;
CTarget* pt;
CLabel* pl;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
char name[100];
@@ -1937,7 +1936,7 @@ void CBrain::UpdateInterface(float rTime)
CTarget* ptg;
CObject* power;
D3DVECTOR pos, hPos;
- FPOINT ppos;
+ Math::Point ppos;
float energy, limit, angle, range;
int icon;
bool bOnBoard;
@@ -2006,7 +2005,7 @@ void CBrain::UpdateInterface(float rTime)
if ( range < 0.2f && range != 0.0f && !m_physics->RetLand() )
{
- if ( Mod(m_time, 0.5f) >= 0.2f ) // blinks?
+ if ( Math::Mod(m_time, 0.5f) >= 0.2f ) // blinks?
{
range = 1.0f;
icon = 1; // yellow
@@ -2035,7 +2034,7 @@ void CBrain::UpdateInterface(float rTime)
pc = (CCompass*)pw->SearchControl(EVENT_OBJECT_COMPASS);
if ( pc != 0 )
{
- angle = -(m_object->RetAngleY(0)+PI/2.0f);
+ angle = -(m_object->RetAngleY(0)+Math::PI/2.0f);
pc->SetDirection(angle);
pc->SetState(STATE_VISIBLE, m_main->RetShowMap());
@@ -2045,7 +2044,7 @@ void CBrain::UpdateInterface(float rTime)
pb = (CButton*)pw->SearchControl(EVENT_OBJECT_REC);
if ( pb != 0 )
{
- if ( m_bTraceRecord && Mod(m_time, 0.4f) >= 0.2f )
+ if ( m_bTraceRecord && Math::Mod(m_time, 0.4f) >= 0.2f )
{
pb->SetState(STATE_CHECK);
}
@@ -2067,7 +2066,7 @@ void CBrain::UpdateInterface(float rTime)
angle = m_object->RetGunGoalV();
if ( m_object->RetType() != OBJECT_MOBILErc )
{
- angle += 10.0f*PI/360.0f;
+ angle += 10.0f*Math::PI/360.0f;
}
ppos.x = 0.5f-(64.0f/640.0f)/2.0f;
ppos.y = 0.5f-(64.0f/480.0f)/2.0f;
@@ -2975,7 +2974,7 @@ bool CBrain::TraceRecordPut(char *buffer, int max, TraceOper oper, float param)
if ( oper == TO_TURN )
{
- param = -param*180.0f/PI;
+ param = -param*180.0f/Math::PI;
sprintf(line, "\tturn(%d);\n", (int)param);
//? sprintf(line, "\tturn(%.1f);\n", param);
strncat(buffer, line, max-1);
diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp
index 52609a9..255feb7 100644
--- a/src/object/motion/motion.cpp
+++ b/src/object/motion/motion.cpp
@@ -16,15 +16,14 @@
// motion.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
-#include "math/all.h"
#include "common/struct.h"
+#include "math/const.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -133,21 +132,21 @@ bool CMotion::EventProcess(const Event &event)
}
dir = m_object->RetLinVibration();
- dir.x = Smooth(dir.x, m_linVibration.x, time);
- dir.y = Smooth(dir.y, m_linVibration.y, time);
- dir.z = Smooth(dir.z, m_linVibration.z, time);
+ dir.x = Math::Smooth(dir.x, m_linVibration.x, time);
+ dir.y = Math::Smooth(dir.y, m_linVibration.y, time);
+ dir.z = Math::Smooth(dir.z, m_linVibration.z, time);
m_object->SetLinVibration(dir);
dir = m_object->RetCirVibration();
- dir.x = Smooth(dir.x, m_cirVibration.x, time);
- dir.y = Smooth(dir.y, m_cirVibration.y, time);
- dir.z = Smooth(dir.z, m_cirVibration.z, time);
+ dir.x = Math::Smooth(dir.x, m_cirVibration.x, time);
+ dir.y = Math::Smooth(dir.y, m_cirVibration.y, time);
+ dir.z = Math::Smooth(dir.z, m_cirVibration.z, time);
m_object->SetCirVibration(dir);
dir = m_object->RetInclinaison();
- dir.x = Smooth(dir.x, m_inclinaison.x, time);
- dir.y = Smooth(dir.y, m_inclinaison.y, time);
- dir.z = Smooth(dir.z, m_inclinaison.z, time);
+ dir.x = Math::Smooth(dir.x, m_inclinaison.x, time);
+ dir.y = Math::Smooth(dir.y, m_inclinaison.y, time);
+ dir.z = Math::Smooth(dir.z, m_inclinaison.z, time);
m_object->SetInclinaison(dir);
return true;
diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h
index 555fbe4..1c3ab6c 100644
--- a/src/object/motion/motion.h
+++ b/src/object/motion/motion.h
@@ -19,6 +19,9 @@
#pragma once
+#include "common/event.h"
+#include "common/misc.h"
+#include "object/object.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp
index 3caf79a..62a58dc 100644
--- a/src/object/motion/motionant.cpp
+++ b/src/object/motion/motionant.cpp
@@ -16,14 +16,13 @@
// motionant.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/func.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -407,8 +406,8 @@ void CMotionAnt::CreatePhysics()
m_physics->SetLinMotionZ(MO_TERFORCE, 5.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 10.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 1.0f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 1.0f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 1.0f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 1.0f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 20.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 20.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 40.0f);
@@ -472,24 +471,12 @@ bool CMotionAnt::EventProcess(const Event &event)
return true;
}
-// Calculates a value (radians) proportional between a and b (degrees).
-
-inline float Propf(float a, float b, float p)
-{
- float aa, bb;
-
- aa = a*PI/180.0f;
- bb = b*PI/180.0f;
-
- return aa+p*(bb-aa);
-}
-
// Management of an event.
bool CMotionAnt::EventFrame(const Event &event)
{
D3DVECTOR dir, pos, speed;
- FPOINT dim;
+ Math::Point dim;
float s, a, prog, time;
float tSt[9], tNd[9];
int i, ii, st, nd, action;
@@ -499,7 +486,7 @@ bool CMotionAnt::EventFrame(const Event &event)
if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = Abs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
+ a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -517,8 +504,8 @@ bool CMotionAnt::EventFrame(const Event &event)
if ( bStop )
{
- prog = Mod(m_armTimeAbs, 2.0f)/10.0f;
- a = Mod(m_armMember, 1.0f);
+ prog = Math::Mod(m_armTimeAbs, 2.0f)/10.0f;
+ a = Math::Mod(m_armMember, 1.0f);
a = (prog-a)*event.rTime*2.0f; // stop position is pleasantly
m_armMember += a;
}
@@ -550,8 +537,8 @@ bool CMotionAnt::EventFrame(const Event &event)
}
else
{
- if ( i < 3 ) prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
- else prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
+ if ( i < 3 ) prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
+ else prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
if ( m_bArmStop )
{
prog = (float)m_armTimeIndex/3.0f;
@@ -578,7 +565,7 @@ bool CMotionAnt::EventFrame(const Event &event)
nd = 3*3*3*3*action + nd*3*3*3 + (i%3)*3;
// More and more soft ...
- time = event.rTime*(10.0f+Min(m_armTimeAction*100.0f, 200.0f));
+ time = event.rTime*(10.0f+Math::Min(m_armTimeAction*100.0f, 200.0f));
}
tSt[0] = m_armAngles[st+ 0]; // x
@@ -605,7 +592,7 @@ bool CMotionAnt::EventFrame(const Event &event)
{
for ( ii=0 ; ii<9 ; ii++ )
{
- tSt[ii] += Rand()*50.0f;
+ tSt[ii] += Math::Rand()*50.0f;
tNd[ii] = tSt[ii];
}
//? time = 100.0f;
@@ -614,27 +601,27 @@ bool CMotionAnt::EventFrame(const Event &event)
if ( i < 3 ) // right leg (1..3) ?
{
- m_object->SetAngleX(3+3*i+0, Smooth(m_object->RetAngleX(3+3*i+0), Propf(tSt[0], tNd[0], prog), time));
- m_object->SetAngleY(3+3*i+0, Smooth(m_object->RetAngleY(3+3*i+0), Propf(tSt[1], tNd[1], prog), time));
- m_object->SetAngleZ(3+3*i+0, Smooth(m_object->RetAngleZ(3+3*i+0), Propf(tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(3+3*i+1, Smooth(m_object->RetAngleX(3+3*i+1), Propf(tSt[3], tNd[3], prog), time));
- m_object->SetAngleY(3+3*i+1, Smooth(m_object->RetAngleY(3+3*i+1), Propf(tSt[4], tNd[4], prog), time));
- m_object->SetAngleZ(3+3*i+1, Smooth(m_object->RetAngleZ(3+3*i+1), Propf(tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(3+3*i+2, Smooth(m_object->RetAngleX(3+3*i+2), Propf(tSt[6], tNd[6], prog), time));
- m_object->SetAngleY(3+3*i+2, Smooth(m_object->RetAngleY(3+3*i+2), Propf(tSt[7], tNd[7], prog), time));
- m_object->SetAngleZ(3+3*i+2, Smooth(m_object->RetAngleZ(3+3*i+2), Propf(tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(3+3*i+0, Math::Smooth(m_object->RetAngleX(3+3*i+0), Math::PropAngle(tSt[0], tNd[0], prog), time));
+ m_object->SetAngleY(3+3*i+0, Math::Smooth(m_object->RetAngleY(3+3*i+0), Math::PropAngle(tSt[1], tNd[1], prog), time));
+ m_object->SetAngleZ(3+3*i+0, Math::Smooth(m_object->RetAngleZ(3+3*i+0), Math::PropAngle(tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(3+3*i+1, Math::Smooth(m_object->RetAngleX(3+3*i+1), Math::PropAngle(tSt[3], tNd[3], prog), time));
+ m_object->SetAngleY(3+3*i+1, Math::Smooth(m_object->RetAngleY(3+3*i+1), Math::PropAngle(tSt[4], tNd[4], prog), time));
+ m_object->SetAngleZ(3+3*i+1, Math::Smooth(m_object->RetAngleZ(3+3*i+1), Math::PropAngle(tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(3+3*i+2, Math::Smooth(m_object->RetAngleX(3+3*i+2), Math::PropAngle(tSt[6], tNd[6], prog), time));
+ m_object->SetAngleY(3+3*i+2, Math::Smooth(m_object->RetAngleY(3+3*i+2), Math::PropAngle(tSt[7], tNd[7], prog), time));
+ m_object->SetAngleZ(3+3*i+2, Math::Smooth(m_object->RetAngleZ(3+3*i+2), Math::PropAngle(tSt[8], tNd[8], prog), time));
}
else // left leg (4..6) ?
{
- m_object->SetAngleX(3+3*i+0, Smooth(m_object->RetAngleX(3+3*i+0), Propf(-tSt[0], -tNd[0], prog), time));
- m_object->SetAngleY(3+3*i+0, Smooth(m_object->RetAngleY(3+3*i+0), Propf(-tSt[1], -tNd[1], prog), time));
- m_object->SetAngleZ(3+3*i+0, Smooth(m_object->RetAngleZ(3+3*i+0), Propf( tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(3+3*i+1, Smooth(m_object->RetAngleX(3+3*i+1), Propf(-tSt[3], -tNd[3], prog), time));
- m_object->SetAngleY(3+3*i+1, Smooth(m_object->RetAngleY(3+3*i+1), Propf(-tSt[4], -tNd[4], prog), time));
- m_object->SetAngleZ(3+3*i+1, Smooth(m_object->RetAngleZ(3+3*i+1), Propf( tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(3+3*i+2, Smooth(m_object->RetAngleX(3+3*i+2), Propf(-tSt[6], -tNd[6], prog), time));
- m_object->SetAngleY(3+3*i+2, Smooth(m_object->RetAngleY(3+3*i+2), Propf(-tSt[7], -tNd[7], prog), time));
- m_object->SetAngleZ(3+3*i+2, Smooth(m_object->RetAngleZ(3+3*i+2), Propf( tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(3+3*i+0, Math::Smooth(m_object->RetAngleX(3+3*i+0), Math::PropAngle(-tSt[0], -tNd[0], prog), time));
+ m_object->SetAngleY(3+3*i+0, Math::Smooth(m_object->RetAngleY(3+3*i+0), Math::PropAngle(-tSt[1], -tNd[1], prog), time));
+ m_object->SetAngleZ(3+3*i+0, Math::Smooth(m_object->RetAngleZ(3+3*i+0), Math::PropAngle( tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(3+3*i+1, Math::Smooth(m_object->RetAngleX(3+3*i+1), Math::PropAngle(-tSt[3], -tNd[3], prog), time));
+ m_object->SetAngleY(3+3*i+1, Math::Smooth(m_object->RetAngleY(3+3*i+1), Math::PropAngle(-tSt[4], -tNd[4], prog), time));
+ m_object->SetAngleZ(3+3*i+1, Math::Smooth(m_object->RetAngleZ(3+3*i+1), Math::PropAngle( tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(3+3*i+2, Math::Smooth(m_object->RetAngleX(3+3*i+2), Math::PropAngle(-tSt[6], -tNd[6], prog), time));
+ m_object->SetAngleY(3+3*i+2, Math::Smooth(m_object->RetAngleY(3+3*i+2), Math::PropAngle(-tSt[7], -tNd[7], prog), time));
+ m_object->SetAngleZ(3+3*i+2, Math::Smooth(m_object->RetAngleZ(3+3*i+2), Math::PropAngle( tSt[8], tNd[8], prog), time));
}
}
@@ -653,22 +640,22 @@ bool CMotionAnt::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
- dir.z = Prop(0, -50, prog);
+ dir.z = Math::PropAngle(0, -50, prog);
SetInclinaison(dir);
- m_object->SetAngleZ(1, Prop(0, 65, prog)); // head
- m_object->SetAngleZ(2, Prop(0, -95, prog)); // tail
+ m_object->SetAngleZ(1, Math::PropAngle(0, 65, prog)); // head
+ m_object->SetAngleZ(2, Math::PropAngle(0, -95, prog)); // tail
}
else if ( m_actionType == MAS_FIRE ) // shooting?
{
if ( m_progress < 0.75f ) a = m_progress/0.75f;
else a = (1.0f-m_progress)/0.25f;
m_object->SetZoom(2, (a*0.5f)+1.0f); // tail
- m_object->SetAngleX(2, (Rand()-0.5f)*0.3f*a);
- m_object->SetAngleY(2, (Rand()-0.5f)*0.3f*a);
+ m_object->SetAngleX(2, (Math::Rand()-0.5f)*0.3f*a);
+ m_object->SetAngleY(2, (Math::Rand()-0.5f)*0.3f*a);
- dir.x = (Rand()-0.5f)*0.02f*a;
- dir.y = (Rand()-0.5f)*0.05f*a;
- dir.z = (Rand()-0.5f)*0.03f*a;
+ dir.x = (Math::Rand()-0.5f)*0.02f*a;
+ dir.y = (Math::Rand()-0.5f)*0.05f*a;
+ dir.z = (Math::Rand()-0.5f)*0.03f*a;
SetCirVibration(dir);
}
else if ( m_actionType == MAS_TERMINATE ) // ends the shooting?
@@ -677,14 +664,14 @@ bool CMotionAnt::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
- dir.z = Prop(0, -50, prog);
+ dir.z = Math::PropAngle(0, -50, prog);
SetInclinaison(dir);
- m_object->SetAngleZ(1, Prop(0, 65, prog)); // head
- m_object->SetAngleZ(2, Prop(0, -95, prog)); // tail
+ m_object->SetAngleZ(1, Math::PropAngle(0, 65, prog)); // head
+ m_object->SetAngleZ(2, Math::PropAngle(0, -95, prog)); // tail
}
else if ( m_actionType == MAS_BURN ) // burning?
{
- dir = D3DVECTOR(PI, 0.0f, 0.0f);
+ dir = D3DVECTOR(Math::PI, 0.0f, 0.0f);
SetCirVibration(dir);
dir = D3DVECTOR(0.0f, -1.5f, 0.0f);
SetLinVibration(dir);
@@ -692,8 +679,8 @@ bool CMotionAnt::EventFrame(const Event &event)
SetInclinaison(dir);
time = event.rTime*1.0f;
- m_object->SetAngleZ(1, Smooth(m_object->RetAngleZ(1), 0.0f, time)); // head
- m_object->SetAngleZ(2, Smooth(m_object->RetAngleZ(2), 0.0f, time)); // tail
+ m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), 0.0f, time)); // head
+ m_object->SetAngleZ(2, Math::Smooth(m_object->RetAngleZ(2), 0.0f, time)); // tail
}
else if ( m_actionType == MAS_RUIN ) // destroyed?
{
@@ -709,10 +696,10 @@ bool CMotionAnt::EventFrame(const Event &event)
m_lastParticule = m_armTimeAbs;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*5.0f;
- dim.x = Rand()*3.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*5.0f;
+ dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -731,7 +718,7 @@ bool CMotionAnt::EventFrame(const Event &event)
dir.z = 0.0f;
SetLinVibration(dir);
}
- dir.x = m_progress*PI;
+ dir.x = m_progress*Math::PI;
dir.y = 0.0f;
dir.z = 0.0f;
SetCirVibration(dir);
@@ -741,7 +728,7 @@ bool CMotionAnt::EventFrame(const Event &event)
if ( m_progress >= 1.0f )
{
- SetAction(MAS_BACK2, 55.0f+Rand()*10.0f);
+ SetAction(MAS_BACK2, 55.0f+Math::Rand()*10.0f);
}
}
else if ( m_actionType == MAS_BACK2 ) // moves on the back?
@@ -753,13 +740,13 @@ bool CMotionAnt::EventFrame(const Event &event)
if ( rand()%10 == 0 )
{
pos = m_object->RetPosition(0);
- 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;
pos.y -= 1.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = Rand()*2.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 = Math::Rand()*2.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -770,7 +757,7 @@ bool CMotionAnt::EventFrame(const Event &event)
dir.x = sinf(m_armTimeAbs* 4.0f)*0.10f+
sinf(m_armTimeAbs* 7.0f)*0.20f+
sinf(m_armTimeAbs*10.0f)*0.40f+
- sinf(m_armTimeAbs*21.0f)*0.50f+PI;
+ sinf(m_armTimeAbs*21.0f)*0.50f+Math::PI;
dir.y = sinf(m_armTimeAbs* 3.0f)*0.01f+
sinf(m_armTimeAbs* 6.0f)*0.02f+
sinf(m_armTimeAbs*11.0f)*0.04f+
@@ -800,10 +787,10 @@ bool CMotionAnt::EventFrame(const Event &event)
m_lastParticule = m_armTimeAbs;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*5.0f;
- dim.x = Rand()*3.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*5.0f;
+ dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -822,7 +809,7 @@ bool CMotionAnt::EventFrame(const Event &event)
dir.z = 0.0f;
SetLinVibration(dir);
}
- dir.x = (1.0f-m_progress)*PI;
+ dir.x = (1.0f-m_progress)*Math::PI;
dir.y = 0.0f;
dir.z = 0.0f;
SetCirVibration(dir);
@@ -852,12 +839,12 @@ bool CMotionAnt::EventFrame(const Event &event)
}
else
{
- a = Mod(m_armTimeMarch, 1.0f);
+ a = Math::Mod(m_armTimeMarch, 1.0f);
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
else a = 3.0f-4.0f*a; // 1..-1
dir.x = sinf(a)*0.05f;
- s = Mod(m_armTimeMarch/2.0f, 1.0f);
+ s = Math::Mod(m_armTimeMarch/2.0f, 1.0f);
if ( s < 0.5f ) s = -1.0f+4.0f*s; // -1..1
else s = 3.0f-4.0f*s; // 1..-1
dir.z = sinf(s)*0.1f;
@@ -867,7 +854,7 @@ bool CMotionAnt::EventFrame(const Event &event)
m_object->SetAngleZ(2, -sinf(a)*0.3f); // tail
- a = Mod(m_armMember-0.1f, 1.0f);
+ a = Math::Mod(m_armMember-0.1f, 1.0f);
if ( a < 0.33f )
{
dir.y = -(1.0f-(a/0.33f))*0.3f;
diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp
index 9167bbc..41da476 100644
--- a/src/object/motion/motionbee.cpp
+++ b/src/object/motion/motionbee.cpp
@@ -16,14 +16,13 @@
// motionbee.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/func.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -215,7 +214,7 @@ bool CMotionBee::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\ant4.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(12, D3DVECTOR(-0.3f, -0.1f, 0.2f));
- m_object->SetAngleY(12, PI);
+ m_object->SetAngleY(12, Math::PI);
// Creates a left-back leg.
rank = m_engine->CreateObject();
@@ -243,7 +242,7 @@ bool CMotionBee::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\ant4.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(15, D3DVECTOR(0.3f, -0.1f, 0.4f));
- m_object->SetAngleY(15, PI);
+ m_object->SetAngleY(15, Math::PI);
// Creates two middle-left legs.
rank = m_engine->CreateObject();
@@ -271,7 +270,7 @@ bool CMotionBee::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\ant4.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(18, D3DVECTOR(1.0f, -0.1f, 0.7f));
- m_object->SetAngleY(18, PI);
+ m_object->SetAngleY(18, Math::PI);
// Creates front-left leg.
rank = m_engine->CreateObject();
@@ -388,8 +387,8 @@ void CMotionBee::CreatePhysics()
m_physics->SetLinMotionY(MO_RECACCEL, 50.0f);
m_physics->SetLinMotionY(MO_STOACCEL, 50.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 1.0f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 1.0f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 1.0f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 1.0f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 20.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 20.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 40.0f);
@@ -462,7 +461,7 @@ bool CMotionBee::EventFrame(const Event &event)
if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
s = m_physics->RetLinMotionX(MO_MOTSPEED)*0.30f;
- a = Abs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.00f);
+ a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.00f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -475,8 +474,8 @@ bool CMotionBee::EventFrame(const Event &event)
if ( bStop )
{
- prog = Mod(m_armTimeAbs, 2.0f)/10.0f;
- a = Mod(m_armMember, 1.0f);
+ prog = Math::Mod(m_armTimeAbs, 2.0f)/10.0f;
+ a = Math::Mod(m_armMember, 1.0f);
a = (prog-a)*event.rTime*2.0f; // stop position is pleasantly
m_armMember += a;
}
@@ -504,8 +503,8 @@ bool CMotionBee::EventFrame(const Event &event)
}
else
{
- if ( i < 3 ) prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
- else prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
+ if ( i < 3 ) prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
+ else prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
if ( m_bArmStop )
{
prog = (float)m_armTimeIndex/3.0f;
@@ -534,27 +533,27 @@ bool CMotionBee::EventFrame(const Event &event)
if ( i < 3 ) // right leg (1..3) ?
{
- m_object->SetAngleX(3+3*i+0, Prop(m_armAngles[st+ 0], m_armAngles[nd+ 0], prog));
- m_object->SetAngleY(3+3*i+0, Prop(m_armAngles[st+ 1], m_armAngles[nd+ 1], prog));
- m_object->SetAngleZ(3+3*i+0, Prop(m_armAngles[st+ 2], m_armAngles[nd+ 2], prog));
- m_object->SetAngleX(3+3*i+1, Prop(m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
- m_object->SetAngleY(3+3*i+1, Prop(m_armAngles[st+10], m_armAngles[nd+10], prog));
- m_object->SetAngleZ(3+3*i+1, Prop(m_armAngles[st+11], m_armAngles[nd+11], prog));
- m_object->SetAngleX(3+3*i+2, Prop(m_armAngles[st+18], m_armAngles[nd+18], prog));
- m_object->SetAngleY(3+3*i+2, Prop(m_armAngles[st+19], m_armAngles[nd+19], prog));
- m_object->SetAngleZ(3+3*i+2, Prop(m_armAngles[st+20], m_armAngles[nd+20], prog));
+ m_object->SetAngleX(3+3*i+0, Math::PropAngle(m_armAngles[st+ 0], m_armAngles[nd+ 0], prog));
+ m_object->SetAngleY(3+3*i+0, Math::PropAngle(m_armAngles[st+ 1], m_armAngles[nd+ 1], prog));
+ m_object->SetAngleZ(3+3*i+0, Math::PropAngle(m_armAngles[st+ 2], m_armAngles[nd+ 2], prog));
+ m_object->SetAngleX(3+3*i+1, Math::PropAngle(m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
+ m_object->SetAngleY(3+3*i+1, Math::PropAngle(m_armAngles[st+10], m_armAngles[nd+10], prog));
+ m_object->SetAngleZ(3+3*i+1, Math::PropAngle(m_armAngles[st+11], m_armAngles[nd+11], prog));
+ m_object->SetAngleX(3+3*i+2, Math::PropAngle(m_armAngles[st+18], m_armAngles[nd+18], prog));
+ m_object->SetAngleY(3+3*i+2, Math::PropAngle(m_armAngles[st+19], m_armAngles[nd+19], prog));
+ m_object->SetAngleZ(3+3*i+2, Math::PropAngle(m_armAngles[st+20], m_armAngles[nd+20], prog));
}
else // left leg(4..6) ?
{
- m_object->SetAngleX(3+3*i+0, Prop( -m_armAngles[st+ 0], -m_armAngles[nd+ 0], prog));
- m_object->SetAngleY(3+3*i+0, Prop(180-m_armAngles[st+ 1], 180-m_armAngles[nd+ 1], prog));
- m_object->SetAngleZ(3+3*i+0, Prop( -m_armAngles[st+ 2], -m_armAngles[nd+ 2], prog));
- m_object->SetAngleX(3+3*i+1, Prop( m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
- m_object->SetAngleY(3+3*i+1, Prop( -m_armAngles[st+10], -m_armAngles[nd+10], prog));
- m_object->SetAngleZ(3+3*i+1, Prop( -m_armAngles[st+11], -m_armAngles[nd+11], prog));
- m_object->SetAngleX(3+3*i+2, Prop( m_armAngles[st+18], m_armAngles[nd+18], prog));
- m_object->SetAngleY(3+3*i+2, Prop( -m_armAngles[st+19], -m_armAngles[nd+19], prog));
- m_object->SetAngleZ(3+3*i+2, Prop( -m_armAngles[st+20], -m_armAngles[nd+20], prog));
+ m_object->SetAngleX(3+3*i+0, Math::PropAngle( -m_armAngles[st+ 0], -m_armAngles[nd+ 0], prog));
+ m_object->SetAngleY(3+3*i+0, Math::PropAngle(180-m_armAngles[st+ 1], 180-m_armAngles[nd+ 1], prog));
+ m_object->SetAngleZ(3+3*i+0, Math::PropAngle( -m_armAngles[st+ 2], -m_armAngles[nd+ 2], prog));
+ m_object->SetAngleX(3+3*i+1, Math::PropAngle( m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
+ m_object->SetAngleY(3+3*i+1, Math::PropAngle( -m_armAngles[st+10], -m_armAngles[nd+10], prog));
+ m_object->SetAngleZ(3+3*i+1, Math::PropAngle( -m_armAngles[st+11], -m_armAngles[nd+11], prog));
+ m_object->SetAngleX(3+3*i+2, Math::PropAngle( m_armAngles[st+18], m_armAngles[nd+18], prog));
+ m_object->SetAngleY(3+3*i+2, Math::PropAngle( -m_armAngles[st+19], -m_armAngles[nd+19], prog));
+ m_object->SetAngleZ(3+3*i+2, Math::PropAngle( -m_armAngles[st+20], -m_armAngles[nd+20], prog));
}
}
@@ -578,12 +577,12 @@ bool CMotionBee::EventFrame(const Event &event)
}
else
{
- a = Mod(m_armTimeMarch, 1.0f);
+ a = Math::Mod(m_armTimeMarch, 1.0f);
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
else a = 3.0f-4.0f*a; // 1..-1
dir.x = sinf(a)*0.05f;
- s = Mod(m_armTimeMarch/2.0f, 1.0f);
+ s = Math::Mod(m_armTimeMarch/2.0f, 1.0f);
if ( s < 0.5f ) s = -1.0f+4.0f*s; // -1..1
else s = 3.0f-4.0f*s; // 1..-1
dir.z = sinf(s)*0.1f;
@@ -593,7 +592,7 @@ bool CMotionBee::EventFrame(const Event &event)
m_object->SetAngleZ(2, -sinf(a)*0.3f); // tail
- a = Mod(m_armMember-0.1f, 1.0f);
+ a = Math::Mod(m_armMember-0.1f, 1.0f);
if ( a < 0.33f )
{
dir.y = -(1.0f-(a/0.33f))*0.3f;
@@ -623,21 +622,21 @@ bool CMotionBee::EventFrame(const Event &event)
}
#if 0
- a = Rand()*PI/2.0f*prog;
+ a = Math::Rand()*Math::PI/2.0f*prog;
m_object->SetAngleX(21, a); // right wing
- a = -Rand()*PI/4.0f*prog;
+ a = -Math::Rand()*Math::PI/4.0f*prog;
m_object->SetAngleY(21, a);
- a = -Rand()*PI/2.0f*prog;
+ a = -Math::Rand()*Math::PI/2.0f*prog;
m_object->SetAngleX(22, a); // left wing
- a = Rand()*PI/4.0f*prog;
+ a = Math::Rand()*Math::PI/4.0f*prog;
m_object->SetAngleY(22, a);
#else
- m_object->SetAngleX(21, (sinf(m_armTimeAbs*30.0f)+1.0f)*(PI/4.0f)*prog);
- m_object->SetAngleY(21, -Rand()*PI/6.0f*prog);
+ m_object->SetAngleX(21, (sinf(m_armTimeAbs*30.0f)+1.0f)*(Math::PI/4.0f)*prog);
+ m_object->SetAngleY(21, -Math::Rand()*Math::PI/6.0f*prog);
- m_object->SetAngleX(22, -(sinf(m_armTimeAbs*30.0f)+1.0f)*(PI/4.0f)*prog);
- m_object->SetAngleY(22, Rand()*PI/6.0f*prog);
+ m_object->SetAngleX(22, -(sinf(m_armTimeAbs*30.0f)+1.0f)*(Math::PI/4.0f)*prog);
+ m_object->SetAngleY(22, Math::Rand()*Math::PI/6.0f*prog);
#endif
m_object->SetAngleZ(1, sinf(m_armTimeAbs*1.4f)*0.20f); // head
diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp
index 6667a39..bcdf2df 100644
--- a/src/object/motion/motionhuman.cpp
+++ b/src/object/motion/motionhuman.cpp
@@ -16,14 +16,14 @@
// motionhuman.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/func.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -231,7 +231,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\human3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(2, D3DVECTOR(0.0f, 2.3f, -1.2f));
- m_object->SetAngle(2, D3DVECTOR(90.0f*PI/180.0f, 90.0f*PI/180.0f, -50.0f*PI/180.0f));
+ m_object->SetAngle(2, D3DVECTOR(90.0f*Math::PI/180.0f, 90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
// Creates the right forearm.
rank = m_engine->CreateObject();
@@ -241,7 +241,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\human4r.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(3, D3DVECTOR(1.3f, 0.0f, 0.0f));
- m_object->SetAngle(3, D3DVECTOR(0.0f*PI/180.0f, -20.0f*PI/180.0f, 0.0f*PI/180.0f));
+ m_object->SetAngle(3, D3DVECTOR(0.0f*Math::PI/180.0f, -20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
// Creates right hand.
rank = m_engine->CreateObject();
@@ -260,7 +260,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\human6.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(5, D3DVECTOR(0.0f, 0.0f, -0.7f));
- m_object->SetAngle(5, D3DVECTOR(10.0f*PI/180.0f, 0.0f*PI/180.0f, 5.0f*PI/180.0f));
+ m_object->SetAngle(5, D3DVECTOR(10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
// Creates the right leg.
rank = m_engine->CreateObject();
@@ -270,7 +270,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\human7.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(6, D3DVECTOR(0.0f, -1.5f, 0.0f));
- m_object->SetAngle(6, D3DVECTOR(0.0f*PI/180.0f, 0.0f*PI/180.0f, -10.0f*PI/180.0f));
+ m_object->SetAngle(6, D3DVECTOR(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
// Creates the right foot.
rank = m_engine->CreateObject();
@@ -280,7 +280,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\human8.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(7, D3DVECTOR(0.0f, -1.5f, 0.0f));
- m_object->SetAngle(7, D3DVECTOR(-10.0f*PI/180.0f, 5.0f*PI/180.0f, 5.0f*PI/180.0f));
+ m_object->SetAngle(7, D3DVECTOR(-10.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
// Creates the left arm.
rank = m_engine->CreateObject();
@@ -291,7 +291,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(8, D3DVECTOR(0.0f, 2.3f, 1.2f));
- m_object->SetAngle(8, D3DVECTOR(-90.0f*PI/180.0f, -90.0f*PI/180.0f, -50.0f*PI/180.0f));
+ m_object->SetAngle(8, D3DVECTOR(-90.0f*Math::PI/180.0f, -90.0f*Math::PI/180.0f, -50.0f*Math::PI/180.0f));
// Creates the left forearm.
rank = m_engine->CreateObject();
@@ -302,7 +302,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(9, D3DVECTOR(1.3f, 0.0f, 0.0f));
- m_object->SetAngle(9, D3DVECTOR(0.0f*PI/180.0f, 20.0f*PI/180.0f, 0.0f*PI/180.0f));
+ m_object->SetAngle(9, D3DVECTOR(0.0f*Math::PI/180.0f, 20.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f));
// Creates left hand.
rank = m_engine->CreateObject();
@@ -323,7 +323,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(11, D3DVECTOR(0.0f, 0.0f, 0.7f));
- m_object->SetAngle(11, D3DVECTOR(-10.0f*PI/180.0f, 0.0f*PI/180.0f, 5.0f*PI/180.0f));
+ m_object->SetAngle(11, D3DVECTOR(-10.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
// Creates the left leg.
rank = m_engine->CreateObject();
@@ -334,7 +334,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(12, D3DVECTOR(0.0f, -1.5f, 0.0f));
- m_object->SetAngle(12, D3DVECTOR(0.0f*PI/180.0f, 0.0f*PI/180.0f, -10.0f*PI/180.0f));
+ m_object->SetAngle(12, D3DVECTOR(0.0f*Math::PI/180.0f, 0.0f*Math::PI/180.0f, -10.0f*Math::PI/180.0f));
// Creates the left foot.
rank = m_engine->CreateObject();
@@ -345,7 +345,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(13, D3DVECTOR(0.0f, -1.5f, 0.0f));
- m_object->SetAngle(13, D3DVECTOR(10.0f*PI/180.0f, -5.0f*PI/180.0f, 5.0f*PI/180.0f));
+ m_object->SetAngle(13, D3DVECTOR(10.0f*Math::PI/180.0f, -5.0f*Math::PI/180.0f, 5.0f*Math::PI/180.0f));
// Creates the neutron gun.
if ( option != 2 ) // with backpack?
@@ -357,7 +357,7 @@ bool CMotionHuman::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\human9.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(14, D3DVECTOR(-1.5f, 0.3f, -1.35f));
- m_object->SetAngleZ(14, PI);
+ m_object->SetAngleZ(14, Math::PI);
}
m_object->CreateShadowCircle(2.0f, 0.8f);
@@ -600,8 +600,8 @@ void CMotionHuman::CreatePhysics(ObjectType type)
m_physics->SetLinMotionY(MO_RECACCEL, 50.0f);
m_physics->SetLinMotionY(MO_STOACCEL, 50.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.8f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.8f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.8f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.8f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 6.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 6.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 4.0f);
@@ -624,8 +624,8 @@ void CMotionHuman::CreatePhysics(ObjectType type)
m_physics->SetLinMotionY(MO_RECACCEL, 50.0f);
m_physics->SetLinMotionY(MO_STOACCEL, 50.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.6f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.6f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.6f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.6f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 4.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 4.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 3.0f);
@@ -713,25 +713,13 @@ bool CMotionHuman::EventProcess(const Event &event)
return true;
}
-// Calculates a value (radians) proportional between a and b (degrees).
-
-inline float Propf(float a, float b, float p)
-{
- float aa, bb;
-
- aa = a*PI/180.0f;
- bb = b*PI/180.0f;
-
- return aa+p*(bb-aa);
-}
-
// Management of an event.
bool CMotionHuman::EventFrame(const Event &event)
{
D3DMATRIX* mat;
D3DVECTOR dir, actual, pos, speed, pf;
- FPOINT center, dim, p2;
+ Math::Point center, dim, p2;
float s, a, prog, rTime[2], lTime[2], time, rot, hr, hl;
float al, ar, af;
float tSt[9], tNd[9];
@@ -791,7 +779,7 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( s > 0.0f && s < 10.0f ) s = 0.0f; // moving slowly?
//? if ( s < 0.0f && s > -5.0f ) s = -5.0f; // falling slowly?
}
- a = Abs(rot*12.0f);
+ a = fabs(rot*12.0f);
if ( !m_physics->RetLand() && !bSwim ) // in flight?
{
@@ -809,7 +797,7 @@ bool CMotionHuman::EventFrame(const Event &event)
#else
a = m_physics->RetLinMotionX(MO_REASPEED);
s = m_physics->RetLinMotionX(MO_MOTSPEED)*0.2f;
- if ( Abs(a) > Abs(s) ) s = a; // the highest value
+ if ( fabs(a) > fabs(s) ) s = a; // the highest value
#endif
a = m_physics->RetLinMotionX(MO_TERSPEED);
if ( a < 0.0f ) // rises?
@@ -823,7 +811,7 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( a > 0.0f ) s -= a;
}
s *= 2.0f;
- a = Abs(rot*12.0f);
+ a = fabs(rot*12.0f);
if ( !m_physics->RetLand() && !bSwim ) // in flight?
{
@@ -859,9 +847,9 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( bSwim ) // swims?
{
- s += Abs(m_physics->RetLinMotionY(MO_REASPEED)*2.0f);
+ s += fabs(m_physics->RetLinMotionY(MO_REASPEED)*2.0f);
a *= 2.0f;
- m_armTimeSwim += Min(Max(s,a,3.0f),15.0f)*event.rTime*0.05f;
+ m_armTimeSwim += Math::Min(Math::Max(s,a,3.0f),15.0f)*event.rTime*0.05f;
}
bStop = ( s == 0.0f ); // stop?
@@ -946,22 +934,22 @@ bool CMotionHuman::EventFrame(const Event &event)
pos = m_object->RetPosition(0);
m_terrain->MoveOnFloor(pos);
- pf.x = pos.x+cosf(a+PI*1.5f)*0.7f;
+ pf.x = pos.x+cosf(a+Math::PI*1.5f)*0.7f;
pf.y = pos.y;
- pf.z = pos.z-sinf(a+PI*1.5f)*0.7f;
+ pf.z = pos.z-sinf(a+Math::PI*1.5f)*0.7f;
m_terrain->MoveOnFloor(pf);
al = atanf((pf.y-pos.y)/0.7f); // angle for left leg
pf = pos;
- pf.x = pos.x+cosf(a+PI*0.5f)*0.7f;
+ pf.x = pos.x+cosf(a+Math::PI*0.5f)*0.7f;
pf.y = pos.y;
- pf.z = pos.z-sinf(a+PI*0.5f)*0.7f;
+ pf.z = pos.z-sinf(a+Math::PI*0.5f)*0.7f;
m_terrain->MoveOnFloor(pf);
ar = atanf((pf.y-pos.y)/0.7f); // angle to right leg
- pf.x = pos.x+cosf(a+PI)*0.3f;
+ pf.x = pos.x+cosf(a+Math::PI)*0.3f;
pf.y = pos.y;
- pf.z = pos.z-sinf(a+PI)*0.3f;
+ pf.z = pos.z-sinf(a+Math::PI)*0.3f;
m_terrain->MoveOnFloor(pf);
af = atanf((pf.y-pos.y)/0.3f); // angle for feet
}
@@ -990,8 +978,8 @@ bool CMotionHuman::EventFrame(const Event &event)
}
else
{
- if ( i < 2 ) prog = Mod(rTime[i%2], 1.0f);
- else prog = Mod(lTime[i%2], 1.0f);
+ if ( i < 2 ) prog = Math::Mod(rTime[i%2], 1.0f);
+ else prog = Math::Mod(lTime[i%2], 1.0f);
if ( prog < 0.25f ) // t0..t1 ?
{
prog = prog/0.25f; // 0..1
@@ -1022,7 +1010,7 @@ bool CMotionHuman::EventFrame(const Event &event)
}
// Less soft ...
- time = event.rTime*(5.0f+Min(m_armTimeAction*50.0f, 100.0f));
+ time = event.rTime*(5.0f+Math::Min(m_armTimeAction*50.0f, 100.0f));
if ( bSwim ) time *= 0.25f;
}
@@ -1115,22 +1103,22 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( i == 1 ) // right leg?
{
- aa = (ar*180.0f/PI*0.5f);
+ aa = (ar*180.0f/Math::PI*0.5f);
}
else // left leg?
{
- aa = (al*180.0f/PI*0.5f);
+ aa = (al*180.0f/Math::PI*0.5f);
}
tSt[6] += aa;
tNd[6] += aa; // increases the angle X of the foot
if ( i == 1 ) // right leg?
{
- aa = (ar*180.0f/PI);
+ aa = (ar*180.0f/Math::PI);
}
else // left leg?
{
- aa = (al*180.0f/PI);
+ aa = (al*180.0f/Math::PI);
}
if ( aa < 0.0f ) aa = 0.0f;
if ( aa > 30.0f ) aa = 30.0f;
@@ -1142,7 +1130,7 @@ bool CMotionHuman::EventFrame(const Event &event)
tSt[8] += aa;
tNd[8] += aa; // increases the angle Z of the foot
- aa = (af*180.0f/PI)*0.7f;
+ aa = (af*180.0f/Math::PI)*0.7f;
if ( aa < -30.0f ) aa = -30.0f;
if ( aa > 30.0f ) aa = 30.0f;
@@ -1166,7 +1154,7 @@ bool CMotionHuman::EventFrame(const Event &event)
for ( ii=0 ; ii<9 ; ii++ )
{
- tSt[ii] += Rand()*20.0f*deadFactor;
+ tSt[ii] += Math::Rand()*20.0f*deadFactor;
tNd[ii] = tSt[ii];
}
time = 100.0f;
@@ -1174,27 +1162,27 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( i < 2 ) // right member (0..1) ?
{
- m_object->SetAngleX(2+3*i+0, Smooth(m_object->RetAngleX(2+3*i+0), Propf(tSt[0], tNd[0], prog), time));
- m_object->SetAngleY(2+3*i+0, Smooth(m_object->RetAngleY(2+3*i+0), Propf(tSt[1], tNd[1], prog), time));
- m_object->SetAngleZ(2+3*i+0, Smooth(m_object->RetAngleZ(2+3*i+0), Propf(tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(2+3*i+1, Smooth(m_object->RetAngleX(2+3*i+1), Propf(tSt[3], tNd[3], prog), time));
- m_object->SetAngleY(2+3*i+1, Smooth(m_object->RetAngleY(2+3*i+1), Propf(tSt[4], tNd[4], prog), time));
- m_object->SetAngleZ(2+3*i+1, Smooth(m_object->RetAngleZ(2+3*i+1), Propf(tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(2+3*i+2, Smooth(m_object->RetAngleX(2+3*i+2), Propf(tSt[6], tNd[6], prog), time));
- m_object->SetAngleY(2+3*i+2, Smooth(m_object->RetAngleY(2+3*i+2), Propf(tSt[7], tNd[7], prog), time));
- m_object->SetAngleZ(2+3*i+2, Smooth(m_object->RetAngleZ(2+3*i+2), Propf(tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(2+3*i+0, Math::Smooth(m_object->RetAngleX(2+3*i+0), Math::PropAngle(tSt[0], tNd[0], prog), time));
+ m_object->SetAngleY(2+3*i+0, Math::Smooth(m_object->RetAngleY(2+3*i+0), Math::PropAngle(tSt[1], tNd[1], prog), time));
+ m_object->SetAngleZ(2+3*i+0, Math::Smooth(m_object->RetAngleZ(2+3*i+0), Math::PropAngle(tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(2+3*i+1, Math::Smooth(m_object->RetAngleX(2+3*i+1), Math::PropAngle(tSt[3], tNd[3], prog), time));
+ m_object->SetAngleY(2+3*i+1, Math::Smooth(m_object->RetAngleY(2+3*i+1), Math::PropAngle(tSt[4], tNd[4], prog), time));
+ m_object->SetAngleZ(2+3*i+1, Math::Smooth(m_object->RetAngleZ(2+3*i+1), Math::PropAngle(tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(2+3*i+2, Math::Smooth(m_object->RetAngleX(2+3*i+2), Math::PropAngle(tSt[6], tNd[6], prog), time));
+ m_object->SetAngleY(2+3*i+2, Math::Smooth(m_object->RetAngleY(2+3*i+2), Math::PropAngle(tSt[7], tNd[7], prog), time));
+ m_object->SetAngleZ(2+3*i+2, Math::Smooth(m_object->RetAngleZ(2+3*i+2), Math::PropAngle(tSt[8], tNd[8], prog), time));
}
else // left member (2..3) ?
{
- m_object->SetAngleX(2+3*i+0, Smooth(m_object->RetAngleX(2+3*i+0), Propf(-tSt[0], -tNd[0], prog), time));
- m_object->SetAngleY(2+3*i+0, Smooth(m_object->RetAngleY(2+3*i+0), Propf(-tSt[1], -tNd[1], prog), time));
- m_object->SetAngleZ(2+3*i+0, Smooth(m_object->RetAngleZ(2+3*i+0), Propf( tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(2+3*i+1, Smooth(m_object->RetAngleX(2+3*i+1), Propf(-tSt[3], -tNd[3], prog), time));
- m_object->SetAngleY(2+3*i+1, Smooth(m_object->RetAngleY(2+3*i+1), Propf(-tSt[4], -tNd[4], prog), time));
- m_object->SetAngleZ(2+3*i+1, Smooth(m_object->RetAngleZ(2+3*i+1), Propf( tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(2+3*i+2, Smooth(m_object->RetAngleX(2+3*i+2), Propf(-tSt[6], -tNd[6], prog), time));
- m_object->SetAngleY(2+3*i+2, Smooth(m_object->RetAngleY(2+3*i+2), Propf(-tSt[7], -tNd[7], prog), time));
- m_object->SetAngleZ(2+3*i+2, Smooth(m_object->RetAngleZ(2+3*i+2), Propf( tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(2+3*i+0, Math::Smooth(m_object->RetAngleX(2+3*i+0), Math::PropAngle(-tSt[0], -tNd[0], prog), time));
+ m_object->SetAngleY(2+3*i+0, Math::Smooth(m_object->RetAngleY(2+3*i+0), Math::PropAngle(-tSt[1], -tNd[1], prog), time));
+ m_object->SetAngleZ(2+3*i+0, Math::Smooth(m_object->RetAngleZ(2+3*i+0), Math::PropAngle( tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(2+3*i+1, Math::Smooth(m_object->RetAngleX(2+3*i+1), Math::PropAngle(-tSt[3], -tNd[3], prog), time));
+ m_object->SetAngleY(2+3*i+1, Math::Smooth(m_object->RetAngleY(2+3*i+1), Math::PropAngle(-tSt[4], -tNd[4], prog), time));
+ m_object->SetAngleZ(2+3*i+1, Math::Smooth(m_object->RetAngleZ(2+3*i+1), Math::PropAngle( tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(2+3*i+2, Math::Smooth(m_object->RetAngleX(2+3*i+2), Math::PropAngle(-tSt[6], -tNd[6], prog), time));
+ m_object->SetAngleY(2+3*i+2, Math::Smooth(m_object->RetAngleY(2+3*i+2), Math::PropAngle(-tSt[7], -tNd[7], prog), time));
+ m_object->SetAngleZ(2+3*i+2, Math::Smooth(m_object->RetAngleZ(2+3*i+2), Math::PropAngle( tSt[8], tNd[8], prog), time));
}
}
@@ -1219,29 +1207,29 @@ bool CMotionHuman::EventFrame(const Event &event)
a = 1.0f*sinf(m_object->RetAngleZ(11)+m_object->RetAngleZ(12)+m_object->RetAngleZ(13));
if ( a < 0.0f ) hl += a;
- hr = Min(hr, hl);
+ hr = Math::Min(hr, hl);
if ( m_actionType == MHS_FIRE ) // shooting?
{
time = event.rTime*m_actionTime;
- dir.x = (Rand()-0.5f)/8.0f;
- dir.z = (Rand()-0.5f)/8.0f;
+ dir.x = (Math::Rand()-0.5f)/8.0f;
+ dir.z = (Math::Rand()-0.5f)/8.0f;
dir.y = -0.5f; // slightly lower
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
-//? dir.y = Smooth(actual.y, dir.y, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
dir.x = 0.0f;
- dir.y = (Rand()-0.5f)/3.0f;
+ dir.y = (Math::Rand()-0.5f)/3.0f;
dir.z = -0.1f; // slightly leaning forward
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_TAKE || // carrying?
@@ -1253,19 +1241,19 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = 0.0f;
dir.y = -1.5f; // slightly lower
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
-//? dir.y = Smooth(actual.y, dir.y, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -0.2f;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_TAKEHIGH ) // carrying?
@@ -1276,19 +1264,19 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = 0.0f;
dir.y = 0.0f;
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
-//? dir.y = Smooth(actual.y, dir.y, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -0.2f;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_FLAG ) // flag?
@@ -1299,19 +1287,19 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = 0.0f;
dir.y = -2.0f; // slightly lower
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
-//? dir.y = Smooth(actual.y, dir.y, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -0.4f;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_DEADg ) // shooting death (falls)?
@@ -1331,11 +1319,11 @@ bool CMotionHuman::EventFrame(const Event &event)
for ( i=0 ; i<10 ; i++ )
{
pos = m_object->RetPosition(0);
- 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;
m_terrain->MoveOnFloor(pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = 1.2f+Rand()*1.2f;
+ dim.x = 1.2f+Math::Rand()*1.2f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f);
}
@@ -1350,18 +1338,18 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = 0.0f;
dir.y = -1.5f*prog;
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
dir.x = 0.0f;
dir.y = 0.0f;
- dir.z = -(20.0f*PI/180.0f)*prog;
+ dir.z = -(20.0f*Math::PI/180.0f)*prog;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_DEADg2 ) // shooting death (knees)?
@@ -1377,18 +1365,18 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = 0.0f;
dir.y = -1.5f;
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
dir.x = 0.0f;
dir.y = 0.0f;
- dir.z = -(20.0f*PI/180.0f);
+ dir.z = -(20.0f*Math::PI/180.0f);
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_DEADg3 ) // shooting death (face down)?
@@ -1401,11 +1389,11 @@ bool CMotionHuman::EventFrame(const Event &event)
for ( i=0 ; i<20 ; i++ )
{
pos = m_object->RetPosition(0);
- 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;
m_terrain->MoveOnFloor(pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = 2.0f+Rand()*1.5f;
+ dim.x = 2.0f+Math::Rand()*1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f);
}
@@ -1421,18 +1409,18 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.z = 0.0f;
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
- dir.z = -((20.0f*PI/180.0f)+(70.0f*PI/180.0f)*prog);
+ dir.z = -((20.0f*Math::PI/180.0f)+(70.0f*Math::PI/180.0f)*prog);
dir.x = 0.0f;
dir.y = 0.0f;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_DEADg4 ) // shooting death (face down)?
@@ -1448,18 +1436,18 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.z = 0.0f;
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetLinVibration(dir);
- dir.z = -((20.0f*PI/180.0f)+(70.0f*PI/180.0f));
+ dir.z = -((20.0f*Math::PI/180.0f)+(70.0f*Math::PI/180.0f));
dir.x = 0.0f;
dir.y = 0.0f;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
}
else if ( m_actionType == MHS_DEADw ) // drowned?
@@ -1491,13 +1479,13 @@ bool CMotionHuman::EventFrame(const Event &event)
time = 100.0f;
- dir.z = -(90.0f*PI/180.0f)*prog;
- dir.x = Rand()*0.3f*deadFactor;
- dir.y = Rand()*0.3f*deadFactor;
+ dir.z = -(90.0f*Math::PI/180.0f)*prog;
+ dir.x = Math::Rand()*0.3f*deadFactor;
+ dir.y = Math::Rand()*0.3f*deadFactor;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
m_object->SetInclinaison(dir);
m_object->SetCirVibration(D3DVECTOR(0.0f, 0.0f, 0.0f));
@@ -1513,8 +1501,8 @@ bool CMotionHuman::EventFrame(const Event &event)
m_object->SetInclinaison(dir);
SetInclinaison(dir);
-//? dir.x = -(sinf(time*0.05f+PI*1.5f)+1.0f)*100.0f;
- // original code: Min(time/30.0f) (?) changed to time/30.0f
+//? dir.x = -(sinf(time*0.05f+Math::PI*1.5f)+1.0f)*100.0f;
+ // original code: Math::Min(time/30.0f) (?) changed to time/30.0f
dir.x = -(powf(time/30.0f, 4.0f))*1000.0f; // from the distance
dir.y = 0.0f;
dir.z = 0.0f;
@@ -1523,14 +1511,14 @@ bool CMotionHuman::EventFrame(const Event &event)
mat = m_object->RetWorldMatrix(0);
pos = D3DVECTOR(0.5f, 3.7f, 0.0f);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.y += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.y += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*0.5f;
- speed.y = (Rand()-0.5f)*0.5f;
- speed.z = (Rand()-0.5f)*0.5f;
- dim.x = 0.5f+Rand()*0.5f;
+ speed.x = (Math::Rand()-0.5f)*0.5f;
+ speed.y = (Math::Rand()-0.5f)*0.5f;
+ speed.z = (Math::Rand()-0.5f)*0.5f;
+ dim.x = 0.5f+Math::Rand()*0.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTILENS1, 5.0f, 0.0f, 0.0f);
}
@@ -1549,14 +1537,14 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( action == MH_MARCH ) // walking?
{
- dir.x = sinf(Mod(rTime[0]+0.5f, 1.0f)*PI*2.0f)*0.10f;
- dir.y = sinf(Mod(rTime[0]+0.6f, 1.0f)*PI*2.0f)*0.20f;
+ dir.x = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.10f;
+ dir.y = sinf(Math::Mod(rTime[0]+0.6f, 1.0f)*Math::PI*2.0f)*0.20f;
s = m_physics->RetLinMotionX(MO_REASPEED)*0.03f;
}
else if ( action == MH_MARCHTAKE ) // takes walking?
{
- dir.x = sinf(Mod(rTime[0]+0.5f, 1.0f)*PI*2.0f)*0.10f;
- dir.y = sinf(Mod(rTime[0]+0.6f, 1.0f)*PI*2.0f)*0.15f;
+ dir.x = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.10f;
+ dir.y = sinf(Math::Mod(rTime[0]+0.6f, 1.0f)*Math::PI*2.0f)*0.15f;
s = m_physics->RetLinMotionX(MO_REASPEED)*0.02f;
}
else
@@ -1570,9 +1558,9 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = -s*0.7f;
actual = m_object->RetInclinaison();
- dir.x = Smooth(actual.x, dir.x, time);
- dir.y = Smooth(actual.y, dir.y, time);
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
+ dir.y = Math::Smooth(actual.y, dir.y, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
if ( bOnBoard ) dir *= 0.3f;
m_object->SetInclinaison(dir);
SetInclinaison(dir);
@@ -1580,20 +1568,20 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( action == MH_MARCH ) // walking?
{
p2.x = 0.0f;
- p2.y = sinf(Mod(rTime[0]+0.5f, 1.0f)*PI*2.0f)*0.5f;
- p2 = RotatePoint(-m_object->RetAngleY(0), p2);
+ p2.y = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.5f;
+ p2 = Math::RotatePoint(-m_object->RetAngleY(0), p2);
dir.x = p2.x;
dir.z = p2.y;
- dir.y = sinf(Mod(rTime[0]*2.0f, 1.0f)*PI*2.0f)*0.3f;
+ dir.y = sinf(Math::Mod(rTime[0]*2.0f, 1.0f)*Math::PI*2.0f)*0.3f;
}
else if ( action == MH_MARCHTAKE ) // takes walking?
{
p2.x = 0.0f;
- p2.y = sinf(Mod(rTime[0]+0.5f, 1.0f)*PI*2.0f)*0.25f;
- p2 = RotatePoint(-m_object->RetAngleY(0), p2);
+ p2.y = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.25f;
+ p2 = Math::RotatePoint(-m_object->RetAngleY(0), p2);
dir.x = p2.x;
dir.z = p2.y;
- dir.y = sinf(Mod(rTime[0]*2.0f, 1.0f)*PI*2.0f)*0.05f-0.3f;
+ dir.y = sinf(Math::Mod(rTime[0]*2.0f, 1.0f)*Math::PI*2.0f)*0.05f-0.3f;
}
else
{
@@ -1603,18 +1591,18 @@ bool CMotionHuman::EventFrame(const Event &event)
}
actual = m_object->RetLinVibration();
- dir.x = Smooth(actual.x, dir.x, time);
+ dir.x = Math::Smooth(actual.x, dir.x, time);
if ( action == MH_MARCHTAKE ) // takes walking?
{
dir.y = -hr;
}
else
{
- s = Min(m_armTimeAction, 1.0f);
- dir.y = Smooth(actual.y, dir.y, time)*s;
+ s = Math::Min(m_armTimeAction, 1.0f);
+ dir.y = Math::Smooth(actual.y, dir.y, time)*s;
dir.y += -hr*(1.0f-s);
}
- dir.z = Smooth(actual.z, dir.z, time);
+ dir.z = Math::Smooth(actual.z, dir.z, time);
if ( bOnBoard ) dir *= 0.3f;
m_object->SetLinVibration(dir);
@@ -1629,16 +1617,16 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( m_actionType == MHS_TAKE || // takes?
m_actionType == MHS_FLAG ) // takes?
{
- m_object->SetAngleZ(1, Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.6f, event.rTime*5.0f));
+ m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.6f, event.rTime*5.0f));
m_object->SetAngleX(1, sinf(m_armTimeAbs*1.1f)*0.1f);
- m_object->SetAngleY(1, Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
+ m_object->SetAngleY(1, Math::Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
}
else if ( m_actionType == MHS_TAKEOTHER || // takes?
m_actionType == MHS_TAKEHIGH ) // takes?
{
- m_object->SetAngleZ(1, Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.3f, event.rTime*5.0f));
+ m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.3f, event.rTime*5.0f));
m_object->SetAngleX(1, sinf(m_armTimeAbs*1.1f)*0.1f);
- m_object->SetAngleY(1, Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
+ m_object->SetAngleY(1, Math::Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
}
else if ( m_actionType == MHS_WIN ) // win
{
@@ -1659,9 +1647,9 @@ bool CMotionHuman::EventFrame(const Event &event)
}
else
{
- m_object->SetAngleZ(1, Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f, event.rTime*5.0f));
+ m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f, event.rTime*5.0f));
m_object->SetAngleX(1, sinf(m_armTimeAbs*1.1f)*0.1f);
- m_object->SetAngleY(1, Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
+ m_object->SetAngleY(1, Math::Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
}
if ( bOnBoard )
@@ -1692,8 +1680,8 @@ bool CMotionHuman::EventFrame(const Event &event)
}
time = rTime[1]+synchro;
- if ( Abs(m_lastSoundMarch-time) > 0.4f &&
- Mod(time, 0.5f) < 0.1f )
+ if ( fabs(m_lastSoundMarch-time) > 0.4f &&
+ Math::Mod(time, 0.5f) < 0.1f )
{
volume[0] = 0.5f;
freq[0] = 1.0f;
@@ -1761,8 +1749,8 @@ bool CMotionHuman::EventFrame(const Event &event)
{
time = rTime[0]+0.5f;
- if ( Abs(m_lastSoundMarch-time) > 0.9f &&
- Mod(time, 1.0f) < 0.1f )
+ if ( fabs(m_lastSoundMarch-time) > 0.9f &&
+ Math::Mod(time, 1.0f) < 0.1f )
{
m_sound->Play(SOUND_SWIM, m_object->RetPosition(0), 0.5f);
m_lastSoundMarch = time;
@@ -1775,7 +1763,7 @@ bool CMotionHuman::EventFrame(const Event &event)
m_object->RetOption() == 0 ) // helmet?
{
m_sound->Play(SOUND_HUMAN1, m_object->RetPosition(0), (0.5f+m_tired*0.2f));
- m_lastSoundHhh = (4.0f-m_tired*2.5f)+(4.0f-m_tired*2.5f)*Rand();
+ m_lastSoundHhh = (4.0f-m_tired*2.5f)+(4.0f-m_tired*2.5f)*Math::Rand();
}
return true;
diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp
index cd5fb7c..7f98eca 100644
--- a/src/object/motion/motionmother.cpp
+++ b/src/object/motion/motionmother.cpp
@@ -16,14 +16,13 @@
// motionmother.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/func.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -180,7 +179,7 @@ bool CMotionMother::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\mother3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(8, D3DVECTOR(-5.0f, -1.0f, 12.0f));
- m_object->SetAngleY(8, PI);
+ m_object->SetAngleY(8, Math::PI);
// Creates a left-back foot.
rank = m_engine->CreateObject();
@@ -199,7 +198,7 @@ bool CMotionMother::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\mother3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(10, D3DVECTOR(3.5f, -1.0f, 12.0f));
- m_object->SetAngleY(10, PI);
+ m_object->SetAngleY(10, Math::PI);
// Creates a middle-left foot.
rank = m_engine->CreateObject();
@@ -218,7 +217,7 @@ bool CMotionMother::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\mother3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(12, D3DVECTOR(10.0f, -1.0f, 10.0f));
- m_object->SetAngleY(12, PI);
+ m_object->SetAngleY(12, Math::PI);
// Creates a left-front foot.
rank = m_engine->CreateObject();
@@ -341,8 +340,8 @@ void CMotionMother::CreatePhysics()
m_physics->SetLinMotionZ(MO_TERFORCE, 20.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.1f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.1f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.1f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.1f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 10.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 10.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 20.0f);
@@ -411,7 +410,7 @@ bool CMotionMother::EventFrame(const Event &event)
if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = Abs(m_physics->RetCirMotionY(MO_MOTSPEED)*26.0f);
+ a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*26.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -423,16 +422,16 @@ bool CMotionMother::EventFrame(const Event &event)
if ( bStop )
{
- prog = Mod(m_armTimeAbs, 2.0f)/10.0f;
- a = Mod(m_armMember, 1.0f);
+ prog = Math::Mod(m_armTimeAbs, 2.0f)/10.0f;
+ a = Math::Mod(m_armMember, 1.0f);
a = (prog-a)*event.rTime*1.0f; // stop position just pleasantly
m_armMember += a;
}
for ( i=0 ; i<6 ; i++ ) // the six legs
{
- if ( i < 3 ) prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
- else prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
+ if ( i < 3 ) prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
+ else prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
if ( m_bArmStop )
{
prog = (float)m_armTimeIndex/3.0f;
@@ -459,21 +458,21 @@ bool CMotionMother::EventFrame(const Event &event)
nd = nd*27+(i%3)*3;
if ( i < 3 ) // right leg (1..3) ?
{
- m_object->SetAngleX(2+2*i+0, Prop(m_armAngles[st+ 0], m_armAngles[nd+ 0], prog));
- m_object->SetAngleY(2+2*i+0, Prop(m_armAngles[st+ 1], m_armAngles[nd+ 1], prog));
- m_object->SetAngleZ(2+2*i+0, Prop(m_armAngles[st+ 2], m_armAngles[nd+ 2], prog));
- m_object->SetAngleX(2+2*i+1, Prop(m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
- m_object->SetAngleY(2+2*i+1, Prop(m_armAngles[st+10], m_armAngles[nd+10], prog));
- m_object->SetAngleZ(2+2*i+1, Prop(m_armAngles[st+11], m_armAngles[nd+11], prog));
+ m_object->SetAngleX(2+2*i+0, Math::PropAngle(m_armAngles[st+ 0], m_armAngles[nd+ 0], prog));
+ m_object->SetAngleY(2+2*i+0, Math::PropAngle(m_armAngles[st+ 1], m_armAngles[nd+ 1], prog));
+ m_object->SetAngleZ(2+2*i+0, Math::PropAngle(m_armAngles[st+ 2], m_armAngles[nd+ 2], prog));
+ m_object->SetAngleX(2+2*i+1, Math::PropAngle(m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
+ m_object->SetAngleY(2+2*i+1, Math::PropAngle(m_armAngles[st+10], m_armAngles[nd+10], prog));
+ m_object->SetAngleZ(2+2*i+1, Math::PropAngle(m_armAngles[st+11], m_armAngles[nd+11], prog));
}
else // left leg (4..6) ?
{
- m_object->SetAngleX(2+2*i+0, Prop( m_armAngles[st+ 0], m_armAngles[nd+ 0], prog));
- m_object->SetAngleY(2+2*i+0, Prop(180-m_armAngles[st+ 1], 180-m_armAngles[nd+ 1], prog));
- m_object->SetAngleZ(2+2*i+0, Prop( -m_armAngles[st+ 2], -m_armAngles[nd+ 2], prog));
- m_object->SetAngleX(2+2*i+1, Prop( m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
- m_object->SetAngleY(2+2*i+1, Prop( -m_armAngles[st+10], -m_armAngles[nd+10], prog));
- m_object->SetAngleZ(2+2*i+1, Prop( -m_armAngles[st+11], -m_armAngles[nd+11], prog));
+ m_object->SetAngleX(2+2*i+0, Math::PropAngle( m_armAngles[st+ 0], m_armAngles[nd+ 0], prog));
+ m_object->SetAngleY(2+2*i+0, Math::PropAngle(180-m_armAngles[st+ 1], 180-m_armAngles[nd+ 1], prog));
+ m_object->SetAngleZ(2+2*i+0, Math::PropAngle( -m_armAngles[st+ 2], -m_armAngles[nd+ 2], prog));
+ m_object->SetAngleX(2+2*i+1, Math::PropAngle( m_armAngles[st+ 9], m_armAngles[nd+ 9], prog));
+ m_object->SetAngleY(2+2*i+1, Math::PropAngle( -m_armAngles[st+10], -m_armAngles[nd+10], prog));
+ m_object->SetAngleZ(2+2*i+1, Math::PropAngle( -m_armAngles[st+11], -m_armAngles[nd+11], prog));
}
}
@@ -488,12 +487,12 @@ bool CMotionMother::EventFrame(const Event &event)
if ( !bStop && !m_object->RetRuin() )
{
- a = Mod(m_armTimeMarch, 1.0f);
+ a = Math::Mod(m_armTimeMarch, 1.0f);
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
else a = 3.0f-4.0f*a; // 1..-1
dir.x = sinf(a)*0.03f;
- s = Mod(m_armTimeMarch/2.0f, 1.0f);
+ s = Math::Mod(m_armTimeMarch/2.0f, 1.0f);
if ( s < 0.5f ) s = -1.0f+4.0f*s; // -1..1
else s = 3.0f-4.0f*s; // 1..-1
dir.z = sinf(s)*0.05f;
@@ -501,7 +500,7 @@ bool CMotionMother::EventFrame(const Event &event)
dir.y = 0.0f;
m_object->SetInclinaison(dir);
- a = Mod(m_armMember-0.1f, 1.0f);
+ a = Math::Mod(m_armMember-0.1f, 1.0f);
if ( a < 0.33f )
{
dir.y = -(1.0f-(a/0.33f))*0.3f;
diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp
index 08eb546..4ac799b 100644
--- a/src/object/motion/motionspider.cpp
+++ b/src/object/motion/motionspider.cpp
@@ -16,14 +16,13 @@
// motionspider.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/func.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -320,8 +319,8 @@ void CMotionSpider::CreatePhysics()
m_physics->SetLinMotionZ(MO_TERFORCE, 5.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 10.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 1.0f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 1.0f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 1.0f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 1.0f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 20.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 20.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 40.0f);
@@ -386,24 +385,12 @@ bool CMotionSpider::EventProcess(const Event &event)
return true;
}
-// Calculates a value (radians) proportional between a and b (degrees).
-
-inline float Propf(float a, float b, float p)
-{
- float aa, bb;
-
- aa = a*PI/180.0f;
- bb = b*PI/180.0f;
-
- return aa+p*(bb-aa);
-}
-
// Management of an event.
bool CMotionSpider::EventFrame(const Event &event)
{
D3DVECTOR dir, pos, speed;
- FPOINT dim;
+ Math::Point dim;
float s, a, prog, time;
float tSt[12], tNd[12];
int i, ii, st, nd, action;
@@ -413,7 +400,7 @@ bool CMotionSpider::EventFrame(const Event &event)
if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = Abs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
+ a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -432,8 +419,8 @@ bool CMotionSpider::EventFrame(const Event &event)
if ( bStop )
{
- prog = Mod(m_armTimeAbs, 2.0f)/10.0f;
- a = Mod(m_armMember, 1.0f);
+ prog = Math::Mod(m_armTimeAbs, 2.0f)/10.0f;
+ a = Math::Mod(m_armMember, 1.0f);
a = (prog-a)*event.rTime*2.0f; // stop position just pleasantly
m_armMember += a;
}
@@ -465,10 +452,10 @@ bool CMotionSpider::EventFrame(const Event &event)
}
else
{
-//? if ( i < 4 ) prog = Mod(m_armMember+(2.0f-(i%4))*0.25f+0.0f, 1.0f);
-//? else prog = Mod(m_armMember+(2.0f-(i%4))*0.25f+0.3f, 1.0f);
- if ( i < 4 ) prog = Mod(m_armMember+(2.0f-(i%4))*0.25f+0.0f, 1.0f);
- else prog = Mod(m_armMember+(2.0f-(i%4))*0.25f+0.5f, 1.0f);
+//? if ( i < 4 ) prog = Math::Mod(m_armMember+(2.0f-(i%4))*0.25f+0.0f, 1.0f);
+//? else prog = Math::Mod(m_armMember+(2.0f-(i%4))*0.25f+0.3f, 1.0f);
+ if ( i < 4 ) prog = Math::Mod(m_armMember+(2.0f-(i%4))*0.25f+0.0f, 1.0f);
+ else prog = Math::Mod(m_armMember+(2.0f-(i%4))*0.25f+0.5f, 1.0f);
if ( m_bArmStop )
{
prog = (float)m_armTimeIndex/3.0f;
@@ -496,7 +483,7 @@ bool CMotionSpider::EventFrame(const Event &event)
nd = 3*4*4*3*action + nd*3*4*4 + (i%4)*3;
// Less and less soft ...
-//? time = event.rTime*(2.0f+Min(m_armTimeAction*20.0f, 40.0f));
+//? time = event.rTime*(2.0f+Math::Min(m_armTimeAction*20.0f, 40.0f));
time = event.rTime*10.0f;
}
@@ -530,7 +517,7 @@ bool CMotionSpider::EventFrame(const Event &event)
{
for ( ii=0 ; ii<12 ; ii++ )
{
- tSt[ii] += Rand()*20.0f;
+ tSt[ii] += Math::Rand()*20.0f;
tNd[ii] = tSt[ii];
}
//? time = 100.0f;
@@ -539,33 +526,33 @@ bool CMotionSpider::EventFrame(const Event &event)
if ( i < 4 ) // right leg (1..4) ?
{
- m_object->SetAngleX(3+4*i+0, Smooth(m_object->RetAngleX(3+4*i+0), Propf(tSt[ 0], tNd[ 0], prog), time));
- m_object->SetAngleY(3+4*i+0, Smooth(m_object->RetAngleY(3+4*i+0), Propf(tSt[ 1], tNd[ 1], prog), time));
- m_object->SetAngleZ(3+4*i+0, Smooth(m_object->RetAngleZ(3+4*i+0), Propf(tSt[ 2], tNd[ 2], prog), time));
- m_object->SetAngleX(3+4*i+1, Smooth(m_object->RetAngleX(3+4*i+1), Propf(tSt[ 3], tNd[ 3], prog), time));
- m_object->SetAngleY(3+4*i+1, Smooth(m_object->RetAngleY(3+4*i+1), Propf(tSt[ 4], tNd[ 4], prog), time));
- m_object->SetAngleZ(3+4*i+1, Smooth(m_object->RetAngleZ(3+4*i+1), Propf(tSt[ 5], tNd[ 5], prog), time));
- m_object->SetAngleX(3+4*i+2, Smooth(m_object->RetAngleX(3+4*i+2), Propf(tSt[ 6], tNd[ 6], prog), time));
- m_object->SetAngleY(3+4*i+2, Smooth(m_object->RetAngleY(3+4*i+2), Propf(tSt[ 7], tNd[ 7], prog), time));
- m_object->SetAngleZ(3+4*i+2, Smooth(m_object->RetAngleZ(3+4*i+2), Propf(tSt[ 8], tNd[ 8], prog), time));
- m_object->SetAngleX(3+4*i+3, Smooth(m_object->RetAngleX(3+4*i+3), Propf(tSt[ 9], tNd[ 9], prog), time));
- m_object->SetAngleY(3+4*i+3, Smooth(m_object->RetAngleY(3+4*i+3), Propf(tSt[10], tNd[10], prog), time));
- m_object->SetAngleZ(3+4*i+3, Smooth(m_object->RetAngleZ(3+4*i+3), Propf(tSt[11], tNd[11], prog), time));
+ m_object->SetAngleX(3+4*i+0, Math::Smooth(m_object->RetAngleX(3+4*i+0), Math::PropAngle(tSt[ 0], tNd[ 0], prog), time));
+ m_object->SetAngleY(3+4*i+0, Math::Smooth(m_object->RetAngleY(3+4*i+0), Math::PropAngle(tSt[ 1], tNd[ 1], prog), time));
+ m_object->SetAngleZ(3+4*i+0, Math::Smooth(m_object->RetAngleZ(3+4*i+0), Math::PropAngle(tSt[ 2], tNd[ 2], prog), time));
+ m_object->SetAngleX(3+4*i+1, Math::Smooth(m_object->RetAngleX(3+4*i+1), Math::PropAngle(tSt[ 3], tNd[ 3], prog), time));
+ m_object->SetAngleY(3+4*i+1, Math::Smooth(m_object->RetAngleY(3+4*i+1), Math::PropAngle(tSt[ 4], tNd[ 4], prog), time));
+ m_object->SetAngleZ(3+4*i+1, Math::Smooth(m_object->RetAngleZ(3+4*i+1), Math::PropAngle(tSt[ 5], tNd[ 5], prog), time));
+ m_object->SetAngleX(3+4*i+2, Math::Smooth(m_object->RetAngleX(3+4*i+2), Math::PropAngle(tSt[ 6], tNd[ 6], prog), time));
+ m_object->SetAngleY(3+4*i+2, Math::Smooth(m_object->RetAngleY(3+4*i+2), Math::PropAngle(tSt[ 7], tNd[ 7], prog), time));
+ m_object->SetAngleZ(3+4*i+2, Math::Smooth(m_object->RetAngleZ(3+4*i+2), Math::PropAngle(tSt[ 8], tNd[ 8], prog), time));
+ m_object->SetAngleX(3+4*i+3, Math::Smooth(m_object->RetAngleX(3+4*i+3), Math::PropAngle(tSt[ 9], tNd[ 9], prog), time));
+ m_object->SetAngleY(3+4*i+3, Math::Smooth(m_object->RetAngleY(3+4*i+3), Math::PropAngle(tSt[10], tNd[10], prog), time));
+ m_object->SetAngleZ(3+4*i+3, Math::Smooth(m_object->RetAngleZ(3+4*i+3), Math::PropAngle(tSt[11], tNd[11], prog), time));
}
else // left leg (5..8) ?
{
- m_object->SetAngleX(3+4*i+0, Smooth(m_object->RetAngleX(3+4*i+0), Propf(-tSt[ 0], -tNd[ 0], prog), time));
- m_object->SetAngleY(3+4*i+0, Smooth(m_object->RetAngleY(3+4*i+0), Propf(-tSt[ 1], -tNd[ 1], prog), time));
- m_object->SetAngleZ(3+4*i+0, Smooth(m_object->RetAngleZ(3+4*i+0), Propf( tSt[ 2], tNd[ 2], prog), time));
- m_object->SetAngleX(3+4*i+1, Smooth(m_object->RetAngleX(3+4*i+1), Propf(-tSt[ 3], -tNd[ 3], prog), time));
- m_object->SetAngleY(3+4*i+1, Smooth(m_object->RetAngleY(3+4*i+1), Propf(-tSt[ 4], -tNd[ 4], prog), time));
- m_object->SetAngleZ(3+4*i+1, Smooth(m_object->RetAngleZ(3+4*i+1), Propf( tSt[ 5], tNd[ 5], prog), time));
- m_object->SetAngleX(3+4*i+2, Smooth(m_object->RetAngleX(3+4*i+2), Propf(-tSt[ 6], -tNd[ 6], prog), time));
- m_object->SetAngleY(3+4*i+2, Smooth(m_object->RetAngleY(3+4*i+2), Propf(-tSt[ 7], -tNd[ 7], prog), time));
- m_object->SetAngleZ(3+4*i+2, Smooth(m_object->RetAngleZ(3+4*i+2), Propf( tSt[ 8], tNd[ 8], prog), time));
- m_object->SetAngleX(3+4*i+3, Smooth(m_object->RetAngleX(3+4*i+3), Propf(-tSt[ 9], -tNd[ 9], prog), time));
- m_object->SetAngleY(3+4*i+3, Smooth(m_object->RetAngleY(3+4*i+3), Propf(-tSt[10], -tNd[10], prog), time));
- m_object->SetAngleZ(3+4*i+3, Smooth(m_object->RetAngleZ(3+4*i+3), Propf( tSt[11], tNd[11], prog), time));
+ m_object->SetAngleX(3+4*i+0, Math::Smooth(m_object->RetAngleX(3+4*i+0), Math::PropAngle(-tSt[ 0], -tNd[ 0], prog), time));
+ m_object->SetAngleY(3+4*i+0, Math::Smooth(m_object->RetAngleY(3+4*i+0), Math::PropAngle(-tSt[ 1], -tNd[ 1], prog), time));
+ m_object->SetAngleZ(3+4*i+0, Math::Smooth(m_object->RetAngleZ(3+4*i+0), Math::PropAngle( tSt[ 2], tNd[ 2], prog), time));
+ m_object->SetAngleX(3+4*i+1, Math::Smooth(m_object->RetAngleX(3+4*i+1), Math::PropAngle(-tSt[ 3], -tNd[ 3], prog), time));
+ m_object->SetAngleY(3+4*i+1, Math::Smooth(m_object->RetAngleY(3+4*i+1), Math::PropAngle(-tSt[ 4], -tNd[ 4], prog), time));
+ m_object->SetAngleZ(3+4*i+1, Math::Smooth(m_object->RetAngleZ(3+4*i+1), Math::PropAngle( tSt[ 5], tNd[ 5], prog), time));
+ m_object->SetAngleX(3+4*i+2, Math::Smooth(m_object->RetAngleX(3+4*i+2), Math::PropAngle(-tSt[ 6], -tNd[ 6], prog), time));
+ m_object->SetAngleY(3+4*i+2, Math::Smooth(m_object->RetAngleY(3+4*i+2), Math::PropAngle(-tSt[ 7], -tNd[ 7], prog), time));
+ m_object->SetAngleZ(3+4*i+2, Math::Smooth(m_object->RetAngleZ(3+4*i+2), Math::PropAngle( tSt[ 8], tNd[ 8], prog), time));
+ m_object->SetAngleX(3+4*i+3, Math::Smooth(m_object->RetAngleX(3+4*i+3), Math::PropAngle(-tSt[ 9], -tNd[ 9], prog), time));
+ m_object->SetAngleY(3+4*i+3, Math::Smooth(m_object->RetAngleY(3+4*i+3), Math::PropAngle(-tSt[10], -tNd[10], prog), time));
+ m_object->SetAngleZ(3+4*i+3, Math::Smooth(m_object->RetAngleZ(3+4*i+3), Math::PropAngle( tSt[11], tNd[11], prog), time));
}
}
@@ -580,14 +567,14 @@ bool CMotionSpider::EventFrame(const Event &event)
if ( m_actionType == MSS_BURN ) // burning?
{
- dir = D3DVECTOR(PI, 0.0f, 0.0f);
+ dir = D3DVECTOR(Math::PI, 0.0f, 0.0f);
SetCirVibration(dir);
dir = D3DVECTOR(0.0f, 0.0f, 0.0f);
SetLinVibration(dir);
SetInclinaison(dir);
time = event.rTime*1.0f;
- m_object->SetAngleZ(1, Smooth(m_object->RetAngleZ(1), 0.0f, time)); // head
+ m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), 0.0f, time)); // head
}
else if ( m_actionType == MSS_RUIN ) // destroyed?
{
@@ -602,9 +589,9 @@ bool CMotionSpider::EventFrame(const Event &event)
m_object->SetZoomZ(1, 1.0f+m_progress);
m_object->SetZoomX(1, 1.0f+m_progress/2.0f);
- dir.x = (Rand()-0.5f)*0.1f*m_progress;
- dir.y = (Rand()-0.5f)*0.1f*m_progress;
- dir.z = (Rand()-0.5f)*0.1f*m_progress;
+ dir.x = (Math::Rand()-0.5f)*0.1f*m_progress;
+ dir.y = (Math::Rand()-0.5f)*0.1f*m_progress;
+ dir.z = (Math::Rand()-0.5f)*0.1f*m_progress;
m_object->SetCirVibration(dir);
}
else if ( m_actionType == MSS_BACK1 ) // turns on the back?
@@ -614,10 +601,10 @@ bool CMotionSpider::EventFrame(const Event &event)
m_lastParticule = m_armTimeAbs;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*5.0f;
- dim.x = Rand()*3.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*5.0f;
+ dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -636,7 +623,7 @@ bool CMotionSpider::EventFrame(const Event &event)
dir.z = 0.0f;
SetLinVibration(dir);
}
- dir.x = m_progress*PI;
+ dir.x = m_progress*Math::PI;
dir.y = 0.0f;
dir.z = 0.0f;
SetCirVibration(dir);
@@ -646,7 +633,7 @@ bool CMotionSpider::EventFrame(const Event &event)
if ( m_progress >= 1.0f )
{
- SetAction(MSS_BACK2, 55.0f+Rand()*10.0f);
+ SetAction(MSS_BACK2, 55.0f+Math::Rand()*10.0f);
}
}
else if ( m_actionType == MSS_BACK2 ) // moves on the back?
@@ -658,13 +645,13 @@ bool CMotionSpider::EventFrame(const Event &event)
if ( rand()%10 == 0 )
{
pos = m_object->RetPosition(0);
- 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 -= 1.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = Rand()*2.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 = Math::Rand()*2.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -675,7 +662,7 @@ bool CMotionSpider::EventFrame(const Event &event)
dir.x = sinf(m_armTimeAbs* 3.0f)*0.20f+
sinf(m_armTimeAbs* 6.0f)*0.20f+
sinf(m_armTimeAbs*10.0f)*0.20f+
- sinf(m_armTimeAbs*17.0f)*0.30f+PI;
+ sinf(m_armTimeAbs*17.0f)*0.30f+Math::PI;
dir.y = sinf(m_armTimeAbs* 4.0f)*0.02f+
sinf(m_armTimeAbs* 5.0f)*0.02f+
sinf(m_armTimeAbs*11.0f)*0.02f+
@@ -705,10 +692,10 @@ bool CMotionSpider::EventFrame(const Event &event)
m_lastParticule = m_armTimeAbs;
pos = m_object->RetPosition(0);
- speed.x = (Rand()-0.5f)*10.0f;
- speed.z = (Rand()-0.5f)*10.0f;
- speed.y = Rand()*5.0f;
- dim.x = Rand()*3.0f+2.0f;
+ speed.x = (Math::Rand()-0.5f)*10.0f;
+ speed.z = (Math::Rand()-0.5f)*10.0f;
+ speed.y = Math::Rand()*5.0f;
+ dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -727,7 +714,7 @@ bool CMotionSpider::EventFrame(const Event &event)
dir.z = 0.0f;
SetLinVibration(dir);
}
- dir.x = (1.0f-m_progress)*PI;
+ dir.x = (1.0f-m_progress)*Math::PI;
dir.y = 0.0f;
dir.z = 0.0f;
SetCirVibration(dir);
@@ -750,12 +737,12 @@ bool CMotionSpider::EventFrame(const Event &event)
}
else
{
- a = Mod(m_armMember, 1.0f);
+ a = Math::Mod(m_armMember, 1.0f);
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
else a = 3.0f-4.0f*a; // 1..-1
dir.x = sinf(a)*0.05f;
- s = Mod(m_armMember/2.0f, 1.0f);
+ s = Math::Mod(m_armMember/2.0f, 1.0f);
if ( s < 0.5f ) s = -1.0f+4.0f*s; // -1..1
else s = 3.0f-4.0f*s; // 1..-1
dir.z = sinf(s)*0.1f;
diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp
index 317d2ab..95caf3d 100644
--- a/src/object/motion/motiontoto.cpp
+++ b/src/object/motion/motiontoto.cpp
@@ -16,14 +16,13 @@
// motiontoto.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -66,7 +65,7 @@ CMotionToto::CMotionToto(CInstanceManager* iMan, CObject* object)
m_blinkProgress = -1.0f;
m_lastMotorParticule = 0.0f;
m_type = OBJECT_NULL;
- m_mousePos = FPOINT(0.0f, 0.0f);
+ m_mousePos = Math::Point(0.0f, 0.0f);
}
// Object's destructor.
@@ -129,7 +128,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(2, D3DVECTOR(0.85f, 1.04f, 0.25f));
- m_object->SetAngleY(2, -20.0f*PI/180.0f);
+ m_object->SetAngleY(2, -20.0f*Math::PI/180.0f);
// Creates the right eye.
rank = m_engine->CreateObject();
@@ -139,7 +138,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\toto3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(3, D3DVECTOR(0.85f, 1.04f, -0.25f));
- m_object->SetAngleY(3, 20.0f*PI/180.0f);
+ m_object->SetAngleY(3, 20.0f*Math::PI/180.0f);
// Creates left antenna.
rank = m_engine->CreateObject();
@@ -149,7 +148,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\toto4.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(4, D3DVECTOR(0.0f, 1.9f, 0.3f));
- m_object->SetAngleX(4, 30.0f*PI/180.0f);
+ m_object->SetAngleX(4, 30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -158,7 +157,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\toto4.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(5, D3DVECTOR(0.0f, 0.67f, 0.0f));
- m_object->SetAngleX(5, 30.0f*PI/180.0f);
+ m_object->SetAngleX(5, 30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -167,7 +166,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\toto5.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(6, D3DVECTOR(0.0f, 0.70f, 0.0f));
- m_object->SetAngleX(6, 30.0f*PI/180.0f);
+ m_object->SetAngleX(6, 30.0f*Math::PI/180.0f);
// Creates right antenna.
rank = m_engine->CreateObject();
@@ -177,7 +176,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\toto4.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(7, D3DVECTOR(0.0f, 1.9f, -0.3f));
- m_object->SetAngleX(7, -30.0f*PI/180.0f);
+ m_object->SetAngleX(7, -30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -186,7 +185,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\toto4.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(8, D3DVECTOR(0.0f, 0.67f, 0.0f));
- m_object->SetAngleX(8, -30.0f*PI/180.0f);
+ m_object->SetAngleX(8, -30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -195,7 +194,7 @@ bool CMotionToto::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\toto5.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(9, D3DVECTOR(0.0f, 0.70f, 0.0f));
- m_object->SetAngleX(9, -30.0f*PI/180.0f);
+ m_object->SetAngleX(9, -30.0f*Math::PI/180.0f);
m_object->SetZoom(0, 0.5f); // is little
m_object->SetFloorHeight(0.0f);
@@ -223,7 +222,7 @@ return;
m_progress = 0.0f;
m_object->SetAngleY(0, 0.0f);
- m_mousePos = FPOINT(0.5f, 0.5f);
+ m_mousePos = Math::Point(0.5f, 0.5f);
}
// End of the display of informations.
@@ -236,7 +235,7 @@ void CMotionToto::StopDisplayInfo()
// Gives the position of the mouse.
-void CMotionToto::SetMousePos(FPOINT pos)
+void CMotionToto::SetMousePos(Math::Point pos)
{
m_mousePos = pos;
}
@@ -263,7 +262,7 @@ bool CMotionToto::EventFrame(const Event &event)
D3DMATRIX* mat;
D3DVECTOR eye, lookat, dir, perp, nPos, aPos, pos, speed;
D3DVECTOR vibLin, vibCir, dirSpeed, aAntenna;
- FPOINT dim;
+ Math::Point dim;
POINT wDim;
ParticuleType type;
float progress, focus, distance, shift, verti, level, zoom;
@@ -341,7 +340,7 @@ bool CMotionToto::EventFrame(const Event &event)
vibLin = D3DVECTOR(0.0f, 0.0f, 0.0f);
vibCir = D3DVECTOR(0.0f, 0.0f, 0.0f);
aAntenna = D3DVECTOR(0.0f, 0.0f, 0.0f);
- aAntenna.x += 30.0f*PI/180.0f;
+ aAntenna.x += 30.0f*Math::PI/180.0f;
// Calculates the new position.
if ( m_bDisplayInfo )
@@ -400,14 +399,14 @@ bool CMotionToto::EventFrame(const Event &event)
{
if ( rand()%10 < 2 )
{
- m_clownRadius = 2.0f+Rand()*10.0f;
-//? m_clownDelay = m_clownRadius/(2.0f+Rand()*2.0f);
- m_clownDelay = 1.5f+Rand()*1.0f;
+ m_clownRadius = 2.0f+Math::Rand()*10.0f;
+//? m_clownDelay = m_clownRadius/(2.0f+Math::Rand()*2.0f);
+ m_clownDelay = 1.5f+Math::Rand()*1.0f;
}
else
{
m_clownRadius = 0.0f;
- m_clownDelay = 2.0f+Rand()*2.0f;
+ m_clownDelay = 2.0f+Math::Rand()*2.0f;
}
pos = m_object->RetPosition(0);
if ( pos.y < m_water->RetLevel() ) // underwater?
@@ -419,8 +418,8 @@ bool CMotionToto::EventFrame(const Event &event)
}
else
{
- distance -= m_clownRadius*sinf(m_clownTime*PI*2.0f/m_clownDelay);
- shift -= m_clownRadius-m_clownRadius*cosf(m_clownTime*PI*2.0f/m_clownDelay);
+ distance -= m_clownRadius*sinf(m_clownTime*Math::PI*2.0f/m_clownDelay);
+ shift -= m_clownRadius-m_clownRadius*cosf(m_clownTime*Math::PI*2.0f/m_clownDelay);
}
verti += (18.0f-shift)*0.2f;
@@ -472,26 +471,26 @@ bool CMotionToto::EventFrame(const Event &event)
}
// Calculate the new angle.
- nAngle = NormAngle(RotateAngle(eye.x-lookat.x, lookat.z-eye.z)-0.9f);
+ nAngle = Math::NormAngle(Math::RotateAngle(eye.x-lookat.x, lookat.z-eye.z)-0.9f);
if ( linSpeed == 0.0f || m_actionType != -1 )
{
mAngle = nAngle;
}
else
{
- mAngle = NormAngle(RotateAngle(dirSpeed.x, -dirSpeed.z));
+ mAngle = Math::NormAngle(Math::RotateAngle(dirSpeed.x, -dirSpeed.z));
}
- level = Min(linSpeed*0.1f, 1.0f);
+ level = Math::Min(linSpeed*0.1f, 1.0f);
nAngle = nAngle*(1.0f-level) + mAngle*level;
- aAngle = NormAngle(m_object->RetAngleY(0));
+ aAngle = Math::NormAngle(m_object->RetAngleY(0));
if ( nAngle < aAngle )
{
- if ( nAngle+PI*2.0f-aAngle < aAngle-nAngle ) nAngle += PI*2.0f;
+ if ( nAngle+Math::PI*2.0f-aAngle < aAngle-nAngle ) nAngle += Math::PI*2.0f;
}
else
{
- if ( aAngle+PI*2.0f-nAngle < nAngle-aAngle ) aAngle += PI*2.0f;
+ if ( aAngle+Math::PI*2.0f-nAngle < nAngle-aAngle ) aAngle += Math::PI*2.0f;
}
nAngle = aAngle + (nAngle-aAngle)*event.rTime*4.0f;
@@ -501,7 +500,7 @@ bool CMotionToto::EventFrame(const Event &event)
if ( angle > 0.7f ) angle = 0.7f;
if ( angle < -0.7f ) angle = -0.7f;
vibCir.x += angle*1.5f;
- aAntenna.x += Abs(angle)*0.8f; // deviates
+ aAntenna.x += fabs(angle)*0.8f; // deviates
// Leans forward so quickly advance.
angle = linSpeed*0.10f*(1.0f-progress);
@@ -514,23 +513,23 @@ bool CMotionToto::EventFrame(const Event &event)
vibLin.y += (sinf(m_time*2.00f)*0.5f+
sinf(m_time*2.11f)*0.2f)*(1.0f-progress);
- vibCir.z += sinf(m_time*PI* 2.01f)*(PI/ 75.0f)+
- sinf(m_time*PI* 2.51f)*(PI/100.0f)+
- sinf(m_time*PI*19.01f)*(PI/200.0f);
+ vibCir.z += sinf(m_time*Math::PI* 2.01f)*(Math::PI/ 75.0f)+
+ sinf(m_time*Math::PI* 2.51f)*(Math::PI/100.0f)+
+ sinf(m_time*Math::PI*19.01f)*(Math::PI/200.0f);
- vibCir.x += sinf(m_time*PI* 2.03f)*(PI/ 75.0f)+
- sinf(m_time*PI* 2.52f)*(PI/100.0f)+
- sinf(m_time*PI*19.53f)*(PI/200.0f);
+ vibCir.x += sinf(m_time*Math::PI* 2.03f)*(Math::PI/ 75.0f)+
+ sinf(m_time*Math::PI* 2.52f)*(Math::PI/100.0f)+
+ sinf(m_time*Math::PI*19.53f)*(Math::PI/200.0f);
- vibCir.y += (sinf(m_time*PI* 1.07f)*(PI/ 10.0f)+
- sinf(m_time*PI* 1.19f)*(PI/ 17.0f)+
- sinf(m_time*PI* 1.57f)*(PI/ 31.0f))*(1.0f-progress);
+ vibCir.y += (sinf(m_time*Math::PI* 1.07f)*(Math::PI/ 10.0f)+
+ sinf(m_time*Math::PI* 1.19f)*(Math::PI/ 17.0f)+
+ sinf(m_time*Math::PI* 1.57f)*(Math::PI/ 31.0f))*(1.0f-progress);
#endif
// Calculates the animations in action.
if ( m_actionType == MT_ERROR ) // no-no?
{
- vibCir.y += progress*sinf(m_progress*PI*11.0f)*1.0f;
+ vibCir.y += progress*sinf(m_progress*Math::PI*11.0f)*1.0f;
vibCir.z -= progress*0.5f; // leans forward
aAntenna.x -= progress*0.4f; // narrows
@@ -539,27 +538,27 @@ bool CMotionToto::EventFrame(const Event &event)
if ( m_actionType == MT_WARNING ) // warning?
{
- vibCir.x += progress*sinf(m_progress*PI*17.0f)*0.5f;
+ vibCir.x += progress*sinf(m_progress*Math::PI*17.0f)*0.5f;
- aAntenna.x += progress*sinf(m_progress*PI*17.0f)*0.5f; // deviates
- aAntenna.z += progress*cosf(m_progress*PI*17.0f)*0.5f; // turns
+ aAntenna.x += progress*sinf(m_progress*Math::PI*17.0f)*0.5f; // deviates
+ aAntenna.z += progress*cosf(m_progress*Math::PI*17.0f)*0.5f; // turns
}
if ( m_actionType == MT_INFO ) // yes-yes?
{
- vibCir.z += progress*sinf(m_progress*PI*19.0f)*0.7f;
+ vibCir.z += progress*sinf(m_progress*Math::PI*19.0f)*0.7f;
aAntenna.x -= progress*0.2f; // narrows
- aAntenna.z -= progress*cosf(m_progress*PI*19.0f)*0.9f; // turns
+ aAntenna.z -= progress*cosf(m_progress*Math::PI*19.0f)*0.9f; // turns
}
if ( m_actionType == MT_MESSAGE ) // message?
{
- vibCir.x += progress*sinf(m_progress*PI*15.0f)*0.3f;
- vibCir.z += progress*cosf(m_progress*PI*15.0f)*0.3f;
+ vibCir.x += progress*sinf(m_progress*Math::PI*15.0f)*0.3f;
+ vibCir.z += progress*cosf(m_progress*Math::PI*15.0f)*0.3f;
aAntenna.x -= progress*0.4f; // narrows
- aAntenna.z -= progress*cosf(m_progress*PI*19.0f)*0.8f;
+ aAntenna.z -= progress*cosf(m_progress*Math::PI*19.0f)*0.8f;
}
// Initialize the object.
@@ -568,26 +567,26 @@ bool CMotionToto::EventFrame(const Event &event)
if ( m_mousePos.x < 0.15f )
{
progress = 1.0f-m_mousePos.x/0.15f;
- vibCir.y += progress*PI/2.0f;
+ vibCir.y += progress*Math::PI/2.0f;
}
else
{
progress = (m_mousePos.x-0.15f)/0.85f;
- vibCir.y -= progress*PI/3.0f;
+ vibCir.y -= progress*Math::PI/3.0f;
}
- angle = RotateAngle(m_mousePos.x-0.1f, m_mousePos.y-0.5f-vibLin.y*0.2f);
- if ( angle < PI )
+ angle = Math::RotateAngle(m_mousePos.x-0.1f, m_mousePos.y-0.5f-vibLin.y*0.2f);
+ if ( angle < Math::PI )
{
- if ( angle > PI*0.5f ) angle = PI-angle;
- if ( angle > PI*0.3f ) angle = PI*0.3f;
+ if ( angle > Math::PI*0.5f ) angle = Math::PI-angle;
+ if ( angle > Math::PI*0.3f ) angle = Math::PI*0.3f;
vibCir.z += angle;
}
else
{
- angle = PI*2.0f-angle;
- if ( angle > PI*0.5f ) angle = PI-angle;
- if ( angle > PI*0.3f ) angle = PI*0.3f;
+ angle = Math::PI*2.0f-angle;
+ if ( angle > Math::PI*0.5f ) angle = Math::PI-angle;
+ if ( angle > Math::PI*0.3f ) angle = Math::PI*0.3f;
vibCir.z -= angle;
}
}
@@ -609,17 +608,17 @@ bool CMotionToto::EventFrame(const Event &event)
// Calculates the residual movement of the antennas.
pos = aAntenna*0.40f;
- pos.x += sinf(m_time*PI*2.07f)*(PI/50.0f)+
- sinf(m_time*PI*2.59f)*(PI/70.0f)+
- sinf(m_time*PI*2.67f)*(PI/90.0f);
+ pos.x += sinf(m_time*Math::PI*2.07f)*(Math::PI/50.0f)+
+ sinf(m_time*Math::PI*2.59f)*(Math::PI/70.0f)+
+ sinf(m_time*Math::PI*2.67f)*(Math::PI/90.0f);
- pos.y += sinf(m_time*PI*2.22f)*(PI/50.0f)+
- sinf(m_time*PI*2.36f)*(PI/70.0f)+
- sinf(m_time*PI*3.01f)*(PI/90.0f);
+ pos.y += sinf(m_time*Math::PI*2.22f)*(Math::PI/50.0f)+
+ sinf(m_time*Math::PI*2.36f)*(Math::PI/70.0f)+
+ sinf(m_time*Math::PI*3.01f)*(Math::PI/90.0f);
- pos.z += sinf(m_time*PI*2.11f)*(PI/50.0f)+
- sinf(m_time*PI*2.83f)*(PI/70.0f)+
- sinf(m_time*PI*3.09f)*(PI/90.0f);
+ pos.z += sinf(m_time*Math::PI*2.11f)*(Math::PI/50.0f)+
+ sinf(m_time*Math::PI*2.83f)*(Math::PI/70.0f)+
+ sinf(m_time*Math::PI*3.09f)*(Math::PI/90.0f);
m_object->SetAngle(4, pos); // left antenna
m_object->SetAngle(5, pos); // left antenna
@@ -627,17 +626,17 @@ bool CMotionToto::EventFrame(const Event &event)
pos = aAntenna*0.40f;
pos.x = -pos.x;
- pos.x += sinf(m_time*PI*2.33f)*(PI/50.0f)+
- sinf(m_time*PI*2.19f)*(PI/70.0f)+
- sinf(m_time*PI*2.07f)*(PI/90.0f);
+ pos.x += sinf(m_time*Math::PI*2.33f)*(Math::PI/50.0f)+
+ sinf(m_time*Math::PI*2.19f)*(Math::PI/70.0f)+
+ sinf(m_time*Math::PI*2.07f)*(Math::PI/90.0f);
- pos.y += sinf(m_time*PI*2.44f)*(PI/50.0f)+
- sinf(m_time*PI*2.77f)*(PI/70.0f)+
- sinf(m_time*PI*3.22f)*(PI/90.0f);
+ pos.y += sinf(m_time*Math::PI*2.44f)*(Math::PI/50.0f)+
+ sinf(m_time*Math::PI*2.77f)*(Math::PI/70.0f)+
+ sinf(m_time*Math::PI*3.22f)*(Math::PI/90.0f);
- pos.z += sinf(m_time*PI*2.05f)*(PI/50.0f)+
- sinf(m_time*PI*2.38f)*(PI/70.0f)+
- sinf(m_time*PI*2.79f)*(PI/90.0f);
+ pos.z += sinf(m_time*Math::PI*2.05f)*(Math::PI/50.0f)+
+ sinf(m_time*Math::PI*2.38f)*(Math::PI/70.0f)+
+ sinf(m_time*Math::PI*2.79f)*(Math::PI/90.0f);
m_object->SetAngle(7, pos); // right antenna
m_object->SetAngle(8, pos); // right antenna
@@ -653,7 +652,7 @@ bool CMotionToto::EventFrame(const Event &event)
}
else if ( m_actionType == MT_WARNING ) // warning?
{
- m_object->SetAngleX(1, 15.0f*PI/180.0f);
+ m_object->SetAngleX(1, 15.0f*Math::PI/180.0f);
m_object->SetAngleZ(1, 0.0f);
m_object->SetZoomY(1, 1.0f);
m_object->SetZoomZ(1, 1.0f);
@@ -700,7 +699,7 @@ bool CMotionToto::EventFrame(const Event &event)
else
{
m_blinkProgress = -1.0f;
- m_blinkTime = 0.1f+Rand()*4.0f;
+ m_blinkTime = 0.1f+Math::Rand()*4.0f;
m_object->SetZoomY(2, 1.0f);
m_object->SetZoomY(3, 1.0f);
}
@@ -708,23 +707,23 @@ bool CMotionToto::EventFrame(const Event &event)
if ( m_actionType == MT_ERROR ) // no-no?
{
- m_object->SetAngleX(2, -30.0f*PI/180.0f);
- m_object->SetAngleX(3, 30.0f*PI/180.0f);
+ m_object->SetAngleX(2, -30.0f*Math::PI/180.0f);
+ m_object->SetAngleX(3, 30.0f*Math::PI/180.0f);
}
else if ( m_actionType == MT_WARNING ) // warning?
{
- m_object->SetAngleX(2, -15.0f*PI/180.0f);
- m_object->SetAngleX(3, 15.0f*PI/180.0f);
+ m_object->SetAngleX(2, -15.0f*Math::PI/180.0f);
+ m_object->SetAngleX(3, 15.0f*Math::PI/180.0f);
}
else if ( m_actionType == MT_INFO ) // yes-yes?
{
- m_object->SetAngleX(2, 40.0f*PI/180.0f);
- m_object->SetAngleX(3, -40.0f*PI/180.0f);
+ m_object->SetAngleX(2, 40.0f*Math::PI/180.0f);
+ m_object->SetAngleX(3, -40.0f*Math::PI/180.0f);
}
else if ( m_actionType == MT_MESSAGE ) // message?
{
- m_object->SetAngleX(2, 20.0f*PI/180.0f);
- m_object->SetAngleX(3, -20.0f*PI/180.0f);
+ m_object->SetAngleX(2, 20.0f*Math::PI/180.0f);
+ m_object->SetAngleX(3, -20.0f*Math::PI/180.0f);
}
else
{
@@ -746,16 +745,16 @@ bool CMotionToto::EventFrame(const Event &event)
if ( !m_bDisplayInfo &&
pos.y < m_water->RetLevel() ) // underwater?
{
- float t = Mod(m_time, 3.5f);
+ float t = Math::Mod(m_time, 3.5f);
if ( t >= 2.2f || ( t >= 1.2f && t <= 1.4f ) ) // breathe?
{
pos = D3DVECTOR(1.0f, 0.2f, 0.0f);
- pos.z += (Rand()-0.5f)*0.5f;
+ pos.z += (Math::Rand()-0.5f)*0.5f;
speed = pos;
- speed.y += 5.0f+Rand()*5.0f;
- speed.x += Rand()*2.0f;
- speed.z += (Rand()-0.5f)*2.0f;
+ speed.y += 5.0f+Math::Rand()*5.0f;
+ speed.x += Math::Rand()*2.0f;
+ speed.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
speed = Transform(*mat, speed)-pos;
@@ -768,71 +767,71 @@ bool CMotionToto::EventFrame(const Event &event)
else // out of water?
{
pos = D3DVECTOR(0.0f, -0.5f, 0.0f);
- pos.z += (Rand()-0.5f)*0.5f;
+ pos.z += (Math::Rand()-0.5f)*0.5f;
speed = pos;
- speed.y -= (1.5f+Rand()*1.5f) + vibLin.y;
- speed.x += (Rand()-0.5f)*2.0f;
- speed.z += (Rand()-0.5f)*2.0f;
+ speed.y -= (1.5f+Math::Rand()*1.5f) + vibLin.y;
+ speed.x += (Math::Rand()-0.5f)*2.0f;
+ speed.z += (Math::Rand()-0.5f)*2.0f;
// mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Transform(*mat, speed)-pos;
- dim.x = (Rand()*0.4f+0.4f)*(1.0f+Min(linSpeed*0.1f, 5.0f));
+ dim.x = (Math::Rand()*0.4f+0.4f)*(1.0f+Math::Min(linSpeed*0.1f, 5.0f));
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTITOTO, 1.0f+Rand()*1.0f, 0.0f, 1.0f, sheet);
+ m_particule->CreateParticule(pos, speed, dim, PARTITOTO, 1.0f+Math::Rand()*1.0f, 0.0f, 1.0f, sheet);
}
if ( m_actionType != -1 && // current action?
m_progress <= 0.85f )
{
- pos.x = (Rand()-0.5f)*1.0f;
- pos.y = (Rand()-0.5f)*1.0f+3.5f;
- pos.z = (Rand()-0.5f)*1.0f;
+ pos.x = (Math::Rand()-0.5f)*1.0f;
+ pos.y = (Math::Rand()-0.5f)*1.0f+3.5f;
+ pos.z = (Math::Rand()-0.5f)*1.0f;
pos = Transform(*mat, pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = (Rand()*0.3f+0.3f);
+ dim.x = (Math::Rand()*0.3f+0.3f);
dim.y = dim.x;
if ( m_actionType == MT_ERROR ) type = PARTIERROR;
if ( m_actionType == MT_WARNING ) type = PARTIWARNING;
if ( m_actionType == MT_INFO ) type = PARTIINFO;
if ( m_actionType == MT_MESSAGE ) type = PARTIWARNING;
- m_particule->CreateParticule(pos, speed, dim, type, 0.5f+Rand()*0.5f, 0.0f, 1.0f, sheet);
+ m_particule->CreateParticule(pos, speed, dim, type, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, sheet);
- pos.x = 0.50f+(Rand()-0.5f)*0.80f;
- pos.y = 0.86f+(Rand()-0.5f)*0.08f;
+ pos.x = 0.50f+(Math::Rand()-0.5f)*0.80f;
+ pos.y = 0.86f+(Math::Rand()-0.5f)*0.08f;
pos.z = 0.00f;
- dim.x = (Rand()*0.04f+0.04f);
+ dim.x = (Math::Rand()*0.04f+0.04f);
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, type, 0.5f+Rand()*0.5f, 0.0f, 1.0f, SH_INTERFACE);
+ m_particule->CreateParticule(pos, speed, dim, type, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, SH_INTERFACE);
}
//? if ( m_bDisplayInfo && m_main->RetGlint() )
if ( false )
{
- pos.x = (Rand()-0.5f)*1.4f;
- pos.y = (Rand()-0.5f)*1.4f+3.5f;
- pos.z = (Rand()-0.5f)*1.4f;
+ pos.x = (Math::Rand()-0.5f)*1.4f;
+ pos.y = (Math::Rand()-0.5f)*1.4f+3.5f;
+ pos.z = (Math::Rand()-0.5f)*1.4f;
pos = Transform(*mat, pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = (Rand()*0.5f+0.5f);
+ dim.x = (Math::Rand()*0.5f+0.5f);
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 0.5f+Rand()*0.5f, 0.0f, 1.0f, sheet);
+ m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, sheet);
for ( i=0 ; i<10 ; i++ )
{
- pos.x = 0.60f+(Rand()-0.5f)*0.76f;
- pos.y = 0.47f+(Rand()-0.5f)*0.90f;
+ pos.x = 0.60f+(Math::Rand()-0.5f)*0.76f;
+ pos.y = 0.47f+(Math::Rand()-0.5f)*0.90f;
pos.z = 0.00f;
r = rand()%4;
if ( r == 0 ) pos.x = 0.21f; // the left edge
else if ( r == 1 ) pos.x = 0.98f; // the right edge
else if ( r == 2 ) pos.y = 0.02f; // on the lower edge
else pos.y = 0.92f; // on the upper edge
- dim.x = (Rand()*0.02f+0.02f);
+ dim.x = (Math::Rand()*0.02f+0.02f);
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 0.5f+Rand()*0.5f, 0.0f, 1.0f, SH_INTERFACE);
+ m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, SH_INTERFACE);
}
}
}
diff --git a/src/object/motion/motiontoto.h b/src/object/motion/motiontoto.h
index 935e4a5..2201882 100644
--- a/src/object/motion/motiontoto.h
+++ b/src/object/motion/motiontoto.h
@@ -57,7 +57,7 @@ public:
void StartDisplayInfo();
void StopDisplayInfo();
- void SetMousePos(FPOINT pos);
+ void SetMousePos(Math::Point pos);
protected:
bool EventFrame(const Event &event);
@@ -76,6 +76,6 @@ protected:
float m_blinkProgress;
int m_soundChannel;
ObjectType m_type;
- FPOINT m_mousePos;
+ Math::Point m_mousePos;
};
diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp
index 4bd91d0..1c30514 100644
--- a/src/object/motion/motionvehicle.cpp
+++ b/src/object/motion/motionvehicle.cpp
@@ -16,14 +16,13 @@
// motionvehicle.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/func.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -261,7 +260,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->CreateEngineObject(rank);
m_object->SetPosition(3, D3DVECTOR(3.5f, 0.0f, 0.0f));
m_object->SetAngleZ(3, ARM_NEUTRAL_ANGLE3);
- m_object->SetAngleX(3, PI/2.0f);
+ m_object->SetAngleX(3, Math::PI/2.0f);
// Creates the close clamp.
rank = m_engine->CreateObject();
@@ -271,7 +270,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem5.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(4, D3DVECTOR(1.5f, 0.0f, 0.0f));
- m_object->SetAngleZ(4, -PI*0.10f);
+ m_object->SetAngleZ(4, -Math::PI*0.10f);
// Creates the remote clamp.
rank = m_engine->CreateObject();
@@ -281,7 +280,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem6.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(5, D3DVECTOR(1.5f, 0.0f, 0.0f));
- m_object->SetAngleZ(5, PI*0.10f);
+ m_object->SetAngleZ(5, Math::PI*0.10f);
}
if ( type == OBJECT_MOBILEfs ||
@@ -297,7 +296,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem2.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(1, D3DVECTOR(0.0f, 5.3f, 0.0f));
- m_object->SetAngleZ(1, 110.0f*PI/180.0f);
+ m_object->SetAngleZ(1, 110.0f*Math::PI/180.0f);
// Creates the forearm.
rank = m_engine->CreateObject();
@@ -307,7 +306,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(2, D3DVECTOR(5.0f, 0.0f, 0.0f));
- m_object->SetAngleZ(2, -110.0f*PI/180.0f);
+ m_object->SetAngleZ(2, -110.0f*Math::PI/180.0f);
// Creates the sensor.
rank = m_engine->CreateObject();
@@ -317,7 +316,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem4s.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(3, D3DVECTOR(3.5f, 0.0f, 0.0f));
- m_object->SetAngleZ(3, -65.0f*PI/180.0f);
+ m_object->SetAngleZ(3, -65.0f*Math::PI/180.0f);
}
if ( type == OBJECT_MOBILEfc ||
@@ -385,7 +384,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem2w.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(7, D3DVECTOR(-3.0f, 1.0f, 3.0f));
- m_object->SetAngleY(7, PI);
+ m_object->SetAngleY(7, Math::PI);
// Creates the right-front wheel.
rank = m_engine->CreateObject();
@@ -404,7 +403,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem2w.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(9, D3DVECTOR(2.0f, 1.0f, 3.0f));
- m_object->SetAngleY(9, PI);
+ m_object->SetAngleY(9, Math::PI);
}
if ( type == OBJECT_MOBILEtg )
@@ -426,7 +425,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem2w.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(7, D3DVECTOR(-2.0f, 1.0f, 3.0f));
- m_object->SetAngleY(7, PI);
+ m_object->SetAngleY(7, Math::PI);
// Creates the right-front wheel.
rank = m_engine->CreateObject();
@@ -445,7 +444,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem2w.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(9, D3DVECTOR(3.0f, 1.0f, 3.0f));
- m_object->SetAngleY(9, PI);
+ m_object->SetAngleY(9, Math::PI);
}
if ( type == OBJECT_MOBILEta ||
@@ -561,7 +560,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem2f.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(7, D3DVECTOR(-1.8f, 3.0f, -1.5f));
- m_object->SetAngleY(7, 120.0f*PI/180.0f);
+ m_object->SetAngleY(7, 120.0f*Math::PI/180.0f);
// Creates the left-back foot.
rank = m_engine->CreateObject();
@@ -571,7 +570,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\lem2f.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(8, D3DVECTOR(-1.8f, 3.0f, 1.5f));
- m_object->SetAngleY(8, -120.0f*PI/180.0f);
+ m_object->SetAngleY(8, -120.0f*Math::PI/180.0f);
}
if ( type == OBJECT_MOBILEia ||
@@ -666,7 +665,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\roller2c.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(1, D3DVECTOR(3.0f, 4.6f, 0.0f));
- m_object->SetAngleZ(1, PI/8.0f);
+ m_object->SetAngleZ(1, Math::PI/8.0f);
// Creates the cannon.
rank = m_engine->CreateObject();
@@ -698,7 +697,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\recover2.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(2, D3DVECTOR(0.1f, 0.0f, -5.0f));
- m_object->SetAngleZ(2, 126.0f*PI/180.0f);
+ m_object->SetAngleZ(2, 126.0f*Math::PI/180.0f);
// Creates the right forearm.
rank = m_engine->CreateObject();
@@ -708,7 +707,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\recover3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(3, D3DVECTOR(5.0f, 0.0f, -0.5f));
- m_object->SetAngleZ(3, -144.0f*PI/180.0f);
+ m_object->SetAngleZ(3, -144.0f*Math::PI/180.0f);
// Creates the left arm.
rank = m_engine->CreateObject();
@@ -719,7 +718,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(4, D3DVECTOR(0.1f, 0.0f, 5.0f));
- m_object->SetAngleZ(4, 126.0f*PI/180.0f);
+ m_object->SetAngleZ(4, 126.0f*Math::PI/180.0f);
// Creates the left forearm.
rank = m_engine->CreateObject();
@@ -730,7 +729,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->Mirror();
pModFile->CreateEngineObject(rank);
m_object->SetPosition(5, D3DVECTOR(5.0f, 0.0f, 0.5f));
- m_object->SetAngleZ(5, -144.0f*PI/180.0f);
+ m_object->SetAngleZ(5, -144.0f*Math::PI/180.0f);
}
if ( type == OBJECT_MOBILErs )
@@ -819,7 +818,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->CreateEngineObject(rank);
m_posKey = D3DVECTOR(3.0f, 5.7f, 0.0f);
m_object->SetPosition(2, m_posKey);
- m_object->SetAngleY(2, 90.0f*PI/180.0f);
+ m_object->SetAngleY(2, 90.0f*Math::PI/180.0f);
}
// Creates pencils.
@@ -833,7 +832,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel(name);
pModFile->CreateEngineObject(rank);
m_object->SetPosition(10+i, D3DVECTOR(0.0f, 0.0f, 0.0f));
- m_object->SetAngleY(10+i, 45.0f*PI/180.0f*i);
+ m_object->SetAngleY(10+i, 45.0f*Math::PI/180.0f*i);
}
}
@@ -850,7 +849,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->CreateEngineObject(rank);
m_posKey = D3DVECTOR(0.2f, 4.1f, 0.0f);
m_object->SetPosition(2, m_posKey);
- m_object->SetAngleY(2, 90.0f*PI/180.0f);
+ m_object->SetAngleY(2, 90.0f*Math::PI/180.0f);
}
}
@@ -864,8 +863,8 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\apolloj2.mod"); // antenna
pModFile->CreateEngineObject(rank);
m_object->SetPosition(1, D3DVECTOR(5.5f, 8.8f, 2.0f));
- m_object->SetAngleY(1, -120.0f*PI/180.0f);
- m_object->SetAngleZ(1, 45.0f*PI/180.0f);
+ m_object->SetAngleY(1, -120.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(1, 45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -874,7 +873,7 @@ bool CMotionVehicle::Create(D3DVECTOR pos, float angle, ObjectType type,
pModFile->ReadModel("objects\\apolloj3.mod"); // camera
pModFile->CreateEngineObject(rank);
m_object->SetPosition(2, D3DVECTOR(5.5f, 2.8f, -2.0f));
- m_object->SetAngleY(2, 30.0f*PI/180.0f);
+ m_object->SetAngleY(2, 30.0f*Math::PI/180.0f);
// Creates the wheels.
rank = m_engine->CreateObject();
@@ -1107,8 +1106,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 30.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 20.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.8f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.8f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.8f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.8f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 8.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 8.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 12.0f);
@@ -1135,8 +1134,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 20.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 20.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.8f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.8f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.8f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.8f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 10.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 10.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 15.0f);
@@ -1166,8 +1165,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 10.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 10.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 10.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 6.0f);
@@ -1198,8 +1197,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 10.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 10.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 10.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 15.0f);
@@ -1235,8 +1234,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionY(MO_RECACCEL, 50.0f);
m_physics->SetLinMotionY(MO_STOACCEL, 50.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.4f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.4f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.4f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.4f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 2.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 2.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 2.0f);
@@ -1266,8 +1265,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 10.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.3f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.3f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.3f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.3f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 2.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 2.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 4.0f);
@@ -1294,8 +1293,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 10.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 5.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 5.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 10.0f);
@@ -1322,8 +1321,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 10.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.5f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.5f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 5.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 5.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 10.0f);
@@ -1349,8 +1348,8 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
m_physics->SetLinMotionZ(MO_TERFORCE, 10.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 20.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.4f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.4f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.4f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.4f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 2.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 2.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 4.0f);
@@ -1418,23 +1417,23 @@ bool CMotionVehicle::EventFrame(const Event &event)
if ( s > 0.0f )
{
m_wheelTurn[0] = -a*0.05f;
- m_wheelTurn[1] = -a*0.05f+PI;
+ m_wheelTurn[1] = -a*0.05f+Math::PI;
m_wheelTurn[2] = a*0.05f;
- m_wheelTurn[3] = a*0.05f+PI;
+ m_wheelTurn[3] = a*0.05f+Math::PI;
}
else if ( s < 0.0f )
{
m_wheelTurn[0] = a*0.05f;
- m_wheelTurn[1] = a*0.05f+PI;
+ m_wheelTurn[1] = a*0.05f+Math::PI;
m_wheelTurn[2] = -a*0.05f;
- m_wheelTurn[3] = -a*0.05f+PI;
+ m_wheelTurn[3] = -a*0.05f+Math::PI;
}
else
{
- m_wheelTurn[0] = Abs(a)*0.05f;
- m_wheelTurn[1] = -Abs(a)*0.05f+PI;
- m_wheelTurn[2] = -Abs(a)*0.05f;
- m_wheelTurn[3] = Abs(a)*0.05f+PI;
+ m_wheelTurn[0] = fabs(a)*0.05f;
+ m_wheelTurn[1] = -fabs(a)*0.05f+Math::PI;
+ m_wheelTurn[2] = -fabs(a)*0.05f;
+ m_wheelTurn[3] = fabs(a)*0.05f+Math::PI;
}
m_object->SetAngleY(6, m_object->RetAngleY(6)+(m_wheelTurn[0]-m_object->RetAngleY(6))*event.rTime*8.0f);
m_object->SetAngleY(7, m_object->RetAngleY(7)+(m_wheelTurn[1]-m_object->RetAngleY(7))*event.rTime*8.0f);
@@ -1444,9 +1443,9 @@ bool CMotionVehicle::EventFrame(const Event &event)
if ( type == OBJECT_APOLLO2 )
{
m_object->SetAngleY(10, m_object->RetAngleY(6)+(m_wheelTurn[0]-m_object->RetAngleY(6))*event.rTime*8.0f);
- m_object->SetAngleY(11, m_object->RetAngleY(7)+(m_wheelTurn[1]-m_object->RetAngleY(7))*event.rTime*8.0f+PI);
+ m_object->SetAngleY(11, m_object->RetAngleY(7)+(m_wheelTurn[1]-m_object->RetAngleY(7))*event.rTime*8.0f+Math::PI);
m_object->SetAngleY(12, m_object->RetAngleY(8)+(m_wheelTurn[2]-m_object->RetAngleY(8))*event.rTime*8.0f);
- m_object->SetAngleY(13, m_object->RetAngleY(9)+(m_wheelTurn[3]-m_object->RetAngleY(9))*event.rTime*8.0f+PI);
+ m_object->SetAngleY(13, m_object->RetAngleY(9)+(m_wheelTurn[3]-m_object->RetAngleY(9))*event.rTime*8.0f+Math::PI);
}
pos = m_object->RetPosition(0);
@@ -1594,23 +1593,23 @@ bool CMotionVehicle::EventFrame(const Event &event)
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEts )
{
- limit[0] = 8.0f*PI/180.0f;
- limit[1] = -12.0f*PI/180.0f;
+ limit[0] = 8.0f*Math::PI/180.0f;
+ limit[1] = -12.0f*Math::PI/180.0f;
}
else if ( type == OBJECT_MOBILEsa )
{
- limit[0] = 15.0f*PI/180.0f;
- limit[1] = -15.0f*PI/180.0f;
+ limit[0] = 15.0f*Math::PI/180.0f;
+ limit[1] = -15.0f*Math::PI/180.0f;
}
else if ( type == OBJECT_MOBILEdr )
{
- limit[0] = 10.0f*PI/180.0f;
- limit[1] = -10.0f*PI/180.0f;
+ limit[0] = 10.0f*Math::PI/180.0f;
+ limit[1] = -10.0f*Math::PI/180.0f;
}
else
{
- limit[0] = 15.0f*PI/180.0f;
- limit[1] = -10.0f*PI/180.0f;
+ limit[0] = 15.0f*Math::PI/180.0f;
+ limit[1] = -10.0f*Math::PI/180.0f;
}
if ( Length(pos, m_engine->RetEyePt()) < 50.0f ) // suspension?
@@ -1671,8 +1670,8 @@ bool CMotionVehicle::EventFrame(const Event &event)
}
m_object->SetPosition(2, pos);
- s = -Abs(m_physics->RetLinMotionX(MO_MOTSPEED)*0.1f);
- s += -Abs(m_physics->RetCirMotionY(MO_MOTSPEED)*1.5f);
+ s = -fabs(m_physics->RetLinMotionX(MO_MOTSPEED)*0.1f);
+ s += -fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*1.5f);
m_object->SetAngleY(2, m_object->RetAngleY(2)+event.rTime*s); // turns the key
}
@@ -1737,8 +1736,8 @@ bool CMotionVehicle::EventFrameFly(const Event &event)
{
h = m_terrain->RetFloorHeight(paw[i]);
a = -atanf(h*0.5f);
- if ( a > PI*0.2f ) a = PI*0.2f;
- if ( a < -PI*0.2f ) a = -PI*0.2f;
+ if ( a > Math::PI*0.2f ) a = Math::PI*0.2f;
+ if ( a < -Math::PI*0.2f ) a = -Math::PI*0.2f;
hope[i] = a;
}
}
@@ -1753,7 +1752,7 @@ bool CMotionVehicle::EventFrameFly(const Event &event)
for ( i=0 ; i<3 ; i++ )
{
actual = m_object->RetAngleZ(6+i);
- final = Smooth(actual, hope[i], event.rTime*5.0f);
+ final = Math::Smooth(actual, hope[i], event.rTime*5.0f);
if ( final != actual )
{
m_bFlyFix = false; // it is moving
@@ -1801,7 +1800,7 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
}
s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = Abs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
+ a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -1818,8 +1817,8 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
if ( bStop )
{
- prog = Mod(m_armTimeAbs, 2.0f)/10.0f;
- a = Mod(m_armMember, 1.0f);
+ prog = Math::Mod(m_armTimeAbs, 2.0f)/10.0f;
+ a = Math::Mod(m_armMember, 1.0f);
a = (prog-a)*event.rTime*2.0f; // stop position is pleasantly
m_armMember += a;
}
@@ -1839,8 +1838,8 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
}
else
{
- if ( i < 3 ) prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
- else prog = Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
+ if ( i < 3 ) prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.0f, 1.0f);
+ else prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
if ( prog < 0.33f ) // t0..t1 ?
{
prog = prog/0.33f; // 0..1
@@ -1868,27 +1867,27 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
if ( i < 3 ) // right leg (1..3) ?
{
- m_object->SetAngleX(6+3*i+0, Smooth(m_object->RetAngleX(6+3*i+0), Prop(table[st+ 0], table[nd+ 0], prog), time));
- m_object->SetAngleY(6+3*i+0, Smooth(m_object->RetAngleY(6+3*i+0), Prop(table[st+ 1], table[nd+ 1], prog), time));
- m_object->SetAngleZ(6+3*i+0, Smooth(m_object->RetAngleZ(6+3*i+0), Prop(table[st+ 2], table[nd+ 2], prog), time));
- m_object->SetAngleX(6+3*i+1, Smooth(m_object->RetAngleX(6+3*i+1), Prop(table[st+ 9], table[nd+ 9], prog), time));
- m_object->SetAngleY(6+3*i+1, Smooth(m_object->RetAngleY(6+3*i+1), Prop(table[st+10], table[nd+10], prog), time));
- m_object->SetAngleZ(6+3*i+1, Smooth(m_object->RetAngleZ(6+3*i+1), Prop(table[st+11], table[nd+11], prog), time));
- m_object->SetAngleX(6+3*i+2, Smooth(m_object->RetAngleX(6+3*i+2), Prop(table[st+18], table[nd+18], prog), time));
- m_object->SetAngleY(6+3*i+2, Smooth(m_object->RetAngleY(6+3*i+2), Prop(table[st+19], table[nd+19], prog), time));
- m_object->SetAngleZ(6+3*i+2, Smooth(m_object->RetAngleZ(6+3*i+2), Prop(table[st+20], table[nd+20], prog), time));
+ m_object->SetAngleX(6+3*i+0, Math::Smooth(m_object->RetAngleX(6+3*i+0), Math::PropAngle(table[st+ 0], table[nd+ 0], prog), time));
+ m_object->SetAngleY(6+3*i+0, Math::Smooth(m_object->RetAngleY(6+3*i+0), Math::PropAngle(table[st+ 1], table[nd+ 1], prog), time));
+ m_object->SetAngleZ(6+3*i+0, Math::Smooth(m_object->RetAngleZ(6+3*i+0), Math::PropAngle(table[st+ 2], table[nd+ 2], prog), time));
+ m_object->SetAngleX(6+3*i+1, Math::Smooth(m_object->RetAngleX(6+3*i+1), Math::PropAngle(table[st+ 9], table[nd+ 9], prog), time));
+ m_object->SetAngleY(6+3*i+1, Math::Smooth(m_object->RetAngleY(6+3*i+1), Math::PropAngle(table[st+10], table[nd+10], prog), time));
+ m_object->SetAngleZ(6+3*i+1, Math::Smooth(m_object->RetAngleZ(6+3*i+1), Math::PropAngle(table[st+11], table[nd+11], prog), time));
+ m_object->SetAngleX(6+3*i+2, Math::Smooth(m_object->RetAngleX(6+3*i+2), Math::PropAngle(table[st+18], table[nd+18], prog), time));
+ m_object->SetAngleY(6+3*i+2, Math::Smooth(m_object->RetAngleY(6+3*i+2), Math::PropAngle(table[st+19], table[nd+19], prog), time));
+ m_object->SetAngleZ(6+3*i+2, Math::Smooth(m_object->RetAngleZ(6+3*i+2), Math::PropAngle(table[st+20], table[nd+20], prog), time));
}
else // left leg (4..6) ?
{
- m_object->SetAngleX(6+3*i+0, Smooth(m_object->RetAngleX(6+3*i+0), Prop(-table[st+ 0], -table[nd+ 0], prog), time));
- m_object->SetAngleY(6+3*i+0, Smooth(m_object->RetAngleY(6+3*i+0), Prop(-table[st+ 1], -table[nd+ 1], prog), time));
- m_object->SetAngleZ(6+3*i+0, Smooth(m_object->RetAngleZ(6+3*i+0), Prop( table[st+ 2], table[nd+ 2], prog), time));
- m_object->SetAngleX(6+3*i+1, Smooth(m_object->RetAngleX(6+3*i+1), Prop(-table[st+ 9], -table[nd+ 9], prog), time));
- m_object->SetAngleY(6+3*i+1, Smooth(m_object->RetAngleY(6+3*i+1), Prop(-table[st+10], -table[nd+10], prog), time));
- m_object->SetAngleZ(6+3*i+1, Smooth(m_object->RetAngleZ(6+3*i+1), Prop( table[st+11], table[nd+11], prog), time));
- m_object->SetAngleX(6+3*i+2, Smooth(m_object->RetAngleX(6+3*i+2), Prop(-table[st+18], -table[nd+18], prog), time));
- m_object->SetAngleY(6+3*i+2, Smooth(m_object->RetAngleY(6+3*i+2), Prop(-table[st+19], -table[nd+19], prog), time));
- m_object->SetAngleZ(6+3*i+2, Smooth(m_object->RetAngleZ(6+3*i+2), Prop( table[st+20], table[nd+20], prog), time));
+ m_object->SetAngleX(6+3*i+0, Math::Smooth(m_object->RetAngleX(6+3*i+0), Math::PropAngle(-table[st+ 0], -table[nd+ 0], prog), time));
+ m_object->SetAngleY(6+3*i+0, Math::Smooth(m_object->RetAngleY(6+3*i+0), Math::PropAngle(-table[st+ 1], -table[nd+ 1], prog), time));
+ m_object->SetAngleZ(6+3*i+0, Math::Smooth(m_object->RetAngleZ(6+3*i+0), Math::PropAngle( table[st+ 2], table[nd+ 2], prog), time));
+ m_object->SetAngleX(6+3*i+1, Math::Smooth(m_object->RetAngleX(6+3*i+1), Math::PropAngle(-table[st+ 9], -table[nd+ 9], prog), time));
+ m_object->SetAngleY(6+3*i+1, Math::Smooth(m_object->RetAngleY(6+3*i+1), Math::PropAngle(-table[st+10], -table[nd+10], prog), time));
+ m_object->SetAngleZ(6+3*i+1, Math::Smooth(m_object->RetAngleZ(6+3*i+1), Math::PropAngle( table[st+11], table[nd+11], prog), time));
+ m_object->SetAngleX(6+3*i+2, Math::Smooth(m_object->RetAngleX(6+3*i+2), Math::PropAngle(-table[st+18], -table[nd+18], prog), time));
+ m_object->SetAngleY(6+3*i+2, Math::Smooth(m_object->RetAngleY(6+3*i+2), Math::PropAngle(-table[st+19], -table[nd+19], prog), time));
+ m_object->SetAngleZ(6+3*i+2, Math::Smooth(m_object->RetAngleZ(6+3*i+2), Math::PropAngle( table[st+20], table[nd+20], prog), time));
}
}
@@ -1897,12 +1896,12 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
}
else
{
- a = Mod(m_armMember, 1.0f);
+ a = Math::Mod(m_armMember, 1.0f);
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
else a = 3.0f-4.0f*a; // 1..-1
dir.x = sinf(a)*0.05f;
- s = Mod(m_armMember/2.0f, 1.0f);
+ s = Math::Mod(m_armMember/2.0f, 1.0f);
if ( s < 0.5f ) s = -1.0f+4.0f*s; // -1..1
else s = 3.0f-4.0f*s; // 1..-1
dir.z = sinf(s)*0.1f;
@@ -1922,7 +1921,7 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
{
CObject* power;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float zoom, angle, energy, factor;
bool bOnBoard = false;
@@ -1949,16 +1948,16 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
if ( bOnBoard ) factor *= 0.8f;
zoom = 1.3f+
- sinf(m_canonTime*PI*0.31f)*0.10f+
- sinf(m_canonTime*PI*0.52f)*0.08f+
- sinf(m_canonTime*PI*1.53f)*0.05f;
+ sinf(m_canonTime*Math::PI*0.31f)*0.10f+
+ sinf(m_canonTime*Math::PI*0.52f)*0.08f+
+ sinf(m_canonTime*Math::PI*1.53f)*0.05f;
zoom *= factor;
m_object->SetZoomY(2, zoom);
zoom = 1.0f+
- sinf(m_canonTime*PI*0.27f)*0.07f+
- sinf(m_canonTime*PI*0.62f)*0.06f+
- sinf(m_canonTime*PI*1.73f)*0.03f;
+ sinf(m_canonTime*Math::PI*0.27f)*0.07f+
+ sinf(m_canonTime*Math::PI*0.62f)*0.06f+
+ sinf(m_canonTime*Math::PI*1.73f)*0.03f;
zoom *= factor;
m_object->SetZoomZ(2, zoom);
@@ -1971,17 +1970,17 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
m_lastTimeCanon -= event.rTime;
if ( m_lastTimeCanon <= 0.0f )
{
- m_lastTimeCanon = m_engine->ParticuleAdapt(0.5f+Rand()*0.5f);
+ m_lastTimeCanon = m_engine->ParticuleAdapt(0.5f+Math::Rand()*0.5f);
pos = m_object->RetPosition(0);
pos.y += 8.0f;
- speed.y = 7.0f+Rand()*3.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = 2.0f+Rand()*2.0f;
- if ( Rand() < 0.5f ) speed.z = -speed.z;
+ speed.y = 7.0f+Math::Rand()*3.0f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = 2.0f+Math::Rand()*2.0f;
+ if ( Math::Rand() < 0.5f ) speed.z = -speed.z;
mat = m_object->RetRotateMatrix(0);
speed = Transform(*mat, speed);
- dim.x = Rand()*0.1f+0.1f;
+ dim.x = Math::Rand()*0.1f+0.1f;
if ( bOnBoard ) dim.x *= 0.4f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIORGANIC2, 2.0f, 10.0f);
diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp
index fc5dc35..ab3f946 100644
--- a/src/object/motion/motionworm.cpp
+++ b/src/object/motion/motionworm.cpp
@@ -16,14 +16,13 @@
// motionworm.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -188,8 +187,8 @@ void CMotionWorm::CreatePhysics()
m_physics->SetLinMotionZ(MO_TERFORCE, 5.0f);
m_physics->SetLinMotionZ(MO_MOTACCEL, 40.0f);
- m_physics->SetCirMotionY(MO_ADVSPEED, 0.2f*PI);
- m_physics->SetCirMotionY(MO_RECSPEED, 0.2f*PI);
+ m_physics->SetCirMotionY(MO_ADVSPEED, 0.2f*Math::PI);
+ m_physics->SetCirMotionY(MO_RECSPEED, 0.2f*Math::PI);
m_physics->SetCirMotionY(MO_ADVACCEL, 10.0f);
m_physics->SetCirMotionY(MO_RECACCEL, 10.0f);
m_physics->SetCirMotionY(MO_STOACCEL, 20.0f);
@@ -249,7 +248,7 @@ bool CMotionWorm::EventFrame(const Event &event)
{
D3DMATRIX* mat;
D3DVECTOR pos, p, angle, speed;
- FPOINT center, pp, dim;
+ Math::Point center, pp, dim;
float height[WORM_PART+2];
float floor, a, s, px, curve, phase, h, zoom, radius;
int i, under;
@@ -270,7 +269,7 @@ bool CMotionWorm::EventFrame(const Event &event)
under = 0; // no piece under the ground
for ( i=0 ; i<WORM_PART+2 ; i++ )
{
- phase = Mod(m_armTimeMarch-START_TIME-i*0.3f, TIME_UPDOWN+m_timeDown+TIME_UPDOWN+m_timeUp);
+ phase = Math::Mod(m_armTimeMarch-START_TIME-i*0.3f, TIME_UPDOWN+m_timeDown+TIME_UPDOWN+m_timeUp);
if ( phase < TIME_UPDOWN ) // descends?
{
h = -(phase/TIME_UPDOWN)*DOWN_ALTITUDE;
@@ -323,7 +322,7 @@ bool CMotionWorm::EventFrame(const Event &event)
center.y = 0.0f;
pp.x = pos.x;
pp.y = pos.z;
- pp = RotatePoint(center, curve, pp);
+ pp = Math::RotatePoint(center, curve, pp);
pos.x = pp.x;
pos.z = pp.y;
@@ -331,7 +330,7 @@ bool CMotionWorm::EventFrame(const Event &event)
pos.y += m_terrain->RetFloorLevel(p, true)-floor;
m_object->SetPosition(i+1, pos);
- zoom = Mod(m_armTimeAbs*0.5f+100.0f-i*0.1f, 2.0f);
+ zoom = Math::Mod(m_armTimeAbs*0.5f+100.0f-i*0.1f, 2.0f);
if ( zoom > 1.0f ) zoom = 2.0f-zoom;
zoom *= 1.6f;
if ( zoom < 1.0f ) zoom = 1.0f;
@@ -345,10 +344,10 @@ bool CMotionWorm::EventFrame(const Event &event)
pos = p;
pos.y += -height[i];
- 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 = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*2.0f+1.5f;
+ dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -361,8 +360,8 @@ bool CMotionWorm::EventFrame(const Event &event)
pos = m_object->RetPosition(i+2);
pos -= m_object->RetPosition(i+1);
- angle.z = -RotateAngle(Length(pos.x, pos.z), pos.y);
- angle.y = PI-RotateAngle(pos.x, pos.z);
+ angle.z = -Math::RotateAngle(Length(pos.x, pos.z), pos.y);
+ angle.y = Math::PI-Math::RotateAngle(pos.x, pos.z);
angle.x = 0.0f;
m_object->SetAngle(i+1, angle);
diff --git a/src/object/object.cpp b/src/object/object.cpp
index 0f8eb29..130bf3b 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -16,8 +16,6 @@
// object.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -25,6 +23,8 @@
#include "CBot/CBotDll.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"
@@ -162,11 +162,11 @@ void uObject(CBotVar* botThis, void* user)
pos = object->RetAngle(0);
pos += object->RetInclinaison();
pVar = pVar->GivNext(); // "orientation"
- pVar->SetValFloat(360.0f-Mod(pos.y*180.0f/PI, 360.0f));
+ pVar->SetValFloat(360.0f-Math::Mod(pos.y*180.0f/Math::PI, 360.0f));
pVar = pVar->GivNext(); // "pitch"
- pVar->SetValFloat(pos.z*180.0f/PI);
+ pVar->SetValFloat(pos.z*180.0f/Math::PI);
pVar = pVar->GivNext(); // "roll"
- pVar->SetValFloat(pos.x*180.0f/PI);
+ pVar->SetValFloat(pos.x*180.0f/Math::PI);
// Updates the energy level of the object.
pVar = pVar->GivNext(); // "energyLevel"
@@ -1100,7 +1100,7 @@ bool CObject::Write(char *line)
sprintf(name, " resetPos=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
- pos = RetResetAngle()/(PI/180.0f);
+ pos = RetResetAngle()/(Math::PI/180.0f);
sprintf(name, " resetAngle=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
@@ -1202,7 +1202,7 @@ bool CObject::Read(char *line)
SetParam(OpFloat(line, "param", 0.0f));
SetResetCap((ResetCap)OpInt(line, "resetCap", 0));
SetResetPosition(OpDir(line, "resetPos")*g_unit);
- SetResetAngle(OpDir(line, "resetAngle")*(PI/180.0f));
+ SetResetAngle(OpDir(line, "resetAngle")*(Math::PI/180.0f));
SetResetRun(OpInt(line, "resetRun", 0));
m_bBurn = OpInt(line, "burnMode", 0);
m_bVirusMode = OpInt(line, "virusMode", 0);
@@ -1448,7 +1448,7 @@ void CObject::SetFloorHeight(float height)
void CObject::FloorAdjust()
{
D3DVECTOR pos, n;
- FPOINT nn;
+ Math::Point nn;
float a;
pos = RetPosition(0);
@@ -1460,7 +1460,7 @@ void CObject::FloorAdjust()
SetAngleY(0, 0.0f);
#else
a = RetAngleY(0);
- nn = RotatePoint(-a, FPOINT(n.z, n.x));
+ nn = Math::RotatePoint(-a, Math::Point(n.z, n.x));
SetAngleX(0, sinf(nn.x));
SetAngleZ(0, -sinf(nn.y));
#endif
@@ -2269,7 +2269,7 @@ bool CObject::CreateShadowLight(float height, D3DCOLORVALUE color)
light.dvAttenuation1 = 0.0f;
light.dvAttenuation2 = 0.0f;
light.dvTheta = 0.0f;
- light.dvPhi = PI/4.0f;
+ light.dvPhi = Math::PI/4.0f;
m_shadowLight = m_light->CreateLight();
if ( m_shadowLight == -1 ) return false;
@@ -2316,7 +2316,7 @@ bool CObject::CreateEffectLight(float height, D3DCOLORVALUE color)
light.dvAttenuation1 = 0.0f;
light.dvAttenuation2 = 0.0f;
light.dvTheta = 0.0f;
- light.dvPhi = PI/4.0f;
+ light.dvPhi = Math::PI/4.0f;
m_effectLight = m_light->CreateLight();
if ( m_effectLight == -1 ) return false;
@@ -2362,7 +2362,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
ObjectType type, float power)
{
CModFile* pModFile;
- FPOINT p;
+ Math::Point p;
int rank, i;
if ( m_engine->RetRestCreate() < 20 ) return false;
@@ -2398,7 +2398,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico3.mod");
pModFile->CreateEngineObject(rank);
SetPosition(2, D3DVECTOR(0.0f, 0.0f, -33.0f));
- SetAngleY(2, 45.0f*PI/180.0f);
+ SetAngleY(2, 45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2407,7 +2407,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico4.mod");
pModFile->CreateEngineObject(rank);
SetPosition(3, D3DVECTOR(50.0f, 0.0f, 0.0f));
- SetAngleY(3, -60.0f*PI/180.0f);
+ SetAngleY(3, -60.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2416,7 +2416,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico5.mod");
pModFile->CreateEngineObject(rank);
SetPosition(4, D3DVECTOR(35.0f, 0.0f, 0.0f));
- SetAngleY(4, -55.0f*PI/180.0f);
+ SetAngleY(4, -55.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2425,7 +2425,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico3.mod");
pModFile->CreateEngineObject(rank);
SetPosition(5, D3DVECTOR(0.0f, 0.0f, 33.0f));
- SetAngleY(5, -45.0f*PI/180.0f);
+ SetAngleY(5, -45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2434,7 +2434,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico4.mod");
pModFile->CreateEngineObject(rank);
SetPosition(6, D3DVECTOR(50.0f, 0.0f, 0.0f));
- SetAngleY(6, 60.0f*PI/180.0f);
+ SetAngleY(6, 60.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2443,7 +2443,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico5.mod");
pModFile->CreateEngineObject(rank);
SetPosition(7, D3DVECTOR(35.0f, 0.0f, 0.0f));
- SetAngleY(7, 55.0f*PI/180.0f);
+ SetAngleY(7, 55.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2452,7 +2452,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico6.mod");
pModFile->CreateEngineObject(rank);
SetPosition(8, D3DVECTOR(-35.0f, 50.0f, -35.0f));
- SetAngleY(8, -PI/2.0f);
+ SetAngleY(8, -Math::PI/2.0f);
SetZoom(8, 2.0f);
rank = m_engine->CreateObject();
@@ -2470,7 +2470,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\portico6.mod");
pModFile->CreateEngineObject(rank);
SetPosition(10, D3DVECTOR(-35.0f, 50.0f, 35.0f));
- SetAngleY(10, -PI/2.0f);
+ SetAngleY(10, -Math::PI/2.0f);
SetZoom(10, 2.0f);
rank = m_engine->CreateObject();
@@ -2513,10 +2513,10 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
SetObjectParent(1+i, 0);
pModFile->ReadModel("objects\\base2.mod");
pModFile->CreateEngineObject(rank);
- p = RotatePoint(-PI/4.0f*i, 27.8f);
+ p = Math::RotatePoint(-Math::PI/4.0f*i, 27.8f);
SetPosition(1+i, D3DVECTOR(p.x, 30.0f, p.y));
- SetAngleY(1+i, PI/4.0f*i);
- SetAngleZ(1+i, PI/2.0f);
+ SetAngleY(1+i, Math::PI/4.0f*i);
+ SetAngleZ(1+i, Math::PI/2.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2617,7 +2617,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\search3.mod");
pModFile->CreateEngineObject(rank);
SetPosition(2, D3DVECTOR(0.0f, 4.0f, 0.0f));
- SetAngleZ(2, 35.0f*PI/180.0f);
+ SetAngleZ(2, 35.0f*Math::PI/180.0f);
CreateCrashSphere(D3DVECTOR(0.0f, 0.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(D3DVECTOR(0.0f, 6.0f, 0.0f), 9.0f, SOUND_BOUMm, 0.45f);
@@ -2652,7 +2652,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\radar3.mod");
pModFile->CreateEngineObject(rank);
SetPosition(2, D3DVECTOR(0.0f, 11.0f, 0.0f));
- SetAngleY(2, -PI/2.0f);
+ SetAngleY(2, -Math::PI/2.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2703,7 +2703,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->CreateEngineObject(rank);
SetPosition(3+i*2, D3DVECTOR(0.0f, 0.0f, -4.0f));
- SetAngleY(2+i*2, 2.0f*PI/3.0f*i);
+ SetAngleY(2+i*2, 2.0f*Math::PI/3.0f*i);
}
CreateCrashSphere(D3DVECTOR(0.0f, 3.0f, 0.0f), 6.0f, SOUND_BOUMm, 0.45f);
@@ -2747,7 +2747,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\labo2.mod");
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(-9.0f, 3.0f, 0.0f));
- SetAngleZ(1, PI/2.0f);
+ SetAngleZ(1, Math::PI/2.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2764,7 +2764,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\labo4.mod");
pModFile->CreateEngineObject(rank);
SetPosition(3, D3DVECTOR(0.0f, 0.0f, 0.0f));
- SetAngleZ(3, 80.0f*PI/180.0f);
+ SetAngleZ(3, 80.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2773,8 +2773,8 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\labo4.mod");
pModFile->CreateEngineObject(rank);
SetPosition(4, D3DVECTOR(0.0f, 0.0f, 0.0f));
- SetAngleZ(4, 80.0f*PI/180.0f);
- SetAngleY(4, PI*2.0f/3.0f);
+ SetAngleZ(4, 80.0f*Math::PI/180.0f);
+ SetAngleY(4, Math::PI*2.0f/3.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2783,8 +2783,8 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\labo4.mod");
pModFile->CreateEngineObject(rank);
SetPosition(5, D3DVECTOR(0.0f, 0.0f, 0.0f));
- SetAngleZ(5, 80.0f*PI/180.0f);
- SetAngleY(5, -PI*2.0f/3.0f);
+ SetAngleZ(5, 80.0f*Math::PI/180.0f);
+ SetAngleY(5, -Math::PI*2.0f/3.0f);
CreateCrashSphere(D3DVECTOR( 0.0f, 1.0f, 0.0f), 1.5f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(D3DVECTOR( 0.0f, 11.0f, 0.0f), 4.0f, SOUND_BOUMm, 0.45f);
@@ -2815,7 +2815,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\factory2.mod");
pModFile->CreateEngineObject(rank);
SetPosition(1+i, D3DVECTOR(10.0f, 2.0f*i, 10.0f));
- SetAngleZ(1+i, PI/2.0f);
+ SetAngleZ(1+i, Math::PI/2.0f);
SetZoomZ(1+i, 0.30f);
rank = m_engine->CreateObject();
@@ -2825,8 +2825,8 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\factory2.mod");
pModFile->CreateEngineObject(rank);
SetPosition(10+i, D3DVECTOR(10.0f, 2.0f*i, -10.0f));
- SetAngleZ(10+i, -PI/2.0f);
- SetAngleY(10+i, PI);
+ SetAngleZ(10+i, -Math::PI/2.0f);
+ SetAngleY(10+i, Math::PI);
SetZoomZ(10+i, 0.30f);
}
@@ -2873,7 +2873,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\repair2.mod");
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(-11.0f, 13.5f, 0.0f));
- SetAngleZ(1, PI/2.0f);
+ SetAngleZ(1, Math::PI/2.0f);
m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f);
@@ -2950,7 +2950,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\convert3.mod");
pModFile->CreateEngineObject(rank);
SetPosition(2, D3DVECTOR(0.0f, 11.5f, 0.0f));
- SetAngleX(2, -PI*0.35f);
+ SetAngleX(2, -Math::PI*0.35f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -2959,8 +2959,8 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\convert3.mod");
pModFile->CreateEngineObject(rank);
SetPosition(3, D3DVECTOR(0.0f, 11.5f, 0.0f));
- SetAngleY(3, PI);
- SetAngleX(3, -PI*0.35f);
+ SetAngleY(3, Math::PI);
+ SetAngleX(3, -Math::PI*0.35f);
m_terrain->AddBuildingLevel(pos, 7.0f, 9.0f, 1.0f, 0.5f);
@@ -2986,7 +2986,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\roller2c.mod");
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(0.0f, 20.0f, 0.0f));
- SetAngleZ(1, PI/2.0f);
+ SetAngleZ(1, Math::PI/2.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -3024,7 +3024,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\nuclear2.mod");
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(20.0f, 10.0f, 0.0f));
- SetAngleZ(1, 135.0f*PI/180.0f);
+ SetAngleZ(1, 135.0f*Math::PI/180.0f);
CreateCrashSphere(D3DVECTOR( 0.0f, 0.0f, 0.0f), 19.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(D3DVECTOR( 0.0f, 24.0f, 0.0f), 15.0f, SOUND_BOUMm, 0.45f);
@@ -3109,7 +3109,7 @@ bool CObject::CreateBuilding(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\huston2.mod");
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(0.0f, 39.0f, 30.0f));
- SetAngleY(1, -PI/2.0f);
+ SetAngleY(1, -Math::PI/2.0f);
SetZoom(1, 3.0f);
rank = m_engine->CreateObject();
@@ -3874,7 +3874,7 @@ bool CObject::CreateTeen(D3DVECTOR pos, float angle, float zoom, float height,
SetType(type);
- fShadow = Norm(1.0f-height/10.0f);
+ fShadow = Math::Norm(1.0f-height/10.0f);
if ( type == OBJECT_TEEN0 ) // orange pencil lg=10
{
@@ -4122,7 +4122,7 @@ bool CObject::CreateTeen(D3DVECTOR pos, float angle, float zoom, float height,
mat = RetWorldMatrix(0);
pos = Transform(*mat, D3DVECTOR(-56.0f, 22.0f, 0.0f));
- m_particule->CreateParticule(pos, D3DVECTOR(0.0f, 0.0f, 0.0f), FPOINT(20.0f, 20.0f), PARTISELY, 1.0f, 0.0f, 0.0f);
+ m_particule->CreateParticule(pos, D3DVECTOR(0.0f, 0.0f, 0.0f), Math::Point(20.0f, 20.0f), PARTISELY, 1.0f, 0.0f, 0.0f);
pos = Transform(*mat, D3DVECTOR(-65.0f, 40.0f, 0.0f));
color.r = 4.0f;
@@ -4413,7 +4413,7 @@ bool CObject::CreateTeen(D3DVECTOR pos, float angle, float zoom, float height,
mat = RetWorldMatrix(0);
pos = Transform(*mat, D3DVECTOR(0.0f, 50.0f, 0.0f));
- m_particule->CreateParticule(pos, D3DVECTOR(0.0f, 0.0f, 0.0f), FPOINT(100.0f, 100.0f), PARTISELY, 1.0f, 0.0f, 0.0f);
+ m_particule->CreateParticule(pos, D3DVECTOR(0.0f, 0.0f, 0.0f), Math::Point(100.0f, 100.0f), PARTISELY, 1.0f, 0.0f, 0.0f);
pos = Transform(*mat, D3DVECTOR(0.0f, 50.0f, 0.0f));
color.r = 4.0f;
@@ -4843,8 +4843,8 @@ bool CObject::CreateQuartz(D3DVECTOR pos, float angle, float height,
pos.y += 16.0f;
radius = 8.0f;
}
- m_particule->CreateParticule(pos, pos, FPOINT(2.0f, 2.0f), PARTIQUARTZ, 0.7f+Rand()*0.7f, radius, 0.0f);
- m_particule->CreateParticule(pos, pos, FPOINT(2.0f, 2.0f), PARTIQUARTZ, 0.7f+Rand()*0.7f, radius, 0.0f);
+ m_particule->CreateParticule(pos, pos, Math::Point(2.0f, 2.0f), PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
+ m_particule->CreateParticule(pos, pos, Math::Point(2.0f, 2.0f), PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
delete pModFile;
return true;
@@ -4995,8 +4995,8 @@ bool CObject::CreateRoot(D3DVECTOR pos, float angle, float height,
pModFile->ReadModel("objects\\root5.mod");
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(-5.0f, 28.0f, -4.0f));
- SetAngleX(1, -30.0f*PI/180.0f);
- SetAngleZ(1, 20.0f*PI/180.0f);
+ SetAngleX(1, -30.0f*Math::PI/180.0f);
+ SetAngleZ(1, 20.0f*Math::PI/180.0f);
CreateCrashSphere(D3DVECTOR( -7.0f, 2.0f, 3.0f), 4.0f, SOUND_BOUMv, 0.15f);
CreateCrashSphere(D3DVECTOR( 5.0f, 2.0f, -6.0f), 4.0f, SOUND_BOUMv, 0.15f);
@@ -5123,7 +5123,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pModFile->CreateEngineObject(rank);
SetPosition(6, D3DVECTOR(-3.0f, 1.8f, -4.0f));
- SetAngleX(6, -PI/2.0f);
+ SetAngleX(6, -Math::PI/2.0f);
// Creates the left-back wheel.
rank = m_engine->CreateObject();
@@ -5135,7 +5135,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pModFile->CreateEngineObject(rank);
SetPosition(7, D3DVECTOR(-3.0f, 1.0f, 3.0f));
- SetAngleY(7, PI-0.3f);
+ SetAngleY(7, Math::PI-0.3f);
SetAngleX(7, -0.3f);
// Creates the right-front wheel.
@@ -5160,7 +5160,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pModFile->CreateEngineObject(rank);
SetPosition(9, D3DVECTOR(2.0f, 1.0f, 3.0f));
- SetAngleY(9, PI-0.2f);
+ SetAngleY(9, Math::PI-0.2f);
SetAngleX(9, 0.2f);
CreateCrashSphere(D3DVECTOR(0.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f);
@@ -5181,7 +5181,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pModFile->CreateEngineObject(rank);
SetPosition(7, D3DVECTOR(-3.0f, 1.0f, 3.0f));
- SetAngleY(7, PI+0.3f);
+ SetAngleY(7, Math::PI+0.3f);
SetAngleX(7, 0.4f);
// Creates the left-front wheel.
@@ -5194,7 +5194,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pModFile->CreateEngineObject(rank);
SetPosition(9, D3DVECTOR(2.0f, 1.0f, 3.0f));
- SetAngleY(9, PI+0.3f);
+ SetAngleY(9, Math::PI+0.3f);
SetAngleX(9, -0.3f);
CreateCrashSphere(D3DVECTOR(0.0f, 2.8f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f);
@@ -5215,7 +5215,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(3.0f, 5.0f, -2.5f));
- SetAngleX(1, -PI*0.85f);
+ SetAngleX(1, -Math::PI*0.85f);
SetAngleY(1, -0.4f);
SetAngleZ(1, -0.1f);
@@ -5408,7 +5408,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pos.y += 4.0f;
SetPosition(0, pos);
- angle = RetAngleX(0)-PI*0.6f;
+ angle = RetAngleX(0)-Math::PI*0.6f;
SetAngleX(0, angle);
angle = RetAngleZ(0)-0.2f;
@@ -5490,7 +5490,7 @@ bool CObject::CreateRuin(D3DVECTOR pos, float angle, float height,
pos.y += 8.0f;
SetPosition(0, pos);
- angle = RetAngleX(0)+PI*0.4f;
+ angle = RetAngleX(0)+Math::PI*0.4f;
SetAngleX(0, angle);
}
@@ -5531,7 +5531,7 @@ bool CObject::CreateApollo(D3DVECTOR pos, float angle, ObjectType type)
SetObjectParent(i+1, 0);
pModFile->ReadModel("objects\\apollol2.mod");
pModFile->CreateEngineObject(rank);
- SetAngleY(i+1, PI/2.0f*i);
+ SetAngleY(i+1, Math::PI/2.0f*i);
}
rank = m_engine->CreateObject();
@@ -5606,8 +5606,8 @@ bool CObject::CreateApollo(D3DVECTOR pos, float angle, ObjectType type)
pModFile->ReadModel("objects\\apolloj2.mod"); // antenna
pModFile->CreateEngineObject(rank);
SetPosition(5, D3DVECTOR(5.5f, 8.8f, 2.0f));
- SetAngleY(5, -120.0f*PI/180.0f);
- SetAngleZ(5, 45.0f*PI/180.0f);
+ SetAngleY(5, -120.0f*Math::PI/180.0f);
+ SetAngleZ(5, 45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
m_engine->SetObjectType(rank, TYPEDESCENDANT);
@@ -5616,7 +5616,7 @@ bool CObject::CreateApollo(D3DVECTOR pos, float angle, ObjectType type)
pModFile->ReadModel("objects\\apolloj3.mod"); // camera
pModFile->CreateEngineObject(rank);
SetPosition(6, D3DVECTOR(5.5f, 2.8f, -2.0f));
- SetAngleY(6, 30.0f*PI/180.0f);
+ SetAngleY(6, 30.0f*Math::PI/180.0f);
CreateCrashSphere(D3DVECTOR( 3.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(D3DVECTOR(-3.0f, 2.0f, 0.0f), 5.0f, SOUND_BOUMm, 0.45f);
@@ -5677,8 +5677,8 @@ bool CObject::CreateApollo(D3DVECTOR pos, float angle, ObjectType type)
pModFile->ReadModel("objects\\apolloj2.mod"); // antenna
pModFile->CreateEngineObject(rank);
SetPosition(1, D3DVECTOR(0.0f, 5.0f, 0.0f));
- SetAngleY(1, -120.0f*PI/180.0f);
- SetAngleZ(1, 45.0f*PI/180.0f);
+ SetAngleY(1, -120.0f*Math::PI/180.0f);
+ SetAngleZ(1, 45.0f*Math::PI/180.0f);
CreateCrashSphere(D3DVECTOR(0.0f, 4.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.35f);
CreateShadowCircle(3.0f, 0.7f);
@@ -6049,7 +6049,7 @@ void CObject::UpdateEnergyMapping()
float limit[6];
int j;
- if ( Abs(m_energy-m_lastEnergy) < 0.01f ) return;
+ if ( fabs(m_energy-m_lastEnergy) < 0.01f ) return;
m_lastEnergy = m_energy;
ZeroMemory( &mat, sizeof(D3DMATERIAL7) );
@@ -6120,12 +6120,12 @@ bool CObject::EventProcess(const Event &event)
#if ADJUST_ARM
if ( m_bSelect )
{
- if ( event.param == 'X' ) debug_arm1 += 5.0f*PI/180.0f;
- if ( event.param == 'C' ) debug_arm1 -= 5.0f*PI/180.0f;
- if ( event.param == 'V' ) debug_arm2 += 5.0f*PI/180.0f;
- if ( event.param == 'B' ) debug_arm2 -= 5.0f*PI/180.0f;
- if ( event.param == 'N' ) debug_arm3 += 5.0f*PI/180.0f;
- if ( event.param == 'M' ) debug_arm3 -= 5.0f*PI/180.0f;
+ if ( event.param == 'X' ) debug_arm1 += 5.0f*Math::PI/180.0f;
+ if ( event.param == 'C' ) debug_arm1 -= 5.0f*Math::PI/180.0f;
+ if ( event.param == 'V' ) debug_arm2 += 5.0f*Math::PI/180.0f;
+ if ( event.param == 'B' ) debug_arm2 -= 5.0f*Math::PI/180.0f;
+ if ( event.param == 'N' ) debug_arm3 += 5.0f*Math::PI/180.0f;
+ if ( event.param == 'M' ) debug_arm3 -= 5.0f*Math::PI/180.0f;
if ( event.param == 'X' ||
event.param == 'C' ||
event.param == 'V' ||
@@ -6137,7 +6137,7 @@ bool CObject::EventProcess(const Event &event)
SetAngleZ(2, debug_arm2);
SetAngleZ(3, debug_arm3);
char s[100];
- sprintf(s, "a=%.2f b=%.2f c=%.2f", debug_arm1*180.0f/PI, debug_arm2*180.0f/PI, debug_arm3*180.0f/PI);
+ sprintf(s, "a=%.2f b=%.2f c=%.2f", debug_arm1*180.0f/Math::PI, debug_arm2*180.0f/Math::PI, debug_arm3*180.0f/Math::PI);
m_engine->SetInfoText(5, s);
}
}
@@ -6251,7 +6251,7 @@ void CObject::VirusFrame(float rTime)
{
ParticuleType type;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int r;
if ( !m_bVirusMode ) return; // healthy object?
@@ -6279,12 +6279,12 @@ void CObject::VirusFrame(float rTime)
if ( r == 9 ) type = PARTIVIRUS10;
pos = RetPosition(0);
- pos.x += (Rand()-0.5f)*10.0f;
- pos.z += (Rand()-0.5f)*10.0f;
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = Rand()*4.0f+4.0f;
- dim.x = Rand()*0.3f+0.3f;
+ pos.x += (Math::Rand()-0.5f)*10.0f;
+ pos.z += (Math::Rand()-0.5f)*10.0f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = Math::Rand()*4.0f+4.0f;
+ dim.x = Math::Rand()*0.3f+0.3f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, type, 3.0f);
@@ -6324,7 +6324,7 @@ void CObject::PartiFrame(float rTime)
}
angle = RetAngle(i);
- angle += rTime*PI*factor;
+ angle += rTime*Math::PI*factor;
SetAngle(i, angle);
}
}
@@ -6466,7 +6466,7 @@ void CObject::SetViewFromHere(D3DVECTOR &eye, float &dirH, float &dirV,
}
upVec = Transform(m_objectPart[0].matRotate, upVec);
- dirH = -(m_objectPart[part].angle.y+PI/2.0f);
+ dirH = -(m_objectPart[part].angle.y+Math::PI/2.0f);
dirV = 0.0f;
}
@@ -6711,7 +6711,7 @@ void CObject::StartDetectEffect(CObject *target, bool bFound)
{
D3DMATRIX* mat;
D3DVECTOR pos, goal;
- FPOINT dim;
+ Math::Point dim;
mat = RetWorldMatrix(0);
pos = Transform(*mat, D3DVECTOR(2.0f, 3.0f, 0.0f));
@@ -7118,8 +7118,8 @@ void CObject::SetGunGoalV(float gunGoal)
m_type == OBJECT_MOBILEwc ||
m_type == OBJECT_MOBILEic ) // fireball?
{
- if ( gunGoal > 10.0f*PI/180.0f ) gunGoal = 10.0f*PI/180.0f;
- if ( gunGoal < -20.0f*PI/180.0f ) gunGoal = -20.0f*PI/180.0f;
+ if ( gunGoal > 10.0f*Math::PI/180.0f ) gunGoal = 10.0f*Math::PI/180.0f;
+ if ( gunGoal < -20.0f*Math::PI/180.0f ) gunGoal = -20.0f*Math::PI/180.0f;
SetAngleZ(1, gunGoal);
}
else if ( m_type == OBJECT_MOBILEfi ||
@@ -7127,14 +7127,14 @@ void CObject::SetGunGoalV(float gunGoal)
m_type == OBJECT_MOBILEwi ||
m_type == OBJECT_MOBILEii ) // orgaball?
{
- if ( gunGoal > 20.0f*PI/180.0f ) gunGoal = 20.0f*PI/180.0f;
- if ( gunGoal < -20.0f*PI/180.0f ) gunGoal = -20.0f*PI/180.0f;
+ if ( gunGoal > 20.0f*Math::PI/180.0f ) gunGoal = 20.0f*Math::PI/180.0f;
+ if ( gunGoal < -20.0f*Math::PI/180.0f ) gunGoal = -20.0f*Math::PI/180.0f;
SetAngleZ(1, gunGoal);
}
else if ( m_type == OBJECT_MOBILErc ) // phazer?
{
- if ( gunGoal > 45.0f*PI/180.0f ) gunGoal = 45.0f*PI/180.0f;
- if ( gunGoal < -20.0f*PI/180.0f ) gunGoal = -20.0f*PI/180.0f;
+ if ( gunGoal > 45.0f*Math::PI/180.0f ) gunGoal = 45.0f*Math::PI/180.0f;
+ if ( gunGoal < -20.0f*Math::PI/180.0f ) gunGoal = -20.0f*Math::PI/180.0f;
SetAngleZ(2, gunGoal);
}
else
@@ -7152,8 +7152,8 @@ void CObject::SetGunGoalH(float gunGoal)
m_type == OBJECT_MOBILEwc ||
m_type == OBJECT_MOBILEic ) // fireball?
{
- if ( gunGoal > 40.0f*PI/180.0f ) gunGoal = 40.0f*PI/180.0f;
- if ( gunGoal < -40.0f*PI/180.0f ) gunGoal = -40.0f*PI/180.0f;
+ if ( gunGoal > 40.0f*Math::PI/180.0f ) gunGoal = 40.0f*Math::PI/180.0f;
+ if ( gunGoal < -40.0f*Math::PI/180.0f ) gunGoal = -40.0f*Math::PI/180.0f;
SetAngleY(1, gunGoal);
}
else if ( m_type == OBJECT_MOBILEfi ||
@@ -7161,14 +7161,14 @@ void CObject::SetGunGoalH(float gunGoal)
m_type == OBJECT_MOBILEwi ||
m_type == OBJECT_MOBILEii ) // orgaball?
{
- if ( gunGoal > 40.0f*PI/180.0f ) gunGoal = 40.0f*PI/180.0f;
- if ( gunGoal < -40.0f*PI/180.0f ) gunGoal = -40.0f*PI/180.0f;
+ if ( gunGoal > 40.0f*Math::PI/180.0f ) gunGoal = 40.0f*Math::PI/180.0f;
+ if ( gunGoal < -40.0f*Math::PI/180.0f ) gunGoal = -40.0f*Math::PI/180.0f;
SetAngleY(1, gunGoal);
}
else if ( m_type == OBJECT_MOBILErc ) // phazer?
{
- if ( gunGoal > 40.0f*PI/180.0f ) gunGoal = 40.0f*PI/180.0f;
- if ( gunGoal < -40.0f*PI/180.0f ) gunGoal = -40.0f*PI/180.0f;
+ if ( gunGoal > 40.0f*Math::PI/180.0f ) gunGoal = 40.0f*Math::PI/180.0f;
+ if ( gunGoal < -40.0f*Math::PI/180.0f ) gunGoal = -40.0f*Math::PI/180.0f;
SetAngleY(2, gunGoal);
}
else
@@ -7223,7 +7223,7 @@ bool CObject::IsProgram()
void CObject::CreateSelectParticule()
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int i;
// Removes particles preceding.
@@ -7285,7 +7285,7 @@ void CObject::CreateSelectParticule()
void CObject::UpdateSelectParticule()
{
D3DVECTOR pos[4];
- FPOINT dim[4];
+ Math::Point dim[4];
float zoom[4];
float angle;
int i;
@@ -7406,7 +7406,7 @@ void CObject::UpdateSelectParticule()
pos[3] = D3DVECTOR(-5.3f, 2.7f, -1.8f);
}
- angle = RetAngleY(0)/PI;
+ angle = RetAngleY(0)/Math::PI;
zoom[0] = 1.0f;
zoom[1] = 1.0f;
@@ -7414,7 +7414,7 @@ void CObject::UpdateSelectParticule()
zoom[3] = 1.0f;
if ( IsProgram() && // current program?
- Mod(m_aTime, 0.7f) < 0.3f )
+ Math::Mod(m_aTime, 0.7f) < 0.3f )
{
zoom[0] = 0.0f; // blinks
zoom[1] = 0.0f;
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index c3a7752..1408787 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -16,8 +16,6 @@
// robotmain.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -25,6 +23,8 @@
#include "CBot/CBotDll.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"
@@ -268,7 +268,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
m_movie->Flush();
m_movieInfoIndex = -1;
- m_tooltipPos = FPOINT(0.0f, 0.0f);
+ m_tooltipPos = Math::Point(0.0f, 0.0f);
m_tooltipName[0] = 0;
m_tooltipTime = 0.0f;
@@ -279,8 +279,8 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
FlushDisplayInfo();
m_fontSize = 9.0f;
- m_windowPos = FPOINT(0.15f, 0.17f);
- m_windowDim = FPOINT(0.70f, 0.66f);
+ m_windowPos = Math::Point(0.15f, 0.17f);
+ m_windowDim = Math::Point(0.70f, 0.66f);
if ( GetProfileFloat("Edit", "FontSize", fValue) ) m_fontSize = fValue;
if ( GetProfileFloat("Edit", "WindowPos.x", fValue) ) m_windowPos.x = fValue;
@@ -289,7 +289,7 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
if ( GetProfileFloat("Edit", "WindowDim.y", fValue) ) m_windowDim.y = fValue;
m_IOPublic = false;
- m_IODim = FPOINT(320.0f/640.0f, (121.0f+18.0f*8)/480.0f);
+ m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f);
m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle
m_IOPos.y = (1.0f-m_IODim.y)/2.0f;
@@ -443,7 +443,7 @@ void CRobotMain::ChangePhase(Phase phase)
CEdit* pe;
CButton* pb;
D3DCOLORVALUE color;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
char* read;
int rank, numTry;
@@ -1810,26 +1810,26 @@ float CRobotMain::RetFontSize()
// Managing the size of the default window.
-void CRobotMain::SetWindowPos(FPOINT pos)
+void CRobotMain::SetWindowPos(Math::Point pos)
{
m_windowPos = pos;
SetProfileFloat("Edit", "WindowPos.x", m_windowPos.x);
SetProfileFloat("Edit", "WindowPos.y", m_windowPos.y);
}
-FPOINT CRobotMain::RetWindowPos()
+Math::Point CRobotMain::RetWindowPos()
{
return m_windowPos;
}
-void CRobotMain::SetWindowDim(FPOINT dim)
+void CRobotMain::SetWindowDim(Math::Point dim)
{
m_windowDim = dim;
SetProfileFloat("Edit", "WindowDim.x", m_windowDim.x);
SetProfileFloat("Edit", "WindowDim.y", m_windowDim.y);
}
-FPOINT CRobotMain::RetWindowDim()
+Math::Point CRobotMain::RetWindowDim()
{
return m_windowDim;
}
@@ -1848,26 +1848,26 @@ bool CRobotMain::RetIOPublic()
return m_IOPublic;
}
-void CRobotMain::SetIOPos(FPOINT pos)
+void CRobotMain::SetIOPos(Math::Point pos)
{
m_IOPos = pos;
SetProfileFloat("Edit", "IOPos.x", m_IOPos.x);
SetProfileFloat("Edit", "IOPos.y", m_IOPos.y);
}
-FPOINT CRobotMain::RetIOPos()
+Math::Point CRobotMain::RetIOPos()
{
return m_IOPos;
}
-void CRobotMain::SetIODim(FPOINT dim)
+void CRobotMain::SetIODim(Math::Point dim)
{
m_IODim = dim;
SetProfileFloat("Edit", "IODim.x", m_IODim.x);
SetProfileFloat("Edit", "IODim.y", m_IODim.y);
}
-FPOINT CRobotMain::RetIODim()
+Math::Point CRobotMain::RetIODim()
{
return m_IODim;
}
@@ -1882,7 +1882,7 @@ void CRobotMain::StartDisplayVisit(EventMsg event)
CButton* button;
CGroup* group;
D3DVECTOR goal;
- FPOINT pos, dim;
+ Math::Point pos, dim;
int i, j;
if ( m_bEditLock ) return;
@@ -1979,7 +1979,7 @@ void CRobotMain::StartDisplayVisit(EventMsg event)
void CRobotMain::FrameVisit(float rTime)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float level;
if ( m_visitArrow == 0 ) return;
@@ -2363,7 +2363,7 @@ CObject* CRobotMain::SearchObject(ObjectType type)
// Detects the object aimed by the mouse.
-CObject* CRobotMain::DetectObject(FPOINT pos)
+CObject* CRobotMain::DetectObject(Math::Point pos)
{
ObjectType type;
CObject *pObj, *pTarget;
@@ -2641,7 +2641,7 @@ void CRobotMain::HiliteClear()
// Highlights the object with the mouse hovers over.
-void CRobotMain::HiliteObject(FPOINT pos)
+void CRobotMain::HiliteObject(Math::Point pos)
{
CObject* pObj;
char name[100];
@@ -2723,10 +2723,10 @@ void CRobotMain::HiliteFrame(float rTime)
// Creates a tooltip.
-void CRobotMain::CreateTooltip(FPOINT pos, char* text)
+void CRobotMain::CreateTooltip(Math::Point pos, char* text)
{
CWindow* pw;
- FPOINT start, end, dim, offset, corner;
+ Math::Point start, end, dim, offset, corner;
corner.x = pos.x+0.022f;
corner.y = pos.y-0.052f;
@@ -3139,7 +3139,7 @@ bool CRobotMain::EventFrame(const Event &event)
if ( m_bMovieLock && !m_bEditLock ) // movie in progress?
{
CControl* pc;
- FPOINT pos, dim;
+ Math::Point pos, dim;
float zoom;
pc = m_interface->SearchControl(EVENT_OBJECT_MOVIELOCK);
@@ -3165,7 +3165,7 @@ bool CRobotMain::EventFrame(const Event &event)
if ( m_bEditLock || m_bPause ) // edition in progress?
{
CControl* pc;
- FPOINT pos, dim;
+ Math::Point pos, dim;
float zoom;
pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
@@ -3800,13 +3800,13 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
OpString(line, "image", name);
UserDir(dir, name, "");
m_planet->Create(OpInt(line, "mode", 0),
- FPOINT(ppos.x, ppos.z),
+ Math::Point(ppos.x, ppos.z),
OpFloat(line, "dim", 0.2f),
OpFloat(line, "speed", 0.0f),
OpFloat(line, "dir", 0.0f),
dir,
- FPOINT(uv1.x, uv1.z),
- FPOINT(uv2.x, uv2.z));
+ Math::Point(uv1.x, uv1.z),
+ Math::Point(uv2.x, uv2.z));
}
if ( Cmd(line, "FrontsizeName") && !bResetObject )
@@ -4043,7 +4043,7 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
}
pos = OpPos(line, "pos")*g_unit;
- dir = OpFloat(line, "dir", 0.0f)*PI;
+ dir = OpFloat(line, "dir", 0.0f)*Math::PI;
pObj = CreateObject(pos, dir,
OpFloat(line, "z", 1.0f),
OpFloat(line, "h", 0.0f),
@@ -4195,7 +4195,7 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
if ( Cmd(line, "CreateFog") && !bResetObject )
{
ParticuleType type;
- FPOINT dim;
+ Math::Point dim;
float height, ddim, delay;
type = (ParticuleType)(PARTIFOG0+OpInt(line, "type", 0));
@@ -4307,7 +4307,7 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
offset = OpPos(line, "offset");
m_map->SetFixParam(OpFloat(line, "zoom", 1.0f),
offset.x, offset.z,
- OpFloat(line, "angle", 0.0f)*PI/180.0f,
+ OpFloat(line, "angle", 0.0f)*Math::PI/180.0f,
OpInt(line, "mode", 0),
OpInt(line, "debug", 0));
}
@@ -4340,7 +4340,7 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
{
m_camera->StartOver(OE_FADEINw, D3DVECTOR(0.0f, 0.0f, 0.0f), 1.0f);
}
- m_camera->SetFixDirection(OpFloat(line, "fixDirection", 0.25f)*PI);
+ m_camera->SetFixDirection(OpFloat(line, "fixDirection", 0.25f)*Math::PI);
}
if ( Cmd(line, "EndMissionTake") && !bResetObject )
@@ -4927,8 +4927,8 @@ int CRobotMain::CreateSpot(D3DVECTOR pos, D3DCOLORVALUE color)
light.dvDirection = D3DVECTOR(0.0f, -1.0f, 0.0f);
light.dvRange = D3DLIGHT_RANGE_MAX;
light.dvFalloff = 1.0f;
- light.dvTheta = 10.0f*PI/180.0f;
- light.dvPhi = 90.0f*PI/180.0f;
+ light.dvTheta = 10.0f*Math::PI/180.0f;
+ light.dvPhi = 90.0f*Math::PI/180.0f;
light.dvAttenuation0 = 2.0f;
light.dvAttenuation1 = 0.0f;
light.dvAttenuation2 = 0.0f;
@@ -4944,14 +4944,14 @@ int CRobotMain::CreateSpot(D3DVECTOR pos, D3DCOLORVALUE color)
void CRobotMain::ChangeColor()
{
D3DCOLORVALUE colorRef1, colorNew1, colorRef2, colorNew2;
- FPOINT ts, ti;
- FPOINT exclu[6];
+ Math::Point ts, ti;
+ Math::Point exclu[6];
char name[100];
int face;
float tolerance;
- ts = FPOINT(0.0f, 0.0f);
- ti = FPOINT(1.0f, 1.0f); // the entire image
+ ts = Math::Point(0.0f, 0.0f);
+ ti = Math::Point(1.0f, 1.0f); // the entire image
colorRef1.a = 0.0f;
colorRef2.a = 0.0f;
@@ -4964,12 +4964,12 @@ void CRobotMain::ChangeColor()
colorRef2.g = 132.0f/256.0f;
colorRef2.b = 1.0f/256.0f; // orange
colorNew2 = m_dialog->RetGamerColorBand();
- exclu[0] = FPOINT(192.0f/256.0f, 0.0f/256.0f);
- exclu[1] = FPOINT(256.0f/256.0f, 64.0f/256.0f); // crystals + cylinders
- exclu[2] = FPOINT(208.0f/256.0f, 224.0f/256.0f);
- exclu[3] = FPOINT(256.0f/256.0f, 256.0f/256.0f); // SatCom screen
- exclu[4] = FPOINT(0.0f, 0.0f);
- exclu[5] = FPOINT(0.0f, 0.0f); // terminator
+ exclu[0] = Math::Point(192.0f/256.0f, 0.0f/256.0f);
+ exclu[1] = Math::Point(256.0f/256.0f, 64.0f/256.0f); // crystals + cylinders
+ exclu[2] = Math::Point(208.0f/256.0f, 224.0f/256.0f);
+ exclu[3] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom screen
+ exclu[4] = Math::Point(0.0f, 0.0f);
+ exclu[5] = Math::Point(0.0f, 0.0f); // terminator
m_engine->ChangeColor("human.tga", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu);
face = RetGamerFace();
@@ -5009,10 +5009,10 @@ void CRobotMain::ChangeColor()
colorNew2.g = 0.0f;
colorNew2.b = 0.0f;
sprintf(name, "face%.2d.tga", face+1);
- exclu[0] = FPOINT(105.0f/256.0f, 47.0f/166.0f);
- exclu[1] = FPOINT(153.0f/256.0f, 79.0f/166.0f); // blue canister
- exclu[2] = FPOINT(0.0f, 0.0f);
- exclu[3] = FPOINT(0.0f, 0.0f); // terminator
+ exclu[0] = Math::Point(105.0f/256.0f, 47.0f/166.0f);
+ exclu[1] = Math::Point(153.0f/256.0f, 79.0f/166.0f); // blue canister
+ exclu[2] = Math::Point(0.0f, 0.0f);
+ exclu[3] = Math::Point(0.0f, 0.0f); // terminator
m_engine->ChangeColor(name, colorRef1, colorNew1, colorRef2, colorNew2, tolerance, 0.00f, ts, ti, exclu);
colorRef2.r = 0.0f;
@@ -5030,37 +5030,37 @@ void CRobotMain::ChangeColor()
m_engine->ChangeColor("roller.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
m_engine->ChangeColor("search.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
- exclu[0] = FPOINT( 0.0f/256.0f, 160.0f/256.0f);
- exclu[1] = FPOINT(256.0f/256.0f, 256.0f/256.0f); // pencils
- exclu[2] = FPOINT(0.0f, 0.0f);
- exclu[3] = FPOINT(0.0f, 0.0f); // terminator
+ exclu[0] = Math::Point( 0.0f/256.0f, 160.0f/256.0f);
+ exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // pencils
+ exclu[2] = Math::Point(0.0f, 0.0f);
+ exclu[3] = Math::Point(0.0f, 0.0f); // terminator
m_engine->ChangeColor("drawer.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
- exclu[0] = FPOINT(237.0f/256.0f, 176.0f/256.0f);
- exclu[1] = FPOINT(256.0f/256.0f, 220.0f/256.0f); // blue canister
- exclu[2] = FPOINT(106.0f/256.0f, 150.0f/256.0f);
- exclu[3] = FPOINT(130.0f/256.0f, 214.0f/256.0f); // safe location
- exclu[4] = FPOINT(0.0f, 0.0f);
- exclu[5] = FPOINT(0.0f, 0.0f); // terminator
+ exclu[0] = Math::Point(237.0f/256.0f, 176.0f/256.0f);
+ exclu[1] = Math::Point(256.0f/256.0f, 220.0f/256.0f); // blue canister
+ exclu[2] = Math::Point(106.0f/256.0f, 150.0f/256.0f);
+ exclu[3] = Math::Point(130.0f/256.0f, 214.0f/256.0f); // safe location
+ exclu[4] = Math::Point(0.0f, 0.0f);
+ exclu[5] = Math::Point(0.0f, 0.0f); // terminator
m_engine->ChangeColor("subm.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
- exclu[0] = FPOINT(128.0f/256.0f, 160.0f/256.0f);
- exclu[1] = FPOINT(256.0f/256.0f, 256.0f/256.0f); // SatCom
- exclu[2] = FPOINT(0.0f, 0.0f);
- exclu[3] = FPOINT(0.0f, 0.0f); // terminator
+ exclu[0] = Math::Point(128.0f/256.0f, 160.0f/256.0f);
+ exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom
+ exclu[2] = Math::Point(0.0f, 0.0f);
+ exclu[3] = Math::Point(0.0f, 0.0f); // terminator
m_engine->ChangeColor("ant.tga", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu);
m_engine->ChangeColor("mother.tga", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti);
m_engine->ChangeColor("plant.tga", m_colorRefGreen, m_colorNewGreen, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti);
// PARTIPLOUF0 and PARTIDROP :
- ts = FPOINT(0.500f, 0.500f);
- ti = FPOINT(0.875f, 0.750f);
+ ts = Math::Point(0.500f, 0.500f);
+ ti = Math::Point(0.875f, 0.750f);
m_engine->ChangeColor("effect00.tga", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
// PARTIFLIC :
- ts = FPOINT(0.00f, 0.75f);
- ti = FPOINT(0.25f, 1.00f);
+ ts = Math::Point(0.00f, 0.75f);
+ ti = Math::Point(0.25f, 1.00f);
m_engine->ChangeColor("effect02.tga", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
}
@@ -5130,7 +5130,7 @@ float CRobotMain::SearchNearestObject(D3DVECTOR center, CObject *exclu)
{
dist = Length(center, oPos)-80.0f;
if ( dist < 0.0f ) dist = 0.0f;
- min = Min(min, dist);
+ min = Math::Min(min, dist);
continue;
}
}
@@ -5142,7 +5142,7 @@ float CRobotMain::SearchNearestObject(D3DVECTOR center, CObject *exclu)
oPos = pObj->RetPosition(0);
dist = Length(center, oPos)-8.0f;
if ( dist < 0.0f ) dist = 0.0f;
- min = Min(min, dist);
+ min = Math::Min(min, dist);
}
j = 0;
@@ -5150,7 +5150,7 @@ float CRobotMain::SearchNearestObject(D3DVECTOR center, CObject *exclu)
{
dist = Length(center, oPos)-oRadius;
if ( dist < 0.0f ) dist = 0.0f;
- min = Min(min, dist);
+ min = Math::Min(min, dist);
}
}
return min;
@@ -5162,7 +5162,7 @@ bool CRobotMain::FreeSpace(D3DVECTOR &center, float minRadius, float maxRadius,
float space, CObject *exclu)
{
D3DVECTOR pos;
- FPOINT p;
+ Math::Point p;
float radius, ia, angle, dist, flat;
if ( minRadius < maxRadius ) // from internal to external?
@@ -5170,11 +5170,11 @@ bool CRobotMain::FreeSpace(D3DVECTOR &center, float minRadius, float maxRadius,
for ( radius=minRadius ; radius<=maxRadius ; radius+=space )
{
ia = space/radius;
- for ( angle=0.0f ; angle<PI*2.0f ; angle+=ia )
+ for ( angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia )
{
p.x = center.x+radius;
p.y = center.z;
- p = RotatePoint(FPOINT(center.x, center.z), angle, p);
+ p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p);
pos.x = p.x;
pos.z = p.y;
pos.y = 0.0f;
@@ -5197,11 +5197,11 @@ bool CRobotMain::FreeSpace(D3DVECTOR &center, float minRadius, float maxRadius,
for ( radius=maxRadius ; radius>=minRadius ; radius-=space )
{
ia = space/radius;
- for ( angle=0.0f ; angle<PI*2.0f ; angle+=ia )
+ for ( angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia )
{
p.x = center.x+radius;
p.y = center.z;
- p = RotatePoint(FPOINT(center.x, center.z), angle, p);
+ p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p);
pos.x = p.x;
pos.z = p.y;
pos.y = 0.0f;
@@ -5287,7 +5287,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
{
oPos = pObj->RetPosition(0);
dist = Length(center, oPos)-80.0f;
- oMax = Min(oMax, dist);
+ oMax = Math::Min(oMax, dist);
}
else
{
@@ -5295,7 +5295,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
{
dist = Length(center, oPos)-oRadius;
- oMax = Min(oMax, dist);
+ oMax = Math::Min(oMax, dist);
}
}
@@ -5322,7 +5322,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
{
dist = Length(center, oPos)-oRadius-BUILDMARGIN;
- oMax = Min(oMax, dist);
+ oMax = Math::Min(oMax, dist);
}
}
}
@@ -5337,7 +5337,7 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
tMax = 0.0f;
}
- radius = Min(oMax, tMax);
+ radius = Math::Min(oMax, tMax);
if ( radius >= 2.0f )
{
SetShowLimit(1, PARTILIMIT2, metal, center, radius, 10.0f);
@@ -5373,7 +5373,7 @@ void CRobotMain::FlushShowLimit(int i)
void CRobotMain::SetShowLimit(int i, ParticuleType parti, CObject *pObj,
D3DVECTOR pos, float radius, float duration)
{
- FPOINT dim;
+ Math::Point dim;
float dist;
int j;
@@ -5383,12 +5383,12 @@ void CRobotMain::SetShowLimit(int i, ParticuleType parti, CObject *pObj,
if ( radius <= 50.0f )
{
- dim = FPOINT(0.3f, 0.3f);
+ dim = Math::Point(0.3f, 0.3f);
dist = 2.5f;
}
else
{
- dim = FPOINT(1.5f, 1.5f);
+ dim = Math::Point(1.5f, 1.5f);
dist = 10.0f;
}
@@ -5397,7 +5397,7 @@ void CRobotMain::SetShowLimit(int i, ParticuleType parti, CObject *pObj,
m_showLimit[i].pos = pos;
m_showLimit[i].radius = radius;
m_showLimit[i].duration = duration;
- m_showLimit[i].total = (int)((radius*2.0f*PI)/dist);
+ m_showLimit[i].total = (int)((radius*2.0f*Math::PI)/dist);
if ( m_showLimit[i].total > MAXSHOWPARTI ) m_showLimit[i].total = MAXSHOWPARTI;
m_showLimit[i].time = 0.0f;
@@ -5431,7 +5431,7 @@ void CRobotMain::StartShowLimit()
void CRobotMain::FrameShowLimit(float rTime)
{
D3DVECTOR pos;
- FPOINT center, rotate;
+ Math::Point center, rotate;
float angle, factor, speed;
int i, j;
@@ -5474,7 +5474,7 @@ void CRobotMain::FrameShowLimit(float rTime)
center.y = m_showLimit[i].pos.z;
rotate.x = center.x+m_showLimit[i].radius*factor;
rotate.y = center.y;
- rotate = RotatePoint(center, angle, rotate);
+ rotate = Math::RotatePoint(center, angle, rotate);
pos.x = rotate.x;
pos.z = rotate.y;
@@ -5483,9 +5483,9 @@ void CRobotMain::FrameShowLimit(float rTime)
if ( m_showLimit[i].radius <= 50.0f ) pos.y += 0.5f;
else pos.y += 2.0f;
m_particule->SetPosition(m_showLimit[i].parti[j], pos);
-//? m_particule->SetAngle(m_showLimit[i].parti[j], angle-PI/2.0f);
+//? m_particule->SetAngle(m_showLimit[i].parti[j], angle-Math::PI/2.0f);
- angle += (2.0f*PI)/m_showLimit[i].total;
+ angle += (2.0f*Math::PI)/m_showLimit[i].total;
}
}
}
@@ -5889,7 +5889,7 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* pObj, char *cmd)
sprintf(name, " pos=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
- pos = pObj->RetAngle(0)/(PI/180.0f);
+ pos = pObj->RetAngle(0)/(Math::PI/180.0f);
sprintf(name, " angle=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
@@ -5912,7 +5912,7 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* pObj, char *cmd)
pos = pObj->RetAngle(i);
if ( pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f )
{
- pos /= (PI/180.0f);
+ pos /= (Math::PI/180.0f);
sprintf(name, " a%d=%.2f;%.2f;%.2f", i, pos.x, pos.y, pos.z);
strcat(line, name);
}
@@ -6081,7 +6081,7 @@ CObject* CRobotMain::IOReadObject(char *line, char* filename, int objRank)
char op[10];
pos = OpDir(line, "pos")*g_unit;
- dir = OpDir(line, "angle")*(PI/180.0f);
+ dir = OpDir(line, "angle")*(Math::PI/180.0f);
zoom = OpDir(line, "zoom");
type = OpTypeObject(line, "type", OBJECT_NULL);
id = OpInt(line, "id", 0);
@@ -6116,7 +6116,7 @@ CObject* CRobotMain::IOReadObject(char *line, char* filename, int objRank)
dir = OpDir(line, op);
if ( dir.x != 0.0f || dir.y != 0.0f || dir.z != 0.0f )
{
- pObj->SetAngle(i, dir*(PI/180.0f));
+ pObj->SetAngle(i, dir*(Math::PI/180.0f));
}
sprintf(op, "z%d", i);
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 73f7bfc..38f9e3e 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -19,8 +19,10 @@
#pragma once
+#include <stdio.h>
+
+#include "common/misc.h"
#include "graphics/d3d/d3dengine.h"
-#include "common/struct.h"
#include "object/object.h"
#include "graphics/common/mainmovie.h"
#include "graphics/common/camera.h"
@@ -210,17 +212,17 @@ public:
void SetFontSize(float size);
float RetFontSize();
- void SetWindowPos(FPOINT pos);
- FPOINT RetWindowPos();
- void SetWindowDim(FPOINT dim);
- FPOINT RetWindowDim();
+ void SetWindowPos(Math::Point pos);
+ Math::Point RetWindowPos();
+ void SetWindowDim(Math::Point dim);
+ Math::Point RetWindowDim();
void SetIOPublic(bool bMode);
bool RetIOPublic();
- void SetIOPos(FPOINT pos);
- FPOINT RetIOPos();
- void SetIODim(FPOINT dim);
- FPOINT RetIODim();
+ void SetIOPos(Math::Point pos);
+ Math::Point RetIOPos();
+ void SetIODim(Math::Point dim);
+ Math::Point RetIODim();
char* RetTitle();
char* RetResume();
@@ -300,11 +302,11 @@ protected:
CObject* CreateObject(D3DVECTOR pos, float angle, float zoom, float height, ObjectType type, float power=1.0f, bool bTrainer=false, bool bToy=false, int option=0);
int CreateLight(D3DVECTOR direction, D3DCOLORVALUE color);
void HiliteClear();
- void HiliteObject(FPOINT pos);
+ void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime);
- void CreateTooltip(FPOINT pos, char* text);
+ void CreateTooltip(Math::Point pos, char* text);
void ClearTooltip();
- CObject* DetectObject(FPOINT pos);
+ CObject* DetectObject(Math::Point pos);
void ChangeCamera();
void RemoteCamera(float pan, float zoom, float rTime);
void KeyCamera(EventMsg event, long param);
@@ -352,7 +354,7 @@ protected:
float m_lostDelay;
bool m_bFixScene; // scene fixed, no interraction
bool m_bBase; // OBJECT_BASE exists in mission
- FPOINT m_lastMousePos;
+ Math::Point m_lastMousePos;
CObject* m_selectObject;
Phase m_phase;
@@ -387,7 +389,7 @@ protected:
bool m_bMapImage;
char m_mapFilename[100];
- FPOINT m_tooltipPos;
+ Math::Point m_tooltipPos;
char m_tooltipName[100];
float m_tooltipTime;
@@ -406,12 +408,12 @@ protected:
bool m_bWinTerminate;
float m_fontSize;
- FPOINT m_windowPos;
- FPOINT m_windowDim;
+ Math::Point m_windowPos;
+ Math::Point m_windowDim;
bool m_IOPublic;
- FPOINT m_IOPos;
- FPOINT m_IODim;
+ Math::Point m_IOPos;
+ Math::Point m_IODim;
NewScriptName m_newScriptName[MAXNEWSCRIPTNAME];
diff --git a/src/object/task/task.cpp b/src/object/task/task.cpp
index 4be6067..ae92db5 100644
--- a/src/object/task/task.cpp
+++ b/src/object/task/task.cpp
@@ -16,8 +16,6 @@
// task.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/object/task/task.h b/src/object/task/task.h
index 97ac819..1d123a3 100644
--- a/src/object/task/task.h
+++ b/src/object/task/task.h
@@ -20,7 +20,7 @@
#include "common/misc.h"
-#include "math/old/math3d.h"
+#include "math/const.h"
class CInstanceManager;
@@ -43,16 +43,16 @@ class CSound;
const float TAKE_DIST = 6.0f; // distance to an object to pick it
const float TAKE_DIST_OTHER = 1.5f; // additional distance if on friend
-//?const float ARM_NEUTRAL_ANGLE1 = 155.0f*PI/180.0f;
-//?const float ARM_NEUTRAL_ANGLE2 = -125.0f*PI/180.0f;
-//?const float ARM_NEUTRAL_ANGLE3 = -45.0f*PI/180.0f;
-const float ARM_NEUTRAL_ANGLE1 = 110.0f*PI/180.0f;
-const float ARM_NEUTRAL_ANGLE2 = -130.0f*PI/180.0f;
-const float ARM_NEUTRAL_ANGLE3 = -50.0f*PI/180.0f;
+//?const float ARM_NEUTRAL_ANGLE1 = 155.0f*Math::PI/180.0f;
+//?const float ARM_NEUTRAL_ANGLE2 = -125.0f*Math::PI/180.0f;
+//?const float ARM_NEUTRAL_ANGLE3 = -45.0f*Math::PI/180.0f;
+const float ARM_NEUTRAL_ANGLE1 = 110.0f*Math::PI/180.0f;
+const float ARM_NEUTRAL_ANGLE2 = -130.0f*Math::PI/180.0f;
+const float ARM_NEUTRAL_ANGLE3 = -50.0f*Math::PI/180.0f;
-const float ARM_STOCK_ANGLE1 = 110.0f*PI/180.0f;
-const float ARM_STOCK_ANGLE2 = -100.0f*PI/180.0f;
-const float ARM_STOCK_ANGLE3 = -70.0f*PI/180.0f;
+const float ARM_STOCK_ANGLE1 = 110.0f*Math::PI/180.0f;
+const float ARM_STOCK_ANGLE2 = -100.0f*Math::PI/180.0f;
+const float ARM_STOCK_ANGLE3 = -70.0f*Math::PI/180.0f;
class CTask
diff --git a/src/object/task/taskadvance.cpp b/src/object/task/taskadvance.cpp
index 41b1602..8387dbe 100644
--- a/src/object/task/taskadvance.cpp
+++ b/src/object/task/taskadvance.cpp
@@ -16,8 +16,6 @@
// taskadvance.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -81,7 +79,7 @@ bool CTaskAdvance::EventProcess(const Event &event)
Error CTaskAdvance::Start(float length)
{
m_direction = (length>=0.0f)?1.0f:-1.0f;
- m_totalLength = Abs(length);
+ m_totalLength = fabs(length);
m_advanceLength = m_physics->RetLinLength(length);
m_startPos = m_object->RetPosition(0);
m_lastDist = 0.0f;
diff --git a/src/object/task/taskadvance.h b/src/object/task/taskadvance.h
index 2b2dcef..ee7346f 100644
--- a/src/object/task/taskadvance.h
+++ b/src/object/task/taskadvance.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index 77ee14d..a031ade 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -16,14 +16,13 @@
// taskbuild.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -129,7 +128,7 @@ void CTaskBuild::CreateLight()
D3DLIGHT7 light;
D3DCOLORVALUE color;
D3DVECTOR center, pos, dir;
- FPOINT c, p;
+ Math::Point c, p;
float angle;
int i;
@@ -147,7 +146,7 @@ void CTaskBuild::CreateLight()
c.y = center.z;
p.x = center.x+40.0f;
p.y = center.z;
- p = RotatePoint(c, angle, p);
+ p = Math::RotatePoint(c, angle, p);
pos.x = p.x;
pos.z = p.y;
pos.y = center.y+40.0f;
@@ -170,7 +169,7 @@ void CTaskBuild::CreateLight()
light.dvAttenuation1 = 0.0f;
light.dvAttenuation2 = 0.0f;
light.dvTheta = 0.0f;
- light.dvPhi = PI/4.0f;
+ light.dvPhi = Math::PI/4.0f;
m_light->SetLight(m_lightRank[i], light);
color.r = -1.0f;
@@ -180,7 +179,7 @@ void CTaskBuild::CreateLight()
m_light->SetLightColor(m_lightRank[i], color);
m_light->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.25f));
- angle += (PI*2.0f)/TBMAXLIGHT;
+ angle += (Math::PI*2.0f)/TBMAXLIGHT;
}
m_bBlack = false;
@@ -214,7 +213,7 @@ bool CTaskBuild::EventProcess(const Event &event)
{
D3DMATRIX* mat;
D3DVECTOR pos, dir, speed;
- FPOINT dim;
+ Math::Point dim;
float a, g, cirSpeed, dist, linSpeed;
if ( m_engine->RetPause() ) return true;
@@ -229,7 +228,7 @@ bool CTaskBuild::EventProcess(const Event &event)
{
a = m_object->RetAngleY(0);
g = m_angleY;
- cirSpeed = Direction(a, g)*1.0f;
+ cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
@@ -274,13 +273,13 @@ bool CTaskBuild::EventProcess(const Event &event)
pos = m_metal->RetPosition(0);
a = m_object->RetAngleY(0);
- if ( !CreateBuilding(pos, a+PI) )
+ if ( !CreateBuilding(pos, a+Math::PI) )
{
m_metal->SetLock(false); // usable again
m_motion->SetAction(-1);
m_object->SetObjectParent(14, 0);
m_object->SetPosition(14, D3DVECTOR(-1.5f, 0.3f, -1.35f));
- m_object->SetAngleZ(14, PI);
+ m_object->SetAngleZ(14, Math::PI);
m_camera->FlushEffect();
Abort();
m_bError = true;
@@ -299,9 +298,9 @@ bool CTaskBuild::EventProcess(const Event &event)
a = (2.0f-2.0f*m_progress);
if ( a > 1.0f ) a = 1.0f;
- dir.x = (Rand()-0.5f)*a*0.1f;
- dir.z = (Rand()-0.5f)*a*0.1f;
- dir.y = (Rand()-0.5f)*a*0.1f;
+ dir.x = (Math::Rand()-0.5f)*a*0.1f;
+ dir.z = (Math::Rand()-0.5f)*a*0.1f;
+ dir.y = (Math::Rand()-0.5f)*a*0.1f;
m_building->SetCirVibration(dir);
if ( !m_bBlack && m_progress >= 0.25f )
@@ -314,10 +313,10 @@ bool CTaskBuild::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_metal->RetPosition(0);
- speed.x = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
- speed.y = Rand()*10.0f;
- dim.x = Rand()*6.0f+4.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
+ speed.y = Math::Rand()*10.0f;
+ dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFIRE);
@@ -325,16 +324,16 @@ bool CTaskBuild::EventProcess(const Event &event)
mat = m_object->RetWorldMatrix(14);
pos = Transform(*mat, pos);
speed = m_metal->RetPosition(0);
- speed.x += (Rand()-0.5f)*5.0f;
- speed.z += (Rand()-0.5f)*5.0f;
+ speed.x += (Math::Rand()-0.5f)*5.0f;
+ speed.z += (Math::Rand()-0.5f)*5.0f;
speed -= pos;
dim.x = 2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ);
- if ( Rand() < 0.3f )
+ if ( Math::Rand() < 0.3f )
{
- m_sound->Play(SOUND_BUILD, m_object->RetPosition(0), 0.5f, 1.0f*Rand()*1.5f);
+ m_sound->Play(SOUND_BUILD, m_object->RetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f);
}
}
@@ -355,7 +354,7 @@ Error CTaskBuild::Start(ObjectType type)
m_progress = 0.0f;
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
m_bError = true; // operation impossible
@@ -371,7 +370,7 @@ Error CTaskBuild::Start(ObjectType type)
if ( m_object->RetFret() != 0 ) return ERR_MANIP_BUSY;
- m_metal = SearchMetalObject(oAngle, 2.0f, 100.0f, PI*0.25f, err);
+ m_metal = SearchMetalObject(oAngle, 2.0f, 100.0f, Math::PI*0.25f, err);
if ( err == ERR_BUILD_METALNEAR && m_metal != 0 )
{
err = FlatFloor();
@@ -384,7 +383,7 @@ Error CTaskBuild::Start(ObjectType type)
if ( err != ERR_OK ) return err;
m_metal->SetLock(true); // not usable
- m_camera->StartCentering(m_object, PI*0.15f, 99.9f, 0.0f, 1.0f);
+ m_camera->StartCentering(m_object, Math::PI*0.15f, 99.9f, 0.0f, 1.0f);
m_phase = TBP_TURN; // rotation necessary preliminary
m_angleY = oAngle; // angle was reached
@@ -392,7 +391,7 @@ Error CTaskBuild::Start(ObjectType type)
pv = m_object->RetPosition(0);
pv.y += 8.3f;
pm = m_metal->RetPosition(0);
- m_angleZ = RotateAngle(Length2d(pv, pm), Abs(pv.y-pm.y));
+ m_angleZ = Math::RotateAngle(Length2d(pv, pm), fabs(pv.y-pm.y));
m_physics->SetFreeze(true); // it does not move
@@ -414,9 +413,9 @@ Error CTaskBuild::IsEnded()
if ( m_phase == TBP_TURN ) // preliminary rotation?
{
angle = m_object->RetAngleY(0);
- angle = NormAngle(angle); // 0..2*PI
+ angle = Math::NormAngle(angle); // 0..2*Math::PI
- if ( TestAngle(angle, m_angleY-PI*0.01f, m_angleY+PI*0.01f) )
+ if ( Math::TestAngle(angle, m_angleY-Math::PI*0.01f, m_angleY+Math::PI*0.01f) )
{
m_physics->SetMotorSpeedZ(0.0f);
@@ -527,7 +526,7 @@ Error CTaskBuild::IsEnded()
m_motion->SetAction(-1);
m_object->SetObjectParent(14, 0);
m_object->SetPosition(14, D3DVECTOR(-1.5f, 0.3f, -1.35f));
- m_object->SetAngleZ(14, PI);
+ m_object->SetAngleZ(14, Math::PI);
if ( m_type == OBJECT_FACTORY ||
m_type == OBJECT_RESEARCH ||
@@ -576,7 +575,7 @@ Error CTaskBuild::FlatFloor()
CObject *pObj;
ObjectType type;
D3DVECTOR center, pos, oPos, bPos;
- FPOINT c, p;
+ Math::Point c, p;
float radius, max, oRadius, bRadius, angle, dist;
int i, j;
bool bLittleFlat, bBase;
@@ -727,7 +726,7 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
min = 1000000.0f;
pBest = 0;
@@ -747,10 +746,10 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
oPos = pObj->RetPosition(0);
distance = Length(oPos, iPos);
- a = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW!
+ a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW!
if ( distance > dMax ) continue;
- if ( !TestAngle(a, iAngle-aLimit, iAngle+aLimit) ) continue;
+ if ( !Math::TestAngle(a, iAngle-aLimit, iAngle+aLimit) ) continue;
if ( distance < dMin )
{
@@ -758,8 +757,8 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
return pObj;
}
- aa = Abs(a-iAngle);
- if ( aa > PI ) aa = PI*2.0f-aa;
+ aa = fabs(a-iAngle);
+ if ( aa > Math::PI ) aa = Math::PI*2.0f-aa;
magic = distance*aa;
if ( magic < min )
diff --git a/src/object/task/taskbuild.h b/src/object/task/taskbuild.h
index 1cced56..44698bd 100644
--- a/src/object/task/taskbuild.h
+++ b/src/object/task/taskbuild.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "object/object.h"
diff --git a/src/object/task/taskfire.cpp b/src/object/task/taskfire.cpp
index 81becda..a470933 100644
--- a/src/object/task/taskfire.cpp
+++ b/src/object/task/taskfire.cpp
@@ -16,8 +16,6 @@
// taskfire.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -75,7 +73,7 @@ bool CTaskFire::EventProcess(const Event &event)
D3DMATRIX* mat;
D3DVECTOR pos, speed, dir, vib;
ObjectType type;
- FPOINT dim;
+ Math::Point dim;
float energy, fire;
int i, channel;
@@ -119,13 +117,13 @@ bool CTaskFire::EventProcess(const Event &event)
speed += physics->RetLinMotion(MO_REASPEED);
}
- speed.x += (Rand()-0.5f)*10.0f;
- speed.y += (Rand()-0.5f)*20.0f;
- speed.z += (Rand()-0.5f)*30.0f;
+ speed.x += (Math::Rand()-0.5f)*10.0f;
+ speed.y += (Math::Rand()-0.5f)*20.0f;
+ speed.z += (Math::Rand()-0.5f)*30.0f;
speed = Transform(*mat, speed);
speed -= pos;
- dim.x = Rand()*0.5f+0.5f;
+ dim.x = Math::Rand()*0.5f+0.5f;
dim.y = dim.x;
channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN4, 0.8f, 0.0f, 0.0f);
@@ -144,9 +142,9 @@ bool CTaskFire::EventProcess(const Event &event)
pos = Transform(*mat, pos);
speed = D3DVECTOR(200.0f, 0.0f, 0.0f);
- speed.x += (Rand()-0.5f)*6.0f;
- speed.y += (Rand()-0.5f)*12.0f;
- speed.z += (Rand()-0.5f)*12.0f;
+ speed.x += (Math::Rand()-0.5f)*6.0f;
+ speed.y += (Math::Rand()-0.5f)*12.0f;
+ speed.z += (Math::Rand()-0.5f)*12.0f;
speed = Transform(*mat, speed);
speed -= pos;
@@ -157,9 +155,9 @@ bool CTaskFire::EventProcess(const Event &event)
m_particule->SetObjectFather(channel, m_object);
speed = D3DVECTOR(5.0f, 0.0f, 0.0f);
- speed.x += (Rand()-0.5f)*1.0f;
- speed.y += (Rand()-0.5f)*2.0f;
- speed.z += (Rand()-0.5f)*2.0f;
+ speed.x += (Math::Rand()-0.5f)*1.0f;
+ speed.y += (Math::Rand()-0.5f)*2.0f;
+ speed.z += (Math::Rand()-0.5f)*2.0f;
speed = Transform(*mat, speed);
speed -= pos;
speed.y += 5.0f;
@@ -192,8 +190,8 @@ bool CTaskFire::EventProcess(const Event &event)
{
pos = D3DVECTOR(3.0f, 1.0f, 0.0f);
}
- pos.y += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.y += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
pos = Transform(*mat, pos);
speed = D3DVECTOR(200.0f, 0.0f, 0.0f);
@@ -204,13 +202,13 @@ bool CTaskFire::EventProcess(const Event &event)
speed += physics->RetLinMotion(MO_REASPEED);
}
- speed.x += (Rand()-0.5f)*3.0f;
- speed.y += (Rand()-0.5f)*6.0f;
- speed.z += (Rand()-0.5f)*6.0f;
+ speed.x += (Math::Rand()-0.5f)*3.0f;
+ speed.y += (Math::Rand()-0.5f)*6.0f;
+ speed.z += (Math::Rand()-0.5f)*6.0f;
speed = Transform(*mat, speed);
speed -= pos;
- dim.x = Rand()*0.7f+0.7f;
+ dim.x = Math::Rand()*0.7f+0.7f;
dim.y = dim.x;
channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN1, 0.8f, 0.0f, 0.0f);
@@ -221,18 +219,18 @@ bool CTaskFire::EventProcess(const Event &event)
m_progress > 0.3f )
{
pos = D3DVECTOR(-1.0f, 1.0f, 0.0f);
- pos.y += (Rand()-0.5f)*0.4f;
- pos.z += (Rand()-0.5f)*0.4f;
+ pos.y += (Math::Rand()-0.5f)*0.4f;
+ pos.z += (Math::Rand()-0.5f)*0.4f;
pos = Transform(*mat, pos);
speed = D3DVECTOR(-4.0f, 0.0f, 0.0f);
- speed.x += (Rand()-0.5f)*2.0f;
- speed.y += (Rand()-0.2f)*4.0f;
- speed.z += (Rand()-0.5f)*4.0f;
+ speed.x += (Math::Rand()-0.5f)*2.0f;
+ speed.y += (Math::Rand()-0.2f)*4.0f;
+ speed.z += (Math::Rand()-0.5f)*4.0f;
speed = Transform(*mat, speed);
speed -= pos;
- dim.x = Rand()*1.2f+1.2f;
+ dim.x = Math::Rand()*1.2f+1.2f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f);
@@ -243,32 +241,32 @@ bool CTaskFire::EventProcess(const Event &event)
dir = D3DVECTOR(0.0f, 0.0f, 0.0f);
if ( m_progress < 0.1f )
{
- dir.z = (PI*0.04f)*(m_progress*10.0f);
+ dir.z = (Math::PI*0.04f)*(m_progress*10.0f);
}
else if ( m_progress < 0.9f )
{
- dir.z = (PI*0.04f);
+ dir.z = (Math::PI*0.04f);
}
else
{
- dir.z = (PI*0.04f)*(1.0f-(m_progress-0.9f)*10.0f);
+ dir.z = (Math::PI*0.04f)*(1.0f-(m_progress-0.9f)*10.0f);
}
m_object->SetInclinaison(dir);
- vib.x = (Rand()-0.5f)*0.01f;
- vib.y = (Rand()-0.5f)*0.02f;
- vib.z = (Rand()-0.5f)*0.02f;
+ vib.x = (Math::Rand()-0.5f)*0.01f;
+ vib.y = (Math::Rand()-0.5f)*0.02f;
+ vib.z = (Math::Rand()-0.5f)*0.02f;
m_object->SetCirVibration(vib);
- vib.x = (Rand()-0.5f)*0.20f;
- vib.y = (Rand()-0.5f)*0.05f;
- vib.z = (Rand()-0.5f)*0.20f;
+ vib.x = (Math::Rand()-0.5f)*0.20f;
+ vib.y = (Math::Rand()-0.5f)*0.05f;
+ vib.z = (Math::Rand()-0.5f)*0.20f;
m_object->SetLinVibration(vib);
}
if ( m_bRay && m_lastSound <= 0.0f )
{
- m_lastSound = Rand()*0.4f+0.4f;
+ m_lastSound = Math::Rand()*0.4f+0.4f;
m_sound->Play(SOUND_FIREp, m_object->RetPosition(0));
}
@@ -337,7 +335,7 @@ Error CTaskFire::Start(float delay)
m_lastSound = 0.0f;
m_bError = false; // ok
-//? m_camera->StartCentering(m_object, PI*0.15f, 99.9f, 0.0f, 1.0f);
+//? m_camera->StartCentering(m_object, Math::PI*0.15f, 99.9f, 0.0f, 1.0f);
if ( m_bOrganic )
{
diff --git a/src/object/task/taskfire.h b/src/object/task/taskfire.h
index f3d4490..507979f 100644
--- a/src/object/task/taskfire.h
+++ b/src/object/task/taskfire.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
class CInstanceManager;
diff --git a/src/object/task/taskfireant.cpp b/src/object/task/taskfireant.cpp
index 6f3b9c9..0c7aaf6 100644
--- a/src/object/task/taskfireant.cpp
+++ b/src/object/task/taskfireant.cpp
@@ -16,14 +16,13 @@
// taskfireant.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "math/old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
@@ -81,7 +80,7 @@ bool CTaskFireAnt::EventProcess(const Event &event)
{
a = m_object->RetAngleY(0);
g = m_angle;
- cirSpeed = Direction(a, g)*2.0f;
+ cirSpeed = Math::Direction(a, g)*2.0f;
if ( cirSpeed > 2.0f ) cirSpeed = 2.0f;
if ( cirSpeed < -2.0f ) cirSpeed = -2.0f;
@@ -113,7 +112,7 @@ Error CTaskFireAnt::Start(D3DVECTOR impact)
m_physics->SetMotorSpeed(D3DVECTOR(0.0f, 0.0f, 0.0f));
pos = m_object->RetPosition(0);
- m_angle = RotateAngle(m_impact.x-pos.x, pos.z-m_impact.z); // CW !
+ m_angle = Math::RotateAngle(m_impact.x-pos.x, pos.z-m_impact.z); // CW !
m_phase = TFA_TURN;
m_speed = 1.0f/1.0f;
@@ -132,7 +131,7 @@ Error CTaskFireAnt::IsEnded()
{
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float angle, dist;
int i, channel;
@@ -143,8 +142,8 @@ Error CTaskFireAnt::IsEnded()
if ( m_phase == TFA_TURN ) // rotation ?
{
angle = m_object->RetAngleY(0);
- angle = NormAngle(angle); // 0..2*PI
- if ( !TestAngle(angle, m_angle-PI*0.05f, m_angle+PI*0.05f) ) return ERR_CONTINUE;
+ angle = Math::NormAngle(angle); // 0..2*Math::PI
+ if ( !Math::TestAngle(angle, m_angle-Math::PI*0.05f, m_angle+Math::PI*0.05f) ) return ERR_CONTINUE;
m_physics->SetMotorSpeedZ(0.0f); // rotation ended
@@ -181,9 +180,9 @@ Error CTaskFireAnt::IsEnded()
pos = Transform(*mat, pos);
dist = Length(pos, m_impact);
speed = m_impact-pos;
- speed.x += (Rand()-0.5f)*dist*1.2f;
- speed.y += (Rand()-0.5f)*dist*0.4f+50.0f;
- speed.z += (Rand()-0.5f)*dist*1.2f;
+ speed.x += (Math::Rand()-0.5f)*dist*1.2f;
+ speed.y += (Math::Rand()-0.5f)*dist*0.4f+50.0f;
+ speed.z += (Math::Rand()-0.5f)*dist*1.2f;
dim.x = 1.0f;
dim.y = dim.x;
channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN2, 2.0f, 100.0f, 0.0f);
diff --git a/src/object/task/taskfireant.h b/src/object/task/taskfireant.h
index a94d943..8f9ea49 100644
--- a/src/object/task/taskfireant.h
+++ b/src/object/task/taskfireant.h
@@ -19,6 +19,7 @@
#pragma once
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/task/taskflag.cpp b/src/object/task/taskflag.cpp
index 667b179..aa853f2 100644
--- a/src/object/task/taskflag.cpp
+++ b/src/object/task/taskflag.cpp
@@ -16,14 +16,13 @@
// taskflag.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "math/old/math3d.h"
@@ -115,7 +114,7 @@ Error CTaskFlag::Start(TaskFlagOrder order, int rank)
m_bError = false;
m_motion->SetAction(MHS_FLAG); // sets/removes flag
- m_camera->StartCentering(m_object, PI*0.3f, 99.9f, 0.0f, 0.5f);
+ m_camera->StartCentering(m_object, Math::PI*0.3f, 99.9f, 0.0f, 0.5f);
return ERR_OK;
}
@@ -290,7 +289,7 @@ Error CTaskFlag::DeleteFlag()
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
pObj = SearchNearest(iPos, OBJECT_NULL);
if ( pObj == 0 )
@@ -304,9 +303,9 @@ Error CTaskFlag::DeleteFlag()
}
oPos = pObj->RetPosition(0);
- angle = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- aLimit = 45.0f*PI/180.0f;
- if ( !TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
+ angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ aLimit = 45.0f*Math::PI/180.0f;
+ if ( !Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
{
return ERR_FLAG_DELETE;
}
diff --git a/src/object/task/taskflag.h b/src/object/task/taskflag.h
index 31876fe..52e78e4 100644
--- a/src/object/task/taskflag.h
+++ b/src/object/task/taskflag.h
@@ -18,14 +18,15 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
+#include "graphics/d3d/d3dengine.h"
+#include "object/object.h"
class CInstanceManager;
class CTerrain;
class CBrain;
class CPhysics;
-class CObject;
diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp
index c5ffaec..3846564 100644
--- a/src/object/task/taskgoto.cpp
+++ b/src/object/task/taskgoto.cpp
@@ -16,14 +16,13 @@
// taskgoto.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -67,7 +66,7 @@ CTaskGoto::~CTaskGoto()
bool CTaskGoto::EventProcess(const Event &event)
{
D3DVECTOR pos, goal;
- FPOINT rot, repulse;
+ Math::Point rot, repulse;
float a, g, dist, linSpeed, cirSpeed, h, hh, factor, dir;
Error ret;
@@ -102,14 +101,14 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.y /= dist;
a = m_object->RetAngleY(0);
- g = RotateAngle(rot.x, -rot.y); // CW !
- a = Direction(a, g)*1.0f;
+ g = Math::RotateAngle(rot.x, -rot.y); // CW !
+ a = Math::Direction(a, g)*1.0f;
cirSpeed = a;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
- a = NormAngle(a);
- if ( a > PI*0.5f && a < PI*1.5f )
+ a = Math::NormAngle(a);
+ if ( a > Math::PI*0.5f && a < Math::PI*1.5f )
{
linSpeed = 1.0f; // obstacle behind -> advance
cirSpeed = -cirSpeed;
@@ -159,8 +158,8 @@ bool CTaskGoto::EventProcess(const Event &event)
D3DVECTOR min, max;
min = pos;
max = m_goal;
- if ( min.x > max.x ) Swap(min.x, max.x);
- if ( min.z > max.z ) Swap(min.z, max.z);
+ if ( min.x > max.x ) Math::Swap(min.x, max.x);
+ if ( min.z > max.z ) Math::Swap(min.z, max.z);
min.x -= 50.0f;
min.z -= 50.0f;
max.x += 50.0f;
@@ -179,8 +178,8 @@ bool CTaskGoto::EventProcess(const Event &event)
D3DVECTOR min, max;
min = pos;
max = m_goal;
- if ( min.x > max.x ) Swap(min.x, max.x);
- if ( min.z > max.z ) Swap(min.z, max.z);
+ if ( min.x > max.x ) Math::Swap(min.x, max.x);
+ if ( min.z > max.z ) Math::Swap(min.z, max.z);
min.x -= 50.0f;
min.z -= 50.0f;
max.x += 50.0f;
@@ -240,7 +239,7 @@ bool CTaskGoto::EventProcess(const Event &event)
}
goal.y = pos.y;
hh = m_terrain->RetFloorHeight(goal, true, true);
- h = Min(h, hh);
+ h = Math::Min(h, hh);
linSpeed = 0.0f;
if ( h < m_altitude-1.0f )
{
@@ -261,8 +260,8 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.y /= dist;
a = m_object->RetAngleY(0);
- g = RotateAngle(rot.x, -rot.y); // CW !
- cirSpeed = Direction(a, g)*2.0f;
+ g = Math::RotateAngle(rot.x, -rot.y); // CW !
+ cirSpeed = Math::Direction(a, g)*2.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
if ( dist < 4.0f ) cirSpeed *= dist/4.0f; // so close -> turns less
@@ -277,10 +276,10 @@ bool CTaskGoto::EventProcess(const Event &event)
linSpeed = 1.0f; // dark without stopping
}
- linSpeed *= 1.0f-(1.0f-0.3f)*Abs(cirSpeed);
+ linSpeed *= 1.0f-(1.0f-0.3f)*fabs(cirSpeed);
-//? if ( dist < 20.0f && Abs(cirSpeed) >= 0.5f )
- if ( Abs(cirSpeed) >= 0.2f )
+//? if ( dist < 20.0f && fabs(cirSpeed) >= 0.5f )
+ if ( fabs(cirSpeed) >= 0.2f )
{
linSpeed = 0.0f; // turns first, then advance
}
@@ -353,8 +352,8 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.x = m_goal.x-pos.x;
rot.y = m_goal.z-pos.z;
a = m_object->RetAngleY(0);
- g = RotateAngle(rot.x, -rot.y); // CW !
- cirSpeed = Direction(a, g)*1.0f;
+ g = Math::RotateAngle(rot.x, -rot.y); // CW !
+ cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
@@ -402,8 +401,8 @@ bool CTaskGoto::EventProcess(const Event &event)
#if 0
pos = m_object->RetPosition(0);
a = m_object->RetAngleY(0);
- g = RotateAngle(m_goal.x-pos.x, pos.z-m_goal.z); // CW !
- cirSpeed = Direction(a, g)*1.0f;
+ g = Math::RotateAngle(m_goal.x-pos.x, pos.z-m_goal.z); // CW !
+ cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
@@ -411,7 +410,7 @@ bool CTaskGoto::EventProcess(const Event &event)
linSpeed = dist/(m_physics->RetLinStopLength()*1.5f);
if ( linSpeed > 1.0f ) linSpeed = 1.0f;
- if ( dist < 20.0f && Abs(cirSpeed) >= 0.5f )
+ if ( dist < 20.0f && fabs(cirSpeed) >= 0.5f )
{
linSpeed = 0.0f; // turns first, then advance
}
@@ -429,8 +428,8 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.y += repulse.y*2.0f;
a = m_object->RetAngleY(0);
- g = RotateAngle(rot.x, -rot.y); // CW !
- cirSpeed = Direction(a, g)*1.0f;
+ g = Math::RotateAngle(rot.x, -rot.y); // CW !
+ cirSpeed = Math::Direction(a, g)*1.0f;
//? if ( m_physics->RetType() == TYPE_FLYING &&
//? m_physics->RetLand() ) // flying on the ground?
//? {
@@ -448,9 +447,9 @@ bool CTaskGoto::EventProcess(const Event &event)
//? }
if ( linSpeed > 1.0f ) linSpeed = 1.0f;
- linSpeed *= 1.0f-(1.0f-0.3f)*Abs(cirSpeed);
+ linSpeed *= 1.0f-(1.0f-0.3f)*fabs(cirSpeed);
- if ( dist < 20.0f && Abs(cirSpeed) >= 0.5f )
+ if ( dist < 20.0f && fabs(cirSpeed) >= 0.5f )
{
linSpeed = 0.0f; // turns first, then advance
}
@@ -466,7 +465,7 @@ bool CTaskGoto::EventProcess(const Event &event)
{
a = m_object->RetAngleY(0);
g = m_angle;
- cirSpeed = Direction(a, g)*1.0f;
+ cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
@@ -774,8 +773,8 @@ Error CTaskGoto::Start(D3DVECTOR goal, float altitude,
D3DVECTOR min, max;
min = m_object->RetPosition(0);
max = m_goal;
- if ( min.x > max.x ) Swap(min.x, max.x);
- if ( min.z > max.z ) Swap(min.z, max.z);
+ if ( min.x > max.x ) Math::Swap(min.x, max.x);
+ if ( min.z > max.z ) Math::Swap(min.z, max.z);
min.x -= 50.0f;
min.z -= 50.0f;
max.x += 50.0f;
@@ -865,8 +864,8 @@ Error CTaskGoto::IsEnded()
}
if ( m_bApprox ) limit = 2.0f;
- if ( Abs(pos.x - m_bmPoints[m_bmIndex].x) < limit &&
- Abs(pos.z - m_bmPoints[m_bmIndex].z) < limit )
+ if ( fabs(pos.x - m_bmPoints[m_bmIndex].x) < limit &&
+ fabs(pos.z - m_bmPoints[m_bmIndex].z) < limit )
{
m_physics->SetMotorSpeedX(0.0f); // stops the advance
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
@@ -895,7 +894,7 @@ Error CTaskGoto::IsEnded()
if ( m_bTake )
{
- m_angle = RotateAngle(m_goalObject.x-pos.x, pos.z-m_goalObject.z);
+ m_angle = Math::RotateAngle(m_goalObject.x-pos.x, pos.z-m_goalObject.z);
m_phase = TGP_TURN;
}
else
@@ -922,8 +921,8 @@ Error CTaskGoto::IsEnded()
else limit = 1.0f; // flying
if ( m_bApprox ) limit = 2.0f;
- if ( Abs(pos.x - m_goal.x) < limit &&
- Abs(pos.z - m_goal.z) < limit )
+ if ( fabs(pos.x - m_goal.x) < limit &&
+ fabs(pos.z - m_goal.z) < limit )
{
m_physics->SetMotorSpeedX(0.0f); // stops the advance
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
@@ -941,7 +940,7 @@ Error CTaskGoto::IsEnded()
if ( m_bTake )
{
- m_angle = RotateAngle(m_goalObject.x-pos.x, pos.z-m_goalObject.z);
+ m_angle = Math::RotateAngle(m_goalObject.x-pos.x, pos.z-m_goalObject.z);
m_phase = TGP_TURN;
}
else
@@ -952,17 +951,17 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_TURN ) // turns to the object?
{
- angle = NormAngle(m_object->RetAngleY(0));
+ angle = Math::NormAngle(m_object->RetAngleY(0));
limit = 0.02f;
if ( m_bApprox ) limit = 0.10f;
- if ( Abs(angle-m_angle) < limit )
+ if ( fabs(angle-m_angle) < limit )
{
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
if ( m_bmFinalMove == 0.0f ) return ERR_STOP;
m_bmFinalPos = m_object->RetPosition(0);
m_bmFinalDist = m_physics->RetLinLength(m_bmFinalMove);
- m_bmTimeLimit = m_physics->RetLinTimeLength(Abs(m_bmFinalMove))*1.5f;
+ m_bmTimeLimit = m_physics->RetLinTimeLength(fabs(m_bmFinalMove))*1.5f;
if ( m_bmTimeLimit < 0.5f ) m_bmTimeLimit = 0.5f;
m_phase = TGP_MOVE;
}
@@ -980,9 +979,9 @@ Error CTaskGoto::IsEnded()
if ( m_time >= 1.0f )
{
if ( m_crashMode == TGC_RIGHTLEFT ||
- m_crashMode == TGC_RIGHT ) angle = PI/2.0f; // 90 deegres to the right
- else angle = -PI/2.0f; // 90 deegres to the left
- m_angle = NormAngle(m_object->RetAngleY(0)+angle);
+ m_crashMode == TGC_RIGHT ) angle = Math::PI/2.0f; // 90 deegres to the right
+ else angle = -Math::PI/2.0f; // 90 deegres to the left
+ m_angle = Math::NormAngle(m_object->RetAngleY(0)+angle);
m_phase = TGP_CRTURN;
//? m_phase = TGP_ADVANCE;
}
@@ -990,9 +989,9 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_CRTURN ) // turns after collision?
{
- angle = NormAngle(m_object->RetAngleY(0));
+ angle = Math::NormAngle(m_object->RetAngleY(0));
limit = 0.1f;
- if ( Abs(angle-m_angle) < limit )
+ if ( fabs(angle-m_angle) < limit )
{
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
m_pos = pos;
@@ -1012,20 +1011,20 @@ Error CTaskGoto::IsEnded()
{
if ( m_time >= 1.0f )
{
- if ( m_crashMode == TGC_RIGHTLEFT ) angle = -PI;
- if ( m_crashMode == TGC_LEFTRIGHT ) angle = PI;
- if ( m_crashMode == TGC_RIGHT ) angle = PI/2.0f;
- if ( m_crashMode == TGC_LEFT ) angle = -PI/2.0f;
- m_angle = NormAngle(m_object->RetAngleY(0)+angle);
+ if ( m_crashMode == TGC_RIGHTLEFT ) angle = -Math::PI;
+ if ( m_crashMode == TGC_LEFTRIGHT ) angle = Math::PI;
+ if ( m_crashMode == TGC_RIGHT ) angle = Math::PI/2.0f;
+ if ( m_crashMode == TGC_LEFT ) angle = -Math::PI/2.0f;
+ m_angle = Math::NormAngle(m_object->RetAngleY(0)+angle);
m_phase = TGP_CLTURN;
}
}
if ( m_phase == TGP_CLTURN ) // turns after collision?
{
- angle = NormAngle(m_object->RetAngleY(0));
+ angle = Math::NormAngle(m_object->RetAngleY(0));
limit = 0.1f;
- if ( Abs(angle-m_angle) < limit )
+ if ( fabs(angle-m_angle) < limit )
{
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
m_pos = pos;
@@ -1429,11 +1428,11 @@ bool CTaskGoto::LeakSearch(D3DVECTOR &pos, float &delay)
// Calculates the force of repulsion due to obstacles.
// The vector length rendered is between 0 and 1.
-void CTaskGoto::ComputeRepulse(FPOINT &dir)
+void CTaskGoto::ComputeRepulse(Math::Point &dir)
{
#if 0
D3DVECTOR iPos, oPos;
- FPOINT repulse;
+ Math::Point repulse;
CObject *pObj;
float dist, iRadius, oRadius;
int i;
@@ -1478,7 +1477,7 @@ void CTaskGoto::ComputeRepulse(FPOINT &dir)
#else
ObjectType iType, oType;
D3DVECTOR iPos, oPos;
- FPOINT repulse;
+ Math::Point repulse;
CObject *pObj;
float gDist, add, addi, fac, dist, iRadius, oRadius;
int i, j;
@@ -1723,8 +1722,8 @@ void CTaskGoto::BeamStart()
min = m_object->RetPosition(0);
max = m_goal;
- if ( min.x > max.x ) Swap(min.x, max.x);
- if ( min.z > max.z ) Swap(min.z, max.z);
+ if ( min.x > max.x ) Math::Swap(min.x, max.x);
+ if ( min.z > max.z ) Math::Swap(min.z, max.z);
min.x -= 10.0f*BM_DIM_STEP;
min.z -= 10.0f*BM_DIM_STEP;
max.x += 10.0f*BM_DIM_STEP;
@@ -1780,7 +1779,7 @@ Error CTaskGoto::BeamSearch(const D3DVECTOR &start, const D3DVECTOR &goal,
if ( step > 20.0f ) step = 20.0f;
nbIter = 200; // in order not to lower the framerate
m_bmIterCounter = 0;
- return BeamExplore(start, start, goal, goalRadius, 165.0f*PI/180.0f, 22, step, 0, nbIter);
+ return BeamExplore(start, start, goal, goalRadius, 165.0f*Math::PI/180.0f, 22, step, 0, nbIter);
}
// prevPos: previous position
@@ -1890,7 +1889,7 @@ D3DVECTOR CTaskGoto::BeamPoint(const D3DVECTOR &startPoint,
D3DVECTOR resPoint;
float goalAngle;
- goalAngle = RotateAngle(goalPoint.x-startPoint.x, goalPoint.z-startPoint.z);
+ goalAngle = Math::RotateAngle(goalPoint.x-startPoint.x, goalPoint.z-startPoint.z);
resPoint.x = startPoint.x + cosf(goalAngle+angle)*step;
resPoint.z = startPoint.z + sinf(goalAngle+angle)*step;
@@ -1912,8 +1911,8 @@ void CTaskGoto::BitmapDebug(const D3DVECTOR &min, const D3DVECTOR &max,
maxx = (int)((max.x+1600.0f)/BM_DIM_STEP);
maxy = (int)((max.z+1600.0f)/BM_DIM_STEP);
- if ( minx > maxx ) Swap(minx, maxx);
- if ( miny > maxy ) Swap(miny, maxy);
+ if ( minx > maxx ) Math::Swap(minx, maxx);
+ if ( miny > maxy ) Math::Swap(miny, maxy);
OutputDebugString("Bitmap :\n");
for ( y=miny ; y<=maxy ; y++ )
@@ -2110,8 +2109,8 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
int x, y;
bool bAcceptWater, bFly;
- if ( minx > maxx ) Swap(minx, maxx);
- if ( miny > maxy ) Swap(miny, maxy);
+ if ( minx > maxx ) Math::Swap(minx, maxx);
+ if ( miny > maxy ) Math::Swap(miny, maxy);
if ( minx < 0 ) minx = 0;
if ( miny < 0 ) miny = 0;
@@ -2126,7 +2125,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
if ( minx >= m_bmMinX && maxx <= m_bmMaxX &&
miny >= m_bmMinY && maxy <= m_bmMaxY ) return;
- aLimit = 20.0f*PI/180.0f;
+ aLimit = 20.0f*Math::PI/180.0f;
bAcceptWater = false;
bFly = false;
@@ -2139,7 +2138,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
type == OBJECT_MOBILEwt ||
type == OBJECT_MOBILEtg ) // wheels?
{
- aLimit = 20.0f*PI/180.0f;
+ aLimit = 20.0f*Math::PI/180.0f;
}
if ( type == OBJECT_MOBILEta ||
@@ -2147,7 +2146,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEts ) // caterpillars?
{
- aLimit = 35.0f*PI/180.0f;
+ aLimit = 35.0f*Math::PI/180.0f;
}
if ( type == OBJECT_MOBILErt ||
@@ -2155,18 +2154,18 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
type == OBJECT_MOBILErr ||
type == OBJECT_MOBILErs ) // large caterpillars?
{
- aLimit = 35.0f*PI/180.0f;
+ aLimit = 35.0f*Math::PI/180.0f;
}
if ( type == OBJECT_MOBILEsa ) // submarine caterpillars?
{
- aLimit = 35.0f*PI/180.0f;
+ aLimit = 35.0f*Math::PI/180.0f;
bAcceptWater = true;
}
if ( type == OBJECT_MOBILEdr ) // designer caterpillars?
{
- aLimit = 35.0f*PI/180.0f;
+ aLimit = 35.0f*Math::PI/180.0f;
}
if ( type == OBJECT_MOBILEfa ||
@@ -2175,7 +2174,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
type == OBJECT_MOBILEfi ||
type == OBJECT_MOBILEft ) // flying?
{
- aLimit = 15.0f*PI/180.0f;
+ aLimit = 15.0f*Math::PI/180.0f;
bFly = true;
}
@@ -2184,7 +2183,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
type == OBJECT_MOBILEis ||
type == OBJECT_MOBILEii ) // insect legs?
{
- aLimit = 60.0f*PI/180.0f;
+ aLimit = 60.0f*Math::PI/180.0f;
}
for ( y=miny ; y<=maxy ; y++ )
diff --git a/src/object/task/taskgoto.h b/src/object/task/taskgoto.h
index 498bff5..d0e4953 100644
--- a/src/object/task/taskgoto.h
+++ b/src/object/task/taskgoto.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
@@ -95,7 +95,7 @@ protected:
bool AdjustBuilding(D3DVECTOR &pos, float margin, float &distance);
bool GetHotPoint(CObject *pObj, D3DVECTOR &pos, bool bTake, float distance, float &suppl);
bool LeakSearch(D3DVECTOR &pos, float &delay);
- void ComputeRepulse(FPOINT &dir);
+ void ComputeRepulse(Math::Point &dir);
void ComputeFlyingRepulse(float &dir);
int BeamShortcut();
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp
index 5a44ade..d4db1c8 100644
--- a/src/object/task/taskgungoal.cpp
+++ b/src/object/task/taskgungoal.cpp
@@ -16,8 +16,6 @@
// taskgungoal.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -104,7 +102,7 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
}
else
{
- speedV = 1.0f/(Abs(m_finalDirV-m_initialDirV)*1.0f);
+ speedV = 1.0f/(fabs(m_finalDirV-m_initialDirV)*1.0f);
}
m_initialDirH = m_object->RetGunGoalH();
@@ -118,10 +116,10 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
}
else
{
- speedH = 1.0f/(Abs(m_finalDirH-m_initialDirH)*1.0f);
+ speedH = 1.0f/(fabs(m_finalDirH-m_initialDirH)*1.0f);
}
- m_speed = Min(speedV, speedH);
+ m_speed = Math::Min(speedV, speedH);
if ( m_finalDirV != m_initialDirV ||
m_finalDirH != m_initialDirH )
diff --git a/src/object/task/taskgungoal.h b/src/object/task/taskgungoal.h
index 2ef8efc..d8cca60 100644
--- a/src/object/task/taskgungoal.h
+++ b/src/object/task/taskgungoal.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
class CInstanceManager;
diff --git a/src/object/task/taskinfo.cpp b/src/object/task/taskinfo.cpp
index 9897c88..3548426 100644
--- a/src/object/task/taskinfo.cpp
+++ b/src/object/task/taskinfo.cpp
@@ -16,8 +16,6 @@
// taskinfo.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -151,7 +149,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
pos.y += 9.5f;
goal = m_object->RetPosition(0);
goal.y += 4.0f;
- m_particule->CreateRay(pos, goal, PARTIRAY3, FPOINT(2.0f, 2.0f), 1.0f);
+ m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
}
if ( op == 2 ) // reception?
{
@@ -159,7 +157,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
goal.y += 9.5f;
pos = m_object->RetPosition(0);
pos.y += 4.0f;
- m_particule->CreateRay(pos, goal, PARTIRAY3, FPOINT(2.0f, 2.0f), 1.0f);
+ m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
}
m_progress = 0.0f;
diff --git a/src/object/task/taskinfo.h b/src/object/task/taskinfo.h
index 5f08f01..9c0ae12 100644
--- a/src/object/task/taskinfo.h
+++ b/src/object/task/taskinfo.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
class CInstanceManager;
diff --git a/src/object/task/taskmanager.cpp b/src/object/task/taskmanager.cpp
index 08ab0ce..2ec51fc 100644
--- a/src/object/task/taskmanager.cpp
+++ b/src/object/task/taskmanager.cpp
@@ -16,8 +16,6 @@
// taskmanager.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/object/task/taskmanager.h b/src/object/task/taskmanager.h
index 476e90f..36406e4 100644
--- a/src/object/task/taskmanager.h
+++ b/src/object/task/taskmanager.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "object/object.h"
#include "object/task/taskmanip.h"
#include "object/task/taskgoto.h"
diff --git a/src/object/task/taskmanip.cpp b/src/object/task/taskmanip.cpp
index 36bc4ae..3e1fea7 100644
--- a/src/object/task/taskmanip.cpp
+++ b/src/object/task/taskmanip.cpp
@@ -16,14 +16,13 @@
// taskmanip.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "math/old/math3d.h"
@@ -91,7 +90,7 @@ bool CTaskManip::EventProcess(const Event &event)
{
a = m_object->RetAngleY(0);
g = m_angle;
- cirSpeed = Direction(a, g)*1.0f;
+ cirSpeed = Math::Direction(a, g)*1.0f;
if ( m_physics->RetType() == TYPE_FLYING ) // flying on the ground?
{
cirSpeed *= 4.0f; // more fishing
@@ -206,47 +205,47 @@ void CTaskManip::InitAngle()
}
if ( m_arm == TMA_FFRONT )
{
- m_finalAngle[0] = 35.0f*PI/180.0f; // arm
- m_finalAngle[1] = -95.0f*PI/180.0f; // forearm
- m_finalAngle[2] = -27.0f*PI/180.0f; // hand
+ m_finalAngle[0] = 35.0f*Math::PI/180.0f; // arm
+ m_finalAngle[1] = -95.0f*Math::PI/180.0f; // forearm
+ m_finalAngle[2] = -27.0f*Math::PI/180.0f; // hand
}
if ( m_arm == TMA_FBACK )
{
- m_finalAngle[0] = 145.0f*PI/180.0f; // arm
- m_finalAngle[1] = 95.0f*PI/180.0f; // forearm
- m_finalAngle[2] = 27.0f*PI/180.0f; // hand
+ m_finalAngle[0] = 145.0f*Math::PI/180.0f; // arm
+ m_finalAngle[1] = 95.0f*Math::PI/180.0f; // forearm
+ m_finalAngle[2] = 27.0f*Math::PI/180.0f; // hand
}
if ( m_arm == TMA_POWER )
{
- m_finalAngle[0] = 95.0f*PI/180.0f; // arm
- m_finalAngle[1] = 125.0f*PI/180.0f; // forearm
- m_finalAngle[2] = 50.0f*PI/180.0f; // hand
+ m_finalAngle[0] = 95.0f*Math::PI/180.0f; // arm
+ m_finalAngle[1] = 125.0f*Math::PI/180.0f; // forearm
+ m_finalAngle[2] = 50.0f*Math::PI/180.0f; // hand
}
if ( m_arm == TMA_OTHER )
{
if ( m_height <= 3.0f )
{
- m_finalAngle[0] = 55.0f*PI/180.0f; // arm
- m_finalAngle[1] = -90.0f*PI/180.0f; // forearm
- m_finalAngle[2] = -35.0f*PI/180.0f; // hand
+ m_finalAngle[0] = 55.0f*Math::PI/180.0f; // arm
+ m_finalAngle[1] = -90.0f*Math::PI/180.0f; // forearm
+ m_finalAngle[2] = -35.0f*Math::PI/180.0f; // hand
}
else
{
- m_finalAngle[0] = 70.0f*PI/180.0f; // arm
- m_finalAngle[1] = -90.0f*PI/180.0f; // forearm
- m_finalAngle[2] = -50.0f*PI/180.0f; // hand
+ m_finalAngle[0] = 70.0f*Math::PI/180.0f; // arm
+ m_finalAngle[1] = -90.0f*Math::PI/180.0f; // forearm
+ m_finalAngle[2] = -50.0f*Math::PI/180.0f; // hand
}
}
if ( m_hand == TMH_OPEN ) // open clamp?
{
- m_finalAngle[3] = -PI*0.10f; // clamp close
- m_finalAngle[4] = PI*0.10f; // clamp remote
+ m_finalAngle[3] = -Math::PI*0.10f; // clamp close
+ m_finalAngle[4] = Math::PI*0.10f; // clamp remote
}
if ( m_hand == TMH_CLOSE ) // clamp closed?
{
- m_finalAngle[3] = PI*0.05f; // clamp close
- m_finalAngle[4] = -PI*0.05f; // clamp remote
+ m_finalAngle[3] = Math::PI*0.05f; // clamp close
+ m_finalAngle[4] = -Math::PI*0.05f; // clamp remote
}
for ( i=0 ; i<5 ; i++ )
@@ -257,9 +256,9 @@ void CTaskManip::InitAngle()
max = 0.0f;
for ( i=0 ; i<5 ; i++ )
{
- max = Max(max, Abs(m_initialAngle[i] - m_finalAngle[i]));
+ max = Math::Max(max, fabs(m_initialAngle[i] - m_finalAngle[i]));
}
- m_speed = (PI*1.0f)/max;
+ m_speed = (Math::PI*1.0f)/max;
if ( m_speed > 3.0f ) m_speed = 3.0f; // piano, ma non troppo (?)
energy = 0.0f;
@@ -315,7 +314,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
m_speed = 1.0f/1.5f;
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
m_bError = true; // operation impossible
@@ -459,7 +458,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
{
return ERR_MANIP_NIL;
}
- m_angle += PI;
+ m_angle += Math::PI;
m_move = -1.0f; // back necessary
}
if ( m_arm == TMA_POWER )
@@ -508,7 +507,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
if ( m_move != 0.0f ) // forward or backward?
{
- m_timeLimit = m_physics->RetLinTimeLength(Abs(len))*1.5f;
+ m_timeLimit = m_physics->RetLinTimeLength(fabs(len))*1.5f;
if ( m_timeLimit < 0.5f ) m_timeLimit = 0.5f;
}
@@ -535,7 +534,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
if ( m_bSubm )
{
- m_camera->StartCentering(m_object, PI*0.8f, 99.9f, 0.0f, 0.5f);
+ m_camera->StartCentering(m_object, Math::PI*0.8f, 99.9f, 0.0f, 0.5f);
}
m_physics->SetFreeze(true); // it does not move
@@ -564,9 +563,9 @@ Error CTaskManip::IsEnded()
if ( m_bTurn ) // preliminary rotation?
{
angle = m_object->RetAngleY(0);
- angle = NormAngle(angle); // 0..2*PI
+ angle = Math::NormAngle(angle); // 0..2*Math::PI
- if ( TestAngle(angle, m_angle-PI*0.01f, m_angle+PI*0.01f) )
+ if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
{
m_bTurn = false; // rotation ended
m_physics->SetMotorSpeedZ(0.0f);
@@ -800,17 +799,17 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, D3DVECTOR &pos,
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
{
- aLimit = 60.0f*PI/180.0f;
+ aLimit = 60.0f*Math::PI/180.0f;
dLimit = MARGIN_FRONT+10.0f;
}
else
{
-//? aLimit = 7.0f*PI/180.0f;
- aLimit = 15.0f*PI/180.0f; //OK 1.9
+//? aLimit = 7.0f*Math::PI/180.0f;
+ aLimit = 15.0f*Math::PI/180.0f; //OK 1.9
dLimit = MARGIN_FRONT;
}
@@ -848,12 +847,12 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, D3DVECTOR &pos,
if ( pObj->RetZoomY(0) != 1.0f ) continue;
oPos = pObj->RetPosition(0);
- distance = Abs(Length(oPos, iPos)-TAKE_DIST);
+ distance = fabs(Length(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
- angle = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( !TestAngle(angle, iAngle-aLimit*f, iAngle+aLimit*f) ) continue;
+ angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ if ( !Math::TestAngle(angle, iAngle-aLimit*f, iAngle+aLimit*f) ) continue;
if ( distance < -dLimit ||
distance > dLimit ) continue;
@@ -891,17 +890,17 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, D3DVECTOR &pos,
int i;
iPos = m_object->RetPosition(0);
- iAngle = m_object->RetAngleY(0)+PI;
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = m_object->RetAngleY(0)+Math::PI;
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
{
- aLimit = 60.0f*PI/180.0f;
+ aLimit = 60.0f*Math::PI/180.0f;
dLimit = MARGIN_BACK+5.0f;
}
else
{
- aLimit = 7.0f*PI/180.0f;
+ aLimit = 7.0f*Math::PI/180.0f;
dLimit = MARGIN_BACK;
}
@@ -939,12 +938,12 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, D3DVECTOR &pos,
if ( pObj->RetZoomY(0) != 1.0f ) continue;
oPos = pObj->RetPosition(0);
- distance = Abs(Length(oPos, iPos)-TAKE_DIST);
+ distance = fabs(Length(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
- angle = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( !TestAngle(angle, iAngle-aLimit*f, iAngle+aLimit*f) ) continue;
+ angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ if ( !Math::TestAngle(angle, iAngle-aLimit*f, iAngle+aLimit*f) ) continue;
if ( distance < -dLimit ||
distance > dLimit ) continue;
@@ -992,16 +991,16 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, D3DVECTOR &pos,
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
{
- aLimit = 60.0f*PI/180.0f;
+ aLimit = 60.0f*Math::PI/180.0f;
dLimit = MARGIN_FRIEND+10.0f;
}
else
{
- aLimit = 7.0f*PI/180.0f;
+ aLimit = 7.0f*Math::PI/180.0f;
dLimit = MARGIN_FRIEND;
}
@@ -1064,34 +1063,34 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, D3DVECTOR &pos,
if ( type == OBJECT_TOWER ||
type == OBJECT_RESEARCH )
{
- oLimit = 45.0f*PI/180.0f;
+ oLimit = 45.0f*Math::PI/180.0f;
}
else if ( type == OBJECT_ENERGY )
{
- oLimit = 90.0f*PI/180.0f;
+ oLimit = 90.0f*Math::PI/180.0f;
}
else if ( type == OBJECT_LABO )
{
- oLimit = 120.0f*PI/180.0f;
+ oLimit = 120.0f*Math::PI/180.0f;
}
else if ( type == OBJECT_NUCLEAR )
{
- oLimit = 45.0f*PI/180.0f;
+ oLimit = 45.0f*Math::PI/180.0f;
}
else
{
- oLimit = 45.0f*PI/180.0f;
- oAngle += PI; // is behind
+ oLimit = 45.0f*Math::PI/180.0f;
+ oAngle += Math::PI; // is behind
}
- oAngle = NormAngle(oAngle); // 0..2*PI
- angle = RotateAngle(iPos.x-oPos.x, oPos.z-iPos.z); // CW !
- if ( !TestAngle(angle, oAngle-oLimit, oAngle+oLimit) ) continue;
+ oAngle = Math::NormAngle(oAngle); // 0..2*Math::PI
+ angle = Math::RotateAngle(iPos.x-oPos.x, oPos.z-iPos.z); // CW !
+ if ( !Math::TestAngle(angle, oAngle-oLimit, oAngle+oLimit) ) continue;
- distance = Abs(Length(oPos, iPos)-TAKE_DIST);
+ distance = fabs(Length(oPos, iPos)-TAKE_DIST);
if ( distance <= dLimit )
{
- angle = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
+ angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
{
character = pObj->RetCharacter();
height = character->posPower.y;
@@ -1152,7 +1151,7 @@ bool CTaskManip::TruckTakeObject()
pos = D3DVECTOR(4.7f, 0.0f, 0.0f); // relative to the hand (lem4)
fret->SetPosition(0, pos);
fret->SetAngleX(0, 0.0f);
- fret->SetAngleZ(0, PI/2.0f);
+ fret->SetAngleZ(0, Math::PI/2.0f);
fret->SetAngleY(0, 0.0f);
}
@@ -1184,7 +1183,7 @@ bool CTaskManip::TruckTakeObject()
pos = D3DVECTOR(4.7f, 0.0f, 0.0f); // relative to the hand (lem4)
fret->SetPosition(0, pos);
fret->SetAngleX(0, 0.0f);
- fret->SetAngleZ(0, PI/2.0f);
+ fret->SetAngleZ(0, Math::PI/2.0f);
fret->SetAngleY(0, 0.0f);
}
@@ -1203,7 +1202,7 @@ bool CTaskManip::TruckTakeObject()
pos = D3DVECTOR(4.7f, 0.0f, 0.0f); // relative to the hand (lem4)
fret->SetPosition(0, pos);
fret->SetAngleX(0, 0.0f);
- fret->SetAngleZ(0, PI/2.0f);
+ fret->SetAngleZ(0, Math::PI/2.0f);
fret->SetAngleY(0, 0.0f);
m_object->SetFret(fret); // takes
@@ -1218,7 +1217,7 @@ bool CTaskManip::TruckTakeObject()
pos = D3DVECTOR(4.7f, 0.0f, 0.0f); // relative to the hand (lem4)
fret->SetPosition(0, pos);
fret->SetAngleX(0, 0.0f);
- fret->SetAngleZ(0, PI/2.0f);
+ fret->SetAngleZ(0, Math::PI/2.0f);
fret->SetAngleY(0, 0.0f);
fret->SetTruckPart(3); // takes with the hand
@@ -1242,7 +1241,7 @@ bool CTaskManip::TruckTakeObject()
pos = D3DVECTOR(4.7f, 0.0f, 0.0f); // relative to the hand (lem4)
fret->SetPosition(0, pos);
fret->SetAngleX(0, 0.0f);
- fret->SetAngleZ(0, PI/2.0f);
+ fret->SetAngleZ(0, Math::PI/2.0f);
fret->SetAngleY(0, 0.0f);
m_object->SetFret(fret); // takes
@@ -1272,7 +1271,7 @@ bool CTaskManip::TruckDeposeObject()
pos = Transform(*mat, D3DVECTOR(0.0f, 1.0f, 0.0f));
m_terrain->MoveOnFloor(pos);
fret->SetPosition(0, pos);
- fret->SetAngleY(0, m_object->RetAngleY(0)+PI/2.0f);
+ fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
fret->FloorAdjust(); // plate well on the ground
@@ -1291,7 +1290,7 @@ bool CTaskManip::TruckDeposeObject()
pos = Transform(*mat, D3DVECTOR(0.0f, 1.0f, 0.0f));
m_terrain->MoveOnFloor(pos);
fret->SetPosition(0, pos);
- fret->SetAngleY(0, m_object->RetAngleY(0)+PI/2.0f);
+ fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
diff --git a/src/object/task/taskmanip.h b/src/object/task/taskmanip.h
index b2c8c29..da1be09 100644
--- a/src/object/task/taskmanip.h
+++ b/src/object/task/taskmanip.h
@@ -20,8 +20,8 @@
#include "object/task/task.h"
-#include "common/misc.h"
#include "graphics/d3d/d3dengine.h"
+#include "object/object.h"
class CInstanceManager;
diff --git a/src/object/task/taskpen.cpp b/src/object/task/taskpen.cpp
index bd88b26..8a62431 100644
--- a/src/object/task/taskpen.cpp
+++ b/src/object/task/taskpen.cpp
@@ -16,8 +16,6 @@
// taskpen.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -62,7 +60,7 @@ CTaskPen::~CTaskPen()
bool CTaskPen::EventProcess(const Event &event)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
int i;
if ( m_engine->RetPause() ) return true;
@@ -96,12 +94,12 @@ bool CTaskPen::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_supportPos;
- pos.x += (Rand()-0.5f)*5.0f;
- pos.z += (Rand()-0.5f)*5.0f;
- speed.x = (Rand()-0.5f)*3.0f;
- speed.z = (Rand()-0.5f)*3.0f;
- speed.y = Rand()*2.0f;
- dim.x = Rand()*1.5f+2.0f;
+ pos.x += (Math::Rand()-0.5f)*5.0f;
+ pos.z += (Math::Rand()-0.5f)*5.0f;
+ speed.x = (Math::Rand()-0.5f)*3.0f;
+ speed.z = (Math::Rand()-0.5f)*3.0f;
+ speed.y = Math::Rand()*2.0f;
+ dim.x = Math::Rand()*1.5f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
}
@@ -116,12 +114,12 @@ bool CTaskPen::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_supportPos;
- pos.x += (Rand()-0.5f)*5.0f;
- pos.z += (Rand()-0.5f)*5.0f;
- speed.x = (Rand()-0.5f)*3.0f;
- speed.z = (Rand()-0.5f)*3.0f;
- speed.y = Rand()*5.0f;
- dim.x = Rand()*1.0f+1.0f;
+ pos.x += (Math::Rand()-0.5f)*5.0f;
+ pos.z += (Math::Rand()-0.5f)*5.0f;
+ speed.x = (Math::Rand()-0.5f)*3.0f;
+ speed.z = (Math::Rand()-0.5f)*3.0f;
+ speed.y = Math::Rand()*5.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR, 4.0f);
}
@@ -134,7 +132,7 @@ bool CTaskPen::EventProcess(const Event &event)
}
else
{
- pos.y = -3.2f*Bounce(Min(m_progress*1.8f, 1.0f));
+ pos.y = -3.2f*Math::Bounce(Math::Min(m_progress*1.8f, 1.0f));
}
m_object->SetPosition(10+i, pos);
}
@@ -200,7 +198,7 @@ Error CTaskPen::Start(bool bDown, int color)
m_lastParticule = 0.0f;
-//? m_camera->StartCentering(m_object, PI*0.60f, 99.9f, 5.0f, 0.5f);
+//? m_camera->StartCentering(m_object, Math::PI*0.60f, 99.9f, 5.0f, 0.5f);
return ERR_OK;
}
@@ -219,7 +217,7 @@ Error CTaskPen::IsEnded()
{
m_phase = TPP_TURN;
m_progress = 0.0f;
- m_delay = Abs(m_oldAngle-m_newAngle)/PI;
+ m_delay = fabs(m_oldAngle-m_newAngle)/Math::PI;
m_time = 0.0f;
m_lastParticule = 0.0f;
if ( m_delay > 0.0f )
@@ -270,17 +268,17 @@ void CTaskPen::SoundManip(float time, float amplitude, float frequency)
int CTaskPen::AngleToRank(float angle)
{
-//? return (int)(angle/(-45.0f*PI/180.0f));
+//? return (int)(angle/(-45.0f*Math::PI/180.0f));
angle = -angle;
- angle += (45.0f*PI/180.0f)/2.0f;
- return (int)(angle/(45.0f*PI/180.0f));
+ angle += (45.0f*Math::PI/180.0f)/2.0f;
+ return (int)(angle/(45.0f*Math::PI/180.0f));
}
// Converting a color to the angle of carousel of pencils.
float CTaskPen::ColorToAngle(int color)
{
- return -45.0f*PI/180.0f*ColorToRank(color);
+ return -45.0f*Math::PI/180.0f*ColorToRank(color);
}
// Converting a color number to the pencil (0 .. 7).
diff --git a/src/object/task/taskpen.h b/src/object/task/taskpen.h
index 2f1f270..4ed135d 100644
--- a/src/object/task/taskpen.h
+++ b/src/object/task/taskpen.h
@@ -19,6 +19,7 @@
#pragma once
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
index cb47bce..3e3243c 100644
--- a/src/object/task/taskrecover.cpp
+++ b/src/object/task/taskrecover.cpp
@@ -16,14 +16,14 @@
// taskrecover.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/func.h"
+#include "math/geometry.h"
#include "math/old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
@@ -67,7 +67,7 @@ bool CTaskRecover::EventProcess(const Event &event)
{
CObject* power;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float a, g, cirSpeed, angle, energy, dist, linSpeed;
if ( m_engine->RetPause() ) return true;
@@ -78,7 +78,7 @@ bool CTaskRecover::EventProcess(const Event &event)
{
a = m_object->RetAngleY(0);
g = m_angle;
- cirSpeed = Direction(a, g)*1.0f;
+ cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
@@ -91,11 +91,11 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( m_phase == TRP_DOWN )
{
- angle = Prop(126, -10, m_progress);
+ angle = Math::PropAngle(126, -10, m_progress);
m_object->SetAngleZ(2, angle);
m_object->SetAngleZ(4, angle);
- angle = Prop(-144, 0, m_progress);
+ angle = Math::PropAngle(-144, 0, m_progress);
m_object->SetAngleZ(3, angle);
m_object->SetAngleZ(5, angle);
}
@@ -119,9 +119,9 @@ bool CTaskRecover::EventProcess(const Event &event)
power->SetEnergy(energy-ENERGY_RECOVER*event.rTime*m_speed);
}
- speed.x = (Rand()-0.5f)*0.1f*m_progress;
- speed.y = (Rand()-0.5f)*0.1f*m_progress;
- speed.z = (Rand()-0.5f)*0.1f*m_progress;
+ speed.x = (Math::Rand()-0.5f)*0.1f*m_progress;
+ speed.y = (Math::Rand()-0.5f)*0.1f*m_progress;
+ speed.z = (Math::Rand()-0.5f)*0.1f*m_progress;
m_ruin->SetCirVibration(speed);
if ( m_progress >= 0.75f )
@@ -139,13 +139,13 @@ bool CTaskRecover::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_recoverPos;
- pos.x += (Rand()-0.5f)*8.0f*(1.0f-m_progress);
- pos.z += (Rand()-0.5f)*8.0f*(1.0f-m_progress);
+ pos.x += (Math::Rand()-0.5f)*8.0f*(1.0f-m_progress);
+ pos.z += (Math::Rand()-0.5f)*8.0f*(1.0f-m_progress);
pos.y -= 4.0f;
- speed.x = (Rand()-0.5f)*0.0f;
- speed.z = (Rand()-0.5f)*0.0f;
- speed.y = Rand()*15.0f;
- dim.x = Rand()*2.0f+1.5f;
+ speed.x = (Math::Rand()-0.5f)*0.0f;
+ speed.z = (Math::Rand()-0.5f)*0.0f;
+ speed.y = Math::Rand()*15.0f;
+ dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f);
}
@@ -153,11 +153,11 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( m_phase == TRP_UP )
{
- angle = Prop(-10, 126, m_progress);
+ angle = Math::PropAngle(-10, 126, m_progress);
m_object->SetAngleZ(2, angle);
m_object->SetAngleZ(4, angle);
- angle = Prop(0, -144, m_progress);
+ angle = Math::PropAngle(0, -144, m_progress);
m_object->SetAngleZ(3, angle);
m_object->SetAngleZ(5, angle);
@@ -167,10 +167,10 @@ bool CTaskRecover::EventProcess(const Event &event)
pos = m_recoverPos;
pos.y -= 4.0f;
- speed.x = (Rand()-0.5f)*0.0f;
- speed.z = (Rand()-0.5f)*0.0f;
- speed.y = Rand()*15.0f;
- dim.x = Rand()*2.0f+1.5f;
+ speed.x = (Math::Rand()-0.5f)*0.0f;
+ speed.z = (Math::Rand()-0.5f)*0.0f;
+ speed.y = Math::Rand()*15.0f;
+ dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f);
}
@@ -213,7 +213,7 @@ Error CTaskRecover::Start()
iPos = m_object->RetPosition(0);
oPos = m_ruin->RetPosition(0);
- m_angle = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ m_angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
m_metal = 0;
@@ -225,7 +225,7 @@ Error CTaskRecover::Start()
m_bError = false; // ok
- m_camera->StartCentering(m_object, PI*0.85f, 99.9f, 10.0f, 3.0f);
+ m_camera->StartCentering(m_object, Math::PI*0.85f, 99.9f, 10.0f, 3.0f);
return ERR_OK;
}
@@ -235,7 +235,7 @@ Error CTaskRecover::IsEnded()
{
D3DMATRIX* mat;
D3DVECTOR pos, speed, goal;
- FPOINT dim;
+ Math::Point dim;
float angle, dist, time;
int i;
@@ -245,9 +245,9 @@ Error CTaskRecover::IsEnded()
if ( m_phase == TRP_TURN ) // preliminary rotation?
{
angle = m_object->RetAngleY(0);
- angle = NormAngle(angle); // 0..2*PI
+ angle = Math::NormAngle(angle); // 0..2*Math::PI
- if ( TestAngle(angle, m_angle-PI*0.01f, m_angle+PI*0.01f) )
+ if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
{
m_physics->SetMotorSpeedZ(0.0f);
@@ -328,7 +328,7 @@ Error CTaskRecover::IsEnded()
goal = D3DVECTOR(RECOVER_DIST, 3.1f, -3.9f);
goal = Transform(*mat, goal);
m_particule->CreateRay(pos, goal, PARTIRAY2,
- FPOINT(2.0f, 2.0f), 8.0f);
+ Math::Point(2.0f, 2.0f), 8.0f);
m_soundChannel = m_sound->Play(SOUND_RECOVER, m_ruin->RetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 0.6f, 1.0f, 2.0f, SOPER_CONTINUE);
@@ -370,10 +370,10 @@ Error CTaskRecover::IsEnded()
bool CTaskRecover::Abort()
{
- m_object->SetAngleZ(2, 126.0f*PI/180.0f);
- m_object->SetAngleZ(4, 126.0f*PI/180.0f);
- m_object->SetAngleZ(3, -144.0f*PI/180.0f);
- m_object->SetAngleZ(5, -144.0f*PI/180.0f); // rest
+ m_object->SetAngleZ(2, 126.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(4, 126.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(3, -144.0f*Math::PI/180.0f);
+ m_object->SetAngleZ(5, -144.0f*Math::PI/180.0f); // rest
if ( m_soundChannel != -1 )
{
diff --git a/src/object/task/taskrecover.h b/src/object/task/taskrecover.h
index 87efc07..9d9aa07 100644
--- a/src/object/task/taskrecover.h
+++ b/src/object/task/taskrecover.h
@@ -19,6 +19,7 @@
#pragma once
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/task/taskreset.cpp b/src/object/task/taskreset.cpp
index 1b7ff95..f44f22a 100644
--- a/src/object/task/taskreset.cpp
+++ b/src/object/task/taskreset.cpp
@@ -16,8 +16,6 @@
// taskreset.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -66,7 +64,7 @@ CTaskReset::~CTaskReset()
bool CTaskReset::EventProcess(const Event &event)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float angle, duration;
if ( m_engine->RetPause() ) return true;
@@ -88,26 +86,26 @@ bool CTaskReset::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_begin;
- 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_begin;
- 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 *= 1.0f-m_progress*0.5f;
pos += speed*1.5f;
speed = -speed;
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);
@@ -123,12 +121,12 @@ bool CTaskReset::EventProcess(const Event &event)
{
m_lastParticule = m_time;
- 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 = 2.0f+Rand()*2.0f;
- dim.x = Rand()*2.0f+2.0f;
+ speed.y = 2.0f+Math::Rand()*2.0f;
+ dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
}
@@ -146,24 +144,24 @@ bool CTaskReset::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_goal;
- 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_goal;
- 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);
diff --git a/src/object/task/taskreset.h b/src/object/task/taskreset.h
index 4ebc032..d622cd0 100644
--- a/src/object/task/taskreset.h
+++ b/src/object/task/taskreset.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp
index f182250..c002d6a 100644
--- a/src/object/task/tasksearch.cpp
+++ b/src/object/task/tasksearch.cpp
@@ -16,8 +16,6 @@
// tasksearch.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -63,7 +61,7 @@ bool CTaskSearch::EventProcess(const Event &event)
{
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float angle;
int i;
@@ -94,10 +92,10 @@ bool CTaskSearch::EventProcess(const Event &event)
pos = D3DVECTOR(6.5f, 0.2f, 0.0f);
pos = Transform(*mat, pos); // sensor position
- speed.x = (Rand()-0.5f)*20.0f;
- speed.z = (Rand()-0.5f)*20.0f;
+ speed.x = (Math::Rand()-0.5f)*20.0f;
+ speed.z = (Math::Rand()-0.5f)*20.0f;
speed.y = 0.0f;
- dim.x = Rand()*1.0f+1.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGAS);
}
@@ -114,15 +112,15 @@ void CTaskSearch::InitAngle()
if ( m_hand == TSH_UP )
{
- m_finalAngle[0] = 110.0f*PI/180.0f; // arm
- m_finalAngle[1] = -110.0f*PI/180.0f; // forearm
- m_finalAngle[2] = -65.0f*PI/180.0f; // sensor
+ m_finalAngle[0] = 110.0f*Math::PI/180.0f; // arm
+ m_finalAngle[1] = -110.0f*Math::PI/180.0f; // forearm
+ m_finalAngle[2] = -65.0f*Math::PI/180.0f; // sensor
}
if ( m_hand == TSH_DOWN )
{
- m_finalAngle[0] = 25.0f*PI/180.0f; // arm
- m_finalAngle[1] = -70.0f*PI/180.0f; // forearm
- m_finalAngle[2] = -45.0f*PI/180.0f; // sensor
+ m_finalAngle[0] = 25.0f*Math::PI/180.0f; // arm
+ m_finalAngle[1] = -70.0f*Math::PI/180.0f; // forearm
+ m_finalAngle[2] = -45.0f*Math::PI/180.0f; // sensor
}
for ( i=0 ; i<3 ; i++ )
@@ -163,7 +161,7 @@ Error CTaskSearch::Start()
InitAngle();
m_bError = false; // ok
- m_camera->StartCentering(m_object, PI*0.50f, 99.9f, 0.0f, 1.0f);
+ m_camera->StartCentering(m_object, Math::PI*0.50f, 99.9f, 0.0f, 1.0f);
i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f, true);
m_sound->AddEnvelope(i, 0.5f, 1.0f, 0.1f, SOPER_CONTINUE);
diff --git a/src/object/task/tasksearch.h b/src/object/task/tasksearch.h
index 48b1a32..76c0b6d 100644
--- a/src/object/task/tasksearch.h
+++ b/src/object/task/tasksearch.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
class CInstanceManager;
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
index 86e45df..c4993fc 100644
--- a/src/object/task/taskshield.cpp
+++ b/src/object/task/taskshield.cpp
@@ -16,8 +16,6 @@
// taskshield.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -72,7 +70,7 @@ bool CTaskShield::EventProcess(const Event &event)
D3DMATRIX matrix;
D3DVECTOR pos, speed, goal, angle;
D3DCOLORVALUE color;
- FPOINT dim;
+ Math::Point dim;
float energy;
if ( m_engine->RetPause() ) return true;
@@ -99,7 +97,7 @@ bool CTaskShield::EventProcess(const Event &event)
if ( m_phase == TS_UP1 )
{
pos.x = 7.0f;
- pos.y = 4.5f+Bounce(m_progress)*3.0f;
+ pos.y = 4.5f+Math::Bounce(m_progress)*3.0f;
pos.z = 0.0f;
m_object->SetPosition(2, pos);
}
@@ -107,7 +105,7 @@ bool CTaskShield::EventProcess(const Event &event)
if ( m_phase == TS_UP2 )
{
pos.x = 0.0f;
- pos.y = 1.0f+Bounce(m_progress)*3.0f;
+ pos.y = 1.0f+Math::Bounce(m_progress)*3.0f;
pos.z = 0.0f;
m_object->SetPosition(3, pos);
}
@@ -156,12 +154,12 @@ bool CTaskShield::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_shieldPos;
- pos.x += (Rand()-0.5f)*5.0f;
- pos.z += (Rand()-0.5f)*5.0f;
- speed.x = (Rand()-0.5f)*0.0f;
- speed.z = (Rand()-0.5f)*0.0f;
- speed.y = Rand()*15.0f;
- dim.x = Rand()*6.0f+4.0f;
+ pos.x += (Math::Rand()-0.5f)*5.0f;
+ pos.z += (Math::Rand()-0.5f)*5.0f;
+ speed.x = (Math::Rand()-0.5f)*0.0f;
+ speed.z = (Math::Rand()-0.5f)*0.0f;
+ speed.y = Math::Rand()*15.0f;
+ dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
@@ -173,9 +171,9 @@ bool CTaskShield::EventProcess(const Event &event)
pos = m_shieldPos;
dim.x = RetRadius()/20.0f;
dim.y = dim.x;
- angle.x = (Rand()-0.5f)*PI*1.2f;
+ angle.x = (Math::Rand()-0.5f)*Math::PI*1.2f;
angle.y = 0.0f;
- angle.z = (Rand()-0.5f)*PI*1.2f;
+ angle.z = (Math::Rand()-0.5f)*Math::PI*1.2f;
MatRotateXZY(matrix, angle);
goal = Transform(matrix, D3DVECTOR(0.0f, RetRadius()-dim.x, 0.0f));
goal += pos;
@@ -203,12 +201,12 @@ bool CTaskShield::EventProcess(const Event &event)
m_lastParticule = m_time;
pos = m_shieldPos;
- pos.x += (Rand()-0.5f)*5.0f;
- pos.z += (Rand()-0.5f)*5.0f;
- speed.x = (Rand()-0.5f)*3.0f;
- speed.z = (Rand()-0.5f)*3.0f;
- speed.y = (Rand()-0.5f)*3.0f;
- dim.x = Rand()*1.5f+2.0f;
+ pos.x += (Math::Rand()-0.5f)*5.0f;
+ pos.z += (Math::Rand()-0.5f)*5.0f;
+ speed.x = (Math::Rand()-0.5f)*3.0f;
+ speed.z = (Math::Rand()-0.5f)*3.0f;
+ speed.y = (Math::Rand()-0.5f)*3.0f;
+ dim.x = Math::Rand()*1.5f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
}
@@ -217,7 +215,7 @@ bool CTaskShield::EventProcess(const Event &event)
if ( m_phase == TS_DOWN1 )
{
pos.x = 0.0f;
- pos.y = 1.0f+(1.0f-Bounce(m_progress))*3.0f;
+ pos.y = 1.0f+(1.0f-Math::Bounce(m_progress))*3.0f;
pos.z = 0.0f;
m_object->SetPosition(3, pos);
}
@@ -225,7 +223,7 @@ bool CTaskShield::EventProcess(const Event &event)
if ( m_phase == TS_DOWN2 )
{
pos.x = 7.0f;
- pos.y = 4.5f+(1.0f-Bounce(m_progress))*3.0f;
+ pos.y = 4.5f+(1.0f-Math::Bounce(m_progress))*3.0f;
pos.z = 0.0f;
m_object->SetPosition(2, pos);
}
@@ -293,7 +291,7 @@ Error CTaskShield::Start(TaskShieldMode mode, float delay)
{
m_brain->UpdateInterface();
}
-//? m_camera->StartCentering(m_object, PI*0.85f, -PI*0.15f, RetRadius()+40.0f, 3.0f);
+//? m_camera->StartCentering(m_object, Math::PI*0.85f, -Math::PI*0.15f, RetRadius()+40.0f, 3.0f);
return ERR_OK;
}
@@ -344,7 +342,7 @@ Error CTaskShield::IsEnded()
{
CObject* power;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float energy;
if ( m_engine->RetPause() ) return ERR_CONTINUE;
@@ -514,7 +512,7 @@ bool CTaskShield::CreateLight(D3DVECTOR pos)
light.dvAttenuation1 = 0.0f;
light.dvAttenuation2 = 0.0f;
light.dvTheta = 0.0f;
- light.dvPhi = PI/4.0f;
+ light.dvPhi = Math::PI/4.0f;
m_effectLight = m_light->CreateLight();
if ( m_effectLight == -1 ) return false;
diff --git a/src/object/task/taskshield.h b/src/object/task/taskshield.h
index 5917158..916cd6d 100644
--- a/src/object/task/taskshield.h
+++ b/src/object/task/taskshield.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/task/taskspiderexplo.cpp b/src/object/task/taskspiderexplo.cpp
index 496916c..f545b7e 100644
--- a/src/object/task/taskspiderexplo.cpp
+++ b/src/object/task/taskspiderexplo.cpp
@@ -16,8 +16,6 @@
// taskspiderexplo.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/object/task/taskspiderexplo.h b/src/object/task/taskspiderexplo.h
index a08e9dd..0b60f34 100644
--- a/src/object/task/taskspiderexplo.h
+++ b/src/object/task/taskspiderexplo.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
class CInstanceManager;
diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp
index b09366a..adb6e71 100644
--- a/src/object/task/tasktake.cpp
+++ b/src/object/task/tasktake.cpp
@@ -16,15 +16,14 @@
// tasktake.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 "math/old/d3dmath.h"
#include "math/old/math3d.h"
@@ -78,7 +77,7 @@ bool CTaskTake::EventProcess(const Event &event)
{
a = m_object->RetAngleY(0);
g = m_angle;
- cirSpeed = Direction(a, g)*2.0f;
+ cirSpeed = Math::Direction(a, g)*2.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
@@ -108,7 +107,7 @@ Error CTaskTake::Start()
m_progress = 0.0f;
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
m_bError = true; // operation impossible
@@ -141,7 +140,7 @@ Error CTaskTake::Start()
h = m_water->RetLevel(m_object);
if ( pos.y < h ) return ERR_MANIP_WATER; // impossible under water
- other = SearchFriendObject(oAngle, 1.5f, PI*0.50f);
+ other = SearchFriendObject(oAngle, 1.5f, Math::PI*0.50f);
if ( other != 0 && other->RetPower() != 0 )
{
type = other->RetPower()->RetType();
@@ -158,16 +157,16 @@ Error CTaskTake::Start()
type != OBJECT_KEYc &&
type != OBJECT_KEYd &&
type != OBJECT_TNT ) return ERR_MANIP_FRIEND;
-//? m_camera->StartCentering(m_object, PI*0.3f, -PI*0.1f, 0.0f, 0.8f);
+//? m_camera->StartCentering(m_object, Math::PI*0.3f, -Math::PI*0.1f, 0.0f, 0.8f);
m_arm = TTA_FRIEND;
}
else
{
- other = SearchTakeObject(oAngle, 1.5f, PI*0.45f);
+ other = SearchTakeObject(oAngle, 1.5f, Math::PI*0.45f);
if ( other == 0 ) return ERR_MANIP_NIL;
type = other->RetType();
if ( type == OBJECT_URANIUM ) return ERR_MANIP_RADIO;
-//? m_camera->StartCentering(m_object, PI*0.3f, 99.9f, 0.0f, 0.8f);
+//? m_camera->StartCentering(m_object, Math::PI*0.3f, 99.9f, 0.0f, 0.8f);
m_arm = TTA_FFRONT;
m_main->HideDropZone(other); // hides buildable area
}
@@ -179,16 +178,16 @@ Error CTaskTake::Start()
//? if ( speed.x != 0.0f ||
//? speed.z != 0.0f ) return ERR_MANIP_MOTOR;
- other = SearchFriendObject(oAngle, 1.5f, PI*0.50f);
+ other = SearchFriendObject(oAngle, 1.5f, Math::PI*0.50f);
if ( other != 0 && other->RetPower() == 0 )
{
-//? m_camera->StartCentering(m_object, PI*0.3f, -PI*0.1f, 0.0f, 0.8f);
+//? m_camera->StartCentering(m_object, Math::PI*0.3f, -Math::PI*0.1f, 0.0f, 0.8f);
m_arm = TTA_FRIEND;
}
else
{
if ( !IsFreeDeposeObject(D3DVECTOR(2.5f, 0.0f, 0.0f)) ) return ERR_MANIP_OCC;
-//? m_camera->StartCentering(m_object, PI*0.3f, 99.9f, 0.0f, 0.8f);
+//? m_camera->StartCentering(m_object, Math::PI*0.3f, 99.9f, 0.0f, 0.8f);
m_arm = TTA_FFRONT;
}
}
@@ -215,9 +214,9 @@ Error CTaskTake::IsEnded()
if ( m_bTurn ) // preliminary rotation?
{
angle = m_object->RetAngleY(0);
- angle = NormAngle(angle); // 0..2*PI
+ angle = Math::NormAngle(angle); // 0..2*Math::PI
- if ( TestAngle(angle, m_angle-PI*0.01f, m_angle+PI*0.01f) )
+ if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
{
m_bTurn = false; // rotation ended
m_physics->SetMotorSpeedZ(0.0f);
@@ -321,7 +320,7 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
min = 1000000.0f;
pBest = 0;
@@ -356,11 +355,11 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
if ( distance >= 4.0f-dLimit &&
distance <= 4.0f+dLimit )
{
- angle = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
+ angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
{
- a = Abs(angle-iAngle);
- if ( a > PI ) a = PI*2.0f-a;
+ a = fabs(angle-iAngle);
+ if ( a > Math::PI ) a = Math::PI*2.0f-a;
if ( a < min )
{
min = a;
@@ -390,7 +389,7 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
iAngle = m_object->RetAngleY(0);
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
for ( i=0 ; i<1000000 ; i++ )
{
@@ -447,11 +446,11 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
character = pObj->RetCharacter();
oPos = Transform(*mat, character->posPower);
- distance = Abs(Length(oPos, iPos) - (iRad+1.0f));
+ distance = fabs(Length(oPos, iPos) - (iRad+1.0f));
if ( distance <= dLimit )
{
- angle = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
+ angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
{
character = pObj->RetCharacter();
m_height = character->posPower.y;
@@ -474,8 +473,8 @@ bool CTaskTake::TruckTakeObject()
if ( m_arm == TTA_FFRONT ) // takes on the ground in front?
{
-//? fret = SearchTakeObject(angle, 1.5f, PI*0.04f);
- fret = SearchTakeObject(angle, 1.5f, PI*0.15f); //OK 1.9
+//? fret = SearchTakeObject(angle, 1.5f, Math::PI*0.04f);
+ fret = SearchTakeObject(angle, 1.5f, Math::PI*0.15f); //OK 1.9
if ( fret == 0 ) return false; // rien � prendre ?
m_fretType = fret->RetType();
@@ -493,7 +492,7 @@ bool CTaskTake::TruckTakeObject()
if ( m_arm == TTA_FRIEND ) // takes friend's battery?
{
- other = SearchFriendObject(angle, 1.5f, PI*0.04f);
+ other = SearchFriendObject(angle, 1.5f, Math::PI*0.04f);
if ( other == 0 ) return false;
fret = other->RetPower();
@@ -537,7 +536,7 @@ bool CTaskTake::TruckDeposeObject()
pos = Transform(*mat, D3DVECTOR(-0.5f, 1.0f, 0.0f));
m_terrain->MoveOnFloor(pos);
fret->SetPosition(0, pos);
- fret->SetAngleY(0, m_object->RetAngleY(0)+PI/2.0f);
+ fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
fret->FloorAdjust(); // plate well on the ground
@@ -548,7 +547,7 @@ bool CTaskTake::TruckDeposeObject()
if ( m_arm == TTA_FRIEND ) // deposes battery on friends?
{
- other = SearchFriendObject(angle, 1.5f, PI*0.04f);
+ other = SearchFriendObject(angle, 1.5f, Math::PI*0.04f);
if ( other == 0 ) return false;
fret = other->RetPower();
diff --git a/src/object/task/tasktake.h b/src/object/task/tasktake.h
index f94c366..68d2c8e 100644
--- a/src/object/task/tasktake.h
+++ b/src/object/task/tasktake.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "object/object.h"
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
index 1432c3e..efa251f 100644
--- a/src/object/task/taskterraform.cpp
+++ b/src/object/task/taskterraform.cpp
@@ -16,8 +16,6 @@
// taskterraform.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -72,7 +70,7 @@ bool CTaskTerraform::EventProcess(const Event &event)
CObject* power;
D3DMATRIX* mat;
D3DVECTOR pos, dir, speed;
- FPOINT dim;
+ Math::Point dim;
float energy;
if ( m_engine->RetPause() ) return true;
@@ -98,7 +96,7 @@ bool CTaskTerraform::EventProcess(const Event &event)
}
dir.x = 0.0f;
- dir.y = (Rand()-0.5f)*0.2f*m_progress;
+ dir.y = (Math::Rand()-0.5f)*0.2f*m_progress;
dir.z = 0.0f;
m_object->SetCirVibration(dir);
@@ -160,12 +158,12 @@ bool CTaskTerraform::EventProcess(const Event &event)
{
// Battery.
pos = D3DVECTOR(-6.0f, 5.5f+2.0f*m_progress, 0.0f);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*6.0f*(1.0f+m_progress*4.0f);
- speed.z = (Rand()-0.5f)*6.0f*(1.0f+m_progress*4.0f);
- speed.y = 6.0f+Rand()*4.0f*(1.0f+m_progress*2.0f);
+ speed.x = (Math::Rand()-0.5f)*6.0f*(1.0f+m_progress*4.0f);
+ speed.z = (Math::Rand()-0.5f)*6.0f*(1.0f+m_progress*4.0f);
+ speed.y = 6.0f+Math::Rand()*4.0f*(1.0f+m_progress*2.0f);
dim.x = 0.5f+1.5f*m_progress;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 2.0f, 20.0f);
@@ -175,29 +173,29 @@ bool CTaskTerraform::EventProcess(const Event &event)
{
// Left grid.
pos = D3DVECTOR(-1.0f, 5.8f, 3.5f);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
pos = Transform(*mat, pos);
- speed.x = Rand()*4.0f;
- speed.z = Rand()*2.0f;
- speed.y = 2.5f+Rand()*1.0f;
+ speed.x = Math::Rand()*4.0f;
+ speed.z = Math::Rand()*2.0f;
+ speed.y = 2.5f+Math::Rand()*1.0f;
speed = Transform(*mat, speed);
speed -= m_object->RetPosition(0);
- dim.x = Rand()*1.0f+1.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 3.0f);
// Right grid.
pos = D3DVECTOR(-1.0f, 5.8f, -3.5f);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
pos = Transform(*mat, pos);
- speed.x = Rand()*4.0f;
- speed.z = -Rand()*2.0f;
- speed.y = 2.5f+Rand()*1.0f;
+ speed.x = Math::Rand()*4.0f;
+ speed.z = -Math::Rand()*2.0f;
+ speed.y = 2.5f+Math::Rand()*1.0f;
speed = Transform(*mat, speed);
speed -= m_object->RetPosition(0);
- dim.x = Rand()*1.0f+1.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 3.0f);
}
@@ -249,7 +247,7 @@ Error CTaskTerraform::Start()
m_bError = false; // ok
- m_camera->StartCentering(m_object, PI*0.35f, 99.9f, 20.0f, 2.0f);
+ m_camera->StartCentering(m_object, Math::PI*0.35f, 99.9f, 20.0f, 2.0f);
return ERR_OK;
}
@@ -259,7 +257,7 @@ Error CTaskTerraform::IsEnded()
{
CObject* power;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float dist, duration;
int i, max;
@@ -298,26 +296,26 @@ Error CTaskTerraform::IsEnded()
max= (int)(50.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<max ; i++ )
{
- pos.x = m_terraPos.x+(Rand()-0.5f)*80.0f;
- pos.z = m_terraPos.z+(Rand()-0.5f)*80.0f;
+ pos.x = m_terraPos.x+(Math::Rand()-0.5f)*80.0f;
+ pos.z = m_terraPos.z+(Math::Rand()-0.5f)*80.0f;
pos.y = m_terraPos.y;
m_terrain->MoveOnFloor(pos);
dist = Length(pos, m_terraPos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = 2.0f+(40.0f-dist)/(1.0f+Rand()*4.0f);
+ dim.x = 2.0f+(40.0f-dist)/(1.0f+Math::Rand()*4.0f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
pos = m_terraPos;
- speed.x = (Rand()-0.5f)*40.0f;
- speed.z = (Rand()-0.5f)*40.0f;
- speed.y = Rand()*15.0f+15.0f;
+ speed.x = (Math::Rand()-0.5f)*40.0f;
+ speed.z = (Math::Rand()-0.5f)*40.0f;
+ speed.y = Math::Rand()*15.0f+15.0f;
dim.x = 0.6f;
dim.y = dim.x;
pos.y += dim.y;
- duration = Rand()*3.0f+3.0f;
+ duration = Math::Rand()*3.0f+3.0f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK5,
- duration, Rand()*10.0f+15.0f,
+ duration, Math::Rand()*10.0f+15.0f,
duration*0.2f, 1.0f);
}
@@ -410,14 +408,14 @@ bool CTaskTerraform::Terraform()
{
brain = pObj->RetBrain();
if ( brain != 0 ) brain->StopTask();
- motion->SetAction(MAS_BACK1, 0.8f+Rand()*0.3f);
+ motion->SetAction(MAS_BACK1, 0.8f+Math::Rand()*0.3f);
pObj->SetFixed(true); // not moving
}
if ( type == OBJECT_SPIDER )
{
brain = pObj->RetBrain();
if ( brain != 0 ) brain->StopTask();
- motion->SetAction(MSS_BACK1, 0.8f+Rand()*0.3f);
+ motion->SetAction(MSS_BACK1, 0.8f+Math::Rand()*0.3f);
pObj->SetFixed(true); // not moving
}
}
diff --git a/src/object/task/taskterraform.h b/src/object/task/taskterraform.h
index dfb3488..7d5ef30 100644
--- a/src/object/task/taskterraform.h
+++ b/src/object/task/taskterraform.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp
index 35f1eb9..9b02a0c 100644
--- a/src/object/task/taskturn.cpp
+++ b/src/object/task/taskturn.cpp
@@ -16,8 +16,6 @@
// taskturn.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/object/task/taskturn.h b/src/object/task/taskturn.h
index b9a432b..880c4b5 100644
--- a/src/object/task/taskturn.h
+++ b/src/object/task/taskturn.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
class CInstanceManager;
diff --git a/src/object/task/taskwait.cpp b/src/object/task/taskwait.cpp
index 64883c1..9bd5197 100644
--- a/src/object/task/taskwait.cpp
+++ b/src/object/task/taskwait.cpp
@@ -16,8 +16,6 @@
// taskwait.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
diff --git a/src/object/task/taskwait.h b/src/object/task/taskwait.h
index 25e8e67..5fec9ae 100644
--- a/src/object/task/taskwait.h
+++ b/src/object/task/taskwait.h
@@ -19,7 +19,7 @@
#pragma once
-#include "common/misc.h"
+#include "object/task/task.h"
class CInstanceManager;
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index b105a44..7490ab6 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -16,14 +16,14 @@
// physics.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/language.h"
@@ -1027,8 +1027,8 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
factor /= power->RetCapacity();
energy = power->RetEnergy();
- energy -= Abs(motorSpeed.x)*rTime*factor*0.005f;
- energy -= Abs(motorSpeed.z)*rTime*factor*0.005f;
+ energy -= fabs(motorSpeed.x)*rTime*factor*0.005f;
+ energy -= fabs(motorSpeed.z)*rTime*factor*0.005f;
if ( m_type == TYPE_FLYING && motorSpeed.y > 0.0f )
{
@@ -1074,13 +1074,13 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
vibLin.y = sinf(aTime*2.00f)*0.5f+
sinf(aTime*2.11f)*0.3f;
- vibCir.z = sinf(aTime*PI* 2.01f)*(PI/150.0f)+
- sinf(aTime*PI* 2.51f)*(PI/200.0f)+
- sinf(aTime*PI*19.01f)*(PI/400.0f);
+ vibCir.z = sinf(aTime*Math::PI* 2.01f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.51f)*(Math::PI/200.0f)+
+ sinf(aTime*Math::PI*19.01f)*(Math::PI/400.0f);
- vibCir.x = sinf(aTime*PI* 2.03f)*(PI/150.0f)+
- sinf(aTime*PI* 2.52f)*(PI/200.0f)+
- sinf(aTime*PI*19.53f)*(PI/400.0f);
+ vibCir.x = sinf(aTime*Math::PI* 2.03f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.52f)*(Math::PI/200.0f)+
+ sinf(aTime*Math::PI*19.53f)*(Math::PI/400.0f);
speedLin = m_linMotion.realSpeed.x / m_linMotion.advanceSpeed.x;
speedCir = m_cirMotion.realSpeed.y / m_cirMotion.advanceSpeed.y;
@@ -1120,14 +1120,14 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
vibLin.y = sinf(aTime*2.00f)*0.5f+
sinf(aTime*2.11f)*0.3f;
- vibCir.z = sinf(aTime*PI* 2.01f)*(PI/150.0f)+
- sinf(aTime*PI* 2.51f)*(PI/200.0f)+
-//? sinf(aTime*PI*19.01f)*(PI/400.0f)-PI/2.0f;
- sinf(aTime*PI*19.01f)*(PI/400.0f);
+ vibCir.z = sinf(aTime*Math::PI* 2.01f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.51f)*(Math::PI/200.0f)+
+//? sinf(aTime*Math::PI*19.01f)*(Math::PI/400.0f)-Math::PI/2.0f;
+ sinf(aTime*Math::PI*19.01f)*(Math::PI/400.0f);
- vibCir.x = sinf(aTime*PI* 2.03f)*(PI/150.0f)+
- sinf(aTime*PI* 2.52f)*(PI/200.0f)+
- sinf(aTime*PI*19.53f)*(PI/400.0f);
+ vibCir.x = sinf(aTime*Math::PI* 2.03f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.52f)*(Math::PI/200.0f)+
+ sinf(aTime*Math::PI*19.53f)*(Math::PI/400.0f);
speedLin = m_linMotion.realSpeed.x / m_linMotion.advanceSpeed.x;
speedCir = m_cirMotion.realSpeed.y / m_cirMotion.advanceSpeed.y;
@@ -1162,7 +1162,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
{
vibCir.z += m_linMotion.realSpeed.y*0.12f;
}
- vibCir.z -= PI*0.4f;
+ vibCir.z -= Math::PI*0.4f;
vibLin *= m_linVibrationFactor;
vibCir *= m_cirVibrationFactor;
@@ -1197,7 +1197,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
speedLin /= m_linMotion.advanceSpeed.x;
if ( speedLin > 1.0f ) speedLin = 1.0f;
m_linMotion.finalInclin.z = -speedLin*0.30f;
- accel = (0.40f-Abs(incl.z))*4.0f;
+ accel = (0.40f-fabs(incl.z))*4.0f;
if ( incl.z < m_linMotion.finalInclin.z )
{
incl.z += rTime*accel;
@@ -1220,8 +1220,8 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
vibLin.x = 0.0f;
vibLin.z = 0.0f;
- vibLin.y = Abs(character->wheelFront*sinf(incl.z))*0.8f +
- Abs(character->wheelRight*sinf(incl.x))*0.5f;
+ vibLin.y = fabs(character->wheelFront*sinf(incl.z))*0.8f +
+ fabs(character->wheelRight*sinf(incl.x))*0.5f;
m_motion->SetLinVibration(vibLin);
}
@@ -1242,13 +1242,13 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
vibLin.y = sinf(aTime*2.00f)*0.5f+
sinf(aTime*2.11f)*0.3f;
- vibCir.z = sinf(aTime*PI* 2.01f)*(PI/150.0f)+
- sinf(aTime*PI* 2.51f)*(PI/200.0f)+
- sinf(aTime*PI*19.01f)*(PI/400.0f);
+ vibCir.z = sinf(aTime*Math::PI* 2.01f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.51f)*(Math::PI/200.0f)+
+ sinf(aTime*Math::PI*19.01f)*(Math::PI/400.0f);
- vibCir.x = sinf(aTime*PI* 2.03f)*(PI/150.0f)+
- sinf(aTime*PI* 2.52f)*(PI/200.0f)+
- sinf(aTime*PI*19.53f)*(PI/400.0f);
+ vibCir.x = sinf(aTime*Math::PI* 2.03f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.52f)*(Math::PI/200.0f)+
+ sinf(aTime*Math::PI*19.53f)*(Math::PI/400.0f);
if ( bOnBoard ) vibCir *= 0.4f;
@@ -1295,15 +1295,15 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
vibLin.y = sinf(aTime*2.00f)*0.5f+
sinf(aTime*2.11f)*0.3f;
- vibCir.z = (Rand()-0.5f)*0.1f+
- sinf(aTime*PI* 2.01f)*(PI/150.0f)+
- sinf(aTime*PI* 2.51f)*(PI/200.0f)+
- sinf(aTime*PI*19.01f)*(PI/400.0f);
+ vibCir.z = (Math::Rand()-0.5f)*0.1f+
+ sinf(aTime*Math::PI* 2.01f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.51f)*(Math::PI/200.0f)+
+ sinf(aTime*Math::PI*19.01f)*(Math::PI/400.0f);
- vibCir.x = (Rand()-0.5f)*0.1f+
- sinf(aTime*PI* 2.03f)*(PI/150.0f)+
- sinf(aTime*PI* 2.52f)*(PI/200.0f)+
- sinf(aTime*PI*19.53f)*(PI/400.0f);
+ vibCir.x = (Math::Rand()-0.5f)*0.1f+
+ sinf(aTime*Math::PI* 2.03f)*(Math::PI/150.0f)+
+ sinf(aTime*Math::PI* 2.52f)*(Math::PI/200.0f)+
+ sinf(aTime*Math::PI*19.53f)*(Math::PI/400.0f);
speedLin = m_linMotion.realSpeed.x / m_linMotion.advanceSpeed.x;
speedCir = m_cirMotion.realSpeed.y / m_cirMotion.advanceSpeed.y;
@@ -1370,7 +1370,7 @@ void CPhysics::UpdateMotionStruct(float rTime, Motion &motion)
motion.currentSpeed.x = speed;
motion.realSpeed.x = speed;
- if ( Abs(motion.terrainSpeed.x) > motion.terrainSlide.x )
+ if ( fabs(motion.terrainSpeed.x) > motion.terrainSlide.x )
{
if ( motion.terrainSpeed.x > 0 )
{
@@ -1405,7 +1405,7 @@ void CPhysics::UpdateMotionStruct(float rTime, Motion &motion)
motion.currentSpeed.y = speed;
motion.realSpeed.y = speed;
- if ( Abs(motion.terrainSpeed.y) > motion.terrainSlide.y )
+ if ( fabs(motion.terrainSpeed.y) > motion.terrainSlide.y )
{
if ( motion.terrainSpeed.y > 0 )
{
@@ -1440,7 +1440,7 @@ void CPhysics::UpdateMotionStruct(float rTime, Motion &motion)
motion.currentSpeed.z = speed;
motion.realSpeed.z = speed;
- if ( Abs(motion.terrainSpeed.z) > motion.terrainSlide.z )
+ if ( fabs(motion.terrainSpeed.z) > motion.terrainSlide.z )
{
if ( motion.terrainSpeed.z > 0 )
{
@@ -1519,8 +1519,8 @@ bool CPhysics::EventFrame(const Event &event)
#endif
//? m_linMotion.terrainSpeed.x = -tAngle.z*m_linMotion.terrainForce.x*h;
//? m_linMotion.terrainSpeed.z = tAngle.x*m_linMotion.terrainForce.z*h;
-//? m_linMotion.terrainSpeed.x = -sinf(tAngle.z)*PI*0.5f*m_linMotion.terrainForce.x*h;
-//? m_linMotion.terrainSpeed.z = sinf(tAngle.x)*PI*0.5f*m_linMotion.terrainForce.z*h;
+//? m_linMotion.terrainSpeed.x = -sinf(tAngle.z)*Math::PI*0.5f*m_linMotion.terrainForce.x*h;
+//? m_linMotion.terrainSpeed.z = sinf(tAngle.x)*Math::PI*0.5f*m_linMotion.terrainForce.z*h;
m_linMotion.terrainSpeed.x = -tanf(tAngle.z)*0.9f*m_linMotion.terrainForce.x*h;
m_linMotion.terrainSpeed.z = tanf(tAngle.x)*0.9f*m_linMotion.terrainForce.z*h;
m_linMotion.terrainSpeed.y = 0.0f;
@@ -1628,8 +1628,8 @@ void CPhysics::SoundMotor(float rTime)
if ( m_lastSoundInsect <= 0.0f && m_object->RetActif() )
{
m_sound->Play(SOUND_INSECTm, m_object->RetPosition(0));
- if ( m_bMotor ) m_lastSoundInsect = 0.4f+Rand()*2.5f;
- else m_lastSoundInsect = 1.5f+Rand()*4.0f;
+ if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
+ else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
else if ( type == OBJECT_ANT )
@@ -1639,8 +1639,8 @@ void CPhysics::SoundMotor(float rTime)
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTa, m_object->RetPosition(0), 1.0f, 1.5f+Rand()*0.5f);
- m_lastSoundInsect = 0.4f+Rand()*0.6f;
+ m_sound->Play(SOUND_INSECTa, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_lastSoundInsect = 0.4f+Math::Rand()*0.6f;
}
}
else if ( m_object->RetActif() )
@@ -1648,8 +1648,8 @@ void CPhysics::SoundMotor(float rTime)
if ( m_lastSoundInsect <= 0.0f )
{
m_sound->Play(SOUND_INSECTa, m_object->RetPosition(0));
- if ( m_bMotor ) m_lastSoundInsect = 0.4f+Rand()*2.5f;
- else m_lastSoundInsect = 1.5f+Rand()*4.0f;
+ if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
+ else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
}
@@ -1660,16 +1660,16 @@ void CPhysics::SoundMotor(float rTime)
if ( m_lastSoundInsect <= 0.0f )
{
m_sound->Play(SOUND_INSECTb, m_object->RetPosition(0));
- if ( m_bMotor ) m_lastSoundInsect = 0.4f+Rand()*2.5f;
- else m_lastSoundInsect = 1.5f+Rand()*4.0f;
+ if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
+ else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
else if ( m_object->RetBurn() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTb, m_object->RetPosition(0), 1.0f, 1.5f+Rand()*0.5f);
- m_lastSoundInsect = 0.3f+Rand()*0.5f;
+ m_sound->Play(SOUND_INSECTb, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_lastSoundInsect = 0.3f+Math::Rand()*0.5f;
}
}
}
@@ -1680,16 +1680,16 @@ void CPhysics::SoundMotor(float rTime)
if ( m_lastSoundInsect <= 0.0f )
{
m_sound->Play(SOUND_INSECTw, m_object->RetPosition(0));
- if ( m_bMotor ) m_lastSoundInsect = 0.4f+Rand()*2.5f;
- else m_lastSoundInsect = 1.5f+Rand()*4.0f;
+ if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
+ else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
else if ( m_object->RetBurn() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTw, m_object->RetPosition(0), 1.0f, 1.5f+Rand()*0.5f);
- m_lastSoundInsect = 0.2f+Rand()*0.2f;
+ m_sound->Play(SOUND_INSECTw, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_lastSoundInsect = 0.2f+Math::Rand()*0.2f;
}
}
}
@@ -1700,8 +1700,8 @@ void CPhysics::SoundMotor(float rTime)
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTs, m_object->RetPosition(0), 1.0f, 1.5f+Rand()*0.5f);
- m_lastSoundInsect = 0.4f+Rand()*0.6f;
+ m_sound->Play(SOUND_INSECTs, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_lastSoundInsect = 0.4f+Math::Rand()*0.6f;
}
}
else if ( m_object->RetActif() )
@@ -1709,8 +1709,8 @@ void CPhysics::SoundMotor(float rTime)
if ( m_lastSoundInsect <= 0.0f )
{
m_sound->Play(SOUND_INSECTs, m_object->RetPosition(0));
- if ( m_bMotor ) m_lastSoundInsect = 0.4f+Rand()*2.5f;
- else m_lastSoundInsect = 1.5f+Rand()*4.0f;
+ if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
+ else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
}
@@ -1764,7 +1764,7 @@ void CPhysics::WaterFrame(float aTime, float rTime)
{
ObjectType type;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float level;
level = m_water->RetLevel();
@@ -1781,23 +1781,23 @@ void CPhysics::WaterFrame(float aTime, float rTime)
m_lastFlameParticule = aTime;
pos = m_object->RetPosition(0);
- 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 = Rand()*5.0f+3.0f;
- dim.x = Rand()*2.0f+1.0f;
+ speed.y = Math::Rand()*5.0f+3.0f;
+ dim.x = Math::Rand()*2.0f+1.0f;
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;
- 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 = 6.0f+Rand()*6.0f+6.0f;
- dim.x = Rand()*1.5f+1.0f+3.0f;
+ speed.y = 6.0f+Math::Rand()*6.0f+6.0f;
+ dim.x = Math::Rand()*1.5f+1.0f+3.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
}
@@ -1873,11 +1873,11 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type)
freq = 1.0f+m_linMotion.terrainSpeed.x/50.0f;
if ( m_linMotion.realSpeed.x == 0.0f )
{
- freq -= Abs(m_cirMotion.realSpeed.y/3.0f);
+ freq -= fabs(m_cirMotion.realSpeed.y/3.0f);
}
else
{
- freq -= Abs(m_cirMotion.realSpeed.y/4.0f);
+ freq -= fabs(m_cirMotion.realSpeed.y/4.0f);
}
m_sound->Frequency(m_soundChannel, freq);
@@ -1928,7 +1928,7 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type)
time = 0.1f;
}
- freq = 0.75f+(Abs(m_motorSpeed.x)+Abs(m_motorSpeed.z))*0.25f;
+ freq = 0.75f+(fabs(m_motorSpeed.x)+fabs(m_motorSpeed.z))*0.25f;
if ( freq > 1.0f ) freq = 1.0f;
if ( m_object->RetToy() ) freq = 1.0f;
@@ -1952,7 +1952,7 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type)
}
freq *= 1.0f + m_linMotion.terrainSpeed.x/100.0f;
- freq *= 1.0f + Abs(m_cirMotion.realSpeed.y/20.0f);
+ freq *= 1.0f + fabs(m_cirMotion.realSpeed.y/20.0f);
m_sound->Frequency(m_soundChannel, freq);
m_soundTimePshhh -= rTime*2.0f;
@@ -1964,7 +1964,7 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type)
{
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
Sound sound;
float amplitude;
int i, max;
@@ -2059,25 +2059,25 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type)
//? m_sound->Play(SOUND_PSHHH, m_object->RetPosition(0), amplitude);
m_sound->Play(SOUND_PSHHH, m_object->RetPosition(0), 1.0f);
- m_soundTimePshhh = 4.0f+4.0f*Rand();
+ m_soundTimePshhh = 4.0f+4.0f*Math::Rand();
max = (int)(10.0f*m_engine->RetParticuleDensity());
for ( i=0 ; i<max ; i++ )
{
pos = D3DVECTOR(-5.0f, 2.0f, 0.0f);
- pos.x += Rand()*4.0f;
- pos.z += (Rand()-0.5f)*2.0f;
+ pos.x += Math::Rand()*4.0f;
+ pos.z += (Math::Rand()-0.5f)*2.0f;
speed = pos;
- speed.x -= Rand()*4.0f;
- speed.y -= Rand()*3.0f;
- speed.z += (Rand()-0.5f)*6.0f;
+ speed.x -= Math::Rand()*4.0f;
+ speed.y -= Math::Rand()*3.0f;
+ speed.z += (Math::Rand()-0.5f)*6.0f;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Transform(*mat, speed)-pos;
- dim.x = Rand()*1.0f+1.0f;
+ dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIMOTOR, 2.0f);
@@ -2121,7 +2121,7 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
Sound sound;
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float freq;
int i;
@@ -2156,7 +2156,7 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
}
freq = 1.0f + m_linMotion.realSpeed.y/100.0f;
- freq *= 1.0f + Abs(m_cirMotion.realSpeed.y/5.0f);
+ freq *= 1.0f + fabs(m_cirMotion.realSpeed.y/5.0f);
m_sound->Frequency(m_soundChannel, freq);
}
else
@@ -2170,7 +2170,7 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
if ( m_timeReactorFail <= m_time )
{
- freq = 1.0f+Rand()*0.5f;
+ freq = 1.0f+Math::Rand()*0.5f;
m_sound->Play(SOUND_FLYf, m_object->RetPosition(0), 1.0f, freq);
m_camera->StartEffect(CE_PET, m_object->RetPosition(0), 1.0f);
@@ -2185,19 +2185,19 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
{
pos = D3DVECTOR(0.0f, -1.0f, 0.0f);
}
- 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;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*5.0f;
- speed.z = (Rand()-0.5f)*5.0f;
- speed.y = -(4.0f+Rand()*4.0f);
- dim.x = (2.0f+Rand()*1.0f);
+ speed.x = (Math::Rand()-0.5f)*5.0f;
+ speed.z = (Math::Rand()-0.5f)*5.0f;
+ speed.y = -(4.0f+Math::Rand()*4.0f);
+ dim.x = (2.0f+Math::Rand()*1.0f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 2.0f, 0.0f, 0.1f);
}
- m_timeReactorFail = m_time+0.10f+Rand()*0.30f;
+ m_timeReactorFail = m_time+0.10f+Math::Rand()*0.30f;
}
else
{
@@ -2210,14 +2210,14 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
{
pos = D3DVECTOR(0.0f, -1.0f, 0.0f);
}
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = -(4.0f+Rand()*4.0f);
- dim.x = (0.7f+Rand()*0.4f);
+ 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 = (0.7f+Math::Rand()*0.4f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 2.0f, 0.0f, 0.1f);
}
@@ -2308,8 +2308,8 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
m_floorHeight = h;
WaterParticule(aTime, pos, type, m_floorLevel,
- Abs(m_linMotion.realSpeed.x),
- Abs(m_cirMotion.realSpeed.y*15.0f));
+ fabs(m_linMotion.realSpeed.x),
+ fabs(m_cirMotion.realSpeed.y*15.0f));
if ( m_type == TYPE_ROLLING )
{
@@ -2325,23 +2325,23 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
if ( !m_bLand ) // in flight?
{
m_terrain->GetNormal(norm, pos);
- a1 = Abs(RotateAngle(Length(norm.x, norm.z), norm.y));
- if ( a1 < (90.0f-55.0f)*PI/180.0f ) // slope exceeds 55 degrees?
+ a1 = fabs(Math::RotateAngle(Length(norm.x, norm.z), norm.y));
+ if ( a1 < (90.0f-55.0f)*Math::PI/180.0f ) // slope exceeds 55 degrees?
{
bSlopingTerrain = true; // very sloped ground
if ( h < 4.0f ) // collision with the ground?
{
- force = 5.0f+Abs(m_linMotion.realSpeed.x*0.3f)+
- Abs(m_linMotion.realSpeed.y*0.3f);
+ force = 5.0f+fabs(m_linMotion.realSpeed.x*0.3f)+
+ fabs(m_linMotion.realSpeed.y*0.3f);
m_linMotion.currentSpeed = norm*force;
MatRotateXZY(matRotate, -angle);
m_linMotion.currentSpeed = Transform(matRotate, m_linMotion.currentSpeed);
if ( aTime-m_soundTimeBoum > 0.5f )
{
- volume = Abs(m_linMotion.realSpeed.x*0.02f)+
- Abs(m_linMotion.realSpeed.y*0.02f);
+ volume = fabs(m_linMotion.realSpeed.x*0.02f)+
+ fabs(m_linMotion.realSpeed.y*0.02f);
freq = 0.5f+m_terrain->RetHardness(pos)*2.5f;
m_sound->Play(SOUND_BOUM, pos, volume, freq);
@@ -2357,7 +2357,7 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
{
if ( !m_bLand ) // in flight?
{
- volume = Abs(m_linMotion.realSpeed.y*0.02f);
+ volume = fabs(m_linMotion.realSpeed.y*0.02f);
freq = 0.5f+m_terrain->RetHardness(pos)*2.5f;
m_sound->Play(SOUND_BOUM, pos, volume, freq);
}
@@ -2369,7 +2369,7 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
if ( h < 0.0f )
{
- f = Abs(m_linMotion.currentSpeed.y/m_linMotion.advanceSpeed.y);
+ f = fabs(m_linMotion.currentSpeed.y/m_linMotion.advanceSpeed.y);
CrashParticule(f);
}
m_linMotion.currentSpeed.y = 0.0f;
@@ -2465,26 +2465,26 @@ void CPhysics::FloorAngle(const D3DVECTOR &pos, D3DVECTOR &angle)
character = m_object->RetCharacter();
- pw.x = pos.x+character->wheelFront*cosf(angle.y+PI*0.0f);
+ pw.x = pos.x+character->wheelFront*cosf(angle.y+Math::PI*0.0f);
pw.y = pos.y;
- pw.z = pos.z-character->wheelFront*sinf(angle.y+PI*0.0f);
+ pw.z = pos.z-character->wheelFront*sinf(angle.y+Math::PI*0.0f);
a1 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelFront);
- pw.x = pos.x+character->wheelBack*cosf(angle.y+PI*1.0f);
+ pw.x = pos.x+character->wheelBack*cosf(angle.y+Math::PI*1.0f);
pw.y = pos.y;
- pw.z = pos.z-character->wheelBack*sinf(angle.y+PI*1.0f);
+ pw.z = pos.z-character->wheelBack*sinf(angle.y+Math::PI*1.0f);
a2 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelBack);
angle.z = (a2-a1)/2.0f;
- pw.x = pos.x+character->wheelLeft*cosf(angle.y+PI*0.5f)*cosf(angle.z);
+ pw.x = pos.x+character->wheelLeft*cosf(angle.y+Math::PI*0.5f)*cosf(angle.z);
pw.y = pos.y;
- pw.z = pos.z-character->wheelLeft*sinf(angle.y+PI*0.5f)*cosf(angle.z);
+ pw.z = pos.z-character->wheelLeft*sinf(angle.y+Math::PI*0.5f)*cosf(angle.z);
a1 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelLeft);
- pw.x = pos.x+character->wheelRight*cosf(angle.y+PI*1.5f)*cosf(angle.z);
+ pw.x = pos.x+character->wheelRight*cosf(angle.y+Math::PI*1.5f)*cosf(angle.z);
pw.y = pos.y;
- pw.z = pos.z-character->wheelRight*sinf(angle.y+PI*1.5f)*cosf(angle.z);
+ pw.z = pos.z-character->wheelRight*sinf(angle.y+Math::PI*1.5f)*cosf(angle.z);
a2 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelRight);
angle.x = (a2-a1)/2.0f;
@@ -2623,7 +2623,7 @@ int CPhysics::ObjectAdapt(const D3DVECTOR &pos, const D3DVECTOR &angle)
sound = pObj->RetCrashSphereSound(j-1);
if ( sound != SOUND_CLICK )
{
- force = Abs(m_linMotion.realSpeed.x);
+ force = fabs(m_linMotion.realSpeed.x);
force *= pObj->RetCrashSphereHardness(j-1)*2.0f;
if ( ExploOther(iType, pObj, oType, force) ) continue;
colType = ExploHimself(iType, oType, force);
@@ -2633,7 +2633,7 @@ int CPhysics::ObjectAdapt(const D3DVECTOR &pos, const D3DVECTOR &angle)
force = Length(m_linMotion.realSpeed);
force *= pObj->RetCrashSphereHardness(j-1);
- volume = Abs(force*0.05f);
+ volume = fabs(force*0.05f);
if ( volume > 1.0f ) volume = 1.0f;
if ( sound != SOUND_CLICK )
{
@@ -3029,7 +3029,7 @@ void CPhysics::FrameParticule(float aTime, float rTime)
if ( bFlash )
{
intensity = 0.0f;
- if ( Rand() < 0.5f ) intensity = 1.0f;
+ if ( Math::Rand() < 0.5f ) intensity = 1.0f;
m_light->SetLightIntensity(effectLight, intensity);
m_light->SetLightIntensitySpeed(effectLight, 10000.0f);
}
@@ -3048,7 +3048,7 @@ void CPhysics::PowerParticule(float factor, bool bBreak)
CObject* fret;
D3DMATRIX* mat;
D3DVECTOR pos, ppos, eye, speed;
- FPOINT dim;
+ Math::Point dim;
bool bCarryPower;
bCarryPower = false;
@@ -3067,12 +3067,12 @@ void CPhysics::PowerParticule(float factor, bool bBreak)
pos.y += 1.0f; // battery center position
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*12.0f;
- speed.y = (Rand()-0.5f)*12.0f;
- speed.z = (Rand()-0.5f)*12.0f;
+ speed.x = (Math::Rand()-0.5f)*12.0f;
+ speed.y = (Math::Rand()-0.5f)*12.0f;
+ speed.z = (Math::Rand()-0.5f)*12.0f;
ppos.x = pos.x;
- ppos.y = pos.y+(Rand()-0.5f)*2.0f;
+ ppos.y = pos.y+(Math::Rand()-0.5f)*2.0f;
ppos.z = pos.z;
dim.x = 1.0f*factor;
@@ -3085,13 +3085,13 @@ void CPhysics::PowerParticule(float factor, bool bBreak)
pos = D3DVECTOR(3.0f, 5.6f, 0.0f); // position of battery holder
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*12.0f;
- speed.y = (Rand()-0.5f)*12.0f;
- speed.z = (Rand()-0.5f)*12.0f;
+ speed.x = (Math::Rand()-0.5f)*12.0f;
+ speed.y = (Math::Rand()-0.5f)*12.0f;
+ speed.z = (Math::Rand()-0.5f)*12.0f;
ppos.x = pos.x;
ppos.y = pos.y;
- ppos.z = pos.z+(Rand()-0.5f)*2.0f;
+ ppos.z = pos.z+(Math::Rand()-0.5f)*2.0f;
dim.x = 1.0f*factor;
dim.y = 1.0f*factor;
@@ -3106,7 +3106,7 @@ void CPhysics::PowerParticule(float factor, bool bBreak)
void CPhysics::CrashParticule(float crash)
{
D3DVECTOR pos, ppos, speed;
- FPOINT dim;
+ Math::Point dim;
float len;
int i, max;
@@ -3120,9 +3120,9 @@ void CPhysics::CrashParticule(float crash)
for ( i=0 ; i<max ; i++ )
{
- ppos.x = pos.x + (Rand()-0.5f)*15.0f*crash;
- ppos.z = pos.z + (Rand()-0.5f)*15.0f*crash;
- ppos.y = pos.y + Rand()*4.0f;
+ ppos.x = pos.x + (Math::Rand()-0.5f)*15.0f*crash;
+ ppos.z = pos.z + (Math::Rand()-0.5f)*15.0f*crash;
+ ppos.y = pos.y + Math::Rand()*4.0f;
len = 1.0f-(Length(ppos, pos)/(15.0f+5.0f));
if ( len <= 0.0f ) continue;
speed.x = (ppos.x-pos.x)*0.1f;
@@ -3140,9 +3140,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
D3DMATRIX* mat;
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
ObjectType type;
- FPOINT c, p;
+ Math::Point c, p;
float h, a, delay, level;
int r, i, nb;
@@ -3174,13 +3174,13 @@ void CPhysics::MotorParticule(float aTime, float rTime)
for ( i=0 ; i<nb ; i++ )
{
pos = m_object->RetPosition(0);
- pos.x += (Rand()-0.5f)*4.0f;
- pos.y += (Rand()-0.5f)*4.0f;
- pos.z += (Rand()-0.5f)*4.0f;
- speed.y = (Rand()-0.5f)*8.0f+8.0f;
- speed.x = (Rand()-0.5f)*0.2f;
- speed.z = (Rand()-0.5f)*0.2f;
- dim.x = 0.06f+Rand()*0.10f;
+ pos.x += (Math::Rand()-0.5f)*4.0f;
+ pos.y += (Math::Rand()-0.5f)*4.0f;
+ pos.z += (Math::Rand()-0.5f)*4.0f;
+ speed.y = (Math::Rand()-0.5f)*8.0f+8.0f;
+ speed.x = (Math::Rand()-0.5f)*0.2f;
+ speed.z = (Math::Rand()-0.5f)*0.2f;
+ dim.x = 0.06f+Math::Rand()*0.10f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
}
@@ -3213,11 +3213,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
for ( i=0 ; i<nb ; i++ )
{
pos = m_object->RetPosition(0);
- if ( type == OBJECT_HUMAN ) pos.y -= Rand()*2.0f;
- else pos.y += Rand()*2.0f;
- pos.x += (Rand()-0.5f)*2.0f;
- pos.z += (Rand()-0.5f)*2.0f;
- speed.y = -((Rand()-0.5f)*8.0f+8.0f);
+ if ( type == OBJECT_HUMAN ) pos.y -= Math::Rand()*2.0f;
+ else pos.y += Math::Rand()*2.0f;
+ pos.x += (Math::Rand()-0.5f)*2.0f;
+ pos.z += (Math::Rand()-0.5f)*2.0f;
+ speed.y = -((Math::Rand()-0.5f)*8.0f+8.0f);
speed.x = 0.0f;
speed.z = 0.0f;
dim.x = 0.2f;
@@ -3233,21 +3233,21 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( m_bLand &&
aTime-m_lastSlideParticule >= m_engine->ParticuleAdapt(0.05f) )
{
- h = Max(Abs(m_linMotion.terrainSpeed.x),
- Abs(m_linMotion.terrainSpeed.z));
+ h = Math::Max(fabs(m_linMotion.terrainSpeed.x),
+ fabs(m_linMotion.terrainSpeed.z));
if ( h > m_linMotion.terrainSlide.x+0.5f &&
m_linMotion.motorSpeed.x == 0.0f ) // slides a stop?
{
m_lastSlideParticule = aTime;
mat = m_object->RetWorldMatrix(0);
- pos.x = (Rand()-0.5f)*1.0f;
+ pos.x = (Math::Rand()-0.5f)*1.0f;
pos.y = -m_object->RetCharacter()->height;
- pos.z = Rand()*0.4f+1.0f;
+ pos.z = Math::Rand()*0.4f+1.0f;
if ( rand()%2 == 0 ) pos.z = -pos.z;
pos = Transform(*mat, pos);
speed = D3DVECTOR(0.0f, 1.0f, 0.0f);
- dim.x = Rand()*(h-5.0f)/2.0f+1.0f;
+ dim.x = Math::Rand()*(h-5.0f)/2.0f+1.0f;
if ( dim.x > 2.5f ) dim.x = 2.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.2f);
@@ -3262,19 +3262,19 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
if ( aTime-m_lastSlideParticule >= m_engine->ParticuleAdapt(0.05f) )
{
- h = Abs(m_linMotion.motorSpeed.x-m_linMotion.realSpeed.x);
+ h = fabs(m_linMotion.motorSpeed.x-m_linMotion.realSpeed.x);
if ( h > 5.0f )
{
m_lastSlideParticule = aTime;
mat = m_object->RetWorldMatrix(0);
- pos.x = (Rand()-0.5f)*8.0f;
+ pos.x = (Math::Rand()-0.5f)*8.0f;
pos.y = 0.0f;
- pos.z = Rand()*2.0f+3.0f;
+ pos.z = Math::Rand()*2.0f+3.0f;
if ( rand()%2 == 0 ) pos.z = -pos.z;
pos = Transform(*mat, pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*(h-5.0f)/2.0f+1.0f;
+ dim.x = Math::Rand()*(h-5.0f)/2.0f+1.0f;
if ( dim.x > 3.0f ) dim.x = 3.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.2f);
@@ -3289,19 +3289,19 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
if ( aTime-m_lastSlideParticule >= m_engine->ParticuleAdapt(0.05f) )
{
- h = Abs(m_linMotion.motorSpeed.x-m_linMotion.realSpeed.x);
+ h = fabs(m_linMotion.motorSpeed.x-m_linMotion.realSpeed.x);
if ( h > 5.0f )
{
m_lastSlideParticule = aTime;
mat = m_object->RetWorldMatrix(0);
- pos.x = (Rand()-0.5f)*9.0f;
+ pos.x = (Math::Rand()-0.5f)*9.0f;
pos.y = 0.0f;
- pos.z = Rand()*3.0f+3.0f;
+ pos.z = Math::Rand()*3.0f+3.0f;
if ( rand()%2 == 0 ) pos.z = -pos.z;
pos = Transform(*mat, pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*(h-5.0f)/2.0f+1.0f;
+ dim.x = Math::Rand()*(h-5.0f)/2.0f+1.0f;
if ( dim.x > 3.0f ) dim.x = 3.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.2f);
@@ -3330,11 +3330,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*0.6f;
- speed.z = (Rand()-0.5f)*0.6f;
- speed.y = -(0.5f+Rand()*0.3f)*(1.0f-m_reactorTemperature);
+ speed.x = (Math::Rand()-0.5f)*0.6f;
+ speed.z = (Math::Rand()-0.5f)*0.6f;
+ speed.y = -(0.5f+Math::Rand()*0.3f)*(1.0f-m_reactorTemperature);
- dim.x = (1.0f+Rand()*0.5f)*(0.2f+m_reactorTemperature*0.8f);
+ dim.x = (1.0f+Math::Rand()*0.5f)*(0.2f+m_reactorTemperature*0.8f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 3.0f, 0.0f, 0.1f);
@@ -3356,9 +3356,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
m_lastMotorParticule = aTime;
pos = D3DVECTOR(-1.6f, -1.0f, 0.0f);
- pos.x += (Rand()-0.5f)*3.0f;
- pos.y += (Rand()-0.5f)*1.5f;
- pos.z += (Rand()-0.5f)*3.0f;
+ pos.x += (Math::Rand()-0.5f)*3.0f;
+ pos.y += (Math::Rand()-0.5f)*1.5f;
+ pos.z += (Math::Rand()-0.5f)*3.0f;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
@@ -3369,9 +3369,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
}
else
{
- speed.y = 10.0f-2.0f*h - Rand()*(10.0f-h); //against the top
- speed.x = (Rand()-0.5f)*(5.0f-h)*1.0f; // horizontal (xz)
- speed.z = (Rand()-0.5f)*(5.0f-h)*1.0f;
+ speed.y = 10.0f-2.0f*h - Math::Rand()*(10.0f-h); //against the top
+ speed.x = (Math::Rand()-0.5f)*(5.0f-h)*1.0f; // horizontal (xz)
+ speed.z = (Math::Rand()-0.5f)*(5.0f-h)*1.0f;
}
dim.x = 0.12f;
@@ -3383,9 +3383,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
pos = D3DVECTOR(-1.6f, -0.5f, 0.0f);
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*1.0f;
- speed.z = (Rand()-0.5f)*1.0f;
- speed.y = -(4.0f+Rand()*3.0f);
+ speed.x = (Math::Rand()-0.5f)*1.0f;
+ speed.z = (Math::Rand()-0.5f)*1.0f;
+ speed.y = -(4.0f+Math::Rand()*3.0f);
speed.x += m_linMotion.realSpeed.x*0.8f;
speed.z -= m_linMotion.realSpeed.x*m_cirMotion.realSpeed.y*0.05f;
if ( m_linMotion.realSpeed.y > 0.0f )
@@ -3399,11 +3399,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
a = m_object->RetAngleY(0);
p.x = speed.x;
p.y = speed.z;
- p = RotatePoint(-a, p);
+ p = Math::RotatePoint(-a, p);
speed.x = p.x;
speed.z = p.y;
- dim.x = 0.4f+Rand()*0.2f;
+ dim.x = 0.4f+Math::Rand()*0.2f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIEJECT, 0.3f, 10.0f);
@@ -3426,8 +3426,8 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( m_motorSpeed.x == 0.0f && // glide slope due to ground?
m_cirMotion.realSpeed.y == 0.0f )
{
- h = Max(Abs(m_linMotion.realSpeed.x),
- Abs(m_linMotion.realSpeed.z));
+ h = Math::Max(fabs(m_linMotion.realSpeed.x),
+ fabs(m_linMotion.realSpeed.z));
if ( h < 3.0f ) return;
@@ -3439,12 +3439,12 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( r == 1 ) pos = D3DVECTOR(-3.0f, 0.0f, 4.0f);
if ( r == 2 ) pos = D3DVECTOR( 4.0f, 0.0f, 0.0f);
- 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;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = Rand()*h/5.0f+2.0f;
+ dim.x = Math::Rand()*h/5.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
}
@@ -3461,8 +3461,8 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( r == 1 ) pos = D3DVECTOR(-3.0f, 0.0f, 4.0f);
if ( r == 2 ) pos = D3DVECTOR( 4.0f, 0.0f, 0.0f);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
@@ -3479,9 +3479,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
m_lastMotorParticule = aTime;
pos = D3DVECTOR(0.0f, -1.0f, 0.0f);
- pos.x += (Rand()-0.5f)*6.0f;
- pos.y += (Rand()-0.5f)*3.0f;
- pos.z += (Rand()-0.5f)*6.0f;
+ pos.x += (Math::Rand()-0.5f)*6.0f;
+ pos.y += (Math::Rand()-0.5f)*3.0f;
+ pos.z += (Math::Rand()-0.5f)*6.0f;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
@@ -3492,9 +3492,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
}
else
{
- speed.y = 10.0f-2.0f*h - Rand()*(10.0f-h); // against the top
- speed.x = (Rand()-0.5f)*(10.0f-h)*2.0f; // horizontal (xz)
- speed.z = (Rand()-0.5f)*(10.0f-h)*2.0f;
+ speed.y = 10.0f-2.0f*h - Math::Rand()*(10.0f-h); // against the top
+ speed.x = (Math::Rand()-0.5f)*(10.0f-h)*2.0f; // horizontal (xz)
+ speed.z = (Math::Rand()-0.5f)*(10.0f-h)*2.0f;
}
dim.x = 0.2f;
@@ -3506,9 +3506,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
pos = D3DVECTOR(0.0f, 1.0f, 0.0f);
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*1.0f;
- speed.z = (Rand()-0.5f)*1.0f;
- speed.y = -(6.0f+Rand()*4.5f);
+ speed.x = (Math::Rand()-0.5f)*1.0f;
+ speed.z = (Math::Rand()-0.5f)*1.0f;
+ speed.y = -(6.0f+Math::Rand()*4.5f);
speed.x += m_linMotion.realSpeed.x*0.8f;
speed.z -= m_linMotion.realSpeed.x*m_cirMotion.realSpeed.y*0.05f;
if ( m_linMotion.realSpeed.y > 0.0f )
@@ -3522,11 +3522,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
a = m_object->RetAngleY(0);
p.x = speed.x;
p.y = speed.z;
- p = RotatePoint(-a, p);
+ p = Math::RotatePoint(-a, p);
speed.x = p.x;
speed.z = p.y;
- dim.x = 0.7f+Rand()*0.6f;
+ dim.x = 0.7f+Math::Rand()*0.6f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIEJECT, 0.5f, 10.0f);
@@ -3538,7 +3538,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
if ( !m_object->RetDead() )
{
- h = Mod(aTime, 5.0f);
+ h = Math::Mod(aTime, 5.0f);
if ( h < 3.5f && ( h < 1.5f || h > 1.6f ) ) return;
}
if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.06f) ) return;
@@ -3547,11 +3547,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
pos = D3DVECTOR(0.0f, 3.0f, 0.0f);
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
- speed.y = (Rand()-0.5f)*8.0f+8.0f;
- speed.x = (Rand()-0.5f)*0.2f;
- speed.z = (Rand()-0.5f)*0.2f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
+ speed.y = (Math::Rand()-0.5f)*8.0f+8.0f;
+ speed.x = (Math::Rand()-0.5f)*0.2f;
+ speed.z = (Math::Rand()-0.5f)*0.2f;
dim.x = 0.2f;
dim.y = 0.2f;
m_particule->CreateParticule(pos, speed, dim, PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
@@ -3559,13 +3559,13 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( aTime-m_lastSoundWater > 1.5f )
{
m_lastSoundWater = aTime;
- m_sound->Play(SOUND_BLUP, m_object->RetPosition(0), 0.5f+Rand()*0.5f);
+ m_sound->Play(SOUND_BLUP, m_object->RetPosition(0), 0.5f+Math::Rand()*0.5f);
}
}
if ( type == OBJECT_MOBILEsa && m_bSwim )
{
- h = Mod(aTime, 3.0f);
+ h = Math::Mod(aTime, 3.0f);
if ( h < 1.5f && ( h < 0.5f || h > 0.9f ) ) return;
if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.06f) ) return;
m_lastMotorParticule = aTime;
@@ -3573,11 +3573,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
pos = D3DVECTOR(0.0f, 3.0f, 0.0f);
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
- speed.y = (Rand()-0.5f)*8.0f+8.0f;
- speed.x = (Rand()-0.5f)*0.2f;
- speed.z = (Rand()-0.5f)*0.2f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
+ speed.y = (Math::Rand()-0.5f)*8.0f+8.0f;
+ speed.x = (Math::Rand()-0.5f)*0.2f;
+ speed.z = (Math::Rand()-0.5f)*0.2f;
dim.x = 0.2f;
dim.y = 0.2f;
m_particule->CreateParticule(pos, speed, dim, PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
@@ -3585,7 +3585,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( aTime-m_lastSoundWater > 1.5f )
{
m_lastSoundWater = aTime;
- m_sound->Play(SOUND_BLUP, m_object->RetPosition(0), 0.5f+Rand()*0.5f);
+ m_sound->Play(SOUND_BLUP, m_object->RetPosition(0), 0.5f+Math::Rand()*0.5f);
}
}
@@ -3604,16 +3604,16 @@ void CPhysics::MotorParticule(float aTime, float rTime)
m_lastMotorParticule = aTime;
pos = D3DVECTOR(-2.5f, 10.3f, -1.3f);
- pos.x += (Rand()-0.5f)*1.0f;
- pos.z += (Rand()-0.5f)*1.0f;
+ pos.x += (Math::Rand()-0.5f)*1.0f;
+ pos.z += (Math::Rand()-0.5f)*1.0f;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
- speed.x = (Rand()-0.5f)*2.0f;
- speed.z = (Rand()-0.5f)*2.0f;
- speed.y = 1.5f+Rand()*1.0f;
+ speed.x = (Math::Rand()-0.5f)*2.0f;
+ speed.z = (Math::Rand()-0.5f)*2.0f;
+ speed.y = 1.5f+Math::Rand()*1.0f;
- dim.x = Rand()*0.6f+0.4f;
+ dim.x = Math::Rand()*0.6f+0.4f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIMOTOR, 2.0f);
@@ -3640,14 +3640,14 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
speed.x -= 3.0f;
}
- speed.y -= 0.5f+Rand()*2.0f;
- speed.z += (Rand()-0.5f)*3.0f;
+ speed.y -= 0.5f+Math::Rand()*2.0f;
+ speed.z += (Math::Rand()-0.5f)*3.0f;
mat = m_object->RetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Transform(*mat, speed)-pos;
- dim.x = Rand()*0.4f+0.3f;
+ dim.x = Math::Rand()*0.4f+0.3f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIMOTOR, 2.0f);
@@ -3661,7 +3661,7 @@ void CPhysics::WaterParticule(float aTime, D3DVECTOR pos, ObjectType type,
float floor, float advance, float turn)
{
D3DVECTOR ppos, speed;
- FPOINT dim;
+ Math::Point dim;
float delay, level, min, max, force, volume, diam;
int i, nb;
@@ -3711,18 +3711,18 @@ void CPhysics::WaterParticule(float aTime, D3DVECTOR pos, ObjectType type,
for ( i=0 ; i<nb ; i++ )
{
ppos = pos;
- ppos.x += (Rand()-0.5f)*4.0f;
- ppos.z += (Rand()-0.5f)*4.0f;
+ ppos.x += (Math::Rand()-0.5f)*4.0f;
+ ppos.z += (Math::Rand()-0.5f)*4.0f;
ppos.y += 0.6f;
- speed.x = (Rand()-0.5f)*12.0f*force;
- speed.z = (Rand()-0.5f)*12.0f*force;
- speed.y = 6.0f+Rand()*6.0f*force;
+ speed.x = (Math::Rand()-0.5f)*12.0f*force;
+ speed.z = (Math::Rand()-0.5f)*12.0f*force;
+ speed.y = 6.0f+Math::Rand()*6.0f*force;
dim.x = 0.5f;
dim.y = dim.x;
m_particule->CreateParticule(ppos, speed, dim, PARTIDROP, 2.0f, 20.0f, 0.2f);
}
- volume = Abs(m_linMotion.realSpeed.y*0.02f);
+ volume = fabs(m_linMotion.realSpeed.y*0.02f);
if ( volume > 1.0f ) volume = 1.0f;
m_sound->Play(SOUND_PLOUF, pos, volume);
}
@@ -3755,18 +3755,18 @@ void CPhysics::WaterParticule(float aTime, D3DVECTOR pos, ObjectType type,
pos.y = level+0.1f;
if ( advance == 0 )
{
- 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;
}
else
{
- 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.y = 0.0f;
speed.x = 0.0f;
speed.z = 0.0f;
- dim.x = Min(Rand()*force+force+1.0f, 10.0f);
+ dim.x = Math::Min(Math::Rand()*force+force+1.0f, 10.0f);
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFLIC, 3.0f, 0.0f, 0.0f);
}
diff --git a/src/physics/physics.h b/src/physics/physics.h
index 5b3fa29..584ebc4 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -21,6 +21,7 @@
#include "graphics/d3d/d3dengine.h"
#include "common/misc.h"
+#include "object/object.h"
class CInstanceManager;
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index 7387771..3ffa13c 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.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>
diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp
index e8785ca..b370343 100644
--- a/src/script/cmdtoken.cpp
+++ b/src/script/cmdtoken.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>
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 592d2a6..94c1228 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -16,8 +16,6 @@
// script.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -25,6 +23,7 @@
#include "CBot/CBotDll.h"
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/d3dmath.h"
#include "common/global.h"
@@ -215,7 +214,7 @@ bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GivValFloat();
- result->SetValFloat(sinf(value*PI/180.0f));
+ result->SetValFloat(sinf(value*Math::PI/180.0f));
return true;
}
@@ -226,7 +225,7 @@ bool rCos(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GivValFloat();
- result->SetValFloat(cosf(value*PI/180.0f));
+ result->SetValFloat(cosf(value*Math::PI/180.0f));
return true;
}
@@ -237,7 +236,7 @@ bool rTan(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GivValFloat();
- result->SetValFloat(tanf(value*PI/180.0f));
+ result->SetValFloat(tanf(value*Math::PI/180.0f));
return true;
}
@@ -248,7 +247,7 @@ bool raSin(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GivValFloat();
- result->SetValFloat(asinf(value)*180.0f/PI);
+ result->SetValFloat(asinf(value)*180.0f/Math::PI);
return true;
}
@@ -259,7 +258,7 @@ bool raCos(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GivValFloat();
- result->SetValFloat(acosf(value)*180.0f/PI);
+ result->SetValFloat(acosf(value)*180.0f/Math::PI);
return true;
}
@@ -270,7 +269,7 @@ bool raTan(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GivValFloat();
- result->SetValFloat(atanf(value)*180.0f/PI);
+ result->SetValFloat(atanf(value)*180.0f/Math::PI);
return true;
}
@@ -302,7 +301,7 @@ bool rPow(CBotVar* var, CBotVar* result, int& exception, void* user)
bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- result->SetValFloat(Rand());
+ result->SetValFloat(Math::Rand());
return true;
}
@@ -313,7 +312,7 @@ bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user)
float value;
value = var->GivValFloat();
- result->SetValFloat(Abs(value));
+ result->SetValFloat(fabs(value));
return true;
}
@@ -537,7 +536,7 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
type = OBJECT_NULL;
angle = 0.0f;
- focus = PI*2.0f;
+ focus = Math::PI*2.0f;
minDist = 0.0f*g_unit;
maxDist = 1000.0f*g_unit;
sens = 1.0f;
@@ -559,12 +558,12 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
var = var->GivNext();
if ( var != 0 )
{
- angle = -var->GivValFloat()*PI/180.0f;
+ angle = -var->GivValFloat()*Math::PI/180.0f;
var = var->GivNext();
if ( var != 0 )
{
- focus = var->GivValFloat()*PI/180.0f;
+ focus = var->GivValFloat()*Math::PI/180.0f;
var = var->GivNext();
if ( var != 0 )
@@ -595,7 +594,7 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
iPos = pThis->RetPosition(0);
iAngle = pThis->RetAngleY(0)+angle;
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( sens >= 0.0f ) best = 100000.0f;
else best = 0.0f;
@@ -660,7 +659,7 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
d = Length2d(iPos, oPos);
if ( d < minDist || d > maxDist ) continue; // too close or too far?
- if ( focus >= PI*2.0f )
+ if ( focus >= Math::PI*2.0f )
{
if ( (sens >= 0.0f && d < best) ||
(sens < 0.0f && d > best) )
@@ -671,8 +670,8 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
continue;
}
- a = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
+ a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
{
if ( (sens >= 0.0f && d < best) ||
(sens < 0.0f && d > best) )
@@ -758,7 +757,7 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
{
type = OBJECT_NULL;
angle = 0.0f;
- focus = 45.0f*PI/180.0f;
+ focus = 45.0f*Math::PI/180.0f;
minDist = 0.0f*g_unit;
maxDist = 20.0f*g_unit;
sens = 1.0f;
@@ -780,7 +779,7 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
iPos = pThis->RetPosition(0);
iAngle = pThis->RetAngleY(0)+angle;
- iAngle = NormAngle(iAngle); // 0..2*PI
+ iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
bGoal = 100000.0f;
pGoal = 0;
@@ -845,10 +844,10 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
oPos = pObj->RetPosition(0);
d = Length2d(iPos, oPos);
- a = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
if ( d < bGoal &&
- TestAngle(a, iAngle-(5.0f*PI/180.0f)/2.0f, iAngle+(5.0f*PI/180.0f)/2.0f) )
+ Math::TestAngle(a, iAngle-(5.0f*Math::PI/180.0f)/2.0f, iAngle+(5.0f*Math::PI/180.0f)/2.0f) )
{
bGoal = d;
pGoal = pObj;
@@ -856,7 +855,7 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( d < minDist || d > maxDist ) continue; // too close or too far?
- if ( focus >= PI*2.0f )
+ if ( focus >= Math::PI*2.0f )
{
if ( (sens >= 0.0f && d < best) ||
(sens < 0.0f && d > best) )
@@ -867,7 +866,7 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
continue;
}
- if ( TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
+ if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
{
if ( (sens >= 0.0f && d < best) ||
(sens < 0.0f && d > best) )
@@ -938,9 +937,9 @@ bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user)
iPos = pThis->RetPosition(0);
a = pThis->RetAngleY(0);
- g = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ g = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- result->SetValFloat(-Direction(a, g)*180.0f/PI);
+ result->SetValFloat(-Math::Direction(a, g)*180.0f/Math::PI);
return true;
}
@@ -986,7 +985,7 @@ bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( !GetPoint(var, exception, pos) ) return true;
- angle = var->GivValFloat()*PI/180.0f;
+ angle = var->GivValFloat()*Math::PI/180.0f;
var = var->GivNext();
type = (ObjectType)var->GivValInt();
@@ -1312,7 +1311,7 @@ bool rTurn(CBotVar* var, CBotVar* result, int& exception, void* user)
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
value = var->GivValFloat();
- err = script->m_primaryTask->StartTaskTurn(-value*PI/180.0f);
+ err = script->m_primaryTask->StartTaskTurn(-value*Math::PI/180.0f);
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -1435,7 +1434,7 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
{
type = OBJECT_NULL;
angle = 0.0f;
- focus = PI*2.0f;
+ focus = Math::PI*2.0f;
minDist = 0.0f*g_unit;
maxDist = 1000.0f*g_unit;
sens = 1.0f;
@@ -1502,7 +1501,7 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
d = Length2d(iPos, oPos);
if ( d < minDist || d > maxDist ) continue; // too close or too far?
- if ( focus >= PI*2.0f )
+ if ( focus >= Math::PI*2.0f )
{
if ( d < best )
{
@@ -1512,8 +1511,8 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
continue;
}
- a = RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
- if ( TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
+ a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
{
if ( d < best )
{
@@ -2202,7 +2201,7 @@ bool rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
value = var->GivValFloat();
- err = script->m_primaryTask->StartTaskGunGoal(value*PI/180.0f, 0.0f);
+ err = script->m_primaryTask->StartTaskGunGoal(value*Math::PI/180.0f, 0.0f);
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -3677,7 +3676,7 @@ bool CScript::ReadScript(char* filename)
delete m_script;
m_script = 0;
- edit = m_interface->CreateEdit(FPOINT(0.0f, 0.0f), FPOINT(0.0f, 0.0f), 0, EVENT_EDIT9);
+ edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
edit->SetMaxChar(EDITSTUDIOMAX);
edit->SetAutoIndent(m_engine->RetEditIndentMode());
edit->ReadText(name);
@@ -3709,7 +3708,7 @@ bool CScript::WriteScript(char* filename)
return false;
}
- edit = m_interface->CreateEdit(FPOINT(0.0f, 0.0f), FPOINT(0.0f, 0.0f), 0, EVENT_EDIT9);
+ edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
edit->SetMaxChar(EDITSTUDIOMAX);
edit->SetAutoIndent(m_engine->RetEditIndentMode());
edit->SetText(m_script);
diff --git a/src/script/script.h b/src/script/script.h
index 5500218..2c7066c 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -19,6 +19,8 @@
#pragma once
+#include <stdio.h>
+
#include "common/event.h"
diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp
index 5b8f469..d28dee5 100644
--- a/src/sound/sound.cpp
+++ b/src/sound/sound.cpp
@@ -16,8 +16,6 @@
// sound.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <stdlib.h>
#include <ctype.h>
@@ -28,6 +26,7 @@
#include "common/language.h"
#include "common/struct.h"
#include "common/iman.h"
+#include "math/geometry.h"
#include "math/old/math3d.h"
#include "sound/sound.h"
@@ -977,9 +976,9 @@ void CSound::ComputeVolumePan2D(int channel, const D3DVECTOR &pos)
m_channel[channel].volume = 1.0f-((dist-10.0f)/100.0f);
#endif
- a = RotateAngle(m_lookat.x-m_eye.x, m_eye.z-m_lookat.z);
- g = RotateAngle(pos.x-m_eye.x, m_eye.z-pos.z);
- m_channel[channel].pan = sinf(Direction(a, g));
+ a = Math::RotateAngle(m_lookat.x-m_eye.x, m_eye.z-m_lookat.z);
+ g = Math::RotateAngle(pos.x-m_eye.x, m_eye.z-pos.z);
+ m_channel[channel].pan = sinf(Math::Direction(a, g));
}
// Sounds in the middle.
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index 701971c..4f9e9cd 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.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>
@@ -57,7 +55,7 @@ CButton::~CButton()
// Creates a new button.
-bool CButton::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CButton::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -151,7 +149,7 @@ bool CButton::EventProcess(const Event &event)
void CButton::Draw()
{
- FPOINT pos, dim, uv1, uv2;
+ Math::Point pos, dim, uv1, uv2;
#if !_NEWLOOK
float dp;
#endif
diff --git a/src/ui/button.h b/src/ui/button.h
index cc34997..34c4a96 100644
--- a/src/ui/button.h
+++ b/src/ui/button.h
@@ -32,7 +32,7 @@ public:
CButton(CInstanceManager* iMan);
virtual ~CButton();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/check.cpp b/src/ui/check.cpp
index b4b944e..c1ddcc2 100644
--- a/src/ui/check.cpp
+++ b/src/ui/check.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>
@@ -49,7 +47,7 @@ CCheck::~CCheck()
// Creates a new button.
-bool CCheck::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
char name[100];
char* p;
@@ -96,7 +94,7 @@ bool CCheck::EventProcess(const Event &event)
void CCheck::Draw()
{
- FPOINT iDim, pos;
+ Math::Point iDim, pos;
float zoomExt, zoomInt;
int icon;
diff --git a/src/ui/check.h b/src/ui/check.h
index 8bb2c9c..9c1f442 100644
--- a/src/ui/check.h
+++ b/src/ui/check.h
@@ -32,7 +32,7 @@ public:
CCheck(CInstanceManager* iMan);
virtual ~CCheck();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index bf635ff..2490b6c 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.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>
@@ -60,7 +58,7 @@ CColor::~CColor()
// Creates a new button.
-bool CColor::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -137,7 +135,7 @@ void CColor::Draw()
LPDIRECT3DDEVICE7 device;
D3DLVERTEX vertex[4]; // 2 triangles
D3DCOLOR color;
- FPOINT p1, p2;
+ Math::Point p1, p2;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
diff --git a/src/ui/color.h b/src/ui/color.h
index 86d9434..041c7d2 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -33,7 +33,7 @@ public:
CColor(CInstanceManager* iMan);
virtual ~CColor();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp
index d856e19..e7e1eee 100644
--- a/src/ui/compass.cpp
+++ b/src/ui/compass.cpp
@@ -14,14 +14,13 @@
// * 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/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "math/old/math3d.h"
#include "common/event.h"
@@ -48,7 +47,7 @@ CCompass::~CCompass()
// Creates a new button.
-bool CCompass::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CCompass::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -84,7 +83,7 @@ void CCompass::Draw()
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
- FPOINT p1, p2, p3, c, uv1, uv2;
+ Math::Point p1, p2, p3, c, uv1, uv2;
D3DVECTOR n;
float dp;
@@ -128,17 +127,17 @@ void CCompass::Draw()
{
p1.x = c.x;
p1.y = c.y+m_dim.x*0.40f;
- p1 = RotatePoint(c, m_dir, p1);
+ p1 = Math::RotatePoint(c, m_dir, p1);
p1.x = c.x+(p1.x-c.x)*(m_dim.x/m_dim.y);
p2.x = c.x+m_dim.x*0.20f;
p2.y = c.y-m_dim.x*0.40f;
- p2 = RotatePoint(c, m_dir, p2);
+ p2 = Math::RotatePoint(c, m_dir, p2);
p2.x = c.x+(p2.x-c.x)*(m_dim.x/m_dim.y);
p3.x = c.x-m_dim.x*0.20f;
p3.y = c.y-m_dim.x*0.40f;
- p3 = RotatePoint(c, m_dir, p3);
+ p3 = Math::RotatePoint(c, m_dir, p3);
p3.x = c.x+(p3.x-c.x)*(m_dim.x/m_dim.y);
uv1.x = 96.0f/256.0f;
diff --git a/src/ui/compass.h b/src/ui/compass.h
index 113623b..5cad65a 100644
--- a/src/ui/compass.h
+++ b/src/ui/compass.h
@@ -32,7 +32,7 @@ public:
CCompass(CInstanceManager* iMan);
virtual ~CCompass();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 63ac8ca..ee08e9f 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.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>
@@ -62,10 +60,10 @@ CControl::CControl(CInstanceManager* iMan)
m_bCapture = false;
m_bGlint = false;
- m_glintCorner1 = FPOINT(0.0f, 0.0f);
- m_glintCorner2 = FPOINT(0.0f, 0.0f);
+ m_glintCorner1 = Math::Point(0.0f, 0.0f);
+ m_glintCorner2 = Math::Point(0.0f, 0.0f);
m_glintProgress = 999.0f;
- m_glintMouse = FPOINT(0.0f, 0.0f);
+ m_glintMouse = Math::Point(0.0f, 0.0f);
}
// Object's destructor.
@@ -78,7 +76,7 @@ CControl::~CControl()
// Creates a new button.
// pos: [0..1]
-bool CControl::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
char text[100];
char* p;
@@ -112,7 +110,7 @@ bool CControl::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
}
-void CControl::SetPos(FPOINT pos)
+void CControl::SetPos(Math::Point pos)
{
m_pos = pos;
@@ -121,14 +119,14 @@ void CControl::SetPos(FPOINT pos)
GlintCreate(pos);
}
-FPOINT CControl::RetPos()
+Math::Point CControl::RetPos()
{
return m_pos;
}
-void CControl::SetDim(FPOINT dim)
+void CControl::SetDim(Math::Point dim)
{
- FPOINT pos;
+ Math::Point pos;
m_dim = dim;
@@ -137,7 +135,7 @@ void CControl::SetDim(FPOINT dim)
GlintCreate(pos);
}
-FPOINT CControl::RetDim()
+Math::Point CControl::RetDim()
{
return m_dim;
}
@@ -298,7 +296,7 @@ bool CControl::SetTooltip(char* name)
return true;
}
-bool CControl::GetTooltip(FPOINT pos, char* name)
+bool CControl::GetTooltip(Math::Point pos, char* name)
{
if ( m_tooltip[0] == 0 ) return false;
if ( (m_state & STATE_VISIBLE) == 0 ) return false;
@@ -402,7 +400,7 @@ void CControl::GlintDelete()
// Creates a reflection for that button.
-void CControl::GlintCreate(FPOINT ref, bool bLeft, bool bUp)
+void CControl::GlintCreate(Math::Point ref, bool bLeft, bool bUp)
{
float offset;
@@ -442,7 +440,7 @@ void CControl::GlintCreate(FPOINT ref, bool bLeft, bool bUp)
void CControl::GlintFrame(const Event &event)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
if ( (m_state & STATE_GLINT ) == 0 ||
(m_state & STATE_ENABLE ) == 0 ||
@@ -454,11 +452,11 @@ void CControl::GlintFrame(const Event &event)
if ( m_glintProgress >= 2.0f && Detect(m_glintMouse) )
{
- pos.x = m_glintCorner1.x + (m_glintCorner2.x-m_glintCorner1.x)*Rand();
- pos.y = m_glintCorner1.y + (m_glintCorner2.y-m_glintCorner1.y)*Rand();
+ pos.x = m_glintCorner1.x + (m_glintCorner2.x-m_glintCorner1.x)*Math::Rand();
+ pos.y = m_glintCorner1.y + (m_glintCorner2.y-m_glintCorner1.y)*Math::Rand();
pos.z = 0.0f;
speed = D3DVECTOR(0.0f, 0.0f, 0.0f);
- dim.x = ((15.0f+Rand()*15.0f)/640.0f);
+ dim.x = ((15.0f+Math::Rand()*15.0f)/640.0f);
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim, PARTICONTROL,
1.0f, 0.0f, 0.0f, SH_INTERFACE);
@@ -472,7 +470,7 @@ void CControl::GlintFrame(const Event &event)
void CControl::Draw()
{
- FPOINT pos;
+ Math::Point pos;
float zoomExt, zoomInt;
int icon;
@@ -609,7 +607,7 @@ void CControl::Draw()
void CControl::DrawPart(int icon, float zoom, float ex)
{
- FPOINT p1, p2, c, uv1, uv2;
+ Math::Point p1, p2, c, uv1, uv2;
float dp;
p1.x = m_pos.x;
@@ -651,12 +649,12 @@ void CControl::DrawPart(int icon, float zoom, float ex)
// Draws an icon made up of a rectangular (if x = 0)
// or 3 pieces.
-void CControl::DrawIcon(FPOINT pos, FPOINT dim, FPOINT uv1, FPOINT uv2,
+void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2,
float ex)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[8]; // 6 triangles
- FPOINT p1, p2, p3, p4;
+ Math::Point p1, p2, p3, p4;
D3DVECTOR n;
device = m_engine->RetD3DDevice();
@@ -719,12 +717,12 @@ void CControl::DrawIcon(FPOINT pos, FPOINT dim, FPOINT uv1, FPOINT uv2,
// Draws a rectangular icon made up of 9 pieces.
-void CControl::DrawIcon(FPOINT pos, FPOINT dim, FPOINT uv1, FPOINT uv2,
- FPOINT corner, float ex)
+void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2,
+ Math::Point corner, float ex)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[8]; // 6 triangles
- FPOINT p1, p2, p3, p4;
+ Math::Point p1, p2, p3, p4;
D3DVECTOR n;
device = m_engine->RetD3DDevice();
@@ -787,9 +785,9 @@ void CControl::DrawIcon(FPOINT pos, FPOINT dim, FPOINT uv1, FPOINT uv2,
// Draw round the hatch of a button.
-void CControl::DrawWarning(FPOINT pos, FPOINT dim)
+void CControl::DrawWarning(Math::Point pos, Math::Point dim)
{
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
float dp;
dp = 0.5f/256.0f;
@@ -831,9 +829,9 @@ void CControl::DrawWarning(FPOINT pos, FPOINT dim)
// Draw the shade under a button.
-void CControl::DrawShadow(FPOINT pos, FPOINT dim, float deep)
+void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep)
{
- FPOINT uv1, uv2, corner;
+ Math::Point uv1, uv2, corner;
float dp;
dp = 0.5f/256.0f;
@@ -865,7 +863,7 @@ void CControl::DrawShadow(FPOINT pos, FPOINT dim, float deep)
// Detects whether a position is in the button.
-bool CControl::Detect(FPOINT pos)
+bool CControl::Detect(Math::Point pos)
{
return ( pos.x >= m_pos.x &&
pos.x <= m_pos.x+m_dim.x &&
diff --git a/src/ui/control.h b/src/ui/control.h
index 8f677c7..d6aeadc 100644
--- a/src/ui/control.h
+++ b/src/ui/control.h
@@ -61,14 +61,14 @@ public:
CControl(CInstanceManager* iMan);
virtual ~CControl();
- virtual bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
virtual bool EventProcess(const Event &event);
- virtual void SetPos(FPOINT pos);
- virtual FPOINT RetPos();
- virtual void SetDim(FPOINT dim);
- virtual FPOINT RetDim();
+ virtual void SetPos(Math::Point pos);
+ virtual Math::Point RetPos();
+ virtual void SetDim(Math::Point dim);
+ virtual Math::Point RetDim();
virtual bool SetState(int state, bool bState);
virtual bool SetState(int state);
virtual bool ClearState(int state);
@@ -87,7 +87,7 @@ public:
virtual void SetFontType(FontType font);
virtual FontType RetFontType();
virtual bool SetTooltip(char* name);
- virtual bool GetTooltip(FPOINT pos, char* name);
+ virtual bool GetTooltip(Math::Point pos, char* name);
virtual void SetFocus(bool bFocus);
virtual bool RetFocus();
@@ -97,14 +97,14 @@ public:
protected:
void GlintDelete();
- void GlintCreate(FPOINT ref, bool bLeft=true, bool bUp=true);
+ void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
void GlintFrame(const Event &event);
void DrawPart(int icon, float zoom, float ex);
- void DrawIcon(FPOINT pos, FPOINT dim, FPOINT uv1, FPOINT uv2, float ex=0.0f);
- void DrawIcon(FPOINT pos, FPOINT dim, FPOINT uv1, FPOINT uv2, FPOINT corner, float ex);
- void DrawWarning(FPOINT pos, FPOINT dim);
- void DrawShadow(FPOINT pos, FPOINT dim, float deep=1.0f);
- virtual bool Detect(FPOINT pos);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
+ void DrawWarning(Math::Point pos, Math::Point dim);
+ void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
+ virtual bool Detect(Math::Point pos);
protected:
CInstanceManager* m_iMan;
@@ -114,8 +114,8 @@ protected:
CParticule* m_particule;
CSound* m_sound;
- FPOINT m_pos; // corner upper / left
- FPOINT m_dim; // dimensions
+ Math::Point m_pos; // corner upper / left
+ Math::Point m_dim; // dimensions
int m_icon;
EventMsg m_eventMsg; // message to send when clicking
int m_state; // states (STATE_ *)
@@ -129,10 +129,10 @@ protected:
bool m_bCapture;
bool m_bGlint;
- FPOINT m_glintCorner1;
- FPOINT m_glintCorner2;
+ Math::Point m_glintCorner1;
+ Math::Point m_glintCorner2;
float m_glintProgress;
- FPOINT m_glintMouse;
+ Math::Point m_glintMouse;
};
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index a4e2131..5921453 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -16,8 +16,6 @@
// displayinfo.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -70,8 +68,8 @@ CDisplayInfo::CDisplayInfo(CInstanceManager* iMan)
m_bInfoMaximized = true;
m_bInfoMinimized = false;
- m_infoFinalPos = m_infoActualPos = m_infoNormalPos = FPOINT(0.00f, 0.00f);
- m_infoFinalDim = m_infoActualPos = m_infoNormalDim = FPOINT(1.00f, 1.00f);
+ m_infoFinalPos = m_infoActualPos = m_infoNormalPos = Math::Point(0.00f, 0.00f);
+ m_infoFinalDim = m_infoActualPos = m_infoNormalDim = Math::Point(1.00f, 1.00f);
m_lightSuppl = -1;
m_toto = 0;
@@ -339,7 +337,7 @@ void CDisplayInfo::HyperUpdate()
void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
{
D3DLIGHT7 light;
- FPOINT pos, dim;
+ Math::Point pos, dim;
CWindow* pw;
CEdit* edit;
CButton* button;
@@ -375,7 +373,7 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
//? pw->SetClosable(true);
//? GetResource(RES_TEXT, RT_DISINFO_TITLE, res);
//? pw->SetName(res);
-//? pw->SetMinDim(FPOINT(0.56f, 0.40f));
+//? pw->SetMinDim(Math::Point(0.56f, 0.40f));
//? pw->SetMaximized(m_bInfoMaximized);
//? pw->SetMinimized(m_bInfoMinimized);
//? m_main->SetEditFull(m_bInfoMaximized);
@@ -476,14 +474,14 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
// Repositions all controls editing.
-void CDisplayInfo::AdjustDisplayInfo(FPOINT wpos, FPOINT wdim)
+void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim)
{
CWindow* pw;
CEdit* edit;
CButton* button;
CSlider* slider;
CGroup* group;
- FPOINT pos, dim;
+ Math::Point pos, dim;
wpos.x = 50.0f/640.0f;
wpos.y = 30.0f/480.0f;
@@ -696,7 +694,7 @@ void CDisplayInfo::UpdateIndexButton()
CButton* button;
CGroup* group;
CEdit* edit;
- FPOINT pos, dim;
+ Math::Point pos, dim;
char* filename;
char* loading;
diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h
index 2a40535..ebf38b1 100644
--- a/src/ui/displayinfo.h
+++ b/src/ui/displayinfo.h
@@ -51,7 +51,7 @@ public:
protected:
bool EventFrame(const Event &event);
void HyperUpdate();
- void AdjustDisplayInfo(FPOINT wpos, FPOINT wdim);
+ void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
void ChangeIndexButton(int index);
void UpdateIndexButton();
void UpdateCopyButton();
@@ -74,12 +74,12 @@ protected:
int m_index;
CameraType m_infoCamera;
- FPOINT m_infoNormalPos;
- FPOINT m_infoNormalDim;
- FPOINT m_infoActualPos;
- FPOINT m_infoActualDim;
- FPOINT m_infoFinalPos;
- FPOINT m_infoFinalDim;
+ Math::Point m_infoNormalPos;
+ Math::Point m_infoNormalDim;
+ Math::Point m_infoActualPos;
+ Math::Point m_infoActualDim;
+ Math::Point m_infoFinalPos;
+ Math::Point m_infoFinalDim;
int m_lightSuppl;
bool m_bEditLock;
bool m_bInitPause;
diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp
index a1307a3..3fa2687 100644
--- a/src/ui/displaytext.cpp
+++ b/src/ui/displaytext.cpp
@@ -16,8 +16,6 @@
// displaytext.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -205,7 +203,7 @@ void CDisplayText::DisplayText(char *text, D3DVECTOR goal, float height,
CButton* button;
CGroup* group;
CLabel* label;
- FPOINT pos, ppos, dim;
+ Math::Point pos, ppos, dim;
Sound sound;
float hLine, hBox;
int nLine, icon, i;
diff --git a/src/ui/displaytext.h b/src/ui/displaytext.h
index 2a2a6cb..381e2f6 100644
--- a/src/ui/displaytext.h
+++ b/src/ui/displaytext.h
@@ -19,6 +19,8 @@
#pragma once
+#include "common/event.h"
+#include "common/misc.h"
#include "graphics/d3d/d3dengine.h"
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 92d190d..e09ca9a 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -16,8 +16,6 @@
// edit.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <stdlib.h>
#include <stdio.h>
@@ -85,7 +83,7 @@ bool IsSep(int character)
CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan)
{
- FPOINT pos;
+ Math::Point pos;
int i;
m_maxChar = 100;
@@ -139,10 +137,10 @@ CEdit::~CEdit()
// Creates a new editable line.
-bool CEdit::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CEdit::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CScroll* pc;
- FPOINT start, end;
+ Math::Point start, end;
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
CControl::Create(pos, dim, icon, eventMsg);
@@ -174,13 +172,13 @@ bool CEdit::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
}
-void CEdit::SetPos(FPOINT pos)
+void CEdit::SetPos(Math::Point pos)
{
CControl::SetPos(pos);
MoveAdjust();
}
-void CEdit::SetDim(FPOINT dim)
+void CEdit::SetDim(Math::Point dim)
{
CControl::SetDim(dim);
MoveAdjust();
@@ -188,7 +186,7 @@ void CEdit::SetDim(FPOINT dim)
void CEdit::MoveAdjust()
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
float height;
m_lineDescent = m_engine->RetText()->RetDescent(m_fontSize, m_fontType);
@@ -552,7 +550,7 @@ void CEdit::SendModifEvent()
// Detects whether the mouse is over a hyperlink character.
-bool CEdit::IsLinkPos(FPOINT pos)
+bool CEdit::IsLinkPos(Math::Point pos)
{
int i;
@@ -569,7 +567,7 @@ bool CEdit::IsLinkPos(FPOINT pos)
// Positions the cursor after a double click.
-void CEdit::MouseDoubleClick(FPOINT mouse)
+void CEdit::MouseDoubleClick(Math::Point mouse)
{
int i, character;
@@ -608,7 +606,7 @@ void CEdit::MouseDoubleClick(FPOINT mouse)
// Positions the cursor when clicked.
-void CEdit::MouseClick(FPOINT mouse)
+void CEdit::MouseClick(Math::Point mouse)
{
int i;
@@ -627,7 +625,7 @@ void CEdit::MouseClick(FPOINT mouse)
// Positions the cursor when clicked released.
-void CEdit::MouseRelease(FPOINT mouse)
+void CEdit::MouseRelease(Math::Point mouse)
{
int i, j, rank;
@@ -655,7 +653,7 @@ void CEdit::MouseRelease(FPOINT mouse)
// Positions the cursor after movement.
-void CEdit::MouseMove(FPOINT mouse)
+void CEdit::MouseMove(Math::Point mouse)
{
int i;
@@ -687,9 +685,9 @@ void CEdit::MouseMove(FPOINT mouse)
// Positions the cursor when clicked.
-int CEdit::MouseDetect(FPOINT mouse)
+int CEdit::MouseDetect(Math::Point mouse)
{
- FPOINT pos;
+ Math::Point pos;
float indentLength, offset, size;
int i, len, c;
bool bTitle;
@@ -883,7 +881,7 @@ bool CEdit::HyperGo(EventMsg event)
void CEdit::Draw()
{
- FPOINT pos, ppos, dim, start, end;
+ Math::Point pos, ppos, dim, start, end;
float size, indentLength;
int i, j, beg, len, c1, c2, o1, o2, eol, iIndex, line;
@@ -904,7 +902,7 @@ void CEdit::Draw()
// Displays all lines.
c1 = m_cursor1;
c2 = m_cursor2;
- if ( c1 > c2 ) Swap(c1, c2); // always c1 <= c2
+ if ( c1 > c2 ) Math::Swap(c1, c2); // always c1 <= c2
if ( m_bInsideScroll )
{
@@ -1070,7 +1068,7 @@ void CEdit::Draw()
}
// Shows the cursor.
- if ( (m_bEdit && m_bFocus && m_bHilite && Mod(m_timeBlink, 1.0f) <= 0.5f) ) // it blinks
+ if ( (m_bEdit && m_bFocus && m_bHilite && Math::Mod(m_timeBlink, 1.0f) <= 0.5f) ) // it blinks
{
pos.y = m_pos.y+m_dim.y-m_lineHeight-(m_bMulti?MARGY:MARGY1*2.0f);
for ( i=m_lineFirst ; i<m_lineTotal ; i++ )
@@ -1120,10 +1118,10 @@ void CEdit::Draw()
// Draw an image part.
-void CEdit::DrawImage(FPOINT pos, char *name, float width,
+void CEdit::DrawImage(Math::Point pos, char *name, float width,
float offset, float height, int nbLine)
{
- FPOINT uv1, uv2, dim;
+ Math::Point uv1, uv2, dim;
float dp;
char filename[100];
@@ -1152,9 +1150,9 @@ void CEdit::DrawImage(FPOINT pos, char *name, float width,
// Draw the background.
-void CEdit::DrawBack(FPOINT pos, FPOINT dim)
+void CEdit::DrawBack(Math::Point pos, Math::Point dim)
{
- FPOINT uv1,uv2, corner;
+ Math::Point uv1,uv2, corner;
float dp;
if ( m_bGeneric ) return;
@@ -1204,9 +1202,9 @@ void CEdit::DrawBack(FPOINT pos, FPOINT dim)
// Draws an icon background.
-void CEdit::DrawPart(FPOINT pos, FPOINT dim, int icon)
+void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon)
{
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
float dp;
#if _POLISH
@@ -2503,7 +2501,7 @@ bool CEdit::Cut()
c1 = m_cursor1;
c2 = m_cursor2;
- if ( c1 > c2 ) Swap(c1, c2); // always c1 <= c2
+ if ( c1 > c2 ) Math::Swap(c1, c2); // always c1 <= c2
if ( c1 == c2 )
{
@@ -2582,7 +2580,7 @@ bool CEdit::Copy()
c1 = m_cursor1;
c2 = m_cursor2;
- if ( c1 > c2 ) Swap(c1, c2); // always c1 <= c2
+ if ( c1 > c2 ) Math::Swap(c1, c2); // always c1 <= c2
if ( c1 == c2 )
{
@@ -2872,7 +2870,7 @@ void CEdit::DeleteOne(int dir)
}
}
- if ( m_cursor1 > m_cursor2 ) Swap(m_cursor1, m_cursor2);
+ if ( m_cursor1 > m_cursor2 ) Math::Swap(m_cursor1, m_cursor2);
hole = m_cursor2-m_cursor1;
end = m_len-hole;
for ( i=m_cursor1 ; i<end ; i++ )
@@ -2960,7 +2958,7 @@ bool CEdit::Shift(bool bLeft)
c2 = m_cursor2;
if ( c1 > c2 )
{
- Swap(c1, c2); // always c1 <= c2
+ Math::Swap(c1, c2); // always c1 <= c2
bInvert = true;
}
@@ -3000,7 +2998,7 @@ bool CEdit::Shift(bool bLeft)
}
}
- if ( bInvert ) Swap(c1, c2);
+ if ( bInvert ) Math::Swap(c1, c2);
m_cursor1 = c1;
m_cursor2 = c2;
@@ -3010,7 +3008,7 @@ bool CEdit::Shift(bool bLeft)
return true;
}
-// Min conversion <-> shift the selection.
+// Math::Min conversion <-> shift the selection.
bool CEdit::MinMaj(bool bMaj)
{
@@ -3022,7 +3020,7 @@ bool CEdit::MinMaj(bool bMaj)
c1 = m_cursor1;
c2 = m_cursor2;
- if ( c1 > c2 ) Swap(c1, c2); // alwyas c1 <= c2
+ if ( c1 > c2 ) Math::Swap(c1, c2); // alwyas c1 <= c2
for ( i=c1 ; i<c2 ; i++ )
{
diff --git a/src/ui/edit.h b/src/ui/edit.h
index 7ac6c53..cd3c5b9 100644
--- a/src/ui/edit.h
+++ b/src/ui/edit.h
@@ -88,10 +88,10 @@ public:
CEdit(CInstanceManager* iMan);
virtual ~CEdit();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- void SetPos(FPOINT pos);
- void SetDim(FPOINT dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
bool EventProcess(const Event &event);
void Draw();
@@ -155,20 +155,20 @@ public:
protected:
void SendModifEvent();
- bool IsLinkPos(FPOINT pos);
- void MouseDoubleClick(FPOINT mouse);
- void MouseClick(FPOINT mouse);
- void MouseMove(FPOINT mouse);
- void MouseRelease(FPOINT mouse);
- int MouseDetect(FPOINT mouse);
+ bool IsLinkPos(Math::Point pos);
+ void MouseDoubleClick(Math::Point mouse);
+ void MouseClick(Math::Point mouse);
+ void MouseMove(Math::Point mouse);
+ void MouseRelease(Math::Point mouse);
+ int MouseDetect(Math::Point mouse);
void MoveAdjust();
void HyperJump(char *name, char *marker);
bool HyperAdd(char *filename, int firstLine);
- void DrawImage(FPOINT pos, char *name, float width, float offset, float height, int nbLine);
- void DrawBack(FPOINT pos, FPOINT dim);
- void DrawPart(FPOINT pos, FPOINT dim, int icon);
+ void DrawImage(Math::Point pos, char *name, float width, float offset, float height, int nbLine);
+ void DrawBack(Math::Point pos, Math::Point dim);
+ void DrawPart(Math::Point pos, Math::Point dim, int icon);
void FreeImage();
void LoadImage(char *name);
@@ -234,8 +234,8 @@ protected:
float m_timeBlink;
float m_timeLastClick;
float m_timeLastScroll;
- FPOINT m_mouseFirstPos;
- FPOINT m_mouseLastPos;
+ Math::Point m_mouseFirstPos;
+ Math::Point m_mouseLastPos;
float m_column;
bool m_bCapture;
diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp
index dfbd65a..285094b 100644
--- a/src/ui/editvalue.cpp
+++ b/src/ui/editvalue.cpp
@@ -16,8 +16,6 @@
// editvalue.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -62,7 +60,7 @@ CEditValue::~CEditValue()
// Creates a new button.
-bool CEditValue::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CEdit* pe;
CButton* pc;
@@ -92,13 +90,13 @@ bool CEditValue::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
}
-void CEditValue::SetPos(FPOINT pos)
+void CEditValue::SetPos(Math::Point pos)
{
CControl::SetPos(pos);
MoveAdjust();
}
-void CEditValue::SetDim(FPOINT dim)
+void CEditValue::SetDim(Math::Point dim)
{
CControl::SetDim(dim);
MoveAdjust();
@@ -106,7 +104,7 @@ void CEditValue::SetDim(FPOINT dim)
void CEditValue::MoveAdjust()
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
if ( m_edit != 0 )
{
diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h
index a05224f..1b45df9 100644
--- a/src/ui/editvalue.h
+++ b/src/ui/editvalue.h
@@ -42,10 +42,10 @@ public:
CEditValue(CInstanceManager* iMan);
virtual ~CEditValue();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- void SetPos(FPOINT pos);
- void SetDim(FPOINT dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
bool EventProcess(const Event &event);
void Draw();
diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp
index b7a1b1a..072a923 100644
--- a/src/ui/gauge.cpp
+++ b/src/ui/gauge.cpp
@@ -16,8 +16,6 @@
// gauge.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -50,7 +48,7 @@ CGauge::~CGauge()
// Creates a new button.
-bool CGauge::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CGauge::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -84,7 +82,7 @@ bool CGauge::EventProcess(const Event &event)
void CGauge::Draw()
{
- FPOINT pos, dim, ddim, uv1, uv2, corner;
+ Math::Point pos, dim, ddim, uv1, uv2, corner;
float dp;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
diff --git a/src/ui/gauge.h b/src/ui/gauge.h
index 2fef15b..70eae92 100644
--- a/src/ui/gauge.h
+++ b/src/ui/gauge.h
@@ -32,7 +32,7 @@ public:
CGauge(CInstanceManager* iMan);
virtual ~CGauge();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/group.cpp b/src/ui/group.cpp
index a19e39b..c77e131 100644
--- a/src/ui/group.cpp
+++ b/src/ui/group.cpp
@@ -16,8 +16,6 @@
// group.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -50,7 +48,7 @@ CGroup::~CGroup()
// Creates a new button.
-bool CGroup::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CGroup::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -83,7 +81,7 @@ bool CGroup::EventProcess(const Event &event)
void CGroup::Draw()
{
- FPOINT uv1,uv2, corner, pos, dim;
+ Math::Point uv1,uv2, corner, pos, dim;
float dp;
int icon;
@@ -283,13 +281,13 @@ void CGroup::Draw()
uv2.y = 255.5f/256.0f;
DrawIcon(pos, dim, uv1, uv2); // ul
pos.x += dim.x;
- Swap(uv1.x, uv2.x);
+ Math::Swap(uv1.x, uv2.x);
DrawIcon(pos, dim, uv1, uv2); // ur
pos.y -= dim.y;
- Swap(uv1.y, uv2.y);
+ Math::Swap(uv1.y, uv2.y);
DrawIcon(pos, dim, uv1, uv2); // dr
pos.x -= dim.x;
- Swap(uv1.x, uv2.x);
+ Math::Swap(uv1.x, uv2.x);
DrawIcon(pos, dim, uv1, uv2); // dl
m_engine->SetState(D3DSTATETTw);
@@ -301,13 +299,13 @@ void CGroup::Draw()
uv2.y = 255.5f/256.0f;
DrawIcon(pos, dim, uv1, uv2); // ul
pos.x += dim.x;
- Swap(uv1.x, uv2.x);
+ Math::Swap(uv1.x, uv2.x);
DrawIcon(pos, dim, uv1, uv2); // ur
pos.y -= dim.y;
- Swap(uv1.y, uv2.y);
+ Math::Swap(uv1.y, uv2.y);
DrawIcon(pos, dim, uv1, uv2); // dr
pos.x -= dim.x;
- Swap(uv1.x, uv2.x);
+ Math::Swap(uv1.x, uv2.x);
DrawIcon(pos, dim, uv1, uv2); // dl
}
if ( m_icon == 13 ) // corner upper / left?
diff --git a/src/ui/group.h b/src/ui/group.h
index 264ae54..3133b54 100644
--- a/src/ui/group.h
+++ b/src/ui/group.h
@@ -32,7 +32,7 @@ public:
CGroup(CInstanceManager* iMan);
virtual ~CGroup();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/image.cpp b/src/ui/image.cpp
index f229585..9019858 100644
--- a/src/ui/image.cpp
+++ b/src/ui/image.cpp
@@ -16,8 +16,6 @@
// image.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -55,7 +53,7 @@ CImage::~CImage()
// Creates a new button.
-bool CImage::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -106,7 +104,7 @@ bool CImage::EventProcess(const Event &event)
void CImage::Draw()
{
- FPOINT uv1,uv2, corner, pos, dim;
+ Math::Point uv1,uv2, corner, pos, dim;
float dp;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
diff --git a/src/ui/image.h b/src/ui/image.h
index 9d2aa29..d327598 100644
--- a/src/ui/image.h
+++ b/src/ui/image.h
@@ -32,7 +32,7 @@ public:
CImage(CInstanceManager* iMan);
virtual ~CImage();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 99b4755..8b8a888 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -16,8 +16,6 @@
// interface.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -98,7 +96,7 @@ void CInterface::Flush()
// Creates a new button.
-CWindow* CInterface::CreateWindows(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CWindow* pc;
int i;
@@ -134,7 +132,7 @@ CWindow* CInterface::CreateWindows(FPOINT pos, FPOINT dim, int icon, EventMsg ev
// Creates a new button.
-CButton* CInterface::CreateButton(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CButton* CInterface::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CButton* pc;
int i;
@@ -156,7 +154,7 @@ CButton* CInterface::CreateButton(FPOINT pos, FPOINT dim, int icon, EventMsg eve
// Creates a new button.
-CColor* CInterface::CreateColor(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CColor* CInterface::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CColor* pc;
int i;
@@ -178,7 +176,7 @@ CColor* CInterface::CreateColor(FPOINT pos, FPOINT dim, int icon, EventMsg event
// Creates a new button.
-CCheck* CInterface::CreateCheck(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CCheck* CInterface::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CCheck* pc;
int i;
@@ -200,7 +198,7 @@ CCheck* CInterface::CreateCheck(FPOINT pos, FPOINT dim, int icon, EventMsg event
// Creates a new button.
-CKey* CInterface::CreateKey(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CKey* pc;
int i;
@@ -222,7 +220,7 @@ CKey* CInterface::CreateKey(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
// Creates a new button.
-CGroup* CInterface::CreateGroup(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CGroup* CInterface::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CGroup* pc;
int i;
@@ -244,7 +242,7 @@ CGroup* CInterface::CreateGroup(FPOINT pos, FPOINT dim, int icon, EventMsg event
// Creates a new button.
-CImage* CInterface::CreateImage(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CImage* pc;
int i;
@@ -266,7 +264,7 @@ CImage* CInterface::CreateImage(FPOINT pos, FPOINT dim, int icon, EventMsg event
// Creates a new label.
-CLabel* CInterface::CreateLabel(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg,
+CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
char *name)
{
CLabel* pc;
@@ -290,7 +288,7 @@ CLabel* CInterface::CreateLabel(FPOINT pos, FPOINT dim, int icon, EventMsg event
// Creates a new pave editable.
-CEdit* CInterface::CreateEdit(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CEdit* pc;
int i;
@@ -312,7 +310,7 @@ CEdit* CInterface::CreateEdit(FPOINT pos, FPOINT dim, int icon, EventMsg eventMs
// Creates a new pave editable.
-CEditValue* CInterface::CreateEditValue(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CEditValue* pc;
int i;
@@ -334,7 +332,7 @@ CEditValue* CInterface::CreateEditValue(FPOINT pos, FPOINT dim, int icon, EventM
// Creates a new lift.
-CScroll* CInterface::CreateScroll(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CScroll* CInterface::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CScroll* pc;
int i;
@@ -356,7 +354,7 @@ CScroll* CInterface::CreateScroll(FPOINT pos, FPOINT dim, int icon, EventMsg eve
// Creates a new cursor.
-CSlider* CInterface::CreateSlider(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CSlider* pc;
int i;
@@ -378,7 +376,7 @@ CSlider* CInterface::CreateSlider(FPOINT pos, FPOINT dim, int icon, EventMsg eve
// Creates a new list.
-CList* CInterface::CreateList(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg,
+CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
float expand)
{
CList* pc;
@@ -401,7 +399,7 @@ CList* CInterface::CreateList(FPOINT pos, FPOINT dim, int icon, EventMsg eventMs
// Creates a new shortcut.
-CShortcut* CInterface::CreateShortcut(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CShortcut* CInterface::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CShortcut* ps;
int i;
@@ -423,7 +421,7 @@ CShortcut* CInterface::CreateShortcut(FPOINT pos, FPOINT dim, int icon, EventMsg
// Creates a new compass.
-CCompass* CInterface::CreateCompass(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CCompass* CInterface::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CCompass* pc;
int i;
@@ -445,7 +443,7 @@ CCompass* CInterface::CreateCompass(FPOINT pos, FPOINT dim, int icon, EventMsg e
// Creates a new target.
-CTarget* CInterface::CreateTarget(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CTarget* CInterface::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CTarget* pc;
int i;
@@ -467,7 +465,7 @@ CTarget* CInterface::CreateTarget(FPOINT pos, FPOINT dim, int icon, EventMsg eve
// Creates a new map.
-CMap* CInterface::CreateMap(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CMap* pm;
int i;
@@ -560,7 +558,7 @@ bool CInterface::EventProcess(const Event &event)
// Gives the tooltip binding to the window.
-bool CInterface::GetTooltip(FPOINT pos, char* name)
+bool CInterface::GetTooltip(Math::Point pos, char* name)
{
int i;
diff --git a/src/ui/interface.h b/src/ui/interface.h
index 4c58997..0b3ba0d 100644
--- a/src/ui/interface.h
+++ b/src/ui/interface.h
@@ -19,6 +19,10 @@
#pragma once
+#include "common/event.h"
+#include "math/point.h"
+
+
class CInstanceManager;
class CD3DEngine;
class CControl;
@@ -53,26 +57,26 @@ public:
~CInterface();
bool EventProcess(const Event &event);
- bool GetTooltip(FPOINT pos, char* name);
+ bool GetTooltip(Math::Point pos, char* name);
void Flush();
- CWindow* CreateWindows(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CButton* CreateButton(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CColor* CreateColor(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CCheck* CreateCheck(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CKey* CreateKey(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CGroup* CreateGroup(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CImage* CreateImage(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CLabel* CreateLabel(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg, char *name);
- CEdit* CreateEdit(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CEditValue* CreateEditValue(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CScroll* CreateScroll(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CSlider* CreateSlider(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CList* CreateList(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg, float expand=1.2f);
- CShortcut* CreateShortcut(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CCompass* CreateCompass(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CTarget* CreateTarget(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CMap* CreateMap(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name);
+ CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f);
+ CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool DeleteControl(EventMsg eventMsg);
CControl* SearchControl(EventMsg eventMsg);
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index d996244..1b8925d 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -16,8 +16,6 @@
// key.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -78,7 +76,7 @@ CKey::~CKey()
// Creates a new button.
-bool CKey::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
char name[100];
char* p;
@@ -184,7 +182,7 @@ bool CKey::TestKey(int key)
void CKey::Draw()
{
- FPOINT iDim, pos;
+ Math::Point iDim, pos;
float zoomExt, zoomInt, h;
int icon;
char text[100];
diff --git a/src/ui/key.h b/src/ui/key.h
index c3f46fd..ebca010 100644
--- a/src/ui/key.h
+++ b/src/ui/key.h
@@ -32,7 +32,7 @@ public:
CKey(CInstanceManager* iMan);
virtual ~CKey();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/label.cpp b/src/ui/label.cpp
index 288631c..5458d28 100644
--- a/src/ui/label.cpp
+++ b/src/ui/label.cpp
@@ -16,8 +16,6 @@
// label.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -50,7 +48,7 @@ CLabel::~CLabel()
// Creates a new button.
-bool CLabel::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -72,7 +70,7 @@ bool CLabel::EventProcess(const Event &event)
void CLabel::Draw()
{
- FPOINT pos;
+ Math::Point pos;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
diff --git a/src/ui/label.h b/src/ui/label.h
index 1594deb..c6199ba 100644
--- a/src/ui/label.h
+++ b/src/ui/label.h
@@ -32,7 +32,7 @@ public:
CLabel(CInstanceManager* iMan);
virtual ~CLabel();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index be9dbda..f924fde 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -16,8 +16,6 @@
// list.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -90,7 +88,7 @@ CList::~CList()
// Creates a new list.
-bool CList::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg,
+bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
float expand)
{
m_expand = expand;
@@ -109,7 +107,7 @@ bool CList::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg,
bool CList::MoveAdjust()
{
- FPOINT ipos, idim, ppos, ddim;
+ Math::Point ipos, idim, ppos, ddim;
float marging, h;
int i;
@@ -186,12 +184,12 @@ EventMsg CList::RetEventMsgScroll()
}
-void CList::SetPos(FPOINT pos)
+void CList::SetPos(Math::Point pos)
{
CControl::SetPos(pos);
}
-void CList::SetDim(FPOINT dim)
+void CList::SetDim(Math::Point dim)
{
m_dim = dim;
MoveAdjust();
@@ -263,7 +261,7 @@ bool CList::EventProcess(const Event &event)
m_button[i] != 0 )
{
m_blinkTime += event.rTime;
- if ( Mod(m_blinkTime, 0.7f) < 0.3f )
+ if ( Math::Mod(m_blinkTime, 0.7f) < 0.3f )
{
m_button[i]->ClearState(STATE_ENABLE);
m_button[i]->ClearState(STATE_CHECK);
@@ -353,7 +351,7 @@ bool CList::EventProcess(const Event &event)
void CList::Draw()
{
- FPOINT uv1, uv2, corner, pos, dim, ppos, ddim;
+ Math::Point uv1, uv2, corner, pos, dim, ppos, ddim;
float dp;
int i, j;
char text[100];
@@ -555,7 +553,7 @@ void CList::Draw()
// Displays text in a box.
-void CList::DrawCase(char *text, FPOINT pos, float width, int justif)
+void CList::DrawCase(char *text, Math::Point pos, float width, int justif)
{
if ( justif == 1 )
{
diff --git a/src/ui/list.h b/src/ui/list.h
index ae55d35..ead058b 100644
--- a/src/ui/list.h
+++ b/src/ui/list.h
@@ -39,10 +39,10 @@ public:
CList(CInstanceManager* iMan);
~CList();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg, float expand);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand);
- void SetPos(FPOINT pos);
- void SetDim(FPOINT dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
bool SetState(int state, bool bState);
bool SetState(int state);
@@ -87,7 +87,7 @@ protected:
void UpdateButton();
void UpdateScroll();
void MoveScroll();
- void DrawCase(char *text, FPOINT pos, float width, int justif);
+ void DrawCase(char *text, Math::Point pos, float width, int justif);
protected:
CButton* m_button[LISTMAXDISPLAY];
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 175474d..f57a913 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -16,8 +16,6 @@
// maindialog.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -207,7 +205,7 @@ CMainDialog::CMainDialog(CInstanceManager* iMan)
m_bEffect = true;
m_shotDelay = 0;
- m_glintMouse = FPOINT(0.0f, 0.0f);
+ m_glintMouse = Math::Point(0.0f, 0.0f);
m_glintTime = 1000.0f;
for ( i=0 ; i<10 ; i++ )
@@ -248,7 +246,7 @@ void CMainDialog::ChangePhase(Phase phase)
CColor* pco;
CGroup* pg;
CImage* pi;
- FPOINT pos, dim, ddim;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
char name[100];
char* gamer;
@@ -3103,7 +3101,7 @@ void CMainDialog::GlintMove()
{
CWindow* pw;
CGroup* pg;
- FPOINT pos, dim, zoom;
+ Math::Point pos, dim, zoom;
if ( m_phase == PHASE_SIMUL ) return;
@@ -3255,7 +3253,7 @@ void CMainDialog::GlintMove()
// Returns the position for a sound.
-D3DVECTOR SoundPos(FPOINT pos)
+D3DVECTOR SoundPos(Math::Point pos)
{
D3DVECTOR s;
@@ -3272,8 +3270,8 @@ D3DVECTOR SoundRand()
{
D3DVECTOR s;
- s.x = (Rand()-0.5f)*2.0f;
- s.y = (Rand()-0.5f)*2.0f;
+ s.x = (Math::Rand()-0.5f)*2.0f;
+ s.y = (Math::Rand()-0.5f)*2.0f;
s.z = 0.0f;
return s;
@@ -3286,7 +3284,7 @@ void CMainDialog::FrameParticule(float rTime)
#if _NEWLOOK
#else
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
float *pParti, *pGlint;
int nParti, nGlint;
int i, r, ii;
@@ -3409,15 +3407,15 @@ void CMainDialog::FrameParticule(float rTime)
ii = rand()%nParti;
m_partiPos[i].x = pParti[ii*5+0]/640.0f;
m_partiPos[i].y = (480.0f-pParti[ii*5+1])/480.0f;
- m_partiTime[i] = pParti[ii*5+2]+Rand()*pParti[ii*5+3];
+ m_partiTime[i] = pParti[ii*5+2]+Math::Rand()*pParti[ii*5+3];
m_partiPhase[i] = (int)pParti[ii*5+4];
if ( m_partiPhase[i] == 3 )
{
- m_sound->Play(SOUND_PSHHH, SoundPos(m_partiPos[i]), 0.3f+Rand()*0.3f);
+ m_sound->Play(SOUND_PSHHH, SoundPos(m_partiPos[i]), 0.3f+Math::Rand()*0.3f);
}
else
{
- m_sound->Play(SOUND_GGG, SoundPos(m_partiPos[i]), 0.1f+Rand()*0.4f);
+ m_sound->Play(SOUND_GGG, SoundPos(m_partiPos[i]), 0.1f+Math::Rand()*0.4f);
}
}
@@ -3430,13 +3428,13 @@ void CMainDialog::FrameParticule(float rTime)
speed.x = 0.0f;
speed.y = 0.0f;
speed.z = 0.0f;
- dim.x = 0.04f+Rand()*0.04f;
+ dim.x = 0.04f+Math::Rand()*0.04f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim,
rand()%2?PARTIGLINT:PARTICONTROL,
- Rand()*0.4f+0.4f, 0.0f, 0.0f,
+ Math::Rand()*0.4f+0.4f, 0.0f, 0.0f,
SH_INTERFACE);
- m_partiTime[i] = 0.5f+Rand()*0.5f;
+ m_partiTime[i] = 0.5f+Math::Rand()*0.5f;
}
if ( r == 2 )
@@ -3444,38 +3442,38 @@ void CMainDialog::FrameParticule(float rTime)
ii = rand()%7;
if ( ii == 0 )
{
- m_sound->Play(SOUND_ENERGY, SoundRand(), 0.2f+Rand()*0.2f);
- m_partiTime[i] = 1.0f+Rand()*1.0f;
+ m_sound->Play(SOUND_ENERGY, SoundRand(), 0.2f+Math::Rand()*0.2f);
+ m_partiTime[i] = 1.0f+Math::Rand()*1.0f;
}
if ( ii == 1 )
{
- m_sound->Play(SOUND_STATION, SoundRand(), 0.2f+Rand()*0.2f);
- m_partiTime[i] = 1.0f+Rand()*2.0f;
+ m_sound->Play(SOUND_STATION, SoundRand(), 0.2f+Math::Rand()*0.2f);
+ m_partiTime[i] = 1.0f+Math::Rand()*2.0f;
}
if ( ii == 2 )
{
- m_sound->Play(SOUND_ALARM, SoundRand(), 0.1f+Rand()*0.1f);
- m_partiTime[i] = 2.0f+Rand()*4.0f;
+ m_sound->Play(SOUND_ALARM, SoundRand(), 0.1f+Math::Rand()*0.1f);
+ m_partiTime[i] = 2.0f+Math::Rand()*4.0f;
}
if ( ii == 3 )
{
- m_sound->Play(SOUND_INFO, SoundRand(), 0.1f+Rand()*0.1f);
- m_partiTime[i] = 2.0f+Rand()*4.0f;
+ m_sound->Play(SOUND_INFO, SoundRand(), 0.1f+Math::Rand()*0.1f);
+ m_partiTime[i] = 2.0f+Math::Rand()*4.0f;
}
if ( ii == 4 )
{
- m_sound->Play(SOUND_RADAR, SoundRand(), 0.2f+Rand()*0.2f);
- m_partiTime[i] = 0.5f+Rand()*1.0f;
+ m_sound->Play(SOUND_RADAR, SoundRand(), 0.2f+Math::Rand()*0.2f);
+ m_partiTime[i] = 0.5f+Math::Rand()*1.0f;
}
if ( ii == 5 )
{
- m_sound->Play(SOUND_GFLAT, SoundRand(), 0.3f+Rand()*0.3f);
- m_partiTime[i] = 2.0f+Rand()*4.0f;
+ m_sound->Play(SOUND_GFLAT, SoundRand(), 0.3f+Math::Rand()*0.3f);
+ m_partiTime[i] = 2.0f+Math::Rand()*4.0f;
}
if ( ii == 6 )
{
- m_sound->Play(SOUND_ALARMt, SoundRand(), 0.1f+Rand()*0.1f);
- m_partiTime[i] = 2.0f+Rand()*4.0f;
+ m_sound->Play(SOUND_ALARMt, SoundRand(), 0.1f+Math::Rand()*0.1f);
+ m_partiTime[i] = 2.0f+Math::Rand()*4.0f;
}
}
}
@@ -3491,27 +3489,27 @@ void CMainDialog::FrameParticule(float rTime)
pos.x = m_partiPos[i].x;
pos.y = m_partiPos[i].y;
pos.z = 0.0f;
- pos.x += (Rand()-0.5f)*0.01f;
- pos.y += (Rand()-0.5f)*0.01f;
- speed.x = (Rand()-0.5f)*0.2f;
- speed.y = (Rand()-0.5f)*0.2f;
+ pos.x += (Math::Rand()-0.5f)*0.01f;
+ pos.y += (Math::Rand()-0.5f)*0.01f;
+ speed.x = (Math::Rand()-0.5f)*0.2f;
+ speed.y = (Math::Rand()-0.5f)*0.2f;
speed.z = 0.0f;
- dim.x = 0.005f+Rand()*0.005f;
+ dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ,
- Rand()*0.2f+0.2f, 0.0f, 0.0f,
+ Math::Rand()*0.2f+0.2f, 0.0f, 0.0f,
SH_INTERFACE);
pos.x = m_partiPos[i].x;
pos.y = m_partiPos[i].y;
pos.z = 0.0f;
- speed.x = (Rand()-0.5f)*0.5f;
- speed.y = (0.3f+Rand()*0.3f);
+ speed.x = (Math::Rand()-0.5f)*0.5f;
+ speed.y = (0.3f+Math::Rand()*0.3f);
speed.z = 0.0f;
- dim.x = 0.01f+Rand()*0.01f;
+ dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim,
(ParticuleType)(PARTILENS1+rand()%3),
- Rand()*0.5f+0.5f, 2.0f, 0.0f,
+ Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
SH_INTERFACE);
}
if ( m_partiPhase[i] == 2 ) // sparks?
@@ -3519,26 +3517,26 @@ void CMainDialog::FrameParticule(float rTime)
pos.x = m_partiPos[i].x;
pos.y = m_partiPos[i].y;
pos.z = 0.0f;
- pos.x += (Rand()-0.5f)*0.01f;
- pos.y += (Rand()-0.5f)*0.01f;
- speed.x = (Rand()-0.5f)*0.2f;
- speed.y = (Rand()-0.5f)*0.2f;
+ pos.x += (Math::Rand()-0.5f)*0.01f;
+ pos.y += (Math::Rand()-0.5f)*0.01f;
+ speed.x = (Math::Rand()-0.5f)*0.2f;
+ speed.y = (Math::Rand()-0.5f)*0.2f;
speed.z = 0.0f;
- dim.x = 0.005f+Rand()*0.005f;
+ dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ,
- Rand()*0.2f+0.2f, 0.0f, 0.0f,
+ Math::Rand()*0.2f+0.2f, 0.0f, 0.0f,
SH_INTERFACE);
pos.x = m_partiPos[i].x;
pos.y = m_partiPos[i].y;
pos.z = 0.0f;
- speed.x = (Rand()-0.5f)*0.5f;
- speed.y = (0.3f+Rand()*0.3f);
+ speed.x = (Math::Rand()-0.5f)*0.5f;
+ speed.y = (0.3f+Math::Rand()*0.3f);
speed.z = 0.0f;
- dim.x = 0.005f+Rand()*0.005f;
+ dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS,
- Rand()*0.5f+0.5f, 2.0f, 0.0f,
+ Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
SH_INTERFACE);
}
if ( m_partiPhase[i] == 3 ) // smoke?
@@ -3546,22 +3544,22 @@ void CMainDialog::FrameParticule(float rTime)
pos.x = m_partiPos[i].x;
pos.y = m_partiPos[i].y;
pos.z = 0.0f;
- pos.x += (Rand()-0.5f)*0.03f;
- pos.y += (Rand()-0.5f)*0.03f;
- speed.x = (Rand()-0.5f)*0.2f;
- speed.y = Rand()*0.5f;
+ pos.x += (Math::Rand()-0.5f)*0.03f;
+ pos.y += (Math::Rand()-0.5f)*0.03f;
+ speed.x = (Math::Rand()-0.5f)*0.2f;
+ speed.y = Math::Rand()*0.5f;
speed.z = 0.0f;
- dim.x = 0.03f+Rand()*0.07f;
+ dim.x = 0.03f+Math::Rand()*0.07f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH,
- Rand()*0.4f+0.4f, 0.0f, 0.0f,
+ Math::Rand()*0.4f+0.4f, 0.0f, 0.0f,
SH_INTERFACE);
}
}
else
{
m_partiPhase[i] = 0;
- m_partiTime[i] = 2.0f+Rand()*4.0f;
+ m_partiTime[i] = 2.0f+Math::Rand()*4.0f;
}
}
}
@@ -3570,10 +3568,10 @@ void CMainDialog::FrameParticule(float rTime)
// Some nice particles following the mouse.
-void CMainDialog::NiceParticule(FPOINT mouse, bool bPress)
+void CMainDialog::NiceParticule(Math::Point mouse, bool bPress)
{
D3DVECTOR pos, speed;
- FPOINT dim;
+ Math::Point dim;
if ( !m_bRain ) return;
if ( (m_phase == PHASE_SIMUL ||
@@ -3587,13 +3585,13 @@ void CMainDialog::NiceParticule(FPOINT mouse, bool bPress)
pos.x = mouse.x;
pos.y = mouse.y;
pos.z = 0.0f;
- speed.x = (Rand()-0.5f)*0.5f;
- speed.y = (0.3f+Rand()*0.3f);
+ speed.x = (Math::Rand()-0.5f)*0.5f;
+ speed.y = (0.3f+Math::Rand()*0.3f);
speed.z = 0.0f;
- dim.x = 0.005f+Rand()*0.005f;
+ dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS,
- Rand()*0.5f+0.5f, 2.0f, 0.0f,
+ Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
SH_INTERFACE);
}
else
@@ -3601,14 +3599,14 @@ void CMainDialog::NiceParticule(FPOINT mouse, bool bPress)
pos.x = mouse.x;
pos.y = mouse.y;
pos.z = 0.0f;
- speed.x = (Rand()-0.5f)*0.5f;
- speed.y = (0.3f+Rand()*0.3f);
+ speed.x = (Math::Rand()-0.5f)*0.5f;
+ speed.y = (0.3f+Math::Rand()*0.3f);
speed.z = 0.0f;
- dim.x = 0.01f+Rand()*0.01f;
+ dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim,
(ParticuleType)(PARTILENS1+rand()%3),
- Rand()*0.5f+0.5f, 2.0f, 0.0f,
+ Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
SH_INTERFACE);
}
}
@@ -4037,9 +4035,9 @@ void CMainDialog::NameDelete()
bool EqColor(const D3DCOLORVALUE &c1, const D3DCOLORVALUE &c2)
{
- return (Abs(c1.r-c2.r) < 0.01f &&
- Abs(c1.g-c2.g) < 0.01f &&
- Abs(c1.b-c2.b) < 0.01f );
+ return (fabs(c1.r-c2.r) < 0.01f &&
+ fabs(c1.g-c2.g) < 0.01f &&
+ fabs(c1.b-c2.b) < 0.01f );
}
// Updates all the buttons for the character.
@@ -6026,7 +6024,7 @@ void CMainDialog::UpdateKey()
CWindow* pw;
CScroll* ps;
CKey* pk;
- FPOINT pos, dim;
+ Math::Point pos, dim;
int first, i;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
@@ -6092,10 +6090,10 @@ void CMainDialog::StartAbort()
{
CWindow* pw;
CButton* pb;
- FPOINT pos, dim;
+ Math::Point pos, dim;
char name[100];
- StartDialog(FPOINT(0.3f, 0.8f), true, false, false);
+ StartDialog(Math::Point(0.3f, 0.8f), true, false, false);
m_bDialogDelete = false;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
@@ -6174,10 +6172,10 @@ void CMainDialog::StartDeleteObject()
{
CWindow* pw;
CButton* pb;
- FPOINT pos, dim;
+ Math::Point pos, dim;
char name[100];
- StartDialog(FPOINT(0.7f, 0.3f), false, true, true);
+ StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
@@ -6208,11 +6206,11 @@ void CMainDialog::StartDeleteGame(char *gamer)
{
CWindow* pw;
CButton* pb;
- FPOINT pos, dim;
+ Math::Point pos, dim;
char name[100];
char text[100];
- StartDialog(FPOINT(0.7f, 0.3f), false, true, true);
+ StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
@@ -6244,10 +6242,10 @@ void CMainDialog::StartQuit()
{
CWindow* pw;
CButton* pb;
- FPOINT pos, dim;
+ Math::Point pos, dim;
char name[100];
- StartDialog(FPOINT(0.6f, 0.3f), false, true, true);
+ StartDialog(Math::Point(0.6f, 0.3f), false, true, true);
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return;
@@ -6273,11 +6271,11 @@ void CMainDialog::StartQuit()
// Beginning of displaying a dialog.
-void CMainDialog::StartDialog(FPOINT dim, bool bFire, bool bOK, bool bCancel)
+void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCancel)
{
CWindow* pw;
CButton* pb;
- FPOINT pos, ddim;
+ Math::Point pos, ddim;
char name[100];
StartSuspend();
@@ -6363,7 +6361,7 @@ void CMainDialog::FrameDialog(float rTime)
{
CWindow* pw;
D3DVECTOR pos, speed;
- FPOINT dim, dpos, ddim;
+ Math::Point dim, dpos, ddim;
float zoom;
int i;
@@ -6378,7 +6376,7 @@ void CMainDialog::FrameDialog(float rTime)
{
if ( m_dialogTime < 0.50f )
{
- zoom = Bounce(m_dialogTime/0.50f);
+ zoom = Math::Bounce(m_dialogTime/0.50f);
}
else
{
@@ -6416,44 +6414,44 @@ void CMainDialog::FrameDialog(float rTime)
for ( i=0 ; i<2 ; i++ )
{
// Bottom.
- pos.x = dpos.x + ddim.x*Rand();
+ pos.x = dpos.x + ddim.x*Math::Rand();
pos.y = dpos.y;
- pos.x += (Rand()-0.5f)*(6.0f/640.0f);
- pos.y += Rand()*(16.0f/480.0f)-(10.0f/480.0f);
- dim.x = 0.01f+Rand()*0.01f;
+ pos.x += (Math::Rand()-0.5f)*(6.0f/640.0f);
+ pos.y += Math::Rand()*(16.0f/480.0f)-(10.0f/480.0f);
+ dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim,
(ParticuleType)(PARTILENS1+rand()%3),
1.0f, 0.0f, 0.0f, SH_INTERFACE);
// Top.
- pos.x = dpos.x + ddim.x*Rand();
+ pos.x = dpos.x + ddim.x*Math::Rand();
pos.y = dpos.y + ddim.y;
- pos.x += (Rand()-0.5f)*(6.0f/640.0f);
- pos.y -= Rand()*(16.0f/480.0f)-(10.0f/480.0f);
- dim.x = 0.01f+Rand()*0.01f;
+ pos.x += (Math::Rand()-0.5f)*(6.0f/640.0f);
+ pos.y -= Math::Rand()*(16.0f/480.0f)-(10.0f/480.0f);
+ dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim,
(ParticuleType)(PARTILENS1+rand()%3),
1.0f, 0.0f, 0.0f, SH_INTERFACE);
// Left.
- pos.y = dpos.y + ddim.y*Rand();
+ pos.y = dpos.y + ddim.y*Math::Rand();
pos.x = dpos.x;
- pos.x += Rand()*(16.0f/640.0f)-(10.0f/640.0f);
- pos.y += (Rand()-0.5f)*(6.0f/480.0f);
- dim.x = 0.01f+Rand()*0.01f;
+ pos.x += Math::Rand()*(16.0f/640.0f)-(10.0f/640.0f);
+ pos.y += (Math::Rand()-0.5f)*(6.0f/480.0f);
+ dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim,
(ParticuleType)(PARTILENS1+rand()%3),
1.0f, 0.0f, 0.0f, SH_INTERFACE);
// Right.
- pos.y = dpos.y + ddim.y*Rand();
+ pos.y = dpos.y + ddim.y*Math::Rand();
pos.x = dpos.x + ddim.x;
- pos.x -= Rand()*(16.0f/640.0f)-(10.0f/640.0f);
- pos.y += (Rand()-0.5f)*(6.0f/480.0f);
- dim.x = 0.01f+Rand()*0.01f;
+ pos.x -= Math::Rand()*(16.0f/640.0f)-(10.0f/640.0f);
+ pos.y += (Math::Rand()-0.5f)*(6.0f/480.0f);
+ dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
m_particule->CreateParticule(pos, speed, dim,
(ParticuleType)(PARTILENS1+rand()%3),
diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h
index 9173dde..5819cf8 100644
--- a/src/ui/maindialog.h
+++ b/src/ui/maindialog.h
@@ -92,7 +92,7 @@ public:
void StartDeleteObject();
void StartDeleteGame(char *gamer);
void StartQuit();
- void StartDialog(FPOINT dim, bool bFire, bool bOK, bool bCancel);
+ void StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCancel);
void FrameDialog(float rTime);
void StopDialog();
bool IsDialog();
@@ -129,7 +129,7 @@ public:
protected:
void GlintMove();
void FrameParticule(float rTime);
- void NiceParticule(FPOINT mouse, bool bPress);
+ void NiceParticule(Math::Point mouse, bool bPress);
void ReadNameList();
void UpdateNameList();
void UpdateNameEdit();
@@ -228,7 +228,7 @@ protected:
bool m_bCameraInvertY; // for CCamera
bool m_bEffect; // for CCamera
- FPOINT m_glintMouse;
+ Math::Point m_glintMouse;
float m_glintTime;
int m_loadingCounter;
@@ -236,8 +236,8 @@ protected:
bool m_bDialog; // this dialogue?
bool m_bDialogFire; // setting on fire?
bool m_bDialogDelete;
- FPOINT m_dialogPos;
- FPOINT m_dialogDim;
+ Math::Point m_dialogPos;
+ Math::Point m_dialogDim;
float m_dialogParti;
float m_dialogTime;
bool m_bInitPause;
@@ -245,7 +245,7 @@ protected:
int m_partiPhase[10];
float m_partiTime[10];
- FPOINT m_partiPos[10];
+ Math::Point m_partiPos[10];
SceneInfo m_sceneInfo[MAXSCENE];
};
diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp
index 72452d8..2b05775 100644
--- a/src/ui/mainmap.cpp
+++ b/src/ui/mainmap.cpp
@@ -16,8 +16,6 @@
// mainmap.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -72,7 +70,7 @@ CMainMap::~CMainMap()
void CMainMap::CreateMap()
{
CWindow* pw;
- FPOINT pos, dim;
+ Math::Point pos, dim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
if ( pw == 0 )
@@ -169,7 +167,7 @@ void CMainMap::DimMap()
CWindow* pw;
CMap* pm;
CSlider* ps;
- FPOINT pos, dim;
+ Math::Point pos, dim;
float value;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
@@ -369,7 +367,7 @@ bool CMainMap::RetFixImage()
// The object is detected in the mini-map.
-CObject* CMainMap::DetectMap(FPOINT pos, bool &bInMap)
+CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap)
{
CWindow* pw;
CMap* pm;
diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h
index 1c0e1fd..6b10d94 100644
--- a/src/ui/mainmap.h
+++ b/src/ui/mainmap.h
@@ -19,6 +19,10 @@
#pragma once
+#include "common/struct.h"
+#include "math/point.h"
+
+
class CInstanceManager;
class CEvent;
class CD3DEngine;
@@ -45,7 +49,7 @@ public:
void MapEnable(bool bEnable);
bool RetShowMap();
bool RetFixImage();
- CObject* DetectMap(FPOINT pos, bool &bInMap);
+ CObject* DetectMap(Math::Point pos, bool &bInMap);
void SetHilite(CObject* pObj);
void SetToy(bool bToy);
void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug);
diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp
index c68f21c..5d574e4 100644
--- a/src/ui/mainshort.cpp
+++ b/src/ui/mainshort.cpp
@@ -16,8 +16,6 @@
// mainshort.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -111,7 +109,7 @@ bool CMainShort::CreateShortcuts()
CObject* pObj;
CControl* pc;
ObjectType type;
- FPOINT pos, dim;
+ Math::Point pos, dim;
int i, rank, icon;
char name[100];
@@ -319,10 +317,10 @@ void CMainShort::SelectNext()
// The object detected by the mouse hovers over.
-CObject* CMainShort::DetectShort(FPOINT pos)
+CObject* CMainShort::DetectShort(Math::Point pos)
{
CControl* pc;
- FPOINT cpos, cdim;
+ Math::Point cpos, cdim;
int i;
for ( i=0 ; i<20 ; i++ )
diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h
index 1b507d4..82b0253 100644
--- a/src/ui/mainshort.h
+++ b/src/ui/mainshort.h
@@ -19,8 +19,11 @@
#pragma once
+#include "common/event.h"
+#include "math/point.h"
+
+
class CInstanceManager;
-class CEvent;
class CD3DEngine;
class CInterface;
class CRobotMain;
@@ -40,7 +43,7 @@ public:
bool UpdateShortcuts();
void SelectShortcut(EventMsg event);
void SelectNext();
- CObject* DetectShort(FPOINT pos);
+ CObject* DetectShort(Math::Point pos);
void SetHilite(CObject* pObj);
protected:
diff --git a/src/ui/map.cpp b/src/ui/map.cpp
index a4bdecb..437ad58 100644
--- a/src/ui/map.cpp
+++ b/src/ui/map.cpp
@@ -16,14 +16,13 @@
// map.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
#include <d3d.h>
#include "common/struct.h"
+#include "math/geometry.h"
#include "graphics/d3d/d3dengine.h"
#include "common/event.h"
#include "math/old/math3d.h"
@@ -82,7 +81,7 @@ CMap::~CMap()
// Creates a new button.
-bool CMap::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -224,7 +223,7 @@ bool CMap::EventProcess(const Event &event)
// Adjusts the offset to not exceed the card.
-FPOINT CMap::AdjustOffset(FPOINT offset)
+Math::Point CMap::AdjustOffset(Math::Point offset)
{
float limit;
@@ -261,7 +260,7 @@ void CMap::SetHilite(CObject* pObj)
// Detects an object in the map.
-CObject* CMap::DetectObject(FPOINT pos, bool &bInMap)
+CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
{
float dist, min;
int i, best;
@@ -301,7 +300,7 @@ CObject* CMap::DetectObject(FPOINT pos, bool &bInMap)
// Selects an object.
-void CMap::SelectObject(FPOINT pos)
+void CMap::SelectObject(Math::Point pos)
{
CObject *pObj;
bool bInMap;
@@ -318,7 +317,7 @@ void CMap::SelectObject(FPOINT pos)
void CMap::Draw()
{
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
int i;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
@@ -388,14 +387,14 @@ void CMap::Draw()
// Computing a point for drawFocus.
-FPOINT CMap::MapInter(FPOINT pos, float dir)
+Math::Point CMap::MapInter(Math::Point pos, float dir)
{
- FPOINT p1;
+ Math::Point p1;
float limit;
p1.x = pos.x+1.0f;
p1.y = pos.y;
- p1 = RotatePoint(pos, dir, p1);
+ p1 = Math::RotatePoint(pos, dir, p1);
p1.x -= pos.x;
p1.y -= pos.y;
@@ -432,9 +431,9 @@ FPOINT CMap::MapInter(FPOINT pos, float dir)
// Draw the field of vision of the selected object.
-void CMap::DrawFocus(FPOINT pos, float dir, ObjectType type, MapColor color)
+void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color)
{
- FPOINT p0, p1, p2, uv1, uv2, rel;
+ Math::Point p0, p1, p2, uv1, uv2, rel;
float aMin, aMax, aOct, focus, a;
float limit[5];
bool bEnding;
@@ -456,22 +455,22 @@ void CMap::DrawFocus(FPOINT pos, float dir, ObjectType type, MapColor color)
pos.y = m_mapPos.y*0.75f+m_mapDim.y*pos.y*0.75f;
focus = m_engine->RetFocus();
- dir += PI/2.0f;
- aMin = NormAngle(dir-PI/4.0f*focus);
- aMax = NormAngle(dir+PI/4.0f*focus);
+ dir += Math::PI/2.0f;
+ aMin = Math::NormAngle(dir-Math::PI/4.0f*focus);
+ aMax = Math::NormAngle(dir+Math::PI/4.0f*focus);
if ( aMin > aMax )
{
- aMax += PI*2.0f; // aMax always after aMin
+ aMax += Math::PI*2.0f; // aMax always after aMin
}
- limit[0] = RotateAngle( 1.0f-rel.x, 1.0f-rel.y); // upper/right
- limit[1] = RotateAngle(-1.0f-rel.x, 1.0f-rel.y); // upper/left
- limit[2] = RotateAngle(-1.0f-rel.x, -1.0f-rel.y); // lower/left
- limit[3] = RotateAngle( 1.0f-rel.x, -1.0f-rel.y); // lower/right
- limit[4] = limit[0]+PI*2.0f;
+ limit[0] = Math::RotateAngle( 1.0f-rel.x, 1.0f-rel.y); // upper/right
+ limit[1] = Math::RotateAngle(-1.0f-rel.x, 1.0f-rel.y); // upper/left
+ limit[2] = Math::RotateAngle(-1.0f-rel.x, -1.0f-rel.y); // lower/left
+ limit[3] = Math::RotateAngle( 1.0f-rel.x, -1.0f-rel.y); // lower/right
+ limit[4] = limit[0]+Math::PI*2.0f;
- a = NormAngle(aMin);
+ a = Math::NormAngle(aMin);
for ( quart=0 ; quart<4 ; quart++ )
{
if ( a >= limit[quart+0] &&
@@ -492,8 +491,8 @@ void CMap::DrawFocus(FPOINT pos, float dir, ObjectType type, MapColor color)
{
quart ++;
aOct = limit[quart%4];
- if ( quart >= 4 ) aOct += PI*2.0f;
- if ( aOct >= aMax-CHOUIA )
+ if ( quart >= 4 ) aOct += Math::PI*2.0f;
+ if ( aOct >= aMax-Math::VERY_SMALL )
{
aOct = aMax;
bEnding = true;
@@ -514,10 +513,10 @@ void CMap::DrawFocus(FPOINT pos, float dir, ObjectType type, MapColor color)
// Draw an object.
-void CMap::DrawObject(FPOINT pos, float dir, ObjectType type, MapColor color,
+void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color,
bool bSelect, bool bHilite)
{
- FPOINT p1, p2, p3, p4, p5, dim, uv1, uv2;
+ Math::Point p1, p2, p3, p4, p5, dim, uv1, uv2;
bool bOut, bUp, bDown, bLeft, bRight;
pos.x = (pos.x-m_offset.x)*(m_zoom*0.5f)/m_half+0.5f;
@@ -539,7 +538,7 @@ void CMap::DrawObject(FPOINT pos, float dir, ObjectType type, MapColor color,
if ( color == MAPCOLOR_BBOX && !m_bRadar ) return;
if ( color == MAPCOLOR_ALIEN && !m_bRadar ) return;
- if ( Mod(m_time+(pos.x+pos.y)*4.0f, 0.6f) > 0.2f )
+ if ( Math::Mod(m_time+(pos.x+pos.y)*4.0f, 0.6f) > 0.2f )
{
return; // flashes
}
@@ -632,44 +631,44 @@ void CMap::DrawObject(FPOINT pos, float dir, ObjectType type, MapColor color,
{
p1.x = pos.x;
p1.y = pos.y+dim.y*1.4f;
- p1 = RotatePoint(pos, dir, p1);
+ p1 = Math::RotatePoint(pos, dir, p1);
p1.x = pos.x+(p1.x-pos.x)*0.75f;
p2.x = pos.x+dim.x*1.2f;
p2.y = pos.y+dim.y*0.8f;
- p2 = RotatePoint(pos, dir, p2);
+ p2 = Math::RotatePoint(pos, dir, p2);
p2.x = pos.x+(p2.x-pos.x)*0.75f;
p3.x = pos.x+dim.x*1.2f;
p3.y = pos.y-dim.y*1.0f;
- p3 = RotatePoint(pos, dir, p3);
+ p3 = Math::RotatePoint(pos, dir, p3);
p3.x = pos.x+(p3.x-pos.x)*0.75f;
p4.x = pos.x-dim.x*1.2f;
p4.y = pos.y-dim.y*1.0f;
- p4 = RotatePoint(pos, dir, p4);
+ p4 = Math::RotatePoint(pos, dir, p4);
p4.x = pos.x+(p4.x-pos.x)*0.75f;
p5.x = pos.x-dim.x*1.2f;
p5.y = pos.y+dim.y*0.8f;
- p5 = RotatePoint(pos, dir, p5);
+ p5 = Math::RotatePoint(pos, dir, p5);
p5.x = pos.x+(p5.x-pos.x)*0.75f;
}
else
{
p1.x = pos.x;
p1.y = pos.y+dim.y*2.4f;
- p1 = RotatePoint(pos, dir, p1);
+ p1 = Math::RotatePoint(pos, dir, p1);
p1.x = pos.x+(p1.x-pos.x)*0.75f;
p2.x = pos.x+dim.x*1.0f;
p2.y = pos.y-dim.y*1.6f;
- p2 = RotatePoint(pos, dir, p2);
+ p2 = Math::RotatePoint(pos, dir, p2);
p2.x = pos.x+(p2.x-pos.x)*0.75f;
p3.x = pos.x-dim.x*1.0f;
p3.y = pos.y-dim.y*1.6f;
- p3 = RotatePoint(pos, dir, p3);
+ p3 = Math::RotatePoint(pos, dir, p3);
p3.x = pos.x+(p3.x-pos.x)*0.75f;
}
}
@@ -785,10 +784,10 @@ void CMap::DrawObject(FPOINT pos, float dir, ObjectType type, MapColor color,
// Draws the icon of an object.
-void CMap::DrawObjectIcon(FPOINT pos, FPOINT dim, MapColor color,
+void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
ObjectType type, bool bHilite)
{
- FPOINT ppos, ddim, uv1, uv2;
+ Math::Point ppos, ddim, uv1, uv2;
float dp;
int icon;
@@ -893,9 +892,9 @@ void CMap::DrawObjectIcon(FPOINT pos, FPOINT dim, MapColor color,
// Draw the object with the mouse hovers over.
-void CMap::DrawHilite(FPOINT pos)
+void CMap::DrawHilite(Math::Point pos)
{
- FPOINT dim, uv1, uv2;
+ Math::Point dim, uv1, uv2;
bool bOut, bUp, bDown, bLeft, bRight;
if ( m_bToy || m_fixImage[0] != 0 ) return; // map with still image?
@@ -929,7 +928,7 @@ void CMap::DrawHilite(FPOINT pos)
// Draws a triangular icon.
-void CMap::DrawTriangle(FPOINT p1, FPOINT p2, FPOINT p3, FPOINT uv1, FPOINT uv2)
+void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[3]; // 1 triangle
@@ -949,7 +948,7 @@ void CMap::DrawTriangle(FPOINT p1, FPOINT p2, FPOINT p3, FPOINT uv1, FPOINT uv2)
// Draw a pentagon icon (a 5 rating, what!).
-void CMap::DrawPenta(FPOINT p1, FPOINT p2, FPOINT p3, FPOINT p4, FPOINT p5, FPOINT uv1, FPOINT uv2)
+void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[5]; // 1 pentagon
@@ -979,11 +978,11 @@ void CMap::DrawPenta(FPOINT p1, FPOINT p2, FPOINT p3, FPOINT p4, FPOINT p5, FPOI
// Draw the vertex array.
-void CMap::DrawVertex(FPOINT uv1, FPOINT uv2, float zoom)
+void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
- FPOINT p1, p2, c;
+ Math::Point p1, p2, c;
D3DVECTOR n;
device = m_engine->RetD3DDevice();
@@ -1161,7 +1160,7 @@ void CMap::UpdateObject(CObject* pObj)
ObjectType type;
MapColor color;
D3DVECTOR pos;
- FPOINT ppos;
+ Math::Point ppos;
float dir;
if ( !m_bEnable ) return;
@@ -1174,11 +1173,11 @@ void CMap::UpdateObject(CObject* pObj)
type = pObj->RetType();
pos = pObj->RetPosition(0);
- dir = -(pObj->RetAngleY(0)+PI/2.0f);
+ dir = -(pObj->RetAngleY(0)+Math::PI/2.0f);
if ( m_angle != 0.0f )
{
- ppos = RotatePoint(m_angle, FPOINT(pos.x, pos.z));
+ ppos = RotatePoint(m_angle, Math::Point(pos.x, pos.z));
pos.x = ppos.x;
pos.z = ppos.y;
dir += m_angle;
diff --git a/src/ui/map.h b/src/ui/map.h
index f2df265..9551d12 100644
--- a/src/ui/map.h
+++ b/src/ui/map.h
@@ -20,7 +20,6 @@
#include "ui/control.h"
-#include "common/struct.h"
#include "object/object.h"
@@ -54,7 +53,7 @@ struct MapObject
CObject* object;
MapColor color;
ObjectType type;
- FPOINT pos;
+ Math::Point pos;
float dir;
};
@@ -66,7 +65,7 @@ public:
CMap(CInstanceManager* iMan);
~CMap();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
void Draw();
@@ -94,20 +93,20 @@ public:
void FlushObject();
void UpdateObject(CObject* pObj);
- CObject* DetectObject(FPOINT pos, bool &bInMap);
+ CObject* DetectObject(Math::Point pos, bool &bInMap);
void SetHilite(CObject* pObj);
protected:
- FPOINT AdjustOffset(FPOINT offset);
- void SelectObject(FPOINT pos);
- FPOINT MapInter(FPOINT pos, float dir);
- void DrawFocus(FPOINT pos, float dir, ObjectType type, MapColor color);
- void DrawObject(FPOINT pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
- void DrawObjectIcon(FPOINT pos, FPOINT dim, MapColor color, ObjectType type, bool bHilite);
- void DrawHilite(FPOINT pos);
- void DrawTriangle(FPOINT p1, FPOINT p2, FPOINT p3, FPOINT uv1, FPOINT uv2);
- void DrawPenta(FPOINT p1, FPOINT p2, FPOINT p3, FPOINT p4, FPOINT p5, FPOINT uv1, FPOINT uv2);
- void DrawVertex(FPOINT uv1, FPOINT uv2, float zoom);
+ Math::Point AdjustOffset(Math::Point offset);
+ void SelectObject(Math::Point pos);
+ Math::Point MapInter(Math::Point pos, float dir);
+ void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
+ void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
+ void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
+ void DrawHilite(Math::Point pos);
+ void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
+ void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
+ void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
protected:
CTerrain* m_terrain;
@@ -118,7 +117,7 @@ protected:
float m_time;
float m_half;
float m_zoom;
- FPOINT m_offset;
+ Math::Point m_offset;
float m_angle;
D3DCOLORVALUE m_floorColor;
D3DCOLORVALUE m_waterColor;
@@ -126,8 +125,8 @@ protected:
int m_totalFix;
int m_totalMove;
int m_hiliteRank;
- FPOINT m_mapPos;
- FPOINT m_mapDim;
+ Math::Point m_mapPos;
+ Math::Point m_mapDim;
bool m_bRadar;
char m_fixImage[100];
int m_mode;
diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp
index 7cc8304..40b5545 100644
--- a/src/ui/scroll.cpp
+++ b/src/ui/scroll.cpp
@@ -16,8 +16,6 @@
// scroll.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -63,7 +61,7 @@ CScroll::~CScroll()
// Creates a new button.
-bool CScroll::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CScroll::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
CControl::Create(pos, dim, icon, eventMsg);
@@ -73,13 +71,13 @@ bool CScroll::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
}
-void CScroll::SetPos(FPOINT pos)
+void CScroll::SetPos(Math::Point pos)
{
CControl::SetPos(pos);
MoveAdjust();
}
-void CScroll::SetDim(FPOINT dim)
+void CScroll::SetDim(Math::Point dim)
{
CControl::SetDim(dim);
MoveAdjust();
@@ -90,7 +88,7 @@ void CScroll::SetDim(FPOINT dim)
void CScroll::MoveAdjust()
{
CButton* pc;
- FPOINT pos, dim;
+ Math::Point pos, dim;
if ( m_dim.y < m_dim.x*2.0f ) // very short lift?
{
@@ -106,7 +104,7 @@ void CScroll::MoveAdjust()
{
m_buttonUp = new CButton(m_iMan);
pc = (CButton*)m_buttonUp;
- pc->Create(FPOINT(0.0f, 0.0f), FPOINT(0.0f, 0.0f), 49, EVENT_NULL);
+ pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL);
pc->SetRepeat(true);
m_eventUp = pc->RetEventMsg();
}
@@ -115,7 +113,7 @@ void CScroll::MoveAdjust()
{
m_buttonDown = new CButton(m_iMan);
pc = (CButton*)m_buttonDown;
- pc->Create(FPOINT(0.0f, 0.0f), FPOINT(0.0f, 0.0f), 50, EVENT_NULL);
+ pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL);
pc->SetRepeat(true);
m_eventDown = pc->RetEventMsg();
}
@@ -148,7 +146,7 @@ void CScroll::MoveAdjust()
void CScroll::AdjustGlint()
{
- FPOINT ref;
+ Math::Point ref;
float hButton, h;
hButton = m_buttonUp?m_dim.x/0.75f:0.0f;
@@ -201,7 +199,7 @@ bool CScroll::ClearState(int state)
bool CScroll::EventProcess(const Event &event)
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
float hButton, h, value;
CControl::EventProcess(event);
@@ -322,7 +320,7 @@ bool CScroll::EventProcess(const Event &event)
void CScroll::Draw()
{
- FPOINT pos, dim, ppos, ddim;
+ Math::Point pos, dim, ppos, ddim;
float hButton;
int icon, n, i;
@@ -375,9 +373,9 @@ void CScroll::Draw()
// Draws a rectangle.
-void CScroll::DrawVertex(FPOINT pos, FPOINT dim, int icon)
+void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
{
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
float ex, dp;
if ( icon == 0 )
diff --git a/src/ui/scroll.h b/src/ui/scroll.h
index 67dc543..26b8d9b 100644
--- a/src/ui/scroll.h
+++ b/src/ui/scroll.h
@@ -20,7 +20,6 @@
#include "ui/control.h"
-#include "common/struct.h"
class CD3DEngine;
@@ -37,10 +36,10 @@ public:
CScroll(CInstanceManager* iMan);
~CScroll();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- void SetPos(FPOINT pos);
- void SetDim(FPOINT dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
bool SetState(int state, bool bState);
bool SetState(int state);
@@ -61,7 +60,7 @@ public:
protected:
void MoveAdjust();
void AdjustGlint();
- void DrawVertex(FPOINT pos, FPOINT dim, int icon);
+ void DrawVertex(Math::Point pos, Math::Point dim, int icon);
protected:
CButton* m_buttonUp;
@@ -72,7 +71,7 @@ protected:
float m_step;
bool m_bCapture;
- FPOINT m_pressPos;
+ Math::Point m_pressPos;
float m_pressValue;
EventMsg m_eventUp;
diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp
index 7022bf2..c96cc92 100644
--- a/src/ui/shortcut.cpp
+++ b/src/ui/shortcut.cpp
@@ -16,8 +16,6 @@
// shortcut.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -50,7 +48,7 @@ CShortcut::~CShortcut()
// Creates a new button.
-bool CShortcut::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CShortcut::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -132,7 +130,7 @@ void CShortcut::Draw()
if ( m_state & STATE_FRAME )
{
- FPOINT p1, p2, c, uv1, uv2;
+ Math::Point p1, p2, c, uv1, uv2;
float zoom, dp;
m_engine->SetTexture("button2.tga");
@@ -170,9 +168,9 @@ void CShortcut::Draw()
DrawIcon(p1, p2, uv1, uv2);
}
- if ( (m_state & STATE_RUN) && Mod(m_time, 0.7f) >= 0.3f )
+ if ( (m_state & STATE_RUN) && Math::Mod(m_time, 0.7f) >= 0.3f )
{
- FPOINT uv1, uv2;
+ Math::Point uv1, uv2;
float dp;
m_engine->SetTexture("button3.tga");
@@ -199,7 +197,7 @@ void CShortcut::DrawVertex(int icon, float zoom)
{
LPDIRECT3DDEVICE7 device;
D3DVERTEX2 vertex[4]; // 2 triangles
- FPOINT p1, p2, c;
+ Math::Point p1, p2, c;
D3DVECTOR n;
float u1, u2, v1, v2, dp;
diff --git a/src/ui/shortcut.h b/src/ui/shortcut.h
index 0b36c84..528afd2 100644
--- a/src/ui/shortcut.h
+++ b/src/ui/shortcut.h
@@ -32,7 +32,7 @@ public:
CShortcut(CInstanceManager* iMan);
~CShortcut();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp
index 6c2a46a..39c8f6b 100644
--- a/src/ui/slider.cpp
+++ b/src/ui/slider.cpp
@@ -16,8 +16,6 @@
// slider.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -73,7 +71,7 @@ CSlider::~CSlider()
// Creates a new button.
-bool CSlider::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CSlider::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
CControl::Create(pos, dim, icon, eventMsg);
@@ -83,13 +81,13 @@ bool CSlider::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
}
-void CSlider::SetPos(FPOINT pos)
+void CSlider::SetPos(Math::Point pos)
{
CControl::SetPos(pos);
MoveAdjust();
}
-void CSlider::SetDim(FPOINT dim)
+void CSlider::SetDim(Math::Point dim)
{
CControl::SetDim(dim);
MoveAdjust();
@@ -97,7 +95,7 @@ void CSlider::SetDim(FPOINT dim)
void CSlider::MoveAdjust()
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
m_bHoriz = ( m_dim.x > m_dim.y );
@@ -118,7 +116,7 @@ void CSlider::MoveAdjust()
if ( m_buttonLeft == 0 )
{
m_buttonLeft = new CButton(m_iMan);
- m_buttonLeft->Create(FPOINT(0.0f, 0.0f), FPOINT(0.0f, 0.0f), m_bHoriz?55:49, EVENT_NULL); // </^
+ m_buttonLeft->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?55:49, EVENT_NULL); // </^
m_buttonLeft->SetRepeat(true);
if ( m_state & STATE_SHADOW ) m_buttonLeft->SetState(STATE_SHADOW);
m_eventUp = m_buttonLeft->RetEventMsg();
@@ -127,7 +125,7 @@ void CSlider::MoveAdjust()
if ( m_buttonRight == 0 )
{
m_buttonRight = new CButton(m_iMan);
- m_buttonRight->Create(FPOINT(0.0f, 0.0f), FPOINT(0.0f, 0.0f), m_bHoriz?48:50, EVENT_NULL); // >/v
+ m_buttonRight->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?48:50, EVENT_NULL); // >/v
m_buttonRight->SetRepeat(true);
if ( m_state & STATE_SHADOW ) m_buttonRight->SetState(STATE_SHADOW);
m_eventDown = m_buttonRight->RetEventMsg();
@@ -184,7 +182,7 @@ void CSlider::MoveAdjust()
void CSlider::AdjustGlint()
{
- FPOINT ref;
+ Math::Point ref;
float w;
if ( m_bHoriz )
@@ -247,7 +245,7 @@ bool CSlider::ClearState(int state)
bool CSlider::EventProcess(const Event &event)
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
float value;
if ( (m_state & STATE_VISIBLE) == 0 ) return true;
@@ -384,7 +382,7 @@ bool CSlider::EventProcess(const Event &event)
void CSlider::Draw()
{
- FPOINT pos, dim, ppos, ddim, spos;
+ Math::Point pos, dim, ppos, ddim, spos;
int icon;
float h;
char text[100];
@@ -491,9 +489,9 @@ void CSlider::Draw()
// Draws a rectangle.
-void CSlider::DrawVertex(FPOINT pos, FPOINT dim, int icon)
+void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
{
- FPOINT uv1, uv2, corner;
+ Math::Point uv1, uv2, corner;
float ex, dp;
if ( icon == 0 )
diff --git a/src/ui/slider.h b/src/ui/slider.h
index 8d1033f..a1eb127 100644
--- a/src/ui/slider.h
+++ b/src/ui/slider.h
@@ -20,7 +20,6 @@
#include "ui/control.h"
-#include "common/struct.h"
class CD3DEngine;
@@ -34,10 +33,10 @@ public:
CSlider(CInstanceManager* iMan);
~CSlider();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- void SetPos(FPOINT pos);
- void SetDim(FPOINT dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
bool SetState(int state, bool bState);
bool SetState(int state);
@@ -57,7 +56,7 @@ public:
protected:
void MoveAdjust();
void AdjustGlint();
- void DrawVertex(FPOINT pos, FPOINT dim, int icon);
+ void DrawVertex(Math::Point pos, Math::Point dim, int icon);
protected:
CButton* m_buttonLeft;
@@ -72,7 +71,7 @@ protected:
float m_marginButton;
bool m_bCapture;
- FPOINT m_pressPos;
+ Math::Point m_pressPos;
float m_pressValue;
EventMsg m_eventUp;
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index 1cc522b..b4d196b 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -16,8 +16,6 @@
// studio.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <stdlib.h>
#include <stdio.h>
@@ -553,7 +551,7 @@ void CStudio::ColorizeScript(CEdit* edit)
void CStudio::StartEditScript(CScript *script, char* name, int rank)
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
CWindow* pw;
CEdit* edit;
CButton* button;
@@ -591,7 +589,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
pw->SetClosable(true);
GetResource(RES_TEXT, RT_STUDIO_TITLE, res);
pw->SetName(res);
- pw->SetMinDim(FPOINT(0.49f, 0.50f));
+ pw->SetMinDim(Math::Point(0.49f, 0.50f));
pw->SetMaximized(m_bEditMaximized);
pw->SetMinimized(m_bEditMinimized);
m_main->SetEditFull(m_bEditMaximized);
@@ -669,7 +667,7 @@ void CStudio::AdjustEditScript()
CGroup* group;
CSlider* slider;
CList* list;
- FPOINT wpos, wdim, pos, dim, ppos, ddim;
+ Math::Point wpos, wdim, pos, dim, ppos, ddim;
float hList;
wpos = m_editActualPos;
@@ -1030,7 +1028,7 @@ void CStudio::StartDialog(StudioDialog type)
CLabel* pla;
CList* pli;
CEdit* pe;
- FPOINT pos, dim;
+ Math::Point pos, dim;
char name[100];
m_dialog = type;
@@ -1073,13 +1071,13 @@ void CStudio::StartDialog(StudioDialog type)
pw->SetState(STATE_SHADOW);
pw->SetMovable(true);
pw->SetClosable(true);
- pw->SetMinDim(FPOINT(320.0f/640.0f, (121.0f+18.0f*4)/480.0f));
+ pw->SetMinDim(Math::Point(320.0f/640.0f, (121.0f+18.0f*4)/480.0f));
if ( m_dialog == SD_OPEN ) GetResource(RES_TEXT, RT_IO_OPEN, name);
if ( m_dialog == SD_SAVE ) GetResource(RES_TEXT, RT_IO_SAVE, name);
pw->SetName(name);
- pos = FPOINT(0.0f, 0.0f);
- dim = FPOINT(0.0f, 0.0f);
+ pos = Math::Point(0.0f, 0.0f);
+ dim = Math::Point(0.0f, 0.0f);
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
@@ -1195,7 +1193,7 @@ void CStudio::AdjustDialog()
CLabel* pla;
CList* pli;
CEdit* pe;
- FPOINT wpos, wdim, ppos, ddim;
+ Math::Point wpos, wdim, ppos, ddim;
int nli, nch;
char name[100];
@@ -1315,7 +1313,7 @@ void CStudio::AdjustDialog()
bool CStudio::EventDialog(const Event &event)
{
CWindow* pw;
- FPOINT wpos, wdim;
+ Math::Point wpos, wdim;
pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
if ( pw == 0 ) return false;
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 194ca64..0c9eac2 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -97,10 +97,10 @@ protected:
bool m_bEditMinimized;
CameraType m_editCamera;
- FPOINT m_editActualPos;
- FPOINT m_editActualDim;
- FPOINT m_editFinalPos;
- FPOINT m_editFinalDim;
+ Math::Point m_editActualPos;
+ Math::Point m_editActualDim;
+ Math::Point m_editFinalPos;
+ Math::Point m_editFinalDim;
float m_time;
float m_fixInfoTextTime;
diff --git a/src/ui/target.cpp b/src/ui/target.cpp
index 4e282b9..0f18efd 100644
--- a/src/ui/target.cpp
+++ b/src/ui/target.cpp
@@ -16,8 +16,6 @@
// target.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -52,7 +50,7 @@ CTarget::~CTarget()
// Creates a new button.
-bool CTarget::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CTarget::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -161,7 +159,7 @@ void CTarget::Draw()
// Returns the tooltip.
-bool CTarget::GetTooltip(FPOINT pos, char* name)
+bool CTarget::GetTooltip(Math::Point pos, char* name)
{
#if 0
if ( (m_state&STATE_VISIBLE) && Detect(pos) ) // in the window?
@@ -194,7 +192,7 @@ bool CTarget::GetTooltip(FPOINT pos, char* name)
// Detects the object aimed by the mouse.
-CObject* CTarget::DetectFriendObject(FPOINT pos)
+CObject* CTarget::DetectFriendObject(Math::Point pos)
{
ObjectType type;
CObject *pObj, *pTarget;
diff --git a/src/ui/target.h b/src/ui/target.h
index 7959c9a..df1c962 100644
--- a/src/ui/target.h
+++ b/src/ui/target.h
@@ -33,14 +33,14 @@ public:
CTarget(CInstanceManager* iMan);
~CTarget();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool EventProcess(const Event &event);
void Draw();
- bool GetTooltip(FPOINT pos, char* name);
+ bool GetTooltip(Math::Point pos, char* name);
protected:
- CObject* DetectFriendObject(FPOINT pos);
+ CObject* DetectFriendObject(Math::Point pos);
protected:
};
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 26e0a07..41998f1 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -16,8 +16,6 @@
// window.cpp
-#define STRICT
-#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h>
@@ -70,8 +68,8 @@ CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
m_bMinimized = false;
m_bFixed = false;
- m_minDim = FPOINT(0.0f, 0.0f);
- m_maxDim = FPOINT(1.0f, 1.0f);
+ m_minDim = Math::Point(0.0f, 0.0f);
+ m_maxDim = Math::Point(1.0f, 1.0f);
m_buttonReduce = 0;
m_buttonFull = 0;
@@ -130,7 +128,7 @@ void CWindow::Flush()
// Creates a new window.
-bool CWindow::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
@@ -141,7 +139,7 @@ bool CWindow::Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
// Creates a new button.
-CButton* CWindow::CreateButton(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CButton* pc;
int i;
@@ -163,7 +161,7 @@ CButton* CWindow::CreateButton(FPOINT pos, FPOINT dim, int icon, EventMsg eventM
// Creates a new button.
-CColor* CWindow::CreateColor(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CColor* pc;
int i;
@@ -185,7 +183,7 @@ CColor* CWindow::CreateColor(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg
// Creates a new button.
-CCheck* CWindow::CreateCheck(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CCheck* pc;
int i;
@@ -207,7 +205,7 @@ CCheck* CWindow::CreateCheck(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg
// Creates a new button.
-CKey* CWindow::CreateKey(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CKey* pc;
int i;
@@ -229,7 +227,7 @@ CKey* CWindow::CreateKey(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
// Creates a new button.
-CGroup* CWindow::CreateGroup(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CGroup* pc;
int i;
@@ -251,7 +249,7 @@ CGroup* CWindow::CreateGroup(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg
// Creates a new button.
-CImage* CWindow::CreateImage(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CImage* pc;
int i;
@@ -273,7 +271,7 @@ CImage* CWindow::CreateImage(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg
// Creates a new label.
-CLabel* CWindow::CreateLabel(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg,
+CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
char *name)
{
CLabel* pc;
@@ -314,7 +312,7 @@ CLabel* CWindow::CreateLabel(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg
// Creates a new editable pave.
-CEdit* CWindow::CreateEdit(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CEdit* pc;
int i;
@@ -336,7 +334,7 @@ CEdit* CWindow::CreateEdit(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
// Creates a new editable pave.
-CEditValue* CWindow::CreateEditValue(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CEditValue* pc;
int i;
@@ -358,7 +356,7 @@ CEditValue* CWindow::CreateEditValue(FPOINT pos, FPOINT dim, int icon, EventMsg
// Creates a new elevator.
-CScroll* CWindow::CreateScroll(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CScroll* pc;
int i;
@@ -380,7 +378,7 @@ CScroll* CWindow::CreateScroll(FPOINT pos, FPOINT dim, int icon, EventMsg eventM
// Creates a new cursor.
-CSlider* CWindow::CreateSlider(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CSlider* pc;
int i;
@@ -402,7 +400,7 @@ CSlider* CWindow::CreateSlider(FPOINT pos, FPOINT dim, int icon, EventMsg eventM
// Creates a new list.
-CList* CWindow::CreateList(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg,
+CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
float expand)
{
CList* pc;
@@ -425,7 +423,7 @@ CList* CWindow::CreateList(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg,
// Creates a new shortcut.
-CShortcut* CWindow::CreateShortcut(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CShortcut* ps;
int i;
@@ -447,7 +445,7 @@ CShortcut* CWindow::CreateShortcut(FPOINT pos, FPOINT dim, int icon, EventMsg ev
// Creates a new card.
-CMap* CWindow::CreateMap(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CMap* pm;
int i;
@@ -469,7 +467,7 @@ CMap* CWindow::CreateMap(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
// Creates a new gauge.
-CGauge* CWindow::CreateGauge(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CGauge* pc;
int i;
@@ -491,7 +489,7 @@ CGauge* CWindow::CreateGauge(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg
// Creates a new compass.
-CCompass* CWindow::CreateCompass(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CCompass* pc;
int i;
@@ -513,7 +511,7 @@ CCompass* CWindow::CreateCompass(FPOINT pos, FPOINT dim, int icon, EventMsg even
// Creates a new target.
-CTarget* CWindow::CreateTarget(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg)
+CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
{
CTarget* pc;
int i;
@@ -576,7 +574,7 @@ CControl* CWindow::SearchControl(EventMsg eventMsg)
// Makes the tooltip binds to the window.
-bool CWindow::GetTooltip(FPOINT pos, char* name)
+bool CWindow::GetTooltip(Math::Point pos, char* name)
{
int i;
@@ -677,13 +675,13 @@ void CWindow::SetName(char* name)
}
-void CWindow::SetPos(FPOINT pos)
+void CWindow::SetPos(Math::Point pos)
{
CControl::SetPos(pos);
MoveAdjust();
}
-void CWindow::SetDim(FPOINT dim)
+void CWindow::SetDim(Math::Point dim)
{
if ( dim.x < m_minDim.x ) dim.x = m_minDim.x;
if ( dim.x > m_maxDim.x ) dim.x = m_maxDim.x;
@@ -696,7 +694,7 @@ void CWindow::SetDim(FPOINT dim)
void CWindow::MoveAdjust()
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
float h, offset;
h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType);
@@ -734,22 +732,22 @@ void CWindow::MoveAdjust()
}
-void CWindow::SetMinDim(FPOINT dim)
+void CWindow::SetMinDim(Math::Point dim)
{
m_minDim = dim;
}
-void CWindow::SetMaxDim(FPOINT dim)
+void CWindow::SetMaxDim(Math::Point dim)
{
m_maxDim = dim;
}
-FPOINT CWindow::RetMinDim()
+Math::Point CWindow::RetMinDim()
{
return m_minDim;
}
-FPOINT CWindow::RetMaxDim()
+Math::Point CWindow::RetMaxDim()
{
return m_maxDim;
}
@@ -913,9 +911,9 @@ EventMsg CWindow::RetEventMsgClose()
// Detects whether the mouse is in an edge of the window, to resize it.
// Bit returns: 0 = left, 1 = down, 2 = right, 3 = up, 1 = all.
-int CWindow::BorderDetect(FPOINT pos)
+int CWindow::BorderDetect(Math::Point pos)
{
- FPOINT dim;
+ Math::Point dim;
float h;
int flags;
@@ -966,7 +964,7 @@ int CWindow::BorderDetect(FPOINT pos)
bool CWindow::EventProcess(const Event &event)
{
- FPOINT pos;
+ Math::Point pos;
int i, flags;
if ( event.event == EVENT_MOUSEMOVE )
@@ -1124,7 +1122,7 @@ bool CWindow::EventProcess(const Event &event)
void CWindow::Draw()
{
- FPOINT pos, dim;
+ Math::Point pos, dim;
float width, h, sw;
int i;
@@ -1143,7 +1141,7 @@ void CWindow::Draw()
// Draws the shadow under the title bar.
{
- FPOINT sPos, sDim;
+ Math::Point sPos, sDim;
pos.x = m_pos.x+0.01f;
dim.x = m_dim.x-0.02f;
@@ -1206,9 +1204,9 @@ void CWindow::Draw()
// Draws a rectangle.
-void CWindow::DrawVertex(FPOINT pos, FPOINT dim, int icon)
+void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
{
- FPOINT p1, p2, uv1, uv2, corner;
+ Math::Point p1, p2, uv1, uv2, corner;
float dp;
int i;
@@ -1576,11 +1574,11 @@ void CWindow::DrawVertex(FPOINT pos, FPOINT dim, int icon)
// Draws hatching.
-void CWindow::DrawHach(FPOINT pos, FPOINT dim)
+void CWindow::DrawHach(Math::Point pos, Math::Point dim)
{
#if _NEWLOOK
#else
- FPOINT ppos, ddim, uv1, uv2;
+ Math::Point ppos, ddim, uv1, uv2;
float dp, max, ndim;
bool bStop;
diff --git a/src/ui/window.h b/src/ui/window.h
index b06fcfb..169c68e 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -52,24 +52,24 @@ public:
~CWindow();
void Flush();
- bool Create(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CButton* CreateButton(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CColor* CreateColor(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CCheck* CreateCheck(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CKey* CreateKey(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CGroup* CreateGroup(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CImage* CreateImage(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CLabel* CreateLabel(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg, char *name);
- CEdit* CreateEdit(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CEditValue* CreateEditValue(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CScroll* CreateScroll(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CSlider* CreateSlider(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CList* CreateList(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg, float expand=1.2f);
- CShortcut* CreateShortcut(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CMap* CreateMap(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CGauge* CreateGauge(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CCompass* CreateCompass(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
- CTarget* CreateTarget(FPOINT pos, FPOINT dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name);
+ CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f);
+ CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
bool DeleteControl(EventMsg eventMsg);
CControl* SearchControl(EventMsg eventMsg);
@@ -82,13 +82,13 @@ public:
void SetTrashEvent(bool bTrash);
bool RetTrashEvent();
- void SetPos(FPOINT pos);
- void SetDim(FPOINT dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
- void SetMinDim(FPOINT dim);
- void SetMaxDim(FPOINT dim);
- FPOINT RetMinDim();
- FPOINT RetMaxDim();
+ void SetMinDim(Math::Point dim);
+ void SetMaxDim(Math::Point dim);
+ Math::Point RetMinDim();
+ Math::Point RetMaxDim();
void SetMovable(bool bMode);
bool RetMovable();
@@ -106,18 +106,18 @@ public:
void SetFixed(bool bFix);
bool RetFixed();
- bool GetTooltip(FPOINT pos, char* name);
+ bool GetTooltip(Math::Point pos, char* name);
bool EventProcess(const Event &event);
void Draw();
protected:
- int BorderDetect(FPOINT pos);
+ int BorderDetect(Math::Point pos);
void AdjustButtons();
void MoveAdjust();
- void DrawVertex(FPOINT pos, FPOINT dim, int icon);
- void DrawHach(FPOINT pos, FPOINT dim);
+ void DrawVertex(Math::Point pos, Math::Point dim, int icon);
+ void DrawHach(Math::Point pos, Math::Point dim);
protected:
CControl* m_table[MAXWINDOW];
@@ -127,8 +127,8 @@ protected:
bool m_bMinimized;
bool m_bFixed;
- FPOINT m_minDim;
- FPOINT m_maxDim;
+ Math::Point m_minDim;
+ Math::Point m_maxDim;
CButton* m_buttonReduce;
CButton* m_buttonFull;
@@ -138,7 +138,7 @@ protected:
bool m_bRedim;
bool m_bClosable;
bool m_bCapture;
- FPOINT m_pressPos;
+ Math::Point m_pressPos;
int m_pressFlags;
D3DMouse m_pressMouse;
};