Refactored Math::Vector to glm::vec3 in CrashSphere, CObjectFactory, old_object.h, old_object_interface.h

dev
Tomasz Kapuściński 2022-01-03 22:51:36 +01:00
parent b4bfb8b242
commit 300a2d8569
7 changed files with 529 additions and 532 deletions

View File

@ -22,7 +22,6 @@
#include "common/logger.h" #include "common/logger.h"
#include "math/sphere.h" #include "math/sphere.h"
#include "math/vector.h"
#include "sound/sound_type.h" #include "sound/sound_type.h"
@ -32,7 +31,7 @@
*/ */
struct CrashSphere struct CrashSphere
{ {
CrashSphere(const Math::Vector& pos = Math::Vector(), CrashSphere(const glm::vec3& pos = { 0, 0, 0 },
float radius = 0.0f, float radius = 0.0f,
SoundType _sound = SOUND_NONE, SoundType _sound = SOUND_NONE,
float _hardness = 0.45f) float _hardness = 0.45f)

File diff suppressed because it is too large Load Diff

View File

@ -24,8 +24,6 @@
#pragma once #pragma once
#include "math/vector.h"
#include "object/object_type.h" #include "object/object_type.h"
#include <memory> #include <memory>

View File

@ -114,9 +114,9 @@ COldObject::COldObject(int id)
m_name = ""; m_name = "";
m_shadowLight = -1; m_shadowLight = -1;
m_shadowHeight = 0.0f; m_shadowHeight = 0.0f;
m_linVibration = Math::Vector(0.0f, 0.0f, 0.0f); m_linVibration = glm::vec3(0.0f, 0.0f, 0.0f);
m_cirVibration = Math::Vector(0.0f, 0.0f, 0.0f); m_cirVibration = glm::vec3(0.0f, 0.0f, 0.0f);
m_tilt = Math::Vector(0.0f, 0.0f, 0.0f); m_tilt = glm::vec3(0.0f, 0.0f, 0.0f);
m_power = nullptr; m_power = nullptr;
m_cargo = nullptr; m_cargo = nullptr;
@ -625,11 +625,11 @@ void COldObject::InitPart(int part)
m_objectPart[part].object = -1; m_objectPart[part].object = -1;
m_objectPart[part].parentPart = -1; m_objectPart[part].parentPart = -1;
m_objectPart[part].position = Math::Vector(0.0f, 0.0f, 0.0f); m_objectPart[part].position = glm::vec3(0.0f, 0.0f, 0.0f);
m_objectPart[part].angle.y = 0.0f; m_objectPart[part].angle.y = 0.0f;
m_objectPart[part].angle.x = 0.0f; m_objectPart[part].angle.x = 0.0f;
m_objectPart[part].angle.z = 0.0f; m_objectPart[part].angle.z = 0.0f;
m_objectPart[part].zoom = Math::Vector(1.0f, 1.0f, 1.0f); m_objectPart[part].zoom = glm::vec3(1.0f, 1.0f, 1.0f);
m_objectPart[part].bTranslate = true; m_objectPart[part].bTranslate = true;
m_objectPart[part].bRotate = true; m_objectPart[part].bRotate = true;
@ -1050,7 +1050,7 @@ int COldObject::GetOption()
void COldObject::Write(CLevelParserLine* line) void COldObject::Write(CLevelParserLine* line)
{ {
Math::Vector pos; glm::vec3 pos;
line->AddParam("camera", MakeUnique<CLevelParserParam>(GetCameraType())); line->AddParam("camera", MakeUnique<CLevelParserParam>(GetCameraType()));
@ -1146,7 +1146,7 @@ void COldObject::Write(CLevelParserLine* line)
void COldObject::Read(CLevelParserLine* line) void COldObject::Read(CLevelParserLine* line)
{ {
Math::Vector zoom = line->GetParam("zoom")->AsPoint(Math::Vector(1.0f, 1.0f, 1.0f)); glm::vec3 zoom = line->GetParam("zoom")->AsPoint(glm::vec3(1.0f, 1.0f, 1.0f));
if (zoom.x != 1.0f || zoom.y != 1.0f || zoom.z != 1.0f) if (zoom.x != 1.0f || zoom.y != 1.0f || zoom.z != 1.0f)
SetScale(zoom); SetScale(zoom);
@ -1348,7 +1348,7 @@ Math::Sphere COldObject::GetJostlingSphere() const
void COldObject::SetFloorHeight(float height) void COldObject::SetFloorHeight(float height)
{ {
Math::Vector pos; glm::vec3 pos;
pos = m_objectPart[0].position; pos = m_objectPart[0].position;
m_terrain->AdjustToFloor(pos); m_terrain->AdjustToFloor(pos);
@ -1367,7 +1367,7 @@ void COldObject::SetFloorHeight(float height)
void COldObject::FloorAdjust() void COldObject::FloorAdjust()
{ {
Math::Vector pos, n; glm::vec3 pos, n;
glm::vec2 nn; glm::vec2 nn;
float a; float a;
@ -1384,7 +1384,7 @@ void COldObject::FloorAdjust()
// Getes the linear vibration. // Getes the linear vibration.
void COldObject::SetLinVibration(Math::Vector dir) void COldObject::SetLinVibration(glm::vec3 dir)
{ {
if ( m_linVibration.x != dir.x || if ( m_linVibration.x != dir.x ||
m_linVibration.y != dir.y || m_linVibration.y != dir.y ||
@ -1395,14 +1395,14 @@ void COldObject::SetLinVibration(Math::Vector dir)
} }
} }
Math::Vector COldObject::GetLinVibration() glm::vec3 COldObject::GetLinVibration()
{ {
return m_linVibration; return m_linVibration;
} }
// Getes the circular vibration. // Getes the circular vibration.
void COldObject::SetCirVibration(Math::Vector dir) void COldObject::SetCirVibration(glm::vec3 dir)
{ {
if ( m_cirVibration.x != dir.x || if ( m_cirVibration.x != dir.x ||
m_cirVibration.y != dir.y || m_cirVibration.y != dir.y ||
@ -1413,14 +1413,14 @@ void COldObject::SetCirVibration(Math::Vector dir)
} }
} }
Math::Vector COldObject::GetCirVibration() glm::vec3 COldObject::GetCirVibration()
{ {
return m_cirVibration; return m_cirVibration;
} }
// Getes the inclination. // Getes the inclination.
void COldObject::SetTilt(Math::Vector dir) void COldObject::SetTilt(glm::vec3 dir)
{ {
if ( m_tilt.x != dir.x || if ( m_tilt.x != dir.x ||
m_tilt.y != dir.y || m_tilt.y != dir.y ||
@ -1431,7 +1431,7 @@ void COldObject::SetTilt(Math::Vector dir)
} }
} }
Math::Vector COldObject::GetTilt() glm::vec3 COldObject::GetTilt()
{ {
return m_tilt; return m_tilt;
} }
@ -1439,7 +1439,7 @@ Math::Vector COldObject::GetTilt()
// Getes the position of center of the object. // Getes the position of center of the object.
void COldObject::SetPartPosition(int part, const Math::Vector &pos) void COldObject::SetPartPosition(int part, const glm::vec3 &pos)
{ {
m_objectPart[part].position = pos; m_objectPart[part].position = pos;
m_objectPart[part].bTranslate = true; // it will recalculate the matrices m_objectPart[part].bTranslate = true; // it will recalculate the matrices
@ -1448,7 +1448,7 @@ void COldObject::SetPartPosition(int part, const Math::Vector &pos)
{ {
int rank = m_objectPart[0].object; int rank = m_objectPart[0].object;
Math::Vector shPos = pos; glm::vec3 shPos = pos;
m_terrain->AdjustToFloor(shPos, true); m_terrain->AdjustToFloor(shPos, true);
m_engine->SetObjectShadowSpotPos(rank, shPos); m_engine->SetObjectShadowSpotPos(rank, shPos);
@ -1463,21 +1463,21 @@ void COldObject::SetPartPosition(int part, const Math::Vector &pos)
if ( m_shadowLight != -1 ) if ( m_shadowLight != -1 )
{ {
Math::Vector lightPos = pos; glm::vec3 lightPos = pos;
lightPos.y += m_shadowHeight; lightPos.y += m_shadowHeight;
m_lightMan->SetLightPos(m_shadowLight, lightPos); m_lightMan->SetLightPos(m_shadowLight, lightPos);
} }
} }
} }
Math::Vector COldObject::GetPartPosition(int part) const glm::vec3 COldObject::GetPartPosition(int part) const
{ {
return m_objectPart[part].position; return m_objectPart[part].position;
} }
// Getes the rotation around three axis. // Getes the rotation around three axis.
void COldObject::SetPartRotation(int part, const Math::Vector &angle) void COldObject::SetPartRotation(int part, const glm::vec3 &angle)
{ {
m_objectPart[part].angle = angle; m_objectPart[part].angle = angle;
m_objectPart[part].bRotate = true; // it will recalculate the matrices m_objectPart[part].bRotate = true; // it will recalculate the matrices
@ -1488,7 +1488,7 @@ void COldObject::SetPartRotation(int part, const Math::Vector &angle)
} }
} }
Math::Vector COldObject::GetPartRotation(int part) const glm::vec3 COldObject::GetPartRotation(int part) const
{ {
return m_objectPart[part].angle; return m_objectPart[part].angle;
} }
@ -1552,7 +1552,7 @@ void COldObject::SetPartScale(int part, float zoom)
m_objectPart[part].zoom.z != 1.0f ); m_objectPart[part].zoom.z != 1.0f );
} }
void COldObject::SetPartScale(int part, Math::Vector zoom) void COldObject::SetPartScale(int part, glm::vec3 zoom)
{ {
m_objectPart[part].bTranslate = true; // it will recalculate the matrices m_objectPart[part].bTranslate = true; // it will recalculate the matrices
m_objectPart[part].zoom = zoom; m_objectPart[part].zoom = zoom;
@ -1562,7 +1562,7 @@ void COldObject::SetPartScale(int part, Math::Vector zoom)
m_objectPart[part].zoom.z != 1.0f ); m_objectPart[part].zoom.z != 1.0f );
} }
Math::Vector COldObject::GetPartScale(int part) const glm::vec3 COldObject::GetPartScale(int part) const
{ {
return m_objectPart[part].zoom; return m_objectPart[part].zoom;
} }
@ -1672,12 +1672,12 @@ CObject* COldObject::GetPower()
return m_power; return m_power;
} }
void COldObject::SetPowerPosition(const Math::Vector& powerPosition) void COldObject::SetPowerPosition(const glm::vec3& powerPosition)
{ {
m_powerPosition = powerPosition; m_powerPosition = powerPosition;
} }
Math::Vector COldObject::GetPowerPosition() glm::vec3 COldObject::GetPowerPosition()
{ {
return m_powerPosition; return m_powerPosition;
} }
@ -1758,15 +1758,15 @@ bool COldObject::CreateShadowLight(float height, Gfx::Color color)
{ {
if ( !m_engine->GetLightMode() ) return true; if ( !m_engine->GetLightMode() ) return true;
Math::Vector pos = GetPosition(); glm::vec3 pos = GetPosition();
m_shadowHeight = height; m_shadowHeight = height;
Gfx::Light light; Gfx::Light light;
light.type = Gfx::LIGHT_SPOT; light.type = Gfx::LIGHT_SPOT;
light.diffuse = color; light.diffuse = color;
light.ambient = color * 0.1f; light.ambient = color * 0.1f;
light.position = Math::Vector(pos.x, pos.y+height, pos.z); light.position = glm::vec3(pos.x, pos.y+height, pos.z);
light.direction = Math::Vector(0.0f, -1.0f, 0.0f); // against the bottom light.direction = glm::vec3(0.0f, -1.0f, 0.0f); // against the bottom
light.spotIntensity = 128; light.spotIntensity = 128;
light.attenuation0 = 1.0f; light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f; light.attenuation1 = 0.0f;
@ -1819,7 +1819,7 @@ bool COldObject::CreateShadowCircle(float radius, float intensity,
bool COldObject::UpdateTransformObject(int part, bool bForceUpdate) bool COldObject::UpdateTransformObject(int part, bool bForceUpdate)
{ {
Math::Vector position, angle, eye; glm::vec3 position, angle, eye;
bool bModif = false; bool bModif = false;
int parent; int parent;
@ -2297,10 +2297,10 @@ void COldObject::VirusFrame(float rTime)
{ {
m_lastVirusParticle = m_aTime; m_lastVirusParticle = m_aTime;
Math::Vector pos = GetPosition(); glm::vec3 pos = GetPosition();
pos.x += (Math::Rand()-0.5f)*10.0f; pos.x += (Math::Rand()-0.5f)*10.0f;
pos.z += (Math::Rand()-0.5f)*10.0f; pos.z += (Math::Rand()-0.5f)*10.0f;
Math::Vector speed; glm::vec3 speed;
speed.x = (Math::Rand()-0.5f)*2.0f; speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = (Math::Rand()-0.5f)*2.0f; speed.z = (Math::Rand()-0.5f)*2.0f;
speed.y = Math::Rand()*4.0f+4.0f; speed.y = Math::Rand()*4.0f+4.0f;
@ -2316,7 +2316,7 @@ void COldObject::VirusFrame(float rTime)
void COldObject::PartiFrame(float rTime) void COldObject::PartiFrame(float rTime)
{ {
Math::Vector pos, angle, factor; glm::vec3 pos, angle, factor;
int i, channel; int i, channel;
for ( i=0 ; i<OBJECTMAXPART ; i++ ) for ( i=0 ; i<OBJECTMAXPART ; i++ )
@ -2337,11 +2337,11 @@ void COldObject::PartiFrame(float rTime)
// Each song spins differently. // Each song spins differently.
switch( i%5 ) switch( i%5 )
{ {
case 0: factor = Math::Vector( 0.5f, 0.3f, 0.6f); break; case 0: factor = glm::vec3( 0.5f, 0.3f, 0.6f); break;
case 1: factor = Math::Vector(-0.3f, 0.4f,-0.2f); break; case 1: factor = glm::vec3(-0.3f, 0.4f,-0.2f); break;
case 2: factor = Math::Vector( 0.4f,-0.6f,-0.3f); break; case 2: factor = glm::vec3( 0.4f,-0.6f,-0.3f); break;
case 3: factor = Math::Vector(-0.6f,-0.2f, 0.0f); break; case 3: factor = glm::vec3(-0.6f,-0.2f, 0.0f); break;
case 4: factor = Math::Vector( 0.4f, 0.1f,-0.7f); break; case 4: factor = glm::vec3( 0.4f, 0.1f,-0.7f); break;
} }
angle = GetPartRotation(i); angle = GetPartRotation(i);
@ -2354,8 +2354,8 @@ void COldObject::PartiFrame(float rTime)
// Changes the perspective to view if it was like in the vehicle, // Changes the perspective to view if it was like in the vehicle,
// or behind the vehicle. // or behind the vehicle.
void COldObject::AdjustCamera(Math::Vector &eye, float &dirH, float &dirV, void COldObject::AdjustCamera(glm::vec3 &eye, float &dirH, float &dirV,
Math::Vector &lookat, Math::Vector &upVec, glm::vec3 &lookat, glm::vec3 &upVec,
Gfx::CameraType type) Gfx::CameraType type)
{ {
float speed; float speed;
@ -2459,7 +2459,7 @@ void COldObject::AdjustCamera(Math::Vector &eye, float &dirH, float &dirV,
lookat = Math::Transform(m_objectPart[part].matWorld, lookat); lookat = Math::Transform(m_objectPart[part].matWorld, lookat);
// Camera tilts when turning. // Camera tilts when turning.
upVec = Math::Vector(0.0f, 1.0f, 0.0f); upVec = glm::vec3(0.0f, 1.0f, 0.0f);
if ( m_physics != nullptr ) if ( m_physics != nullptr )
{ {
if ( m_physics->GetLand() ) // on ground? if ( m_physics->GetLand() ) // on ground?
@ -2920,7 +2920,7 @@ float COldObject::GetShowLimitRadius()
void COldObject::CreateSelectParticle() void COldObject::CreateSelectParticle()
{ {
Math::Vector pos, speed; glm::vec3 pos, speed;
glm::vec2 dim; glm::vec2 dim;
int i; int i;
@ -2971,8 +2971,8 @@ void COldObject::CreateSelectParticle()
m_type == OBJECT_MOBILEst || m_type == OBJECT_MOBILEst ||
m_type == OBJECT_MOBILEdr ) // vehicle? m_type == OBJECT_MOBILEdr ) // vehicle?
{ {
pos = Math::Vector(0.0f, 0.0f, 0.0f); pos = glm::vec3(0.0f, 0.0f, 0.0f);
speed = Math::Vector(0.0f, 0.0f, 0.0f); speed = glm::vec3(0.0f, 0.0f, 0.0f);
dim.x = 0.0f; dim.x = 0.0f;
dim.y = 0.0f; dim.y = 0.0f;
m_partiSel[0] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f); m_partiSel[0] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
@ -2988,7 +2988,7 @@ void COldObject::CreateSelectParticle()
void COldObject::UpdateSelectParticle() void COldObject::UpdateSelectParticle()
{ {
Math::Vector pos[4]; glm::vec3 pos[4];
glm::vec2 dim[4]; glm::vec2 dim[4];
float zoom[4]; float zoom[4];
float angle; float angle;
@ -3008,26 +3008,26 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILErs || m_type == OBJECT_MOBILErs ||
m_type == OBJECT_MOBILErp ) // large caterpillars? m_type == OBJECT_MOBILErp ) // large caterpillars?
{ {
pos[0] = Math::Vector(4.2f, 2.8f, 1.5f); pos[0] = glm::vec3(4.2f, 2.8f, 1.5f);
pos[1] = Math::Vector(4.2f, 2.8f, -1.5f); pos[1] = glm::vec3(4.2f, 2.8f, -1.5f);
dim[0].x = 1.5f; dim[0].x = 1.5f;
dim[1].x = 1.5f; dim[1].x = 1.5f;
} }
else if ( m_type == OBJECT_MOBILEsa || else if ( m_type == OBJECT_MOBILEsa ||
m_type == OBJECT_MOBILEst ) // submarine? m_type == OBJECT_MOBILEst ) // submarine?
{ {
pos[0] = Math::Vector(3.6f, 4.0f, 2.0f); pos[0] = glm::vec3(3.6f, 4.0f, 2.0f);
pos[1] = Math::Vector(3.6f, 4.0f, -2.0f); pos[1] = glm::vec3(3.6f, 4.0f, -2.0f);
} }
else if ( m_type == OBJECT_MOBILEtg ) // target? else if ( m_type == OBJECT_MOBILEtg ) // target?
{ {
pos[0] = Math::Vector(3.4f, 6.5f, 2.0f); pos[0] = glm::vec3(3.4f, 6.5f, 2.0f);
pos[1] = Math::Vector(3.4f, 6.5f, -2.0f); pos[1] = glm::vec3(3.4f, 6.5f, -2.0f);
} }
else if ( m_type == OBJECT_MOBILEdr ) // designer? else if ( m_type == OBJECT_MOBILEdr ) // designer?
{ {
pos[0] = Math::Vector(4.9f, 3.5f, 2.5f); pos[0] = glm::vec3(4.9f, 3.5f, 2.5f);
pos[1] = Math::Vector(4.9f, 3.5f, -2.5f); pos[1] = glm::vec3(4.9f, 3.5f, -2.5f);
} }
else if ( m_type == OBJECT_MOBILEwt || else if ( m_type == OBJECT_MOBILEwt ||
m_type == OBJECT_MOBILEtt || m_type == OBJECT_MOBILEtt ||
@ -3035,15 +3035,15 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILEit || m_type == OBJECT_MOBILEit ||
GetTrainer()) // trainer ? GetTrainer()) // trainer ?
{ {
pos[0] = Math::Vector(4.2f, 2.5f, 1.2f); pos[0] = glm::vec3(4.2f, 2.5f, 1.2f);
pos[1] = Math::Vector(4.2f, 2.5f, -1.2f); pos[1] = glm::vec3(4.2f, 2.5f, -1.2f);
dim[0].x = 1.5f; dim[0].x = 1.5f;
dim[1].x = 1.5f; dim[1].x = 1.5f;
} }
else else
{ {
pos[0] = Math::Vector(4.2f, 2.5f, 1.5f); pos[0] = glm::vec3(4.2f, 2.5f, 1.5f);
pos[1] = Math::Vector(4.2f, 2.5f, -1.5f); pos[1] = glm::vec3(4.2f, 2.5f, -1.5f);
} }
// Red back lens // Red back lens
@ -3053,8 +3053,8 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILEit || m_type == OBJECT_MOBILEit ||
GetTrainer()) // trainer? GetTrainer()) // trainer?
{ {
pos[2] = Math::Vector(-4.0f, 2.5f, 2.2f); pos[2] = glm::vec3(-4.0f, 2.5f, 2.2f);
pos[3] = Math::Vector(-4.0f, 2.5f, -2.2f); pos[3] = glm::vec3(-4.0f, 2.5f, -2.2f);
} }
else if ( m_type == OBJECT_MOBILEfa || else if ( m_type == OBJECT_MOBILEfa ||
m_type == OBJECT_MOBILEfb || m_type == OBJECT_MOBILEfb ||
@ -3062,8 +3062,8 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILEfi || m_type == OBJECT_MOBILEfi ||
m_type == OBJECT_MOBILEfs ) // flying? m_type == OBJECT_MOBILEfs ) // flying?
{ {
pos[2] = Math::Vector(-4.0f, 3.1f, 4.5f); pos[2] = glm::vec3(-4.0f, 3.1f, 4.5f);
pos[3] = Math::Vector(-4.0f, 3.1f, -4.5f); pos[3] = glm::vec3(-4.0f, 3.1f, -4.5f);
dim[2].x = 0.6f; dim[2].x = 0.6f;
dim[3].x = 0.6f; dim[3].x = 0.6f;
} }
@ -3073,8 +3073,8 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILEwi || m_type == OBJECT_MOBILEwi ||
m_type == OBJECT_MOBILEws ) // wheels? m_type == OBJECT_MOBILEws ) // wheels?
{ {
pos[2] = Math::Vector(-4.5f, 2.7f, 2.8f); pos[2] = glm::vec3(-4.5f, 2.7f, 2.8f);
pos[3] = Math::Vector(-4.5f, 2.7f, -2.8f); pos[3] = glm::vec3(-4.5f, 2.7f, -2.8f);
} }
else if ( m_type == OBJECT_MOBILEia || else if ( m_type == OBJECT_MOBILEia ||
m_type == OBJECT_MOBILEib || m_type == OBJECT_MOBILEib ||
@ -3082,8 +3082,8 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILEii || m_type == OBJECT_MOBILEii ||
m_type == OBJECT_MOBILEis ) // legs? m_type == OBJECT_MOBILEis ) // legs?
{ {
pos[2] = Math::Vector(-4.5f, 2.7f, 2.8f); pos[2] = glm::vec3(-4.5f, 2.7f, 2.8f);
pos[3] = Math::Vector(-4.5f, 2.7f, -2.8f); pos[3] = glm::vec3(-4.5f, 2.7f, -2.8f);
} }
else if ( m_type == OBJECT_MOBILEta || else if ( m_type == OBJECT_MOBILEta ||
m_type == OBJECT_MOBILEtb || m_type == OBJECT_MOBILEtb ||
@ -3091,16 +3091,16 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILEti || m_type == OBJECT_MOBILEti ||
m_type == OBJECT_MOBILEts ) // caterpillars? m_type == OBJECT_MOBILEts ) // caterpillars?
{ {
pos[2] = Math::Vector(-3.6f, 4.2f, 3.0f); pos[2] = glm::vec3(-3.6f, 4.2f, 3.0f);
pos[3] = Math::Vector(-3.6f, 4.2f, -3.0f); pos[3] = glm::vec3(-3.6f, 4.2f, -3.0f);
} }
else if ( m_type == OBJECT_MOBILErt || else if ( m_type == OBJECT_MOBILErt ||
m_type == OBJECT_MOBILErc || m_type == OBJECT_MOBILErc ||
m_type == OBJECT_MOBILErr || m_type == OBJECT_MOBILErr ||
m_type == OBJECT_MOBILErs ) // large caterpillars? m_type == OBJECT_MOBILErs ) // large caterpillars?
{ {
pos[2] = Math::Vector(-5.0f, 5.2f, 2.5f); pos[2] = glm::vec3(-5.0f, 5.2f, 2.5f);
pos[3] = Math::Vector(-5.0f, 5.2f, -2.5f); pos[3] = glm::vec3(-5.0f, 5.2f, -2.5f);
} }
if ( m_type == OBJECT_MOBILErp || ( GetTrainer() && if ( m_type == OBJECT_MOBILErp || ( GetTrainer() &&
( m_type == OBJECT_MOBILErt || ( m_type == OBJECT_MOBILErt ||
@ -3108,24 +3108,24 @@ void COldObject::UpdateSelectParticle()
m_type == OBJECT_MOBILErr || m_type == OBJECT_MOBILErr ||
m_type == OBJECT_MOBILErs))) // large caterpillars (trainer)? m_type == OBJECT_MOBILErs))) // large caterpillars (trainer)?
{ {
pos[2] = Math::Vector(-4.6f, 5.2f, 2.6f); pos[2] = glm::vec3(-4.6f, 5.2f, 2.6f);
pos[3] = Math::Vector(-4.6f, 5.2f, -2.6f); pos[3] = glm::vec3(-4.6f, 5.2f, -2.6f);
} }
if ( m_type == OBJECT_MOBILEsa || if ( m_type == OBJECT_MOBILEsa ||
m_type == OBJECT_MOBILEst ) // submarine? m_type == OBJECT_MOBILEst ) // submarine?
{ {
pos[2] = Math::Vector(-3.6f, 4.0f, 2.0f); pos[2] = glm::vec3(-3.6f, 4.0f, 2.0f);
pos[3] = Math::Vector(-3.6f, 4.0f, -2.0f); pos[3] = glm::vec3(-3.6f, 4.0f, -2.0f);
} }
if ( m_type == OBJECT_MOBILEtg ) // target? if ( m_type == OBJECT_MOBILEtg ) // target?
{ {
pos[2] = Math::Vector(-2.4f, 6.5f, 2.0f); pos[2] = glm::vec3(-2.4f, 6.5f, 2.0f);
pos[3] = Math::Vector(-2.4f, 6.5f, -2.0f); pos[3] = glm::vec3(-2.4f, 6.5f, -2.0f);
} }
if ( m_type == OBJECT_MOBILEdr ) // designer? if ( m_type == OBJECT_MOBILEdr ) // designer?
{ {
pos[2] = Math::Vector(-5.3f, 2.7f, 1.8f); pos[2] = glm::vec3(-5.3f, 2.7f, 1.8f);
pos[3] = Math::Vector(-5.3f, 2.7f, -1.8f); pos[3] = glm::vec3(-5.3f, 2.7f, -1.8f);
} }
angle = GetRotationY()/Math::PI; angle = GetRotationY()/Math::PI;
@ -3198,32 +3198,32 @@ void COldObject::SetAuto(std::unique_ptr<CAuto> automat)
} }
Math::Vector COldObject::GetPosition() const glm::vec3 COldObject::GetPosition() const
{ {
return GetPartPosition(0); return GetPartPosition(0);
} }
void COldObject::SetPosition(const Math::Vector& pos) void COldObject::SetPosition(const glm::vec3& pos)
{ {
SetPartPosition(0, pos); SetPartPosition(0, pos);
} }
Math::Vector COldObject::GetRotation() const glm::vec3 COldObject::GetRotation() const
{ {
return GetPartRotation(0); return GetPartRotation(0);
} }
void COldObject::SetRotation(const Math::Vector& rotation) void COldObject::SetRotation(const glm::vec3& rotation)
{ {
SetPartRotation(0, rotation); SetPartRotation(0, rotation);
} }
Math::Vector COldObject::GetScale() const glm::vec3 COldObject::GetScale() const
{ {
return GetPartScale(0); return GetPartScale(0);
} }
void COldObject::SetScale(const Math::Vector& scale) void COldObject::SetScale(const glm::vec3& scale)
{ {
SetPartScale(0, scale); SetPartScale(0, scale);
} }

View File

@ -58,9 +58,9 @@ struct ObjectPart
int object = -1; // number of the object in CEngine int object = -1; // number of the object in CEngine
int parentPart = -1; // number of father part int parentPart = -1; // number of father part
int masterParti = -1; // master canal of the particle int masterParti = -1; // master canal of the particle
Math::Vector position; glm::vec3 position = { 0, 0, 0 };
Math::Vector angle; glm::vec3 angle = { 0, 0, 0 };
Math::Vector zoom; glm::vec3 zoom = { 0, 0, 0 };
bool bTranslate = false; bool bTranslate = false;
bool bRotate = false; bool bRotate = false;
bool bZoom = false; bool bZoom = false;
@ -134,18 +134,18 @@ public:
void SetFloorHeight(float height); void SetFloorHeight(float height);
void FloorAdjust() override; void FloorAdjust() override;
void SetLinVibration(Math::Vector dir) override; void SetLinVibration(glm::vec3 dir) override;
Math::Vector GetLinVibration(); glm::vec3 GetLinVibration();
void SetCirVibration(Math::Vector dir) override; void SetCirVibration(glm::vec3 dir) override;
Math::Vector GetCirVibration(); glm::vec3 GetCirVibration();
void SetTilt(Math::Vector dir); void SetTilt(glm::vec3 dir);
Math::Vector GetTilt() override; glm::vec3 GetTilt() override;
void SetPartPosition(int part, const Math::Vector &pos); void SetPartPosition(int part, const glm::vec3 &pos);
Math::Vector GetPartPosition(int part) const; glm::vec3 GetPartPosition(int part) const;
void SetPartRotation(int part, const Math::Vector &angle); void SetPartRotation(int part, const glm::vec3 &angle);
Math::Vector GetPartRotation(int part) const; glm::vec3 GetPartRotation(int part) const;
void SetPartRotationY(int part, float angle); void SetPartRotationY(int part, float angle);
void SetPartRotationX(int part, float angle); void SetPartRotationX(int part, float angle);
void SetPartRotationZ(int part, float angle); void SetPartRotationZ(int part, float angle);
@ -154,8 +154,8 @@ public:
float GetPartRotationZ(int part); float GetPartRotationZ(int part);
void SetPartScale(int part, float zoom); void SetPartScale(int part, float zoom);
void SetPartScale(int part, Math::Vector zoom); void SetPartScale(int part, glm::vec3 zoom);
Math::Vector GetPartScale(int part) const; glm::vec3 GetPartScale(int part) const;
void SetPartScaleX(int part, float zoom); void SetPartScaleX(int part, float zoom);
float GetPartScaleX(int part); float GetPartScaleX(int part);
void SetPartScaleY(int part, float zoom); void SetPartScaleY(int part, float zoom);
@ -177,8 +177,8 @@ public:
void SetPower(CObject* power) override; void SetPower(CObject* power) override;
CObject* GetPower() override; CObject* GetPower() override;
Math::Vector GetPowerPosition() override; glm::vec3 GetPowerPosition() override;
void SetPowerPosition(const Math::Vector& powerPosition) override; void SetPowerPosition(const glm::vec3& powerPosition) override;
void SetCargo(CObject* cargo) override; void SetCargo(CObject* cargo) override;
CObject* GetCargo() override; CObject* GetCargo() override;
void SetTransporter(CObject* transporter) override; void SetTransporter(CObject* transporter) override;
@ -188,8 +188,8 @@ public:
Math::Matrix* GetRotateMatrix(int part); Math::Matrix* GetRotateMatrix(int part);
Math::Matrix* GetWorldMatrix(int part) override; Math::Matrix* GetWorldMatrix(int part) override;
void AdjustCamera(Math::Vector &eye, float &dirH, float &dirV, void AdjustCamera(glm::vec3 &eye, float &dirH, float &dirV,
Math::Vector &lookat, Math::Vector &upVec, glm::vec3 &lookat, glm::vec3 &upVec,
Gfx::CameraType type) override; Gfx::CameraType type) override;
Character* GetCharacter() override; Character* GetCharacter() override;
@ -266,15 +266,15 @@ public:
void FlatParent() override; void FlatParent() override;
void SetPosition(const Math::Vector& pos) override; void SetPosition(const glm::vec3& pos) override;
Math::Vector GetPosition() const override; glm::vec3 GetPosition() const override;
void SetRotation(const Math::Vector& rotation) override; void SetRotation(const glm::vec3& rotation) override;
Math::Vector GetRotation() const override; glm::vec3 GetRotation() const override;
using CObject::SetScale; // SetScale(float) version using CObject::SetScale; // SetScale(float) version
void SetScale(const Math::Vector& scale) override; void SetScale(const glm::vec3& scale) override;
Math::Vector GetScale() const override; glm::vec3 GetScale() const override;
void UpdateInterface() override; void UpdateInterface() override;
@ -340,11 +340,11 @@ protected:
int m_option; // option int m_option; // option
int m_shadowLight; // number of light from the shadows int m_shadowLight; // number of light from the shadows
float m_shadowHeight; // height of light from the shadows float m_shadowHeight; // height of light from the shadows
Math::Vector m_linVibration; // linear vibration glm::vec3 m_linVibration; // linear vibration
Math::Vector m_cirVibration; // circular vibration glm::vec3 m_cirVibration; // circular vibration
Math::Vector m_tilt; // tilt glm::vec3 m_tilt; // tilt
CObject* m_power; // battery used by the vehicle CObject* m_power; // battery used by the vehicle
Math::Vector m_powerPosition; glm::vec3 m_powerPosition;
CObject* m_cargo; // object transported CObject* m_cargo; // object transported
CObject* m_transporter; // object with the latter CObject* m_transporter; // object with the latter
int m_transporterLink; // part int m_transporterLink; // part

View File

@ -58,17 +58,17 @@ void COldObjectInterface::FloorAdjust()
} }
void COldObjectInterface::SetLinVibration(Math::Vector dir) void COldObjectInterface::SetLinVibration(glm::vec3 dir)
{ {
throw std::logic_error("SetLinVibration: not implemented!"); throw std::logic_error("SetLinVibration: not implemented!");
} }
void COldObjectInterface::SetCirVibration(Math::Vector dir) void COldObjectInterface::SetCirVibration(glm::vec3 dir)
{ {
throw std::logic_error("SetCirVibration: not implemented!"); throw std::logic_error("SetCirVibration: not implemented!");
} }
Math::Vector COldObjectInterface::GetTilt() glm::vec3 COldObjectInterface::GetTilt()
{ {
throw std::logic_error("GetTilt: not implemented!"); throw std::logic_error("GetTilt: not implemented!");
} }

View File

@ -24,10 +24,10 @@
#pragma once #pragma once
#include "math/vector.h"
#include "object/object_type.h" #include "object/object_type.h"
#include <glm/glm.hpp>
namespace Math namespace Math
{ {
struct Matrix; struct Matrix;
@ -63,10 +63,10 @@ public:
virtual void FloorAdjust(); virtual void FloorAdjust();
virtual void SetLinVibration(Math::Vector dir); virtual void SetLinVibration(glm::vec3 dir);
virtual void SetCirVibration(Math::Vector dir); virtual void SetCirVibration(glm::vec3 dir);
virtual Math::Vector GetTilt(); virtual glm::vec3 GetTilt();
virtual void SetMasterParticle(int part, int parti); virtual void SetMasterParticle(int part, int parti);