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