summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
Diffstat (limited to 'src/object')
-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
87 files changed, 1696 insertions, 1807 deletions
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;