mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 21:29:18 +02:00
use glm instead of Math3D in vehicle
WARNING: Model rotation is broken
This commit is contained in:
@@ -569,7 +569,7 @@ void driver_mode::update_camera(double const Deltatime)
|
|||||||
Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe
|
Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe
|
||||||
if (Camera.m_owner == nullptr)
|
if (Camera.m_owner == nullptr)
|
||||||
{
|
{
|
||||||
if (controlled && LengthSquared3(controlled->GetPosition() - Camera.Pos) < (1500 * 1500))
|
if (controlled && glm::length(controlled->GetPosition() - Camera.Pos) < 1500)
|
||||||
{
|
{
|
||||||
// gdy bliżej niż 1.5km
|
// gdy bliżej niż 1.5km
|
||||||
Camera.LookAt = controlled->GetPosition() + 0.4 * controlled->VectorUp() * controlled->MoverParameters->Dim.H;
|
Camera.LookAt = controlled->GetPosition() + 0.4 * controlled->VectorUp() * controlled->MoverParameters->Dim.H;
|
||||||
@@ -583,7 +583,7 @@ void driver_mode::update_camera(double const Deltatime)
|
|||||||
if (d && pDynamicNearest)
|
if (d && pDynamicNearest)
|
||||||
{
|
{
|
||||||
// jeśli jakiś jest znaleziony wcześniej
|
// jeśli jakiś jest znaleziony wcześniej
|
||||||
if (100.0 * LengthSquared3(d->GetPosition() - Camera.Pos) > LengthSquared3(pDynamicNearest->GetPosition() - Camera.Pos))
|
if (100.0 * glm::length(d->GetPosition() - Camera.Pos) > glm::length(pDynamicNearest->GetPosition() - Camera.Pos))
|
||||||
{
|
{
|
||||||
d = pDynamicNearest; // jeśli najbliższy nie jest 10 razy bliżej niż
|
d = pDynamicNearest; // jeśli najbliższy nie jest 10 razy bliżej niż
|
||||||
}
|
}
|
||||||
@@ -692,12 +692,12 @@ void driver_mode::update_camera(double const Deltatime)
|
|||||||
else if (Global.shiftState)
|
else if (Global.shiftState)
|
||||||
{
|
{
|
||||||
// patrzenie w bok przez szybę
|
// patrzenie w bok przez szybę
|
||||||
Camera.LookAt = Camera.Pos - (lr ? -1 : 1) * controlled->VectorLeft() * simulation::Train->Occupied()->CabOccupied;
|
Camera.LookAt = Camera.Pos - (lr ? -1.0 : 1.0) * controlled->VectorLeft() * (double)simulation::Train->Occupied()->CabOccupied;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny - jakby z lusterka,
|
{ // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny - jakby z lusterka,
|
||||||
// ale bez odbicia
|
// ale bez odbicia
|
||||||
Camera.LookAt = Camera.Pos - simulation::Train->GetDirection() * simulation::Train->Occupied()->CabOccupied; //-1 albo 1
|
Camera.LookAt = Camera.Pos - simulation::Train->GetDirection() * (double)simulation::Train->Occupied()->CabOccupied; //-1 albo 1
|
||||||
}
|
}
|
||||||
auto const shakeangles{simulation::Train->Dynamic()->shake_angles()};
|
auto const shakeangles{simulation::Train->Dynamic()->shake_angles()};
|
||||||
Camera.Angle.x = 0.5 * shakeangles.second; // hustanie kamery przod tyl
|
Camera.Angle.x = 0.5 * shakeangles.second; // hustanie kamery przod tyl
|
||||||
@@ -723,7 +723,7 @@ void driver_mode::update_camera(double const Deltatime)
|
|||||||
auto shakencamerapos{Camera.m_owneroffset +
|
auto shakencamerapos{Camera.m_owneroffset +
|
||||||
shakescale * glm::vec3(1.5 * Camera.m_owner->ShakeState.offset.x, 2.0 * Camera.m_owner->ShakeState.offset.y, 1.5 * Camera.m_owner->ShakeState.offset.z)};
|
shakescale * glm::vec3(1.5 * Camera.m_owner->ShakeState.offset.x, 2.0 * Camera.m_owner->ShakeState.offset.y, 1.5 * Camera.m_owner->ShakeState.offset.z)};
|
||||||
|
|
||||||
Camera.Pos = (Camera.m_owner->GetWorldPosition(FreeFlyModeFlag ? Math3D::vector3(shakencamerapos) : // TODO: vehicle collision box for the external vehicle camera
|
Camera.Pos = (Camera.m_owner->GetWorldPosition(FreeFlyModeFlag ? glm::dvec3(shakencamerapos) : // TODO: vehicle collision box for the external vehicle camera
|
||||||
simulation::Train->clamp_inside(shakencamerapos)));
|
simulation::Train->clamp_inside(shakencamerapos)));
|
||||||
|
|
||||||
if (!Global.iPause)
|
if (!Global.iPause)
|
||||||
@@ -758,7 +758,7 @@ void driver_mode::update_camera(double const Deltatime)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny
|
// patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny
|
||||||
Camera.LookAt = Camera.m_owner->GetWorldPosition(Camera.m_owneroffset) + Camera.m_owner->VectorFront() * 5.0 * simulation::Train->Occupied()->CabOccupied; //-1 albo 1
|
Camera.LookAt = Camera.m_owner->GetWorldPosition(Camera.m_owneroffset) + Camera.m_owner->VectorFront() * 5.0 * (double)simulation::Train->Occupied()->CabOccupied; //-1 albo 1
|
||||||
}
|
}
|
||||||
Camera.vUp = simulation::Train->GetUp();
|
Camera.vUp = simulation::Train->GetUp();
|
||||||
}
|
}
|
||||||
@@ -1053,17 +1053,17 @@ void driver_mode::DistantView(bool const Near)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto const cab = (vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied);
|
auto const cab = (vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied);
|
||||||
auto const left = vehicle->VectorLeft() * cab;
|
auto const left = vehicle->VectorLeft() * (double)cab;
|
||||||
|
|
||||||
if (true == Near)
|
if (true == Near)
|
||||||
{
|
{
|
||||||
|
|
||||||
Camera.Pos = glm::vec3(Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z) + left * vehicle->GetWidth() + glm::vec3(1.25 * left.x, 1.6, 1.25 * left.z);
|
Camera.Pos = glm::dvec3(Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z) + left * vehicle->GetWidth() + glm::dvec3(1.25 * left.x, 1.6, 1.25 * left.z);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
Camera.Pos = vehicle->GetPosition() + vehicle->VectorFront() * vehicle->MoverParameters->CabOccupied * 50.0 + glm::vec3(-10.0 * left.x, 1.6, -10.0 * left.z);
|
Camera.Pos = vehicle->GetPosition() + vehicle->VectorFront() * (double)vehicle->MoverParameters->CabOccupied * 50.0 + glm::dvec3(-10.0 * left.x, 1.6, -10.0 * left.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera.m_owner = nullptr;
|
Camera.m_owner = nullptr;
|
||||||
@@ -1237,7 +1237,7 @@ void driver_mode::CabView()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// patrz w strone wlasciwej kabiny
|
// patrz w strone wlasciwej kabiny
|
||||||
Camera.LookAt = Camera.m_owner->GetWorldPosition(Camera.m_owneroffset) + Camera.m_owner->VectorFront() * 5.0 * Camera.m_owner->MoverParameters->CabOccupied;
|
Camera.LookAt = Camera.m_owner->GetWorldPosition(Camera.m_owneroffset) + Camera.m_owner->VectorFront() * 5.0 * (double)Camera.m_owner->MoverParameters->CabOccupied;
|
||||||
}
|
}
|
||||||
train->pMechOffset = Camera.m_owneroffset;
|
train->pMechOffset = Camera.m_owneroffset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -510,9 +510,9 @@ void editor_mode::enter()
|
|||||||
auto const *vehicle = Camera.m_owner;
|
auto const *vehicle = Camera.m_owner;
|
||||||
if (vehicle)
|
if (vehicle)
|
||||||
{
|
{
|
||||||
auto const cab = (vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied);
|
const int cab = (vehicle->MoverParameters->CabOccupied == 0 ? 1 : vehicle->MoverParameters->CabOccupied);
|
||||||
auto const left = vehicle->VectorLeft() * cab;
|
const glm::dvec3 left = vehicle->VectorLeft() * (double)cab;
|
||||||
Camera.Pos = glm::vec3(Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z) + left * vehicle->GetWidth() + glm::vec3(1.25f * left.x, 1.6f, 1.25f * left.z);
|
Camera.Pos = glm::dvec3(Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z) + left * vehicle->GetWidth() + glm::dvec3(1.25f * left.x, 1.6f, 1.25f * left.z);
|
||||||
Camera.m_owner = nullptr;
|
Camera.m_owner = nullptr;
|
||||||
Camera.LookAt = vehicle->GetPosition();
|
Camera.LookAt = vehicle->GetPosition();
|
||||||
Camera.RaLook(); // single camera reposition
|
Camera.RaLook(); // single camera reposition
|
||||||
|
|||||||
@@ -928,9 +928,9 @@ sound_source::location() const {
|
|||||||
// otherwise combine offset with the location of the carrier
|
// otherwise combine offset with the location of the carrier
|
||||||
return {
|
return {
|
||||||
m_owner->GetPosition()
|
m_owner->GetPosition()
|
||||||
+ m_owner->VectorLeft() * m_offset.x
|
+ m_owner->VectorLeft() * (double)m_offset.x
|
||||||
+ m_owner->VectorUp() * m_offset.y
|
+ m_owner->VectorUp() * (double)m_offset.y
|
||||||
+ m_owner->VectorFront() * m_offset.z };
|
+ m_owner->VectorFront() * (double)m_offset.z };
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ light_array::update() {
|
|||||||
if( light.index == end::front ) {
|
if( light.index == end::front ) {
|
||||||
// front light set
|
// front light set
|
||||||
light.position = light.owner->GetPosition() + ( light.owner->VectorFront() * ( std::max( 0.0, light.owner->GetLength() * 0.5 - 2.0 ) ) );// +( light.owner->VectorUp() * 0.25 );
|
light.position = light.owner->GetPosition() + ( light.owner->VectorFront() * ( std::max( 0.0, light.owner->GetLength() * 0.5 - 2.0 ) ) );// +( light.owner->VectorUp() * 0.25 );
|
||||||
light.direction = glm::make_vec3( light.owner->VectorFront().getArray() );
|
light.direction = glm::make_vec3( glm::value_ptr(light.owner->VectorFront()) ); // TODO: It is needed to get value_ptr and then make_vec3?
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// rear light set
|
// rear light set
|
||||||
light.position = light.owner->GetPosition() - ( light.owner->VectorFront() * ( std::max( 0.0, light.owner->GetLength() * 0.5 - 2.0 ) ) );// +( light.owner->VectorUp() * 0.25 );
|
light.position = light.owner->GetPosition() - ( light.owner->VectorFront() * ( std::max( 0.0, light.owner->GetLength() * 0.5 - 2.0 ) ) );// +( light.owner->VectorUp() * 0.25 );
|
||||||
light.direction = glm::make_vec3( light.owner->VectorFront().getArray() );
|
light.direction = glm::make_vec3( glm::value_ptr(light.owner->VectorFront()) ); // TODO: It is needed to get value_ptr and then make_vec3?
|
||||||
light.direction.x = -light.direction.x;
|
light.direction.x = -light.direction.x;
|
||||||
light.direction.z = -light.direction.z;
|
light.direction.z = -light.direction.z;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1203,7 +1203,7 @@ bool opengl33_renderer::Render_lowpoly( TDynamicObject *Dynamic, float const Squ
|
|||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
::glMultMatrixd( Dynamic->mMatrix.readArray() );
|
::glMultMatrixd( glm::value_ptr(Dynamic->mMatrix) );
|
||||||
}
|
}
|
||||||
// HACK: reduce light level for vehicle interior if there's strong global lighting source
|
// HACK: reduce light level for vehicle interior if there's strong global lighting source
|
||||||
if( false == Alpha ) {
|
if( false == Alpha ) {
|
||||||
@@ -2890,7 +2890,7 @@ bool opengl33_renderer::Render(TDynamicObject *Dynamic)
|
|||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslated(originoffset.x, originoffset.y, originoffset.z);
|
::glTranslated(originoffset.x, originoffset.y, originoffset.z);
|
||||||
::glMultMatrixd(Dynamic->mMatrix.getArray());
|
::glMultMatrixd(glm::value_ptr(Dynamic->mMatrix));
|
||||||
|
|
||||||
switch (m_renderpass.draw_mode)
|
switch (m_renderpass.draw_mode)
|
||||||
{
|
{
|
||||||
@@ -3012,7 +3012,7 @@ bool opengl33_renderer::Render_cab(TDynamicObject const *Dynamic, float const Li
|
|||||||
|
|
||||||
auto const originoffset = Dynamic->GetPosition() - m_renderpass.pass_camera.position();
|
auto const originoffset = Dynamic->GetPosition() - m_renderpass.pass_camera.position();
|
||||||
::glTranslated(originoffset.x, originoffset.y, originoffset.z);
|
::glTranslated(originoffset.x, originoffset.y, originoffset.z);
|
||||||
::glMultMatrixd(Dynamic->mMatrix.readArray());
|
::glMultMatrixd(glm::value_ptr(Dynamic->mMatrix));
|
||||||
|
|
||||||
switch (m_renderpass.draw_mode)
|
switch (m_renderpass.draw_mode)
|
||||||
{
|
{
|
||||||
@@ -3908,7 +3908,7 @@ bool opengl33_renderer::Render_Alpha(TDynamicObject *Dynamic)
|
|||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
|
||||||
::glTranslated(originoffset.x, originoffset.y, originoffset.z);
|
::glTranslated(originoffset.x, originoffset.y, originoffset.z);
|
||||||
::glMultMatrixd(Dynamic->mMatrix.getArray());
|
::glMultMatrixd(glm::value_ptr(Dynamic->mMatrix));
|
||||||
|
|
||||||
if (Dynamic->fShade > 0.0f)
|
if (Dynamic->fShade > 0.0f)
|
||||||
{
|
{
|
||||||
@@ -4665,7 +4665,7 @@ void opengl33_renderer::Update_Lights(light_array &Lights)
|
|||||||
auto const offset{ 75.f * ( 5.f / cone ) };
|
auto const offset{ 75.f * ( 5.f / cone ) };
|
||||||
headlights.position() =
|
headlights.position() =
|
||||||
scenelight.owner->GetPosition()
|
scenelight.owner->GetPosition()
|
||||||
- scenelight.direction * offset
|
- glm::dvec3(scenelight.direction * offset)
|
||||||
+ up * ( size * 0.5 );
|
+ up * ( size * 0.5 );
|
||||||
/*
|
/*
|
||||||
headlights.projection() = ortho_projection(
|
headlights.projection() = ortho_projection(
|
||||||
|
|||||||
@@ -806,7 +806,7 @@ bool opengl_renderer::Render_lowpoly( TDynamicObject *Dynamic, float const Squar
|
|||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
::glMultMatrixd( Dynamic->mMatrix.getArray() );
|
::glMultMatrixd( glm::value_ptr(Dynamic->mMatrix) );
|
||||||
|
|
||||||
m_renderspecular = true; // vehicles are rendered with specular component. static models without, at least for the time being
|
m_renderspecular = true; // vehicles are rendered with specular component. static models without, at least for the time being
|
||||||
}
|
}
|
||||||
@@ -2480,7 +2480,7 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
|
|||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
::glMultMatrixd( Dynamic->mMatrix.getArray() );
|
::glMultMatrixd( glm::value_ptr(Dynamic->mMatrix) );
|
||||||
|
|
||||||
switch( m_renderpass.draw_mode ) {
|
switch( m_renderpass.draw_mode ) {
|
||||||
|
|
||||||
@@ -2593,7 +2593,7 @@ opengl_renderer::Render_cab( TDynamicObject const *Dynamic, float const Lightlev
|
|||||||
|
|
||||||
auto const originoffset = Dynamic->GetPosition() - m_renderpass.camera.position();
|
auto const originoffset = Dynamic->GetPosition() - m_renderpass.camera.position();
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
::glMultMatrixd( Dynamic->mMatrix.readArray() );
|
::glMultMatrixd( glm::value_ptr(Dynamic->mMatrix) );
|
||||||
|
|
||||||
switch( m_renderpass.draw_mode ) {
|
switch( m_renderpass.draw_mode ) {
|
||||||
case rendermode::color: {
|
case rendermode::color: {
|
||||||
@@ -3675,7 +3675,7 @@ opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) {
|
|||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
::glMultMatrixd( Dynamic->mMatrix.getArray() );
|
::glMultMatrixd( glm::value_ptr(Dynamic->mMatrix) );
|
||||||
|
|
||||||
if( Dynamic->fShade > 0.0f ) {
|
if( Dynamic->fShade > 0.0f ) {
|
||||||
// change light level based on light level of the occupied track
|
// change light level based on light level of the occupied track
|
||||||
|
|||||||
@@ -46,9 +46,10 @@ basic_cell::on_click( TAnimModel const *Instance ) {
|
|||||||
void
|
void
|
||||||
basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) {
|
basic_cell::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) {
|
||||||
// Winger 170204 - szukanie trakcji nad pantografami
|
// Winger 170204 - szukanie trakcji nad pantografami
|
||||||
auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu
|
// TODO: Why glm::make_vec3 and glm::value_ptr?
|
||||||
auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
auto const vFront = glm::make_vec3( glm::value_ptr(Vehicle->VectorFront()) ); // wektor normalny dla płaszczyzny ruchu pantografu
|
||||||
auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
auto const vUp = glm::make_vec3( glm::value_ptr(Vehicle->VectorUp()) ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
||||||
|
auto const vLeft = glm::make_vec3( glm::value_ptr(Vehicle->VectorLeft()) ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
||||||
auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
||||||
|
|
||||||
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
|
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
|
||||||
@@ -689,10 +690,10 @@ basic_section::on_click( TAnimModel const *Instance ) {
|
|||||||
// legacy method, finds and assigns traction piece(s) to pantographs of provided vehicle
|
// legacy method, finds and assigns traction piece(s) to pantographs of provided vehicle
|
||||||
void
|
void
|
||||||
basic_section::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) {
|
basic_section::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) {
|
||||||
|
// TODO: Why glm::make_vec3 and glm::value_ptr?
|
||||||
auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu
|
auto const vFront = glm::make_vec3( glm::value_ptr(Vehicle->VectorFront()) ); // wektor normalny dla płaszczyzny ruchu pantografu
|
||||||
auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
auto const vUp = glm::make_vec3( glm::value_ptr(Vehicle->VectorUp()) ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
||||||
auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
auto const vLeft = glm::make_vec3( glm::value_ptr(Vehicle->VectorLeft()) ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
||||||
auto const position = glm::dvec3{ Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
auto const position = glm::dvec3{ Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
||||||
|
|
||||||
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
|
auto pantograph = Vehicle->pants[ Pantographindex ].fParamPants;
|
||||||
@@ -1058,9 +1059,10 @@ basic_region::update_sounds() {
|
|||||||
void
|
void
|
||||||
basic_region::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) {
|
basic_region::update_traction( TDynamicObject *Vehicle, int const Pantographindex ) {
|
||||||
// TODO: convert vectors to transformation matrix and pass them down the chain along with calculated position
|
// TODO: convert vectors to transformation matrix and pass them down the chain along with calculated position
|
||||||
auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu
|
// TODO: Why glm::make_vec3 and glm::value_ptr?
|
||||||
auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
auto const vFront = glm::make_vec3( glm::value_ptr(Vehicle->VectorFront()) ); // wektor normalny dla płaszczyzny ruchu pantografu
|
||||||
auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
auto const vUp = glm::make_vec3( glm::value_ptr(Vehicle->VectorUp()) ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
||||||
|
auto const vLeft = glm::make_vec3( glm::value_ptr(Vehicle->VectorLeft()) ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
||||||
auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
||||||
|
|
||||||
auto p = Vehicle->pants[ Pantographindex ].fParamPants;
|
auto p = Vehicle->pants[ Pantographindex ].fParamPants;
|
||||||
|
|||||||
@@ -34,6 +34,13 @@ glm::vec3 RotateY(glm::vec3 v, float angle)
|
|||||||
|
|
||||||
return glm::vec3(c * v.x + s * v.z, v.y, c * v.z - s * v.x);
|
return glm::vec3(c * v.x + s * v.z, v.y, c * v.z - s * v.x);
|
||||||
}
|
}
|
||||||
|
glm::dvec3 RotateY(glm::dvec3 v, double angle)
|
||||||
|
{
|
||||||
|
double s = sin(angle);
|
||||||
|
double c = cos(angle);
|
||||||
|
|
||||||
|
return glm::vec3(c * v.x + s * v.z, v.y, c * v.z - s * v.x);
|
||||||
|
}
|
||||||
|
|
||||||
void vector3::RotateZ(double angle)
|
void vector3::RotateZ(double angle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,27 @@ namespace Math3D
|
|||||||
{
|
{
|
||||||
|
|
||||||
glm::vec3 RotateY(glm::vec3 v, float angle);
|
glm::vec3 RotateY(glm::vec3 v, float angle);
|
||||||
|
glm::dvec3 RotateY(glm::dvec3 v, double angle);
|
||||||
|
|
||||||
|
inline glm::dmat4 BasisChange(glm::dvec3 u, glm::dvec3 v, glm::dvec3 n)
|
||||||
|
{
|
||||||
|
glm::dmat4 M(1.0);
|
||||||
|
|
||||||
|
M[0] = glm::dvec4(u, 0.0); // kolumna 0
|
||||||
|
M[1] = glm::dvec4(v, 0.0); // kolumna 1
|
||||||
|
M[2] = glm::dvec4(n, 0.0); // kolumna 2
|
||||||
|
M[3] = glm::dvec4(0.0, 0.0, 0.0, 1.0); // kolumna 3
|
||||||
|
|
||||||
|
return M;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline glm::dmat4 BasisChange(glm::dvec3 v, glm::dvec3 n)
|
||||||
|
{
|
||||||
|
glm::dvec3 u = glm::cross(v, n);
|
||||||
|
return BasisChange(u, v, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Define this to have Math3D.cp generate a main which tests these classes
|
// Define this to have Math3D.cp generate a main which tests these classes
|
||||||
//#define TEST_MATH3D
|
//#define TEST_MATH3D
|
||||||
|
|||||||
@@ -222,12 +222,12 @@ bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
|||||||
|
|
||||||
void TCamera::RaLook()
|
void TCamera::RaLook()
|
||||||
{ // zmiana kierunku patrzenia - przelicza Yaw
|
{ // zmiana kierunku patrzenia - przelicza Yaw
|
||||||
Math3D::vector3 where = glm::dvec3(LookAt )- Pos /*+ Math3D::vector3(0, 3, 0)*/; // trochę w górę od szyn
|
auto where = glm::dvec3(LookAt )- Pos /*+ Math3D::vector3(0, 3, 0)*/; // trochę w górę od szyn
|
||||||
if( ( where.x != 0.0 ) || ( where.z != 0.0 ) ) {
|
if( ( where.x != 0.0 ) || ( where.z != 0.0 ) ) {
|
||||||
Angle.y = atan2( -where.x, -where.z ); // kąt horyzontalny
|
Angle.y = atan2( -where.x, -where.z ); // kąt horyzontalny
|
||||||
m_rotationoffsets.y = 0.0;
|
m_rotationoffsets.y = 0.0;
|
||||||
}
|
}
|
||||||
double l = Math3D::Length3(where);
|
double l = glm::length(where);
|
||||||
if( l > 0.0 ) {
|
if( l > 0.0 ) {
|
||||||
Angle.x = asin( where.y / l ); // kąt w pionie
|
Angle.x = asin( where.y / l ); // kąt w pionie
|
||||||
m_rotationoffsets.x = 0.0;
|
m_rotationoffsets.x = 0.0;
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ void TSpeedPos::Clear()
|
|||||||
fVelNext = -1.0; // prędkość bez ograniczeń
|
fVelNext = -1.0; // prędkość bez ograniczeń
|
||||||
fSectionVelocityDist = 0.0; //brak długości
|
fSectionVelocityDist = 0.0; //brak długości
|
||||||
fDist = 0.0;
|
fDist = 0.0;
|
||||||
vPos = Math3D::vector3(0, 0, 0);
|
vPos = glm::dvec3(0, 0, 0);
|
||||||
trTrack = NULL; // brak wskaźnika
|
trTrack = NULL; // brak wskaźnika
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -536,11 +536,10 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
|
|||||||
}
|
}
|
||||||
// account for the fact tracing begins from active axle, not the actual front of the vehicle
|
// account for the fact tracing begins from active axle, not the actual front of the vehicle
|
||||||
// NOTE: position of the couplers is modified by track offset, but the axles ain't, so we need to account for this as well
|
// NOTE: position of the couplers is modified by track offset, but the axles ain't, so we need to account for this as well
|
||||||
fTrackLength -= (
|
fTrackLength -= glm::length(
|
||||||
pVehicle->AxlePositionGet()
|
pVehicle->AxlePositionGet()
|
||||||
- pVehicle->RearPosition()
|
- pVehicle->RearPosition()
|
||||||
+ pVehicle->VectorLeft() * pVehicle->MoverParameters->OffsetTrackH )
|
+ pVehicle->VectorLeft() * pVehicle->MoverParameters->OffsetTrackH );
|
||||||
.Length();
|
|
||||||
// aktualna odległość ma być ujemna gdyż jesteśmy na końcu składu
|
// aktualna odległość ma być ujemna gdyż jesteśmy na końcu składu
|
||||||
fCurrentDistance = -fLength - fTrackLength;
|
fCurrentDistance = -fLength - fTrackLength;
|
||||||
fTrackLength = pTrack->Length(); //skasowanie zmian w zmiennej żeby poprawnie liczyło w dalszych krokach
|
fTrackLength = pTrack->Length(); //skasowanie zmian w zmiennej żeby poprawnie liczyło w dalszych krokach
|
||||||
@@ -5371,7 +5370,7 @@ basic_event * TController::CheckTrackEventBackward(double fDirection, TTrack *Tr
|
|||||||
{ // sprawdzanie eventu w torze, czy jest sygnałowym - skanowanie do tyłu
|
{ // sprawdzanie eventu w torze, czy jest sygnałowym - skanowanie do tyłu
|
||||||
// NOTE: this method returns only one event which meets the conditions, due to limitations in the caller
|
// NOTE: this method returns only one event which meets the conditions, due to limitations in the caller
|
||||||
// TBD, TODO: clean up the caller and return all suitable events, as in theory things will go awry if the track has more than one signal
|
// TBD, TODO: clean up the caller and return all suitable events, as in theory things will go awry if the track has more than one signal
|
||||||
auto const dir{ Vehicle->VectorFront() * Vehicle->DirectionGet() };
|
auto const dir{ Vehicle->VectorFront() * (double)Vehicle->DirectionGet() };
|
||||||
auto const pos{ End == end::front ? Vehicle->RearPosition() : Vehicle->HeadPosition() };
|
auto const pos{ End == end::front ? Vehicle->RearPosition() : Vehicle->HeadPosition() };
|
||||||
auto const &eventsequence { ( fDirection * Eventdirection > 0 ? Track->m_events2 : Track->m_events1 ) };
|
auto const &eventsequence { ( fDirection * Eventdirection > 0 ? Track->m_events2 : Track->m_events1 ) };
|
||||||
for( auto const &event : eventsequence ) {
|
for( auto const &event : eventsequence ) {
|
||||||
@@ -5512,7 +5511,7 @@ TCommandType TController::BackwardScan( double const Range )
|
|||||||
// opcjonalnie może być skanowanie od "wskaźnika" z przodu, np. W5, Tm=Ms1, koniec toru wg
|
// opcjonalnie może być skanowanie od "wskaźnika" z przodu, np. W5, Tm=Ms1, koniec toru wg
|
||||||
// drugiej osi w kierunku ruchu
|
// drugiej osi w kierunku ruchu
|
||||||
auto const *scantrack{BackwardTraceRoute(scandist, scandir, pVehicles[end::front], e)};
|
auto const *scantrack{BackwardTraceRoute(scandist, scandir, pVehicles[end::front], e)};
|
||||||
auto const dir{startdir *
|
auto const dir{(double)startdir *
|
||||||
pVehicles[end::front]->VectorFront()}; // wektor w kierunku jazdy/szukania
|
pVehicles[end::front]->VectorFront()}; // wektor w kierunku jazdy/szukania
|
||||||
|
|
||||||
// jeśli wstecz wykryto koniec toru to raczej nic się nie da w takiej sytuacji zrobić
|
// jeśli wstecz wykryto koniec toru to raczej nic się nie da w takiej sytuacji zrobić
|
||||||
@@ -5548,7 +5547,7 @@ TCommandType TController::BackwardScan( double const Range )
|
|||||||
}
|
}
|
||||||
scanvel = e->input_value(1); // prędkość przy tym semaforze
|
scanvel = e->input_value(1); // prędkość przy tym semaforze
|
||||||
// przeliczamy odległość od semafora - potrzebne by były współrzędne początku składu
|
// przeliczamy odległość od semafora - potrzebne by były współrzędne początku składu
|
||||||
scandist = sem.Length() - 2; // 2m luzu przy manewrach wystarczy
|
scandist = glm::length(sem) - 2; // 2m luzu przy manewrach wystarczy
|
||||||
if (scandist < 0)
|
if (scandist < 0)
|
||||||
{
|
{
|
||||||
// ujemnych nie ma po co wysyłać
|
// ujemnych nie ma po co wysyłać
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class TSpeedPos
|
|||||||
int iFlags{ spNone }; // flagi typu wpisu do tabelki
|
int iFlags{ spNone }; // flagi typu wpisu do tabelki
|
||||||
bool bMoved{ false }; // czy przesunięty (dotyczy punktu zatrzymania w peronie)
|
bool bMoved{ false }; // czy przesunięty (dotyczy punktu zatrzymania w peronie)
|
||||||
double fMoved{ 0.0 }; // ile przesunięty (dotyczy punktu zatrzymania w peronie)
|
double fMoved{ 0.0 }; // ile przesunięty (dotyczy punktu zatrzymania w peronie)
|
||||||
Math3D::vector3 vPos; // współrzędne XYZ do liczenia odległości
|
glm::dvec3 vPos; // współrzędne XYZ do liczenia odległości
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
TTrack *trTrack{ nullptr }; // wskaźnik na tor o zmiennej prędkości (zwrotnica, obrotnica)
|
TTrack *trTrack{ nullptr }; // wskaźnik na tor o zmiennej prędkości (zwrotnica, obrotnica)
|
||||||
@@ -490,7 +490,7 @@ private:
|
|||||||
std::string Order2Str( TOrders Order ) const;
|
std::string Order2Str( TOrders Order ) const;
|
||||||
// members
|
// members
|
||||||
std::string m_assignment;
|
std::string m_assignment;
|
||||||
Math3D::vector3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego odnosi sie komenda // NOTE: not used
|
glm::dvec3 vCommandLocation; // polozenie wskaznika, sygnalizatora lub innego obiektu do ktorego odnosi sie komenda // NOTE: not used
|
||||||
TOrders OrderList[ maxorders ]; // lista rozkazów
|
TOrders OrderList[ maxorders ]; // lista rozkazów
|
||||||
int OrderPos = 0,
|
int OrderPos = 0,
|
||||||
OrderTop = 0; // rozkaz aktualny oraz wolne miejsce do wstawiania nowych
|
OrderTop = 0; // rozkaz aktualny oraz wolne miejsce do wstawiania nowych
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "vehicle/Driver.h"
|
#include "vehicle/Driver.h"
|
||||||
|
|
||||||
// Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny
|
// Ra: taki zapis funkcjonuje lepiej, ale może nie jest optymalny
|
||||||
#define vWorldFront Math3D::vector3(0, 0, 1)
|
#define vWorldFront glm::vec3(0, 0, 1)
|
||||||
#define vWorldUp Math3D::vector3(0, 1, 0)
|
#define vWorldUp glm::vec3(0, 1, 0)
|
||||||
#define vWorldLeft CrossProduct(vWorldUp, vWorldFront)
|
#define vWorldLeft glm::cross(vWorldUp, vWorldFront)
|
||||||
|
|
||||||
#define M_2PI 6.283185307179586476925286766559;
|
#define M_2PI 6.283185307179586476925286766559;
|
||||||
const float maxrot = (float)(M_PI / 3.0); // 60°
|
const float maxrot = (float)(M_PI / 3.0); // 60°
|
||||||
@@ -72,7 +72,7 @@ TextureTest( std::string const &Name ) {
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void TAnimPant::AKP_4E()
|
void TAnimPant::AKP_4E()
|
||||||
{ // ustawienie wymiarów dla pantografu AKP-4E
|
{ // ustawienie wymiarów dla pantografu AKP-4E
|
||||||
vPos = Math3D::vector3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
vPos = glm::dvec3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
||||||
fLenL1 = 1.22; // 1.176289 w modelach
|
fLenL1 = 1.22; // 1.176289 w modelach
|
||||||
fLenU1 = 1.755; // 1.724482197 w modelach
|
fLenU1 = 1.755; // 1.724482197 w modelach
|
||||||
fHoriz = 0.535; // 0.54555075 przesunięcie ślizgu w długości pojazdu względem
|
fHoriz = 0.535; // 0.54555075 przesunięcie ślizgu w długości pojazdu względem
|
||||||
@@ -99,7 +99,7 @@ void TAnimPant::AKP_4E()
|
|||||||
};
|
};
|
||||||
void TAnimPant::WBL85()
|
void TAnimPant::WBL85()
|
||||||
{ // ustawienie wymiarów dla pantografu WBL88
|
{ // ustawienie wymiarów dla pantografu WBL88
|
||||||
vPos = Math3D::vector3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
vPos = glm::dvec3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
||||||
|
|
||||||
// mnozniki animacji ramion dla pantografu WBL88
|
// mnozniki animacji ramion dla pantografu WBL88
|
||||||
rd1rf = 1.f;
|
rd1rf = 1.f;
|
||||||
@@ -133,7 +133,7 @@ void TAnimPant::WBL85()
|
|||||||
};
|
};
|
||||||
void TAnimPant::EC160_200()
|
void TAnimPant::EC160_200()
|
||||||
{ // ustawienie wymiarów dla pantografow EC160 lub EC200
|
{ // ustawienie wymiarów dla pantografow EC160 lub EC200
|
||||||
vPos = Math3D::vector3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
vPos = glm::dvec3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
||||||
|
|
||||||
// mnozniki animacji ramion dla pantografow EC160 lub EC200
|
// mnozniki animacji ramion dla pantografow EC160 lub EC200
|
||||||
rd1rf = 1.f;
|
rd1rf = 1.f;
|
||||||
@@ -167,7 +167,7 @@ void TAnimPant::EC160_200()
|
|||||||
};
|
};
|
||||||
void TAnimPant::DSAx()
|
void TAnimPant::DSAx()
|
||||||
{ // ustawienie wymiarów dla pantografow z rodziny DSA
|
{ // ustawienie wymiarów dla pantografow z rodziny DSA
|
||||||
vPos = Math3D::vector3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
vPos = glm::dvec3(0, 0, 0); // przypisanie domyśnych współczynników do pantografów
|
||||||
|
|
||||||
// mnozniki animacji ramion dla pantografow z rodziny DSA
|
// mnozniki animacji ramion dla pantografow z rodziny DSA
|
||||||
rd1rf = 1.f;
|
rd1rf = 1.f;
|
||||||
@@ -504,7 +504,7 @@ TDynamicObject * TDynamicObject::GetFirstDynamic(int cpl_type, int cf)
|
|||||||
return FirstFind(cpl_type, cf); // używa referencji
|
return FirstFind(cpl_type, cf); // używa referencji
|
||||||
};
|
};
|
||||||
|
|
||||||
void TDynamicObject::ABuSetModelShake( Math3D::vector3 mShake )
|
void TDynamicObject::ABuSetModelShake(glm::dvec3 mShake)
|
||||||
{
|
{
|
||||||
modelShake = mShake;
|
modelShake = mShake;
|
||||||
};
|
};
|
||||||
@@ -619,7 +619,7 @@ void TDynamicObject::UpdateDoorTranslate(TAnim *pAnim) {
|
|||||||
side::left ) ] };
|
side::left ) ] };
|
||||||
|
|
||||||
pAnim->smAnimated->SetTranslate(
|
pAnim->smAnimated->SetTranslate(
|
||||||
Math3D::vector3{
|
glm::vec3{
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
door.position } );
|
door.position } );
|
||||||
@@ -683,7 +683,7 @@ void TDynamicObject::UpdateDoorPlug(TAnim *pAnim) {
|
|||||||
side::left ) ] };
|
side::left ) ] };
|
||||||
|
|
||||||
pAnim->smAnimated->SetTranslate(
|
pAnim->smAnimated->SetTranslate(
|
||||||
Math3D::vector3 {
|
glm::vec3{
|
||||||
std::min(
|
std::min(
|
||||||
door.position * 2.f,
|
door.position * 2.f,
|
||||||
MoverParameters->Doors.range_out ),
|
MoverParameters->Doors.range_out ),
|
||||||
@@ -722,7 +722,7 @@ void TDynamicObject::UpdatePlatformTranslate( TAnim *pAnim ) {
|
|||||||
side::left ) ] };
|
side::left ) ] };
|
||||||
|
|
||||||
pAnim->smAnimated->SetTranslate(
|
pAnim->smAnimated->SetTranslate(
|
||||||
Math3D::vector3{
|
glm::vec3{
|
||||||
interpolate( 0.f, MoverParameters->Doors.step_range, door.step_position ),
|
interpolate( 0.f, MoverParameters->Doors.step_range, door.step_position ),
|
||||||
0.0,
|
0.0,
|
||||||
0.0 } );
|
0.0 } );
|
||||||
@@ -1081,10 +1081,10 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
|
|||||||
if( dist >= 0.0 ) { continue; }
|
if( dist >= 0.0 ) { continue; }
|
||||||
|
|
||||||
if( smBuforLewy[ i ] ) {
|
if( smBuforLewy[ i ] ) {
|
||||||
smBuforLewy[ i ]->SetTranslate( Math3D::vector3( dist, 0, 0 ) );
|
smBuforLewy[ i ]->SetTranslate( glm::vec3( dist, 0, 0 ) );
|
||||||
}
|
}
|
||||||
if( smBuforPrawy[ i ] ) {
|
if( smBuforPrawy[ i ] ) {
|
||||||
smBuforPrawy[ i ]->SetTranslate( Math3D::vector3( dist, 0, 0 ) );
|
smBuforPrawy[ i ]->SetTranslate( glm::vec3( dist, 0, 0 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // vehicle within 50m
|
} // vehicle within 50m
|
||||||
@@ -1411,19 +1411,20 @@ TDynamicObject * TDynamicObject::ABuFindNearestObject(glm::vec3 pos, TTrack *Tra
|
|||||||
|
|
||||||
if( CouplNr == -2 ) {
|
if( CouplNr == -2 ) {
|
||||||
// wektor [kamera-obiekt] - poszukiwanie obiektu
|
// wektor [kamera-obiekt] - poszukiwanie obiektu
|
||||||
if( Math3D::LengthSquared3( pos - dynamic->vPosition ) < 100.0 ) {
|
if (glm::length(glm::dvec3(pos) - dynamic->vPosition) < 10.0)
|
||||||
|
{
|
||||||
// 10 metrów
|
// 10 metrów
|
||||||
return dynamic;
|
return dynamic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// jeśli (CouplNr) inne niz -2, szukamy sprzęgu
|
// jeśli (CouplNr) inne niz -2, szukamy sprzęgu
|
||||||
if( Math3D::LengthSquared3( pos - dynamic->vCoulpler[ 0 ] ) < 25.0 ) {
|
if (glm::length(glm::dvec3(pos) - dynamic->vCoulpler[0]) < 5.0) {
|
||||||
// 5 metrów
|
// 5 metrów
|
||||||
CouplNr = 0;
|
CouplNr = 0;
|
||||||
return dynamic;
|
return dynamic;
|
||||||
}
|
}
|
||||||
if( Math3D::LengthSquared3( pos - dynamic->vCoulpler[ 1 ] ) < 25.0 ) {
|
if (glm::length(glm::dvec3(pos) - dynamic->vCoulpler[1]) < 5.0) {
|
||||||
// 5 metrów
|
// 5 metrów
|
||||||
CouplNr = 1;
|
CouplNr = 1;
|
||||||
return dynamic;
|
return dynamic;
|
||||||
@@ -1860,7 +1861,7 @@ TDynamicObject::remove_coupler_adapter( int const Side ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TDynamicObject::TDynamicObject() {
|
TDynamicObject::TDynamicObject() {
|
||||||
modelShake = Math3D::vector3(0, 0, 0);
|
modelShake = glm::dvec3(0, 0, 0);
|
||||||
// fTrackBlock = 10000.0; // brak przeszkody na drodze
|
// fTrackBlock = 10000.0; // brak przeszkody na drodze
|
||||||
btnOn = false;
|
btnOn = false;
|
||||||
vUp = vWorldUp;
|
vUp = vWorldUp;
|
||||||
@@ -1897,8 +1898,8 @@ TDynamicObject::TDynamicObject() {
|
|||||||
smBuforLewy[0] = smBuforLewy[1] = NULL;
|
smBuforLewy[0] = smBuforLewy[1] = NULL;
|
||||||
smBuforPrawy[0] = smBuforPrawy[1] = NULL;
|
smBuforPrawy[0] = smBuforPrawy[1] = NULL;
|
||||||
smBogie[0] = smBogie[1] = NULL;
|
smBogie[0] = smBogie[1] = NULL;
|
||||||
bogieRot[0] = bogieRot[1] = Math3D::vector3(0, 0, 0);
|
bogieRot[0] = bogieRot[1] = glm::dvec3(0, 0, 0);
|
||||||
modelRot = Math3D::vector3(0, 0, 0);
|
modelRot = glm::dvec3(0, 0, 0);
|
||||||
cp1 = cp2 = sp1 = sp2 = 0;
|
cp1 = cp2 = sp1 = sp2 = 0;
|
||||||
iDirection = 1; // stoi w kierunku tradycyjnym (0, gdy jest odwrócony)
|
iDirection = 1; // stoi w kierunku tradycyjnym (0, gdy jest odwrócony)
|
||||||
iAxleFirst = 0; // numer pierwszej osi w kierunku ruchu (przełączenie
|
iAxleFirst = 0; // numer pierwszej osi w kierunku ruchu (przełączenie
|
||||||
@@ -2545,7 +2546,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
|||||||
// potem juz liczona prawidlowa wartosc masy
|
// potem juz liczona prawidlowa wartosc masy
|
||||||
MoverParameters->ComputeConstans();
|
MoverParameters->ComputeConstans();
|
||||||
// wektor podłogi dla wagonów, przesuwa ładunek
|
// wektor podłogi dla wagonów, przesuwa ładunek
|
||||||
vFloor = Math3D::vector3(0, 0, MoverParameters->Floor);
|
vFloor = glm::dvec3(0, 0, MoverParameters->Floor);
|
||||||
|
|
||||||
// długość większa od zera oznacza OK; 2mm docisku?
|
// długość większa od zera oznacza OK; 2mm docisku?
|
||||||
return MoverParameters->Dim.L;
|
return MoverParameters->Dim.L;
|
||||||
@@ -2669,7 +2670,7 @@ void TDynamicObject::Move(double fDistance)
|
|||||||
vFront = Axle0.pPosition - Axle1.pPosition; // wektor pomiędzy skrajnymi osiami
|
vFront = Axle0.pPosition - Axle1.pPosition; // wektor pomiędzy skrajnymi osiami
|
||||||
// Ra 2F1J: to nie jest stabilne (powoduje rzucanie taborem) i wymaga
|
// Ra 2F1J: to nie jest stabilne (powoduje rzucanie taborem) i wymaga
|
||||||
// dopracowania
|
// dopracowania
|
||||||
fAdjustment = vFront.Length() - fAxleDist; // na łuku będzie ujemny
|
fAdjustment = glm::length(vFront) - fAxleDist; // na łuku będzie ujemny
|
||||||
// if (fabs(fAdjustment)>0.02) //jeśli jest zbyt dużo, to rozłożyć na kilka przeliczeń (wygasza drgania?)
|
// if (fabs(fAdjustment)>0.02) //jeśli jest zbyt dużo, to rozłożyć na kilka przeliczeń (wygasza drgania?)
|
||||||
//{//parę centymetrów trzeba by już skorygować; te błędy mogą się też
|
//{//parę centymetrów trzeba by już skorygować; te błędy mogą się też
|
||||||
// generować na ostrych łukach
|
// generować na ostrych łukach
|
||||||
@@ -2677,27 +2678,25 @@ void TDynamicObject::Move(double fDistance)
|
|||||||
//}
|
//}
|
||||||
// else
|
// else
|
||||||
// fAdjustment=0.0;
|
// fAdjustment=0.0;
|
||||||
vFront = Normalize(vFront); // kierunek ustawienia pojazdu (wektor jednostkowy)
|
vFront = glm::normalize(vFront); // kierunek ustawienia pojazdu (wektor jednostkowy)
|
||||||
vLeft = Normalize(CrossProduct(vWorldUp, vFront)); // wektor poziomy w lewo,
|
vLeft = glm::normalize(glm::cross(glm::dvec3(vWorldUp), vFront)); // wektor poziomy w lewo,
|
||||||
// normalizacja potrzebna z powodu pochylenia (vFront)
|
// normalizacja potrzebna z powodu pochylenia (vFront)
|
||||||
vUp = CrossProduct(vFront, vLeft); // wektor w górę, będzie jednostkowy
|
vUp = glm::cross(vFront, vLeft); // wektor w górę, będzie jednostkowy
|
||||||
modelRot.z = atan2(-vFront.x, vFront.z); // kąt obrotu pojazdu [rad]; z ABuBogies()
|
modelRot.z = atan2(-vFront.x, vFront.z); // kąt obrotu pojazdu [rad]; z ABuBogies()
|
||||||
auto const roll { Roll() }; // suma przechyłek
|
auto const roll { Roll() }; // suma przechyłek
|
||||||
if (roll != 0.0)
|
if (roll != 0.0)
|
||||||
{ // wyznaczanie przechylenia tylko jeśli jest przechyłka
|
{ // wyznaczanie przechylenia tylko jeśli jest przechyłka
|
||||||
// można by pobrać wektory normalne z toru...
|
// można by pobrać wektory normalne z toru...
|
||||||
mMatrix.Identity(); // ta macierz jest potrzebna głównie do wyświetlania
|
mMatrix = glm::rotate(glm::dmat4(1.0), roll * 0.5, vFront); // ta macierz jest potrzebna głównie do wyświetlania // obrót wzdłuż osi o przechyłkę
|
||||||
mMatrix.Rotation(roll * 0.5, vFront); // obrót wzdłuż osi o przechyłkę
|
vUp = glm::dvec3(mMatrix * glm::dvec4(vUp, 0.0)); // wektor w górę pojazdu (przekręcenie na przechyłce)
|
||||||
vUp = mMatrix * vUp; // wektor w górę pojazdu (przekręcenie na przechyłce)
|
|
||||||
// vLeft=mMatrix*DynamicObject->vLeft;
|
// vLeft=mMatrix*DynamicObject->vLeft;
|
||||||
// vUp=CrossProduct(vFront,vLeft); //wektor w górę
|
// vUp=CrossProduct(vFront,vLeft); //wektor w górę
|
||||||
// vLeft=Normalize(CrossProduct(vWorldUp,vFront)); //wektor w lewo
|
// vLeft=Normalize(CrossProduct(vWorldUp,vFront)); //wektor w lewo
|
||||||
vLeft = Normalize(CrossProduct(vUp, vFront)); // wektor w lewo
|
vLeft = glm::normalize(glm::cross(vUp, vFront)); // wektor w lewo
|
||||||
// vUp=CrossProduct(vFront,vLeft); //wektor w górę
|
// vUp=CrossProduct(vFront,vLeft); //wektor w górę
|
||||||
}
|
}
|
||||||
mMatrix.Identity(); // to też można by od razu policzyć, ale potrzebne jest do wyświetlania
|
mMatrix = Math3D::BasisChange(vLeft, vUp, vFront); // to też można by od razu policzyć, ale potrzebne jest do wyświetlania // przesuwanie jest jednak rzadziej niż renderowanie
|
||||||
mMatrix.BasisChange(vLeft, vUp, vFront); // przesuwanie jest jednak rzadziej niż renderowanie
|
mMatrix = glm::inverse(mMatrix); // wyliczenie macierzy dla pojazdu (potrzebna tylko do wyświetlania?)
|
||||||
mMatrix = Inverse(mMatrix); // wyliczenie macierzy dla pojazdu (potrzebna tylko do wyświetlania?)
|
|
||||||
// if (MoverParameters->CategoryFlag&2)
|
// if (MoverParameters->CategoryFlag&2)
|
||||||
{ // przesunięcia są używane po wyrzuceniu pociągu z toru
|
{ // przesunięcia są używane po wyrzuceniu pociągu z toru
|
||||||
vPosition.x += MoverParameters->OffsetTrackH * vLeft.x; // dodanie przesunięcia w bok
|
vPosition.x += MoverParameters->OffsetTrackH * vLeft.x; // dodanie przesunięcia w bok
|
||||||
@@ -8075,7 +8074,7 @@ TDynamicObject::update_shake( double const Timedelta ) {
|
|||||||
// Granice mozna ustalic doswiadczalnie. Ja proponuje 14:20
|
// Granice mozna ustalic doswiadczalnie. Ja proponuje 14:20
|
||||||
if( Global.iSlowMotion == 0 ) { // musi być pełna prędkość
|
if( Global.iSlowMotion == 0 ) { // musi być pełna prędkość
|
||||||
|
|
||||||
Math3D::vector3 shakevector;
|
glm::dvec3 shakevector;
|
||||||
if( ( MoverParameters->EngineType == TEngineType::DieselElectric )
|
if( ( MoverParameters->EngineType == TEngineType::DieselElectric )
|
||||||
|| ( MoverParameters->EngineType == TEngineType::DieselEngine ) ) {
|
|| ( MoverParameters->EngineType == TEngineType::DieselEngine ) ) {
|
||||||
if( std::abs( MoverParameters->enrot ) > 0.0 ) {
|
if( std::abs( MoverParameters->enrot ) > 0.0 ) {
|
||||||
@@ -8117,7 +8116,7 @@ TDynamicObject::update_shake( double const Timedelta ) {
|
|||||||
auto const iVel { std::min( GetVelocity(), 150.0 ) };
|
auto const iVel { std::min( GetVelocity(), 150.0 ) };
|
||||||
if( iVel > 0.5 ) {
|
if( iVel > 0.5 ) {
|
||||||
// acceleration-driven base shake
|
// acceleration-driven base shake
|
||||||
shakevector += Math3D::vector3(
|
shakevector += glm::dvec3(
|
||||||
-MoverParameters->AccN * Timedelta * 5.0 * Global.ShakingMultiplierRL, // highlight side sway
|
-MoverParameters->AccN * Timedelta * 5.0 * Global.ShakingMultiplierRL, // highlight side sway
|
||||||
-MoverParameters->AccVert * Timedelta * Global.ShakingMultiplierUD,
|
-MoverParameters->AccVert * Timedelta * Global.ShakingMultiplierUD,
|
||||||
-MoverParameters->AccSVBased * Timedelta * 1.5 * Global.ShakingMultiplierBF); // accent acceleration/deceleration
|
-MoverParameters->AccSVBased * Timedelta * 1.5 * Global.ShakingMultiplierBF); // accent acceleration/deceleration
|
||||||
@@ -8128,7 +8127,7 @@ TDynamicObject::update_shake( double const Timedelta ) {
|
|||||||
if( LocalRandom( iVel ) > 25.0 ) {
|
if( LocalRandom( iVel ) > 25.0 ) {
|
||||||
// extra shake at increased velocity
|
// extra shake at increased velocity
|
||||||
shake += ShakeSpring.ComputateForces(
|
shake += ShakeSpring.ComputateForces(
|
||||||
Math3D::vector3(
|
glm::dvec3(
|
||||||
( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.x,
|
( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.x,
|
||||||
( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.y,
|
( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.y,
|
||||||
( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.z )
|
( LocalRandom( iVel * 2 ) - iVel ) / ( ( iVel * 2 ) * 4 ) * BaseShake.jolt_scale.z )
|
||||||
@@ -8138,7 +8137,7 @@ TDynamicObject::update_shake( double const Timedelta ) {
|
|||||||
}
|
}
|
||||||
shake *= 0.85;
|
shake *= 0.85;
|
||||||
|
|
||||||
ShakeState.velocity -= ( shake + ShakeState.velocity * 100 ) * ( BaseShake.jolt_scale.x + BaseShake.jolt_scale.y + BaseShake.jolt_scale.z ) / ( 200 );
|
ShakeState.velocity -= ( shake + ShakeState.velocity * 100.0 ) * ( BaseShake.jolt_scale.x + BaseShake.jolt_scale.y + BaseShake.jolt_scale.z ) / ( 200.0 );
|
||||||
|
|
||||||
// McZapkie:
|
// McZapkie:
|
||||||
ShakeState.offset += ShakeState.velocity * Timedelta;
|
ShakeState.offset += ShakeState.velocity * Timedelta;
|
||||||
@@ -8741,10 +8740,10 @@ vehicle_table::update( double Deltatime, int Iterationcount ) {
|
|||||||
// legacy method, checks for presence and height of traction wire for specified vehicle
|
// legacy method, checks for presence and height of traction wire for specified vehicle
|
||||||
void
|
void
|
||||||
vehicle_table::update_traction( TDynamicObject *Vehicle ) {
|
vehicle_table::update_traction( TDynamicObject *Vehicle ) {
|
||||||
|
// TODO: Why glm::make_vec3 and glm::value_ptr?
|
||||||
auto const vFront = glm::make_vec3( Vehicle->VectorFront().getArray() ); // wektor normalny dla płaszczyzny ruchu pantografu
|
auto const vFront = glm::make_vec3( glm::value_ptr(Vehicle->VectorFront()) ); // wektor normalny dla płaszczyzny ruchu pantografu
|
||||||
auto const vUp = glm::make_vec3( Vehicle->VectorUp().getArray() ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
auto const vUp = glm::make_vec3( glm::value_ptr(Vehicle->VectorUp()) ); // wektor pionu pudła (pochylony od pionu na przechyłce)
|
||||||
auto const vLeft = glm::make_vec3( Vehicle->VectorLeft().getArray() ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
auto const vLeft = glm::make_vec3( glm::value_ptr(Vehicle->VectorLeft()) ); // wektor odległości w bok (odchylony od poziomu na przechyłce)
|
||||||
auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
auto const position = glm::dvec3 { Vehicle->GetPosition() }; // współrzędne środka pojazdu
|
||||||
|
|
||||||
for( int pantographindex = 0; pantographindex < Vehicle->iAnimType[ ANIM_PANTS ]; ++pantographindex ) {
|
for( int pantographindex = 0; pantographindex < Vehicle->iAnimType[ ANIM_PANTS ]; ++pantographindex ) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class TAnimValveGear
|
|||||||
class TAnimPant
|
class TAnimPant
|
||||||
{ // współczynniki do animacji pantografu
|
{ // współczynniki do animacji pantografu
|
||||||
public:
|
public:
|
||||||
Math3D::vector3 vPos; // Ra: współrzędne punktu zerowego pantografu (X dodatnie dla przedniego)
|
glm::dvec3 vPos; // Ra: współrzędne punktu zerowego pantografu (X dodatnie dla przedniego)
|
||||||
double fLenL1; // długość dolnego ramienia 1, odczytana z modelu
|
double fLenL1; // długość dolnego ramienia 1, odczytana z modelu
|
||||||
double fLenU1; // długość górnego ramienia 1, odczytana z modelu
|
double fLenU1; // długość górnego ramienia 1, odczytana z modelu
|
||||||
double fLenL2; // długość dolnego ramienia 2, odczytana z modelu
|
double fLenL2; // długość dolnego ramienia 2, odczytana z modelu
|
||||||
@@ -194,9 +194,9 @@ public:
|
|||||||
static bool bDynamicRemove; // moved from ground
|
static bool bDynamicRemove; // moved from ground
|
||||||
|
|
||||||
//private: // położenie pojazdu w świecie oraz parametry ruchu
|
//private: // położenie pojazdu w świecie oraz parametry ruchu
|
||||||
Math3D::vector3 vPosition; // Ra: pozycja pojazdu liczona zaraz po przesunięciu
|
glm::dvec3 vPosition; // Ra: pozycja pojazdu liczona zaraz po przesunięciu
|
||||||
Math3D::vector3 vCoulpler[ 2 ]; // współrzędne sprzęgów do liczenia zderzeń czołowych
|
glm::dvec3 vCoulpler[2]; // współrzędne sprzęgów do liczenia zderzeń czołowych
|
||||||
Math3D::vector3 vUp, vFront, vLeft; // wektory jednostkowe ustawienia pojazdu
|
glm::dvec3 vUp, vFront, vLeft; // wektory jednostkowe ustawienia pojazdu
|
||||||
int iDirection; // kierunek pojazdu względem czoła składu (1=zgodny,0=przeciwny)
|
int iDirection; // kierunek pojazdu względem czoła składu (1=zgodny,0=przeciwny)
|
||||||
TTrackShape ts; // parametry toru przekazywane do fizyki
|
TTrackShape ts; // parametry toru przekazywane do fizyki
|
||||||
TTrackParam tp; // parametry toru przekazywane do fizyki
|
TTrackParam tp; // parametry toru przekazywane do fizyki
|
||||||
@@ -204,7 +204,7 @@ public:
|
|||||||
TTrackFollower Axle1; // oś z tyłu (od sprzęgu 1)
|
TTrackFollower Axle1; // oś z tyłu (od sprzęgu 1)
|
||||||
int iAxleFirst; // numer pierwszej osi w kierunku ruchu (oś wiążąca pojazd z torem i wyzwalająca eventy)
|
int iAxleFirst; // numer pierwszej osi w kierunku ruchu (oś wiążąca pojazd z torem i wyzwalająca eventy)
|
||||||
float fAxleDist; // rozstaw wózków albo osi do liczenia proporcji zacienienia
|
float fAxleDist; // rozstaw wózków albo osi do liczenia proporcji zacienienia
|
||||||
Math3D::vector3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!!
|
glm::dvec3 modelRot; // obrot pudła względem świata - do przeanalizowania, czy potrzebne!!!
|
||||||
TDynamicObject * ABuFindNearestObject(glm::vec3 pos, TTrack *Track, TDynamicObject *MyPointer, int &CouplNr );
|
TDynamicObject * ABuFindNearestObject(glm::vec3 pos, TTrack *Track, TDynamicObject *MyPointer, int &CouplNr );
|
||||||
|
|
||||||
glm::dvec3 m_future_movement;
|
glm::dvec3 m_future_movement;
|
||||||
@@ -214,7 +214,7 @@ public:
|
|||||||
// parametry położenia pojazdu dostępne publicznie
|
// parametry położenia pojazdu dostępne publicznie
|
||||||
std::string asTrack; // nazwa toru początkowego; wywalić?
|
std::string asTrack; // nazwa toru początkowego; wywalić?
|
||||||
std::string asDestination; // dokąd pojazd ma być kierowany "(stacja):(tor)"
|
std::string asDestination; // dokąd pojazd ma być kierowany "(stacja):(tor)"
|
||||||
Math3D::matrix4x4 mMatrix; // macierz przekształcenia do renderowania modeli
|
glm::dmat4 mMatrix; // macierz przekształcenia do renderowania modeli
|
||||||
TMoverParameters *MoverParameters; // parametry fizyki ruchu oraz przeliczanie
|
TMoverParameters *MoverParameters; // parametry fizyki ruchu oraz przeliczanie
|
||||||
inline TDynamicObject *NextConnected() { return MoverParameters->Neighbours[ end::rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1)
|
inline TDynamicObject *NextConnected() { return MoverParameters->Neighbours[ end::rear ].vehicle; }; // pojazd podłączony od strony sprzęgu 1 (kabina -1)
|
||||||
inline TDynamicObject *PrevConnected() { return MoverParameters->Neighbours[ end::front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1)
|
inline TDynamicObject *PrevConnected() { return MoverParameters->Neighbours[ end::front ].vehicle; }; // pojazd podłączony od strony sprzęgu 0 (kabina 1)
|
||||||
@@ -304,7 +304,7 @@ private:
|
|||||||
void toggle_lights(); // switch light levels for registered interior sections
|
void toggle_lights(); // switch light levels for registered interior sections
|
||||||
private: // Ra: ciąg dalszy animacji, dopiero do ogarnięcia
|
private: // Ra: ciąg dalszy animacji, dopiero do ogarnięcia
|
||||||
// ABuWozki 060504
|
// ABuWozki 060504
|
||||||
Math3D::vector3 bogieRot[2]; // Obroty wozkow w/m korpusu
|
glm::dvec3 bogieRot[2]; // Obroty wozkow w/m korpusu
|
||||||
TSubModel *smBogie[2]; // Wyszukiwanie max 2 wozkow
|
TSubModel *smBogie[2]; // Wyszukiwanie max 2 wozkow
|
||||||
TSubModel *smWahacze[4]; // wahacze (np. nogi, dźwignia w drezynie)
|
TSubModel *smWahacze[4]; // wahacze (np. nogi, dźwignia w drezynie)
|
||||||
TSubModel *smBrakeMode; // Ra 15-01: nastawa hamulca też
|
TSubModel *smBrakeMode; // Ra 15-01: nastawa hamulca też
|
||||||
@@ -316,7 +316,7 @@ private:
|
|||||||
TSubModel *smBuforLewy[2];
|
TSubModel *smBuforLewy[2];
|
||||||
TSubModel *smBuforPrawy[2];
|
TSubModel *smBuforPrawy[2];
|
||||||
TAnimValveGear *pValveGear;
|
TAnimValveGear *pValveGear;
|
||||||
Math3D::vector3 vFloor; // podłoga dla ładunku
|
glm::dvec3 vFloor; // podłoga dla ładunku
|
||||||
public:
|
public:
|
||||||
TAnim *pants; // indeks obiektu animującego dla pantografu 0
|
TAnim *pants; // indeks obiektu animującego dla pantografu 0
|
||||||
TAnim *wipers; // wycieraczki
|
TAnim *wipers; // wycieraczki
|
||||||
@@ -644,7 +644,7 @@ private:
|
|||||||
TDynamicObject * ABuScanNearestObject(glm::vec3 pos, TTrack *Track, double ScanDir, double ScanDist,
|
TDynamicObject * ABuScanNearestObject(glm::vec3 pos, TTrack *Track, double ScanDir, double ScanDist,
|
||||||
int &CouplNr);
|
int &CouplNr);
|
||||||
TDynamicObject * GetFirstDynamic(int cpl_type, int cf = 1);
|
TDynamicObject * GetFirstDynamic(int cpl_type, int cf = 1);
|
||||||
void ABuSetModelShake( Math3D::vector3 mShake);
|
void ABuSetModelShake(glm::dvec3 mShake);
|
||||||
|
|
||||||
// McZapkie-010302
|
// McZapkie-010302
|
||||||
TController *Mechanik;
|
TController *Mechanik;
|
||||||
@@ -693,20 +693,20 @@ private:
|
|||||||
void Move(double fDistance);
|
void Move(double fDistance);
|
||||||
void FastMove(double fDistance);
|
void FastMove(double fDistance);
|
||||||
void RenderSounds();
|
void RenderSounds();
|
||||||
inline Math3D::vector3 GetPosition() const {
|
inline glm::dvec3 GetPosition() const {
|
||||||
return vPosition; };
|
return vPosition; };
|
||||||
// converts location from vehicle coordinates frame to world frame
|
// converts location from vehicle coordinates frame to world frame
|
||||||
inline Math3D::vector3 GetWorldPosition( Math3D::vector3 const &Location ) const {
|
inline glm::dvec3 GetWorldPosition( glm::dvec3 const &Location ) const {
|
||||||
return vPosition + mMatrix * Location; }
|
return vPosition + glm::dvec3(mMatrix * glm::dvec4(Location, 1.0)); }
|
||||||
// pobranie współrzędnych czoła
|
// pobranie współrzędnych czoła
|
||||||
inline Math3D::vector3 HeadPosition() const {
|
inline glm::dvec3 HeadPosition() const {
|
||||||
return vCoulpler[iDirection ^ 1]; };
|
return vCoulpler[iDirection ^ 1]; };
|
||||||
// pobranie współrzędnych tyłu
|
// pobranie współrzędnych tyłu
|
||||||
inline Math3D::vector3 RearPosition() const {
|
inline glm::dvec3 RearPosition() const {
|
||||||
return vCoulpler[iDirection]; };
|
return vCoulpler[iDirection]; };
|
||||||
inline Math3D::vector3 CouplerPosition( end const End ) const {
|
inline glm::dvec3 CouplerPosition( end const End ) const {
|
||||||
return vCoulpler[ End ]; }
|
return vCoulpler[ End ]; }
|
||||||
inline Math3D::vector3 AxlePositionGet() {
|
inline glm::dvec3 AxlePositionGet() {
|
||||||
return iAxleFirst ?
|
return iAxleFirst ?
|
||||||
Axle1.pPosition :
|
Axle1.pPosition :
|
||||||
Axle0.pPosition; };
|
Axle0.pPosition; };
|
||||||
@@ -722,16 +722,16 @@ private:
|
|||||||
( iAxleFirst ? Axle1.pPosition : Axle0.pPosition ) :
|
( iAxleFirst ? Axle1.pPosition : Axle0.pPosition ) :
|
||||||
( iAxleFirst ? Axle0.pPosition : Axle1.pPosition ) ); }
|
( iAxleFirst ? Axle0.pPosition : Axle1.pPosition ) ); }
|
||||||
*/
|
*/
|
||||||
inline Math3D::vector3 VectorFront() const {
|
inline glm::dvec3 VectorFront() const {
|
||||||
return vFront; };
|
return vFront; };
|
||||||
inline Math3D::vector3 VectorUp() const {
|
inline glm::dvec3 VectorUp() const {
|
||||||
return vUp; };
|
return vUp; };
|
||||||
inline Math3D::vector3 VectorLeft() const {
|
inline glm::dvec3 VectorLeft() const {
|
||||||
return vLeft; };
|
return vLeft; };
|
||||||
inline double const * Matrix() const {
|
inline double const * Matrix() const {
|
||||||
return mMatrix.readArray(); };
|
return glm::value_ptr(mMatrix); };
|
||||||
inline double * Matrix() {
|
inline double * Matrix() {
|
||||||
return mMatrix.getArray(); };
|
return glm::value_ptr(mMatrix); };
|
||||||
inline double GetVelocity() const {
|
inline double GetVelocity() const {
|
||||||
return MoverParameters->Vel; };
|
return MoverParameters->Vel; };
|
||||||
inline double GetLength() const {
|
inline double GetLength() const {
|
||||||
@@ -855,11 +855,11 @@ public:
|
|||||||
bool IsHunting { false };
|
bool IsHunting { false };
|
||||||
TSpring ShakeSpring;
|
TSpring ShakeSpring;
|
||||||
struct shake_state {
|
struct shake_state {
|
||||||
Math3D::vector3 velocity {}; // current shaking vector
|
glm::dvec3 velocity{}; // current shaking vector
|
||||||
Math3D::vector3 offset {}; // overall shake-driven offset from base position
|
glm::dvec3 offset{}; // overall shake-driven offset from base position
|
||||||
} ShakeState;
|
} ShakeState;
|
||||||
|
|
||||||
Math3D::vector3 modelShake;
|
glm::dvec3 modelShake;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ TTrain::TTrain() {
|
|||||||
fHaslerTimer = 0;
|
fHaslerTimer = 0;
|
||||||
DynamicSet(NULL); // ustawia wszystkie mv*
|
DynamicSet(NULL); // ustawia wszystkie mv*
|
||||||
//-----
|
//-----
|
||||||
pMechSittingPosition = Math3D::vector3(0, 0, 0); // ABu: 180404
|
pMechSittingPosition = glm::dvec3(0, 0, 0); // ABu: 180404
|
||||||
fTachoTimer = 0.0; // włączenie skoków wskazań prędkościomierza
|
fTachoTimer = 0.0; // włączenie skoków wskazań prędkościomierza
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -5122,10 +5122,10 @@ void TTrain::OnCommand_redmarkerstoggle( TTrain *Train, command_data const &Comm
|
|||||||
|
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
|
||||||
|
auto locationHead = vehicle->HeadPosition() - glm::dvec3(Command.location); // TODO: Maybe command_data should be dvec3?
|
||||||
|
auto locationRear = vehicle->RearPosition() - glm::dvec3(Command.location);
|
||||||
int const CouplNr {
|
int const CouplNr {
|
||||||
clamp(
|
clamp(vehicle->DirectionGet() * (glm::dot(locationHead, locationHead) > glm::dot(locationRear, locationRear) ?
|
||||||
vehicle->DirectionGet()
|
|
||||||
* ( Math3D::LengthSquared3( vehicle->HeadPosition() - Command.location ) > Math3D::LengthSquared3( vehicle->RearPosition() - Command.location ) ?
|
|
||||||
1 :
|
1 :
|
||||||
-1 ),
|
-1 ),
|
||||||
0, 1 ) }; // z [-1,1] zrobić [0,1]
|
0, 1 ) }; // z [-1,1] zrobić [0,1]
|
||||||
@@ -5147,11 +5147,11 @@ void TTrain::OnCommand_endsignalstoggle( TTrain *Train, command_data const &Comm
|
|||||||
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Command.location, 10, false, true ) ) };
|
auto *vehicle { std::get<TDynamicObject *>( simulation::Region->find_vehicle( Command.location, 10, false, true ) ) };
|
||||||
|
|
||||||
if( vehicle == nullptr ) { return; }
|
if( vehicle == nullptr ) { return; }
|
||||||
|
// TODO: Maybe command_data should be dvec3?
|
||||||
int const CouplNr {
|
int const CouplNr {
|
||||||
clamp(
|
clamp(
|
||||||
vehicle->DirectionGet()
|
vehicle->DirectionGet()
|
||||||
* ( Math3D::LengthSquared3( vehicle->HeadPosition() - Command.location ) > Math3D::LengthSquared3( vehicle->RearPosition() - Command.location ) ?
|
* ( Math3D::LengthSquared3( vehicle->HeadPosition() - glm::dvec3(Command.location) ) > Math3D::LengthSquared3( vehicle->RearPosition() - glm::dvec3(Command.location) ) ?
|
||||||
1 :
|
1 :
|
||||||
-1 ),
|
-1 ),
|
||||||
0, 1 ) }; // z [-1,1] zrobić [0,1]
|
0, 1 ) }; // z [-1,1] zrobić [0,1]
|
||||||
@@ -9449,7 +9449,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
{
|
{
|
||||||
*/
|
*/
|
||||||
// configure placement of sound emitters which aren't bound with any device model, and weren't placed manually
|
// configure placement of sound emitters which aren't bound with any device model, and weren't placed manually
|
||||||
auto const caboffset { glm::dvec3 { ( Cabine[ cabindex ].CabPos1 + Cabine[ cabindex ].CabPos2 ) * 0.5 } +glm::dvec3 { 0, 1, 0 } };
|
auto const caboffset { glm::dvec3 { ( Cabine[ cabindex ].CabPos1 + Cabine[ cabindex ].CabPos2 ) * 0.5f } +glm::dvec3 { 0, 1, 0 } };
|
||||||
// NOTE: since radiosound is an incomplete template not using std::optional it gets a special treatment
|
// NOTE: since radiosound is an incomplete template not using std::optional it gets a special treatment
|
||||||
if( m_radiosound.offset() == nullvector ) {
|
if( m_radiosound.offset() == nullvector ) {
|
||||||
m_radiosound.offset( btLampkaRadio.model_offset() );
|
m_radiosound.offset( btLampkaRadio.model_offset() );
|
||||||
@@ -9517,15 +9517,15 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Math3D::vector3 TTrain::MirrorPosition(bool lewe)
|
glm::dvec3 TTrain::MirrorPosition(bool lewe)
|
||||||
{ // zwraca współrzędne widoku kamery z lusterka
|
{ // zwraca współrzędne widoku kamery z lusterka
|
||||||
auto const shiftdirection { ( lewe ? -1 : 1 ) * ( iCabn == 2 ? 1 : -1 ) };
|
auto const shiftdirection { ( lewe ? -1 : 1 ) * ( iCabn == 2 ? 1 : -1 ) };
|
||||||
|
|
||||||
return DynamicObject->mMatrix
|
return DynamicObject->mMatrix *
|
||||||
* Math3D::vector3(
|
glm::dvec4(
|
||||||
mvOccupied->Dim.W * ( 0.5 * shiftdirection ) + ( 0.2 * shiftdirection ),
|
mvOccupied->Dim.W * ( 0.5 * shiftdirection ) + ( 0.2 * shiftdirection ),
|
||||||
1.5 + Cabine[iCabn].CabPos1.y,
|
1.5 + Cabine[iCabn].CabPos1.y,
|
||||||
interpolate( Cabine[ iCabn ].CabPos1.z , Cabine[ iCabn ].CabPos2.z, 0.5 ) );
|
interpolate( Cabine[ iCabn ].CabPos1.z , Cabine[ iCabn ].CabPos2.z, 0.5 ), 0.0 );
|
||||||
};
|
};
|
||||||
|
|
||||||
void TTrain::DynamicSet(TDynamicObject *d)
|
void TTrain::DynamicSet(TDynamicObject *d)
|
||||||
@@ -9697,23 +9697,23 @@ TTrain::MoveToVehicle(TDynamicObject *target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checks whether specified point is within boundaries of the active cab
|
// checks whether specified point is within boundaries of the active cab
|
||||||
bool
|
bool TTrain::point_inside(glm::dvec3 const Point) const
|
||||||
TTrain::point_inside( Math3D::vector3 const Point ) const {
|
{
|
||||||
|
|
||||||
return ( Point.x >= Cabine[ iCabn ].CabPos1.x ) && ( Point.x <= Cabine[ iCabn ].CabPos2.x )
|
return ( Point.x >= Cabine[ iCabn ].CabPos1.x ) && ( Point.x <= Cabine[ iCabn ].CabPos2.x )
|
||||||
&& ( Point.y >= Cabine[ iCabn ].CabPos1.y + 0.5 ) && ( Point.y <= Cabine[ iCabn ].CabPos2.y + 1.8 )
|
&& ( Point.y >= Cabine[ iCabn ].CabPos1.y + 0.5 ) && ( Point.y <= Cabine[ iCabn ].CabPos2.y + 1.8 )
|
||||||
&& ( Point.z >= Cabine[ iCabn ].CabPos1.z ) && ( Point.z <= Cabine[ iCabn ].CabPos2.z );
|
&& ( Point.z >= Cabine[ iCabn ].CabPos1.z ) && ( Point.z <= Cabine[ iCabn ].CabPos2.z );
|
||||||
}
|
}
|
||||||
|
|
||||||
Math3D::vector3
|
glm::dvec3 TTrain::clamp_inside(glm::dvec3 const &Point) const
|
||||||
TTrain::clamp_inside( Math3D::vector3 const &Point ) const {
|
{
|
||||||
|
|
||||||
if( DebugModeFlag ) { return Point; }
|
if( DebugModeFlag ) { return Point; }
|
||||||
|
|
||||||
return {
|
return {
|
||||||
clamp( Point.x, Cabine[ iCabn ].CabPos1.x, Cabine[ iCabn ].CabPos2.x ),
|
clamp( Point.x, (double)Cabine[ iCabn ].CabPos1.x, (double)Cabine[ iCabn ].CabPos2.x ),
|
||||||
clamp( Point.y, Cabine[ iCabn ].CabPos1.y + 0.5, Cabine[ iCabn ].CabPos2.y + 1.8 ),
|
clamp( Point.y, (double)Cabine[ iCabn ].CabPos1.y + 0.5, (double)Cabine[ iCabn ].CabPos2.y + 1.8 ),
|
||||||
clamp( Point.z, Cabine[ iCabn ].CabPos1.z, Cabine[ iCabn ].CabPos2.z ) };
|
clamp( Point.z, (double)Cabine[ iCabn ].CabPos1.z, (double)Cabine[ iCabn ].CabPos2.z ) };
|
||||||
}
|
}
|
||||||
|
|
||||||
const TTrain::screenentry_sequence& TTrain::get_screens() {
|
const TTrain::screenentry_sequence& TTrain::get_screens() {
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ public:
|
|||||||
TGauge &Gauge( int n = -1 ); // pobranie adresu obiektu
|
TGauge &Gauge( int n = -1 ); // pobranie adresu obiektu
|
||||||
TButton &Button( int n = -1 ); // pobranie adresu obiektu
|
TButton &Button( int n = -1 ); // pobranie adresu obiektu
|
||||||
// members
|
// members
|
||||||
Math3D::vector3 CabPos1 { 0, 1, 1 };
|
glm::vec3 CabPos1{0, 1, 1};
|
||||||
Math3D::vector3 CabPos2 { 0, 1, -1 };
|
glm::vec3 CabPos2{0, 1, -1};
|
||||||
bool bEnabled { false };
|
bool bEnabled { false };
|
||||||
bool bOccupied { true };
|
bool bOccupied { true };
|
||||||
/*
|
/*
|
||||||
@@ -153,11 +153,11 @@ class TTrain {
|
|||||||
// McZapkie-010302
|
// McZapkie-010302
|
||||||
bool Init(TDynamicObject *NewDynamicObject, bool e3d = false);
|
bool Init(TDynamicObject *NewDynamicObject, bool e3d = false);
|
||||||
|
|
||||||
inline
|
inline glm::dvec3 GetDirection() const
|
||||||
Math3D::vector3 GetDirection() const {
|
{
|
||||||
return DynamicObject->VectorFront(); };
|
return DynamicObject->VectorFront(); };
|
||||||
inline
|
inline glm::dvec3 GetUp() const
|
||||||
Math3D::vector3 GetUp() const {
|
{
|
||||||
return DynamicObject->VectorUp(); };
|
return DynamicObject->VectorUp(); };
|
||||||
inline
|
inline
|
||||||
std::string GetLabel( TSubModel const *Control ) const {
|
std::string GetLabel( TSubModel const *Control ) const {
|
||||||
@@ -847,9 +847,9 @@ public: // reszta może by?publiczna
|
|||||||
int iCabn { 0 }; // 0: mid, 1: front, 2: rear
|
int iCabn { 0 }; // 0: mid, 1: front, 2: rear
|
||||||
bool is_cab_initialized { false };
|
bool is_cab_initialized { false };
|
||||||
// McZapkie: do poruszania sie po kabinie
|
// McZapkie: do poruszania sie po kabinie
|
||||||
Math3D::vector3 pMechSittingPosition; // ABu 180404
|
glm::dvec3 pMechSittingPosition; // ABu 180404
|
||||||
Math3D::vector3 MirrorPosition( bool lewe );
|
glm::dvec3 MirrorPosition(bool lewe);
|
||||||
Math3D::vector3 pMechOffset; // base position of the driver in the cab
|
glm::dvec3 pMechOffset; // base position of the driver in the cab
|
||||||
glm::vec2 pMechViewAngle { 0.0, 0.0 }; // camera pitch and yaw values, preserved while in external view
|
glm::vec2 pMechViewAngle { 0.0, 0.0 }; // camera pitch and yaw values, preserved while in external view
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -927,8 +927,8 @@ private:
|
|||||||
void DynamicSet(TDynamicObject *d);
|
void DynamicSet(TDynamicObject *d);
|
||||||
void MoveToVehicle( TDynamicObject *target );
|
void MoveToVehicle( TDynamicObject *target );
|
||||||
// checks whether specified point is within boundaries of the active cab
|
// checks whether specified point is within boundaries of the active cab
|
||||||
bool point_inside( Math3D::vector3 const Point ) const;
|
bool point_inside(glm::dvec3 const Point) const;
|
||||||
Math3D::vector3 clamp_inside( Math3D::vector3 const &Point ) const;
|
glm::dvec3 clamp_inside(glm::dvec3 const &Point) const;
|
||||||
const screenentry_sequence & get_screens();
|
const screenentry_sequence & get_screens();
|
||||||
|
|
||||||
uint16_t id();
|
uint16_t id();
|
||||||
|
|||||||
Reference in New Issue
Block a user