mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 06:19:18 +02:00
merge
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -67,6 +67,7 @@ Debug/
|
|||||||
tmp/
|
tmp/
|
||||||
bin/
|
bin/
|
||||||
ipch/
|
ipch/
|
||||||
|
ref/
|
||||||
*.aps
|
*.aps
|
||||||
|
|
||||||
builds/
|
builds/
|
||||||
36
Camera.cpp
36
Camera.cpp
@@ -61,7 +61,7 @@ void TCamera::OnCursorMove(double x, double y)
|
|||||||
void TCamera::Update()
|
void TCamera::Update()
|
||||||
{
|
{
|
||||||
// ABu: zmiana i uniezaleznienie predkosci od FPS
|
// ABu: zmiana i uniezaleznienie predkosci od FPS
|
||||||
double a = (Global::shiftState ? 5.00 : 1.00);
|
double a = ( Global::shiftState ? 5.00 : 1.00);
|
||||||
if (Global::ctrlState)
|
if (Global::ctrlState)
|
||||||
a = a * 100;
|
a = a * 100;
|
||||||
// OldVelocity=Velocity;
|
// OldVelocity=Velocity;
|
||||||
@@ -75,40 +75,6 @@ void TCamera::Update()
|
|||||||
Velocity.y += a;
|
Velocity.y += a;
|
||||||
if (Console::Pressed(Global::Keys[k_MechDown]))
|
if (Console::Pressed(Global::Keys[k_MechDown]))
|
||||||
Velocity.y -= a;
|
Velocity.y -= a;
|
||||||
// McZapkie-170402: zeby nie bylo konfliktow
|
|
||||||
/*
|
|
||||||
if (Console::Pressed(VkKeyScan('d')))
|
|
||||||
Velocity.x+= a*Timer::GetDeltaTime();
|
|
||||||
if (Console::Pressed(VkKeyScan('a')))
|
|
||||||
Velocity.x-= a*Timer::GetDeltaTime();
|
|
||||||
if (Console::Pressed(VkKeyScan('w')))
|
|
||||||
Velocity.z-= a*Timer::GetDeltaTime();
|
|
||||||
if (Console::Pressed(VkKeyScan('s')))
|
|
||||||
Velocity.z+= a*Timer::GetDeltaTime();
|
|
||||||
|
|
||||||
if (Console::Pressed(GLFW_KEY_KP_4) || Console::Pressed(GLFW_KEY_KP_7) ||
|
|
||||||
Console::Pressed(GLFW_KEY_KP_1))
|
|
||||||
Yaw+= +1*M_PI*Timer::GetDeltaTime();
|
|
||||||
|
|
||||||
if (Console::Pressed(GLFW_KEY_KP_6) || Console::Pressed(GLFW_KEY_KP_9) ||
|
|
||||||
Console::Pressed(GLFW_KEY_KP_3))
|
|
||||||
Yaw+= -1*M_PI*Timer::GetDeltaTime();
|
|
||||||
|
|
||||||
if (Pressed(GLFW_KEY_KP_2) || Console::Pressed(GLFW_KEY_KP_1) ||
|
|
||||||
Console::Pressed(GLFW_KEY_KP_3))
|
|
||||||
Pitch+= -1*M_PI*Timer::GetDeltaTime();
|
|
||||||
|
|
||||||
if (Console::Pressed(GLFW_KEY_KP_8) || Console::Pressed(GLFW_KEY_KP_7) ||
|
|
||||||
Console::Pressed(GLFW_KEY_KP_9))
|
|
||||||
Pitch+= +1*M_PI*Timer::GetDeltaTime();
|
|
||||||
if (Console::Pressed(VkKeyScan('.')))
|
|
||||||
Roll+= -1*M_PI*Timer::GetDeltaTime();
|
|
||||||
if (Console::Pressed(VkKeyScan(',')))
|
|
||||||
Roll+= +1*M_PI*Timer::GetDeltaTime();
|
|
||||||
|
|
||||||
if (Console::Pressed(GLFW_KEY_KP_5))
|
|
||||||
Pitch=Roll= 0.0f;
|
|
||||||
*/
|
|
||||||
|
|
||||||
// McZapkie-170402: poruszanie i rozgladanie we free takie samo jak w follow
|
// McZapkie-170402: poruszanie i rozgladanie we free takie samo jak w follow
|
||||||
if (Console::Pressed(Global::Keys[k_MechRight]))
|
if (Console::Pressed(Global::Keys[k_MechRight]))
|
||||||
|
|||||||
6
DynObj.h
6
DynObj.h
@@ -444,7 +444,7 @@ public: // modele składowe pojazdu
|
|||||||
{
|
{
|
||||||
return vUp;
|
return vUp;
|
||||||
};
|
};
|
||||||
inline vector3 VectorLeft()
|
inline vector3 VectorLeft() const
|
||||||
{
|
{
|
||||||
return vLeft;
|
return vLeft;
|
||||||
};
|
};
|
||||||
@@ -460,7 +460,7 @@ public: // modele składowe pojazdu
|
|||||||
{
|
{
|
||||||
return MoverParameters->Dim.L;
|
return MoverParameters->Dim.L;
|
||||||
};
|
};
|
||||||
inline double GetWidth()
|
inline double GetWidth() const
|
||||||
{
|
{
|
||||||
return MoverParameters->Dim.W;
|
return MoverParameters->Dim.W;
|
||||||
};
|
};
|
||||||
@@ -473,7 +473,7 @@ public: // modele składowe pojazdu
|
|||||||
// McZapkie-260202
|
// McZapkie-260202
|
||||||
void LoadMMediaFile(std::string BaseDir, std::string TypeName, std::string ReplacableSkin);
|
void LoadMMediaFile(std::string BaseDir, std::string TypeName, std::string ReplacableSkin);
|
||||||
|
|
||||||
inline double ABuGetDirection() // ABu.
|
inline double ABuGetDirection() const // ABu.
|
||||||
{
|
{
|
||||||
return (Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection());
|
return (Axle1.GetTrack() == MyTrack ? Axle1.GetDirection() : Axle0.GetDirection());
|
||||||
};
|
};
|
||||||
|
|||||||
221
EU07.cpp
221
EU07.cpp
@@ -47,50 +47,81 @@ void cursor_pos_callback(GLFWwindow *window, double x, double y)
|
|||||||
glfwSetCursorPos(window, 0.0, 0.0);
|
glfwSetCursorPos(window, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
|
void key_callback( GLFWwindow *window, int key, int scancode, int action, int mods )
|
||||||
{
|
{
|
||||||
Global::shiftState = (mods & GLFW_MOD_SHIFT) ? true : false;
|
Global::shiftState = ( mods & GLFW_MOD_SHIFT ) ? true : false;
|
||||||
Global::ctrlState = (mods & GLFW_MOD_CONTROL) ? true : false;
|
Global::ctrlState = ( mods & GLFW_MOD_CONTROL ) ? true : false;
|
||||||
|
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT)
|
if( ( key == GLFW_KEY_LEFT_SHIFT )
|
||||||
{
|
|| ( key == GLFW_KEY_LEFT_CONTROL )
|
||||||
World.OnKeyDown(key);
|
|| ( key == GLFW_KEY_LEFT_ALT )
|
||||||
|
|| ( key == GLFW_KEY_RIGHT_SHIFT )
|
||||||
|
|| ( key == GLFW_KEY_RIGHT_CONTROL )
|
||||||
|
|| ( key == GLFW_KEY_RIGHT_ALT ) ) {
|
||||||
|
// don't bother passing these
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (key)
|
if( action == GLFW_PRESS || action == GLFW_REPEAT )
|
||||||
{
|
{
|
||||||
case GLFW_KEY_PAUSE:
|
World.OnKeyDown( key );
|
||||||
if (Global::iPause & 1)
|
|
||||||
Global::iPause &= ~1;
|
|
||||||
else if (!(Global::iMultiplayer & 2) &&
|
|
||||||
(mods & GLFW_MOD_CONTROL))
|
|
||||||
Global::iPause ^= 2;
|
|
||||||
if (Global::iPause)
|
|
||||||
Global::iTextMode = GLFW_KEY_F1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GLFW_KEY_F7:
|
switch( key )
|
||||||
Global::bWireFrame = !Global::bWireFrame;
|
{
|
||||||
++Global::iReCompile;
|
case GLFW_KEY_ESCAPE: {
|
||||||
break;
|
//[Esc] pauzuje tylko bez Debugmode
|
||||||
}
|
if( DebugModeFlag )
|
||||||
}
|
break;
|
||||||
else if (action == GLFW_RELEASE)
|
|
||||||
{
|
if( Global::iPause & 1 ) // jeśli pauza startowa
|
||||||
World.OnKeyUp(key);
|
Global::iPause &= ~1; // odpauzowanie, gdy po wczytaniu miało nie startować
|
||||||
}
|
else if( !( Global::iMultiplayer & 2 ) ) // w multiplayerze pauza nie ma sensu
|
||||||
|
if( !Global::ctrlState ) // z [Ctrl] to radiostop jest
|
||||||
|
Global::iPause ^= 2; // zmiana stanu zapauzowania
|
||||||
|
if( Global::iPause ) // jak pauza
|
||||||
|
Global::iTextMode = GLFW_KEY_F1; // to wyświetlić zegar i informację
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GLFW_KEY_F7:
|
||||||
|
if( DebugModeFlag ) { // siatki wyświetlane tyko w trybie testowym
|
||||||
|
Global::bWireFrame = !Global::bWireFrame;
|
||||||
|
if( true == Global::bWireFrame ) {
|
||||||
|
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
||||||
|
}
|
||||||
|
++Global::iReCompile; // odświeżyć siatki
|
||||||
|
// Ra: jeszcze usunąć siatki ze skompilowanych obiektów!
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( action == GLFW_RELEASE )
|
||||||
|
{
|
||||||
|
World.OnKeyUp( key );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void focus_callback(GLFWwindow *window, int focus)
|
void focus_callback( GLFWwindow *window, int focus )
|
||||||
{
|
{
|
||||||
if (Global::bInactivePause) // jeśli ma być pauzowanie okna w tle
|
if( Global::bInactivePause ) // jeśli ma być pauzowanie okna w tle
|
||||||
if (focus)
|
if( focus )
|
||||||
Global::iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie
|
Global::iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie
|
||||||
else
|
else
|
||||||
Global::iPause |= 4; // włączenie pauzy, gdy nieaktywy
|
Global::iPause |= 4; // włączenie pauzy, gdy nieaktywy
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
||||||
|
}
|
||||||
|
|
||||||
LONG CALLBACK unhandled_handler(::EXCEPTION_POINTERS* e);
|
LONG CALLBACK unhandled_handler(::EXCEPTION_POINTERS* e);
|
||||||
|
LRESULT APIENTRY WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
|
extern HWND Hwnd;
|
||||||
|
extern WNDPROC BaseWindowProc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -106,11 +137,11 @@ int main(int argc, char *argv[])
|
|||||||
Global::LoadIniFile("eu07.ini");
|
Global::LoadIniFile("eu07.ini");
|
||||||
Global::InitKeys();
|
Global::InitKeys();
|
||||||
|
|
||||||
// hunter-271211: ukrywanie konsoli
|
// hunter-271211: ukrywanie konsoli
|
||||||
if (Global::iWriteLogEnabled & 2)
|
if( Global::iWriteLogEnabled & 2 )
|
||||||
{
|
{
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
|
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN );
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
@@ -142,75 +173,85 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// match requested video mode to current to allow for
|
// match requested video mode to current to allow for
|
||||||
// fullwindow creation when resolution is the same
|
// fullwindow creation when resolution is the same
|
||||||
GLFWmonitor *monitor = glfwGetPrimaryMonitor();
|
GLFWmonitor *monitor = glfwGetPrimaryMonitor();
|
||||||
const GLFWvidmode *vmode = glfwGetVideoMode(monitor);
|
const GLFWvidmode *vmode = glfwGetVideoMode(monitor);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RED_BITS, vmode->redBits);
|
glfwWindowHint(GLFW_RED_BITS, vmode->redBits);
|
||||||
glfwWindowHint(GLFW_GREEN_BITS, vmode->greenBits);
|
glfwWindowHint(GLFW_GREEN_BITS, vmode->greenBits);
|
||||||
glfwWindowHint(GLFW_BLUE_BITS, vmode->blueBits);
|
glfwWindowHint(GLFW_BLUE_BITS, vmode->blueBits);
|
||||||
glfwWindowHint(GLFW_REFRESH_RATE, vmode->refreshRate);
|
glfwWindowHint(GLFW_REFRESH_RATE, vmode->refreshRate);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_SAMPLES, Global::iMultisampling);
|
glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_FALSE);
|
||||||
|
glfwWindowHint(GLFW_SAMPLES, 1 << Global::iMultisampling);
|
||||||
|
|
||||||
GLFWwindow *window =
|
if (Global::bFullScreen)
|
||||||
glfwCreateWindow(Global::iWindowWidth, Global::iWindowHeight,
|
|
||||||
"EU07++NG", Global::bFullScreen ? monitor : nullptr, nullptr);
|
|
||||||
|
|
||||||
if (!window)
|
|
||||||
{
|
{
|
||||||
std::cout << "failed to create window" << std::endl;
|
// match screen dimensions with selected monitor, for 'borderless window' in fullscreen mode
|
||||||
return -1;
|
Global::iWindowWidth = vmode->width;
|
||||||
}
|
Global::iWindowHeight = vmode->height;
|
||||||
glfwMakeContextCurrent(window);
|
}
|
||||||
glfwSwapInterval(1); //vsync
|
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); //capture cursor
|
GLFWwindow *window =
|
||||||
glfwSetCursorPos(window, 0.0, 0.0);
|
glfwCreateWindow( Global::iWindowWidth, Global::iWindowHeight,
|
||||||
glfwSetFramebufferSizeCallback(window, window_resize_callback);
|
"EU07++NG", Global::bFullScreen ? monitor : nullptr, nullptr );
|
||||||
glfwSetCursorPosCallback(window, cursor_pos_callback);
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
if (!window)
|
||||||
glfwSetWindowFocusCallback(window, focus_callback);
|
|
||||||
{
|
{
|
||||||
int width, height;
|
std::cout << "failed to create window" << std::endl;
|
||||||
glfwGetFramebufferSize(window, &width, &height);
|
return -1;
|
||||||
window_resize_callback(window, width, height);
|
}
|
||||||
}
|
glfwMakeContextCurrent(window);
|
||||||
|
glfwSwapInterval(Global::VSync ? 1 : 0); //vsync
|
||||||
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); //capture cursor
|
||||||
|
glfwSetCursorPos(window, 0.0, 0.0);
|
||||||
|
glfwSetFramebufferSizeCallback(window, window_resize_callback);
|
||||||
|
glfwSetCursorPosCallback(window, cursor_pos_callback);
|
||||||
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
glfwSetWindowFocusCallback(window, focus_callback);
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
glfwGetFramebufferSize(window, &width, &height);
|
||||||
|
window_resize_callback(window, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
if (glewInit() != GLEW_OK)
|
if (glewInit() != GLEW_OK)
|
||||||
{
|
{
|
||||||
std::cout << "failed to init GLEW" << std::endl;
|
std::cout << "failed to init GLEW" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
#ifdef _WINDOWS
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
// setup wrapper for base glfw window proc, to handle copydata messages
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
Hwnd = glfwGetWin32Window( window );
|
||||||
|
BaseWindowProc = (WNDPROC)::SetWindowLongPtr( Hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc );
|
||||||
|
// switch off the topmost flag
|
||||||
|
::SetWindowPos( Hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
|
||||||
|
#endif
|
||||||
|
|
||||||
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
|
GfxRenderer.Init();
|
||||||
if (!World.Init(window))
|
|
||||||
|
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
|
||||||
|
if (!World.Init(window))
|
||||||
{
|
{
|
||||||
std::cout << "failed to init TWorld" << std::endl;
|
std::cout << "failed to init TWorld" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxRenderer.Init();
|
|
||||||
Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoś zainicjowac trzeba
|
Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoś zainicjowac trzeba
|
||||||
|
|
||||||
if (!joyGetNumDevs())
|
if( !joyGetNumDevs() )
|
||||||
WriteLog("No joystick");
|
WriteLog( "No joystick" );
|
||||||
if (Global::iModifyTGA < 0)
|
if( Global::iModifyTGA < 0 ) { // tylko modyfikacja TGA, bez uruchamiania symulacji
|
||||||
{ // tylko modyfikacja TGA, bez uruchamiania symulacji
|
|
||||||
Global::iMaxTextureSize = 64; //żeby nie zamulać pamięci
|
Global::iMaxTextureSize = 64; //żeby nie zamulać pamięci
|
||||||
World.ModifyTGA(); // rekurencyjne przeglądanie katalogów
|
World.ModifyTGA(); // rekurencyjne przeglądanie katalogów
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if( Global::iConvertModels < 0 ) {
|
||||||
if (Global::iConvertModels < 0)
|
|
||||||
{
|
|
||||||
Global::iConvertModels = -Global::iConvertModels;
|
Global::iConvertModels = -Global::iConvertModels;
|
||||||
World.CreateE3D("models\\"); // rekurencyjne przeglądanie katalogów
|
World.CreateE3D( "models\\" ); // rekurencyjne przeglądanie katalogów
|
||||||
World.CreateE3D("dynamic\\", true);
|
World.CreateE3D( "dynamic\\", true );
|
||||||
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
|
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
|
||||||
|
|
||||||
Console::On(); // włączenie konsoli
|
Console::On(); // włączenie konsoli
|
||||||
@@ -222,8 +263,8 @@ int main(int argc, char *argv[])
|
|||||||
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
||||||
}
|
}
|
||||||
|
|
||||||
delete pConsole;
|
|
||||||
TPythonInterpreter::killInstance();
|
TPythonInterpreter::killInstance();
|
||||||
|
delete pConsole;
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
|||||||
88
Globals.cpp
88
Globals.cpp
@@ -123,6 +123,7 @@ int Global::iFeedbackMode = 1; // tryb pracy informacji zwrotnej
|
|||||||
int Global::iFeedbackPort = 0; // dodatkowy adres dla informacji zwrotnych
|
int Global::iFeedbackPort = 0; // dodatkowy adres dla informacji zwrotnych
|
||||||
bool Global::bFreeFly = false;
|
bool Global::bFreeFly = false;
|
||||||
bool Global::bFullScreen = false;
|
bool Global::bFullScreen = false;
|
||||||
|
bool Global::VSync{ true };
|
||||||
bool Global::bInactivePause = true; // automatyczna pauza, gdy okno nieaktywne
|
bool Global::bInactivePause = true; // automatyczna pauza, gdy okno nieaktywne
|
||||||
float Global::fMouseXScale = 1.5f;
|
float Global::fMouseXScale = 1.5f;
|
||||||
float Global::fMouseYScale = 0.2f;
|
float Global::fMouseYScale = 0.2f;
|
||||||
@@ -306,15 +307,18 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bFullScreen;
|
||||||
Global::bFullScreen = (token == "yes");
|
}
|
||||||
|
else if( token == "vsync" ) {
|
||||||
|
|
||||||
|
Parser.getTokens();
|
||||||
|
Parser >> Global::VSync;
|
||||||
}
|
}
|
||||||
else if (token == "freefly")
|
else if (token == "freefly")
|
||||||
{ // Mczapkie-130302
|
{ // Mczapkie-130302
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bFreeFly;
|
||||||
Global::bFreeFly = (token == "yes");
|
|
||||||
Parser.getTokens(3, false);
|
Parser.getTokens(3, false);
|
||||||
Parser >> Global::pFreeCameraInit[0].x, Global::pFreeCameraInit[0].y,
|
Parser >> Global::pFreeCameraInit[0].x, Global::pFreeCameraInit[0].y,
|
||||||
Global::pFreeCameraInit[0].z;
|
Global::pFreeCameraInit[0].z;
|
||||||
@@ -323,23 +327,20 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bWireFrame;
|
||||||
Global::bWireFrame = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "debugmode")
|
else if (token == "debugmode")
|
||||||
{ // McZapkie! - DebugModeFlag uzywana w mover.pas,
|
{ // McZapkie! - DebugModeFlag uzywana w mover.pas,
|
||||||
// warto tez blokowac cheaty gdy false
|
// warto tez blokowac cheaty gdy false
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> DebugModeFlag;
|
||||||
DebugModeFlag = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "soundenabled")
|
else if (token == "soundenabled")
|
||||||
{ // McZapkie-040302 - blokada dzwieku - przyda
|
{ // McZapkie-040302 - blokada dzwieku - przyda
|
||||||
// sie do debugowania oraz na komp. bez karty
|
// sie do debugowania oraz na komp. bez karty
|
||||||
// dzw.
|
// dzw.
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bSoundEnabled;
|
||||||
Global::bSoundEnabled = (token == "yes");
|
|
||||||
}
|
}
|
||||||
// else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
|
// else if (str==AnsiString("renderalpha")) //McZapkie-1312302 - dwuprzebiegowe renderowanie
|
||||||
// bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));
|
// bRenderAlpha=(GetNextSymbol().LowerCase()==AnsiString("yes"));
|
||||||
@@ -347,15 +348,13 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{ // McZapkie-030402 - logowanie parametrow
|
{ // McZapkie-030402 - logowanie parametrow
|
||||||
// fizycznych dla kazdego pojazdu z maszynista
|
// fizycznych dla kazdego pojazdu z maszynista
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> WriteLogFlag;
|
||||||
WriteLogFlag = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "physicsdeactivation")
|
else if (token == "physicsdeactivation")
|
||||||
{ // McZapkie-291103 - usypianie fizyki
|
{ // McZapkie-291103 - usypianie fizyki
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> PhysicActivationFlag;
|
||||||
PhysicActivationFlag = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "debuglog")
|
else if (token == "debuglog")
|
||||||
{
|
{
|
||||||
@@ -379,8 +378,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// McZapkie-240403 - czestotliwosc odswiezania ekranu
|
// McZapkie-240403 - czestotliwosc odswiezania ekranu
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bAdjustScreenFreq;
|
||||||
Global::bAdjustScreenFreq = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "mousescale")
|
else if (token == "mousescale")
|
||||||
{
|
{
|
||||||
@@ -392,15 +390,13 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// Winger 040204 - 'zywe' patyki dostosowujace sie do trakcji; Ra 2014-03: teraz łamanie
|
// Winger 040204 - 'zywe' patyki dostosowujace sie do trakcji; Ra 2014-03: teraz łamanie
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bEnableTraction;
|
||||||
Global::bEnableTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "loadtraction")
|
else if (token == "loadtraction")
|
||||||
{
|
{
|
||||||
// Winger 140404 - ladowanie sie trakcji
|
// Winger 140404 - ladowanie sie trakcji
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bLoadTraction;
|
||||||
Global::bLoadTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "friction")
|
else if (token == "friction")
|
||||||
{ // mnożnik tarcia - KURS90
|
{ // mnożnik tarcia - KURS90
|
||||||
@@ -413,8 +409,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
// Winger 160404 - zaleznosc napiecia loka od trakcji;
|
// Winger 160404 - zaleznosc napiecia loka od trakcji;
|
||||||
// Ra 2014-03: teraz prąd przy braku sieci
|
// Ra 2014-03: teraz prąd przy braku sieci
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bLiveTraction;
|
||||||
Global::bLiveTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "skyenabled")
|
else if (token == "skyenabled")
|
||||||
{
|
{
|
||||||
@@ -427,15 +422,13 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bManageNodes;
|
||||||
Global::bManageNodes = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "decompressdds")
|
else if (token == "decompressdds")
|
||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bDecompressDDS;
|
||||||
Global::bDecompressDDS = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "defaultext")
|
else if (token == "defaultext")
|
||||||
{
|
{
|
||||||
@@ -458,8 +451,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bnewAirCouplers;
|
||||||
Global::bnewAirCouplers = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "defaultfiltering")
|
else if (token == "defaultfiltering")
|
||||||
{
|
{
|
||||||
@@ -495,7 +487,10 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> token;
|
||||||
|
/*
|
||||||
Global::bUseVBO = (token == "yes");
|
Global::bUseVBO = (token == "yes");
|
||||||
|
*/
|
||||||
|
Global::bUseVBO = false; // temporarily disabled until render paths are sorted out
|
||||||
}
|
}
|
||||||
else if (token == "feedbackmode")
|
else if (token == "feedbackmode")
|
||||||
{
|
{
|
||||||
@@ -562,8 +557,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// podwójna jasność ambient
|
// podwójna jasność ambient
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bDoubleAmbient;
|
||||||
Global::bDoubleAmbient = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "movelight")
|
else if (token == "movelight")
|
||||||
{
|
{
|
||||||
@@ -589,8 +583,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// podwójna jasność ambient
|
// podwójna jasność ambient
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bSmoothTraction;
|
||||||
Global::bSmoothTraction = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "timespeed")
|
else if (token == "timespeed")
|
||||||
{
|
{
|
||||||
@@ -608,8 +601,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// tekst generowany przez GLUT
|
// tekst generowany przez GLUT
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bGlutFont;
|
||||||
Global::bGlutFont = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "latitude")
|
else if (token == "latitude")
|
||||||
{
|
{
|
||||||
@@ -627,8 +619,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// automatyczna pauza, gdy okno nieaktywne
|
// automatyczna pauza, gdy okno nieaktywne
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bInactivePause;
|
||||||
Global::bInactivePause = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "slowmotion")
|
else if (token == "slowmotion")
|
||||||
{
|
{
|
||||||
@@ -646,22 +637,19 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// hunter-271211: ukrywanie konsoli
|
// hunter-271211: ukrywanie konsoli
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bHideConsole;
|
||||||
Global::bHideConsole = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "oldsmudge")
|
else if (token == "oldsmudge")
|
||||||
{
|
{
|
||||||
|
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bOldSmudge;
|
||||||
Global::bOldSmudge = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "rollfix")
|
else if (token == "rollfix")
|
||||||
{
|
{
|
||||||
// Ra: poprawianie przechyłki, aby wewnętrzna szyna była "pozioma"
|
// Ra: poprawianie przechyłki, aby wewnętrzna szyna była "pozioma"
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bRollFix;
|
||||||
Global::bRollFix = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "fpsaverage")
|
else if (token == "fpsaverage")
|
||||||
{
|
{
|
||||||
@@ -786,8 +774,7 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
{
|
{
|
||||||
// czy grupować eventy o tych samych nazwach
|
// czy grupować eventy o tych samych nazwach
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> Global::bJoinEvents;
|
||||||
Global::bJoinEvents = (token == "yes");
|
|
||||||
}
|
}
|
||||||
else if (token == "hiddenevents")
|
else if (token == "hiddenevents")
|
||||||
{
|
{
|
||||||
@@ -832,14 +819,12 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
// maciek001: ustawienia MWD
|
// maciek001: ustawienia MWD
|
||||||
else if (token == "mwdmasterenable") { // główne włączenie maszyny!
|
else if (token == "mwdmasterenable") { // główne włączenie maszyny!
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDmasterEnable;
|
||||||
bMWDmasterEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable) WriteLog("SerialPort Master Enable");
|
if (bMWDdebugEnable) WriteLog("SerialPort Master Enable");
|
||||||
}
|
}
|
||||||
else if (token == "mwddebugenable") { // logowanie pracy
|
else if (token == "mwddebugenable") { // logowanie pracy
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDdebugEnable;
|
||||||
bMWDdebugEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable) WriteLog("MWD Debug Mode On");
|
if (bMWDdebugEnable) WriteLog("MWD Debug Mode On");
|
||||||
}
|
}
|
||||||
else if (token == "mwddebugmode") { // co ma być debugowane?
|
else if (token == "mwddebugmode") { // co ma być debugowane?
|
||||||
@@ -859,14 +844,12 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
}
|
}
|
||||||
else if (token == "mwdinputenable") { // włącz wejścia
|
else if (token == "mwdinputenable") { // włącz wejścia
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDInputEnable;
|
||||||
bMWDInputEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable && bMWDInputEnable) WriteLog("MWD Input Enable");
|
if (bMWDdebugEnable && bMWDInputEnable) WriteLog("MWD Input Enable");
|
||||||
}
|
}
|
||||||
else if (token == "mwdbreakenable") { // włącz obsługę hamulców
|
else if (token == "mwdbreakenable") { // włącz obsługę hamulców
|
||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> token;
|
Parser >> bMWDBreakEnable;
|
||||||
bMWDBreakEnable = (token == "yes");
|
|
||||||
if (bMWDdebugEnable && bMWDBreakEnable) WriteLog("MWD Break Enable");
|
if (bMWDdebugEnable && bMWDBreakEnable) WriteLog("MWD Break Enable");
|
||||||
}
|
}
|
||||||
else if (token == "mwdmainbreakconfig") { // ustawienia hamulca zespolonego
|
else if (token == "mwdmainbreakconfig") { // ustawienia hamulca zespolonego
|
||||||
@@ -1063,6 +1046,7 @@ void Global::InitKeys()
|
|||||||
Keys[k_Univ3] = ';';
|
Keys[k_Univ3] = ';';
|
||||||
Keys[k_Univ4] = '\'';
|
Keys[k_Univ4] = '\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
vector3 Global::GetCameraPosition()
|
vector3 Global::GetCameraPosition()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ class Global
|
|||||||
static float fDistanceFactor;
|
static float fDistanceFactor;
|
||||||
static int iBpp;
|
static int iBpp;
|
||||||
static bool bFullScreen;
|
static bool bFullScreen;
|
||||||
|
static bool VSync;
|
||||||
static bool bFreeFly;
|
static bool bFreeFly;
|
||||||
// float RunningTime;
|
// float RunningTime;
|
||||||
static bool bWireFrame;
|
static bool bWireFrame;
|
||||||
|
|||||||
38
Ground.cpp
38
Ground.cpp
@@ -16,8 +16,6 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Ground.h"
|
#include "Ground.h"
|
||||||
|
|
||||||
#include "GL/glew.h"
|
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Logs.h"
|
#include "Logs.h"
|
||||||
#include "usefull.h"
|
#include "usefull.h"
|
||||||
@@ -42,6 +40,11 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#define _PROBLEND 1
|
#define _PROBLEND 1
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
GLFWAPI HWND glfwGetWin32Window( GLFWwindow* window ); //m7todo: potrzebne do directsound
|
||||||
|
}
|
||||||
|
|
||||||
bool bCondition; // McZapkie: do testowania warunku na event multiple
|
bool bCondition; // McZapkie: do testowania warunku na event multiple
|
||||||
string LogComment;
|
string LogComment;
|
||||||
|
|
||||||
@@ -2499,11 +2502,11 @@ void TGround::FirstInit()
|
|||||||
WriteLog("FirstInit is done");
|
WriteLog("FirstInit is done");
|
||||||
};
|
};
|
||||||
|
|
||||||
bool TGround::Init(std::string asFile)
|
bool TGround::Init(std::string File)
|
||||||
{ // główne wczytywanie scenerii
|
{ // główne wczytywanie scenerii
|
||||||
if (ToLower(asFile).substr(0, 7) == "scenery")
|
if (ToLower(File).substr(0, 7) == "scenery")
|
||||||
asFile = asFile.erase(0, 8); // Ra: usunięcie niepotrzebnych znaków - zgodność wstecz z 2003
|
File = File.erase(0, 8); // Ra: usunięcie niepotrzebnych znaków - zgodność wstecz z 2003
|
||||||
WriteLog("Loading scenery from " + asFile);
|
WriteLog("Loading scenery from " + File);
|
||||||
Global::pGround = this;
|
Global::pGround = this;
|
||||||
// pTrain=NULL;
|
// pTrain=NULL;
|
||||||
pOrigin = aRotate = vector3(0, 0, 0); // zerowanie przesunięcia i obrotu
|
pOrigin = aRotate = vector3(0, 0, 0); // zerowanie przesunięcia i obrotu
|
||||||
@@ -2511,7 +2514,7 @@ bool TGround::Init(std::string asFile)
|
|||||||
// TFileStream *fs;
|
// TFileStream *fs;
|
||||||
// int size;
|
// int size;
|
||||||
std::string subpath = Global::asCurrentSceneryPath; // "scenery/";
|
std::string subpath = Global::asCurrentSceneryPath; // "scenery/";
|
||||||
cParser parser(asFile, cParser::buffer_FILE, subpath, Global::bLoadTraction);
|
cParser parser(File, cParser::buffer_FILE, subpath, Global::bLoadTraction);
|
||||||
std::string token;
|
std::string token;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -5021,6 +5024,7 @@ bool TGround::RenderAlphaVBO(vector3 pPosition)
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
void TGround::Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam)
|
void TGround::Navigate(std::string const &ClassName, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{ // wysłanie komunikatu do sterującego
|
{ // wysłanie komunikatu do sterującego
|
||||||
@@ -5044,8 +5048,7 @@ void TGround::WyslijEvent(const std::string &e, const std::string &d)
|
|||||||
cData.dwData = 'EU07'; // sygnatura
|
cData.dwData = 'EU07'; // sygnatura
|
||||||
cData.cbData = (DWORD)(12 + i + j); // 8+dwa liczniki i dwa zera kończące
|
cData.cbData = (DWORD)(12 + i + j); // 8+dwa liczniki i dwa zera kończące
|
||||||
cData.lpData = &r;
|
cData.lpData = &r;
|
||||||
//m7todo
|
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||||
//Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData);
|
|
||||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + e + " sent" );
|
CommLog( Now() + " " + std::to_string(r.iComm) + " " + e + " sent" );
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -5062,8 +5065,7 @@ void TGround::WyslijUszkodzenia(const std::string &t, char fl)
|
|||||||
cData.dwData = 'EU07'; // sygnatura
|
cData.dwData = 'EU07'; // sygnatura
|
||||||
cData.cbData = (DWORD)(11 + i); // 8+licznik i zero kończące
|
cData.cbData = (DWORD)(11 + i); // 8+licznik i zero kończące
|
||||||
cData.lpData = &r;
|
cData.lpData = &r;
|
||||||
//m7todo
|
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||||
//Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData);
|
|
||||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent");
|
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent");
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -5079,8 +5081,7 @@ void TGround::WyslijString(const std::string &t, int n)
|
|||||||
cData.dwData = 'EU07'; // sygnatura
|
cData.dwData = 'EU07'; // sygnatura
|
||||||
cData.cbData = (DWORD)(10 + i); // 8+licznik i zero kończące
|
cData.cbData = (DWORD)(10 + i); // 8+licznik i zero kończące
|
||||||
cData.lpData = &r;
|
cData.lpData = &r;
|
||||||
//m7todo
|
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||||
//Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData);
|
|
||||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent");
|
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t + " sent");
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -5160,8 +5161,7 @@ void TGround::WyslijNamiary(TGroundNode *t)
|
|||||||
cData.cbData = (DWORD)(10 + i + j); // 8+licznik i zero kończące
|
cData.cbData = (DWORD)(10 + i + j); // 8+licznik i zero kończące
|
||||||
cData.lpData = &r;
|
cData.lpData = &r;
|
||||||
// WriteLog("Ramka gotowa");
|
// WriteLog("Ramka gotowa");
|
||||||
//m7todo
|
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||||
//Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData);
|
|
||||||
// WriteLog("Ramka poszla!");
|
// WriteLog("Ramka poszla!");
|
||||||
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t->asName + " sent");
|
CommLog( Now() + " " + std::to_string(r.iComm) + " " + t->asName + " sent");
|
||||||
};
|
};
|
||||||
@@ -5204,8 +5204,7 @@ void TGround::WyslijObsadzone()
|
|||||||
cData.cbData = 8 + 1984; // 8+licznik i zero kończące
|
cData.cbData = 8 + 1984; // 8+licznik i zero kończące
|
||||||
cData.lpData = &r;
|
cData.lpData = &r;
|
||||||
// WriteLog("Ramka gotowa");
|
// WriteLog("Ramka gotowa");
|
||||||
//m7todo
|
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||||
//Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData);
|
|
||||||
CommLog( Now() + " " + std::to_string(r.iComm) + " obsadzone" + " sent");
|
CommLog( Now() + " " + std::to_string(r.iComm) + " obsadzone" + " sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5229,9 +5228,10 @@ void TGround::WyslijParam(int nr, int fl)
|
|||||||
cData.dwData = 'EU07'; // sygnatura
|
cData.dwData = 'EU07'; // sygnatura
|
||||||
cData.cbData = 12 + i; // 12+rozmiar danych
|
cData.cbData = 12 + i; // 12+rozmiar danych
|
||||||
cData.lpData = &r;
|
cData.lpData = &r;
|
||||||
//m7todo
|
Navigate( "TEU07SRK", WM_COPYDATA, (WPARAM)glfwGetWin32Window( Global::window ), (LPARAM)&cData );
|
||||||
//Navigate("TEU07SRK", WM_COPYDATA, (WPARAM)Global::hWnd, (LPARAM)&cData);
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
2
Ground.h
2
Ground.h
@@ -323,7 +323,7 @@ class TGround
|
|||||||
TGround();
|
TGround();
|
||||||
~TGround();
|
~TGround();
|
||||||
void Free();
|
void Free();
|
||||||
bool Init(std::string asFile);
|
bool Init( std::string File );
|
||||||
void FirstInit();
|
void FirstInit();
|
||||||
void InitTracks();
|
void InitTracks();
|
||||||
void InitTraction();
|
void InitTraction();
|
||||||
|
|||||||
@@ -3005,98 +3005,105 @@ void TMoverParameters::UpdatePipePressure(double dt)
|
|||||||
|
|
||||||
// if (Hamulec is typeid(TWest)) return 0;
|
// if (Hamulec is typeid(TWest)) return 0;
|
||||||
|
|
||||||
switch (BrakeValve)
|
switch (BrakeValve) {
|
||||||
{
|
|
||||||
case W:
|
case K:
|
||||||
{
|
case W: {
|
||||||
if (BrakeLocHandle != NoHandle)
|
|
||||||
|
if( BrakeLocHandle != NoHandle ) {
|
||||||
|
LocBrakePress = LocHandle->GetCP();
|
||||||
|
|
||||||
|
//(Hamulec as TWest).SetLBP(LocBrakePress);
|
||||||
|
Hamulec->SetLBP( LocBrakePress );
|
||||||
|
}
|
||||||
|
if( MBPM < 2 )
|
||||||
|
//(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag])
|
||||||
|
Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
|
||||||
|
else
|
||||||
|
//(Hamulec as TWest).PLC(TotalMass);
|
||||||
|
Hamulec->PLC( TotalMass );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LSt:
|
||||||
|
case EStED: {
|
||||||
|
|
||||||
|
LocBrakePress = LocHandle->GetCP();
|
||||||
|
for( int b = 0; b < 2; b++ )
|
||||||
|
if( ( ( TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) &&
|
||||||
|
( Couplers[ b ].Connected != NULL ) ) // nie podoba mi się to rozwiązanie, chyba trzeba
|
||||||
|
// dodać jakiś wpis do fizyki na to
|
||||||
|
if( ( ( Couplers[ b ].Connected->TrainType & ( dt_ET41 | dt_ET42 ) ) != 0 ) &&
|
||||||
|
( ( Couplers[ b ].CouplingFlag & 36 ) == 36 ) )
|
||||||
|
LocBrakePress = Max0R( Couplers[ b ].Connected->LocHandle->GetCP(), LocBrakePress );
|
||||||
|
|
||||||
|
//if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor))
|
||||||
|
//{
|
||||||
|
// //if (Vel > 10)
|
||||||
|
// // LocBrakePress = 0;
|
||||||
|
// //else if (Vel > 5)
|
||||||
|
// // LocBrakePress = (10 - Vel) / 5 * LocBrakePress;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//(Hamulec as TLSt).SetLBP(LocBrakePress);
|
||||||
|
Hamulec->SetLBP( LocBrakePress );
|
||||||
|
if( ( BrakeValve == EStED ) )
|
||||||
|
if( MBPM < 2 )
|
||||||
|
Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
|
||||||
|
else
|
||||||
|
Hamulec->PLC( TotalMass );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CV1_L_TR:
|
||||||
{
|
{
|
||||||
LocBrakePress = LocHandle->GetCP();
|
LocBrakePress = LocHandle->GetCP();
|
||||||
|
//(Hamulec as TCV1L_TR).SetLBP(LocBrakePress);
|
||||||
//(Hamulec as TWest).SetLBP(LocBrakePress);
|
Hamulec->SetLBP( LocBrakePress );
|
||||||
Hamulec->SetLBP(LocBrakePress);
|
break;
|
||||||
}
|
}
|
||||||
if (MBPM < 2)
|
|
||||||
//(Hamulec as TWest).PLC(MaxBrakePress[LoadFlag])
|
|
||||||
Hamulec->PLC(MaxBrakePress[LoadFlag]);
|
|
||||||
else
|
|
||||||
//(Hamulec as TWest).PLC(TotalMass);
|
|
||||||
Hamulec->PLC(TotalMass);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case LSt:
|
case EP2:
|
||||||
case EStED:
|
{
|
||||||
{
|
Hamulec->PLC( TotalMass );
|
||||||
LocBrakePress = LocHandle->GetCP();
|
break;
|
||||||
for (int b = 0; b < 2; b++)
|
}
|
||||||
if (((TrainType & (dt_ET41 | dt_ET42)) != 0) &&
|
case ESt3AL2:
|
||||||
(Couplers[b].Connected != NULL)) // nie podoba mi się to rozwiązanie, chyba trzeba
|
case NESt3:
|
||||||
// dodać jakiś wpis do fizyki na to
|
case ESt4:
|
||||||
if (((Couplers[b].Connected->TrainType & (dt_ET41 | dt_ET42)) != 0) &&
|
case ESt3:
|
||||||
((Couplers[b].CouplingFlag & 36) == 36))
|
{
|
||||||
LocBrakePress = Max0R(Couplers[b].Connected->LocHandle->GetCP(), LocBrakePress);
|
if( MBPM < 2 )
|
||||||
|
//(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag])
|
||||||
//if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor))
|
Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
|
||||||
//{
|
else
|
||||||
// //if (Vel > 10)
|
//(Hamulec as TNESt3).PLC(TotalMass);
|
||||||
// // LocBrakePress = 0;
|
Hamulec->PLC( TotalMass );
|
||||||
// //else if (Vel > 5)
|
LocBrakePress = LocHandle->GetCP();
|
||||||
// // LocBrakePress = (10 - Vel) / 5 * LocBrakePress;
|
//(Hamulec as TNESt3).SetLBP(LocBrakePress);
|
||||||
//}
|
Hamulec->SetLBP( LocBrakePress );
|
||||||
|
break;
|
||||||
//(Hamulec as TLSt).SetLBP(LocBrakePress);
|
}
|
||||||
Hamulec->SetLBP(LocBrakePress);
|
case KE:
|
||||||
if ((BrakeValve == EStED))
|
{
|
||||||
if (MBPM < 2)
|
LocBrakePress = LocHandle->GetCP();
|
||||||
Hamulec->PLC(MaxBrakePress[LoadFlag]);
|
//(Hamulec as TKE).SetLBP(LocBrakePress);
|
||||||
else
|
Hamulec->SetLBP( LocBrakePress );
|
||||||
Hamulec->PLC(TotalMass);
|
if( MBPM < 2 )
|
||||||
break;
|
//(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag])
|
||||||
}
|
Hamulec->PLC( MaxBrakePress[ LoadFlag ] );
|
||||||
|
else
|
||||||
case CV1_L_TR:
|
//(Hamulec as TKE).PLC(TotalMass);
|
||||||
{
|
Hamulec->PLC( TotalMass );
|
||||||
LocBrakePress = LocHandle->GetCP();
|
break;
|
||||||
//(Hamulec as TCV1L_TR).SetLBP(LocBrakePress);
|
}
|
||||||
Hamulec->SetLBP(LocBrakePress);
|
default:
|
||||||
break;
|
{
|
||||||
}
|
// unsupported brake valve type, we should never land here
|
||||||
|
// ErrorLog( "Unsupported brake valve type (" + std::to_string( BrakeValve ) + ") in " + TypeName );
|
||||||
case EP2:
|
// ::PostQuitMessage( 0 );
|
||||||
{
|
break;
|
||||||
Hamulec->PLC(TotalMass);
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ESt3AL2:
|
|
||||||
case NESt3:
|
|
||||||
case ESt4:
|
|
||||||
case ESt3:
|
|
||||||
{
|
|
||||||
if (MBPM < 2)
|
|
||||||
//(Hamulec as TNESt3).PLC(MaxBrakePress[LoadFlag])
|
|
||||||
Hamulec->PLC(MaxBrakePress[LoadFlag]);
|
|
||||||
else
|
|
||||||
//(Hamulec as TNESt3).PLC(TotalMass);
|
|
||||||
Hamulec->PLC(TotalMass);
|
|
||||||
LocBrakePress = LocHandle->GetCP();
|
|
||||||
//(Hamulec as TNESt3).SetLBP(LocBrakePress);
|
|
||||||
Hamulec->SetLBP(LocBrakePress);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case KE:
|
|
||||||
{
|
|
||||||
LocBrakePress = LocHandle->GetCP();
|
|
||||||
//(Hamulec as TKE).SetLBP(LocBrakePress);
|
|
||||||
Hamulec->SetLBP(LocBrakePress);
|
|
||||||
if (MBPM < 2)
|
|
||||||
//(Hamulec as TKE).PLC(MaxBrakePress[LoadFlag])
|
|
||||||
Hamulec->PLC(MaxBrakePress[LoadFlag]);
|
|
||||||
else
|
|
||||||
//(Hamulec as TKE).PLC(TotalMass);
|
|
||||||
Hamulec->PLC(TotalMass);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
if ((BrakeHandle == FVel6) && (ActiveCab != 0))
|
if ((BrakeHandle == FVel6) && (ActiveCab != 0))
|
||||||
@@ -7252,8 +7259,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ( true == TestFlag( BrakeDelays, bdelay_G ) )
|
if ( ( true == TestFlag( BrakeDelays, bdelay_G ) )
|
||||||
&& ( false == TestFlag(BrakeDelays, bdelay_R) )
|
&& ( ( false == TestFlag(BrakeDelays, bdelay_R ) )
|
||||||
|| ( Power > 1.0 ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy
|
|| ( Power > 1.0 ) ) ) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy
|
||||||
Spg = 0.792;
|
Spg = 0.792;
|
||||||
else
|
else
|
||||||
Spg = 0.507;
|
Spg = 0.507;
|
||||||
|
|||||||
@@ -1800,7 +1800,7 @@ void TModel3d::SaveToBinFile(char const *FileName)
|
|||||||
Root->RaArrayFill(m_pVNT);
|
Root->RaArrayFill(m_pVNT);
|
||||||
sn_utils::ls_uint32(s, MAKE_ID4('V', 'N', 'T', '0'));
|
sn_utils::ls_uint32(s, MAKE_ID4('V', 'N', 'T', '0'));
|
||||||
sn_utils::ls_uint32(s, 8 + iNumVerts * 32);
|
sn_utils::ls_uint32(s, 8 + iNumVerts * 32);
|
||||||
for (size_t i = 0; i < iNumVerts; i++)
|
for (size_t i = 0; i < (size_t)iNumVerts; i++)
|
||||||
m_pVNT[i].serialize(s);
|
m_pVNT[i].serialize(s);
|
||||||
|
|
||||||
if (textures.size())
|
if (textures.size())
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Segment.h"
|
#include "Segment.h"
|
||||||
#include "GL/glew.h"
|
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Logs.h"
|
#include "Logs.h"
|
||||||
|
|||||||
@@ -703,6 +703,7 @@ texture_manager::GetTextureId( std::string Filename, std::string const &Dir, int
|
|||||||
|
|
||||||
if( true == filename.empty() ) {
|
if( true == filename.empty() ) {
|
||||||
// there's nothing matching in the databank nor on the disk, report failure
|
// there's nothing matching in the databank nor on the disk, report failure
|
||||||
|
ErrorLog( "Texture file missing: \"" + Filename + "\"" );
|
||||||
return npos;
|
return npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
42
Train.cpp
42
Train.cpp
@@ -671,7 +671,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
|
|||||||
dsbSwitch->Play(0, 0, 0); // dźwięk tylko po naciśnięciu klawisza
|
dsbSwitch->Play(0, 0, 0); // dźwięk tylko po naciśnięciu klawisza
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cKey == VkKeyScan('q')) // ze Shiftem - włączenie AI
|
else if (cKey == GLFW_KEY_Q) // ze Shiftem - włączenie AI
|
||||||
{ // McZapkie-240302 - wlaczanie automatycznego pilota (zadziala tylko w
|
{ // McZapkie-240302 - wlaczanie automatycznego pilota (zadziala tylko w
|
||||||
// trybie debugmode)
|
// trybie debugmode)
|
||||||
if (DynamicObject->Mechanik)
|
if (DynamicObject->Mechanik)
|
||||||
@@ -1661,7 +1661,7 @@ if ((mvControlled->PantFrontVolt) || (mvControlled->PantRearVolt) ||
|
|||||||
}
|
}
|
||||||
// McZapkie-240302 - wylaczanie automatycznego pilota (w trybie ~debugmode
|
// McZapkie-240302 - wylaczanie automatycznego pilota (w trybie ~debugmode
|
||||||
// mozna tylko raz)
|
// mozna tylko raz)
|
||||||
else if (cKey == VkKeyScan('q')) // bez Shift
|
else if (cKey == GLFW_KEY_Q) // bez Shift
|
||||||
{
|
{
|
||||||
if (DynamicObject->Mechanik)
|
if (DynamicObject->Mechanik)
|
||||||
DynamicObject->Mechanik->TakeControl(false);
|
DynamicObject->Mechanik->TakeControl(false);
|
||||||
@@ -2382,7 +2382,7 @@ if
|
|||||||
{
|
{
|
||||||
// McZapkie: poruszanie sie po kabinie, w updatemechpos zawarte sa wiezy
|
// McZapkie: poruszanie sie po kabinie, w updatemechpos zawarte sa wiezy
|
||||||
|
|
||||||
auto step = 60.0f * Timer::GetDeltaTime();
|
auto step = 1.5f;
|
||||||
auto const camerayaw = Global::pCamera->Yaw;
|
auto const camerayaw = Global::pCamera->Yaw;
|
||||||
Math3D::vector3 direction( 0.0f, 0.0f, step );
|
Math3D::vector3 direction( 0.0f, 0.0f, step );
|
||||||
direction.RotateY( camerayaw );
|
direction.RotateY( camerayaw );
|
||||||
@@ -2396,7 +2396,7 @@ if
|
|||||||
right *= -1.0f;
|
right *= -1.0f;
|
||||||
}
|
}
|
||||||
// if (!GetAsyncKeyState(VK_SHIFT)<0) // bez shifta
|
// if (!GetAsyncKeyState(VK_SHIFT)<0) // bez shifta
|
||||||
if (!(Global::ctrlState)) // gdy [Ctrl] zwolniony (dodatkowe widoki)
|
if (!Global::ctrlState) // gdy [Ctrl] zwolniony (dodatkowe widoki)
|
||||||
{
|
{
|
||||||
if (cKey == Global::Keys[k_MechLeft])
|
if (cKey == Global::Keys[k_MechLeft])
|
||||||
{
|
{
|
||||||
@@ -2441,7 +2441,7 @@ if
|
|||||||
if (DebugModeFlag)
|
if (DebugModeFlag)
|
||||||
{ // przesuwanie składu o 100m
|
{ // przesuwanie składu o 100m
|
||||||
TDynamicObject *d = DynamicObject;
|
TDynamicObject *d = DynamicObject;
|
||||||
if (cKey == VkKeyScan('['))
|
if (cKey == GLFW_KEY_LEFT_BRACKET)
|
||||||
{
|
{
|
||||||
while (d)
|
while (d)
|
||||||
{
|
{
|
||||||
@@ -2455,7 +2455,7 @@ if
|
|||||||
d = d->Prev(); // w drugą stronę też
|
d = d->Prev(); // w drugą stronę też
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (cKey == VkKeyScan(']'))
|
else if (cKey == GLFW_KEY_RIGHT_BRACKET)
|
||||||
{
|
{
|
||||||
while (d)
|
while (d)
|
||||||
{
|
{
|
||||||
@@ -2470,12 +2470,12 @@ if
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cKey == VkKeyScan('-'))
|
if (cKey == GLFW_KEY_MINUS)
|
||||||
{ // zmniejszenie numeru kanału radiowego
|
{ // zmniejszenie numeru kanału radiowego
|
||||||
if (iRadioChannel > 0)
|
if (iRadioChannel > 0)
|
||||||
--iRadioChannel; // 0=wyłączony
|
--iRadioChannel; // 0=wyłączony
|
||||||
}
|
}
|
||||||
else if (cKey == VkKeyScan('='))
|
else if (cKey == GLFW_KEY_EQUAL)
|
||||||
{ // zmniejszenie numeru kanału radiowego
|
{ // zmniejszenie numeru kanału radiowego
|
||||||
if (iRadioChannel < 8)
|
if (iRadioChannel < 8)
|
||||||
++iRadioChannel; // 0=wyłączony
|
++iRadioChannel; // 0=wyłączony
|
||||||
@@ -2546,6 +2546,7 @@ void TTrain::UpdateMechPosition(double dt)
|
|||||||
// shake *= 1.25;
|
// shake *= 1.25;
|
||||||
}
|
}
|
||||||
vMechVelocity -= (shake + vMechVelocity * 100) * (fMechSpringX + fMechSpringY + fMechSpringZ) / (200);
|
vMechVelocity -= (shake + vMechVelocity * 100) * (fMechSpringX + fMechSpringY + fMechSpringZ) / (200);
|
||||||
|
// vMechVelocity -= vMechVelocity * iVel * dt;
|
||||||
// shake *= 0.95 * dt; // shake damping
|
// shake *= 0.95 * dt; // shake damping
|
||||||
|
|
||||||
// McZapkie:
|
// McZapkie:
|
||||||
@@ -2556,15 +2557,15 @@ void TTrain::UpdateMechPosition(double dt)
|
|||||||
vMechVelocity.y = -vMechVelocity.y;
|
vMechVelocity.y = -vMechVelocity.y;
|
||||||
// ABu011104: 5*pMechShake.y, zeby ladnie pudlem rzucalo :)
|
// ABu011104: 5*pMechShake.y, zeby ladnie pudlem rzucalo :)
|
||||||
pNewMechPosition = pMechOffset + vector3(1.5 * pMechShake.x, 2.0 * pMechShake.y, 1.5 * pMechShake.z);
|
pNewMechPosition = pMechOffset + vector3(1.5 * pMechShake.x, 2.0 * pMechShake.y, 1.5 * pMechShake.z);
|
||||||
vMechMovement = 0.5 * vMechMovement;
|
// vMechMovement = 0.5 * vMechMovement;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // hamowanie rzucania przy spadku FPS
|
{ // hamowanie rzucania przy spadku FPS
|
||||||
pMechShake -= pMechShake * std::min(dt, 1.0); // po tym chyba potrafią zostać jakieś ułamki, które powodują zjazd
|
pMechShake -= pMechShake * std::min(dt, 1.0); // po tym chyba potrafią zostać jakieś ułamki, które powodują zjazd
|
||||||
pMechOffset += vMechMovement * dt;
|
pMechOffset += vMechMovement * dt;
|
||||||
vMechVelocity.y = 0.5 * vMechVelocity.y;
|
vMechVelocity.y -= vMechVelocity.y * 50.0 * dt;
|
||||||
pNewMechPosition = pMechOffset + vector3(pMechShake.x, 5 * pMechShake.y, pMechShake.z);
|
pNewMechPosition = pMechOffset + vector3(pMechShake.x, 5 * pMechShake.y, pMechShake.z);
|
||||||
vMechMovement = 0.5 * vMechMovement;
|
// vMechMovement = 0.5 * vMechMovement;
|
||||||
}
|
}
|
||||||
// numer kabiny (-1: kabina B)
|
// numer kabiny (-1: kabina B)
|
||||||
if (DynamicObject->Mechanik) // może nie być?
|
if (DynamicObject->Mechanik) // może nie być?
|
||||||
@@ -2611,6 +2612,21 @@ void TTrain::UpdateMechPosition(double dt)
|
|||||||
pMechPosition = DynamicObject->mMatrix *
|
pMechPosition = DynamicObject->mMatrix *
|
||||||
pNewMechPosition; // położenie względem środka pojazdu w układzie scenerii
|
pNewMechPosition; // położenie względem środka pojazdu w układzie scenerii
|
||||||
pMechPosition += DynamicObject->GetPosition();
|
pMechPosition += DynamicObject->GetPosition();
|
||||||
|
|
||||||
|
// framerate-independent speed reduction that doesn't break at high framerates...
|
||||||
|
Math3D::vector3 movementslowdown = vMechMovement * 35 * dt;
|
||||||
|
if( movementslowdown.LengthSquared() >= vMechMovement.LengthSquared() ) {
|
||||||
|
// if the reduction vector exceeds speed movement we're running at low fps,
|
||||||
|
// fallback on the old behaviour
|
||||||
|
vMechMovement *= 0.5;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
vMechMovement -= movementslowdown;
|
||||||
|
if( vMechMovement.LengthSquared() < 0.01 ) {
|
||||||
|
vMechMovement = Math3D::vector3();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool TTrain::Update( double const Deltatime )
|
bool TTrain::Update( double const Deltatime )
|
||||||
@@ -5039,10 +5055,10 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
//światło wewnętrzne przygaszone (255 216 176)
|
//światło wewnętrzne przygaszone (255 216 176)
|
||||||
if( mvOccupied->ConverterFlag == true ) {
|
if( mvOccupied->ConverterFlag == true ) {
|
||||||
// jasnosc dla zalaczonej przetwornicy
|
// jasnosc dla zalaczonej przetwornicy
|
||||||
DynamicObject->InteriorLightLevel = 0.75f;
|
DynamicObject->InteriorLightLevel = 0.4f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DynamicObject->InteriorLightLevel = 0.375f;
|
DynamicObject->InteriorLightLevel = 0.2f;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class TTrackFollower
|
|||||||
~TTrackFollower();
|
~TTrackFollower();
|
||||||
TTrack * SetCurrentTrack(TTrack *pTrack, int end);
|
TTrack * SetCurrentTrack(TTrack *pTrack, int end);
|
||||||
bool Move(double fDistance, bool bPrimary);
|
bool Move(double fDistance, bool bPrimary);
|
||||||
inline TTrack * GetTrack()
|
inline TTrack * GetTrack() const
|
||||||
{
|
{
|
||||||
return pCurrentTrack;
|
return pCurrentTrack;
|
||||||
};
|
};
|
||||||
@@ -43,7 +43,7 @@ class TTrackFollower
|
|||||||
return vAngles.x;
|
return vAngles.x;
|
||||||
}; // przechyłka policzona przy ustalaniu pozycji
|
}; // przechyłka policzona przy ustalaniu pozycji
|
||||||
//{return pCurrentSegment->GetRoll(fCurrentDistance)*fDirection;}; //zamiast liczyć można pobrać
|
//{return pCurrentSegment->GetRoll(fCurrentDistance)*fDirection;}; //zamiast liczyć można pobrać
|
||||||
inline double GetDirection()
|
inline double GetDirection() const
|
||||||
{
|
{
|
||||||
return fDirection;
|
return fDirection;
|
||||||
}; // zwrot na torze
|
}; // zwrot na torze
|
||||||
|
|||||||
256
World.cpp
256
World.cpp
@@ -90,22 +90,22 @@ void TWorld::TrainDelete(TDynamicObject *d)
|
|||||||
Global::pUserDynamic = NULL; // tego też nie ma
|
Global::pUserDynamic = NULL; // tego też nie ma
|
||||||
};
|
};
|
||||||
|
|
||||||
GLvoid TWorld::glPrint(const char *txt) // custom GL "Print" routine
|
GLvoid TWorld::glPrint( std::string const &Text ) // custom GL "Print" routine
|
||||||
{ // wypisywanie tekstu 2D na ekranie
|
{ // wypisywanie tekstu 2D na ekranie
|
||||||
//m7todo
|
if (Text.empty())
|
||||||
if (!txt)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Global::bGlutFont)
|
if (Global::bGlutFont)
|
||||||
{ // tekst generowany przez GLUT
|
{ // tekst generowany przez GLUT
|
||||||
size_t i, len = strlen(txt);
|
for (size_t i = 0; i < Text.size(); i++)
|
||||||
for (i = 0; i < len; i++)
|
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, Text[i]);
|
||||||
glutBitmapCharacter(GLUT_BITMAP_8_BY_13, txt[i]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
||||||
{ // generowanie przez Display Lists
|
{ // generowanie przez Display Lists
|
||||||
glPushAttrib(GL_LIST_BIT); // pushes the display list bits
|
glPushAttrib(GL_LIST_BIT); // pushes the display list bits
|
||||||
glListBase(base - 32); // sets the base character to 32
|
glListBase(base - 32); // sets the base character to 32
|
||||||
glCallLists((GLsizei)strlen(txt), GL_UNSIGNED_BYTE, txt); // draws the display list text
|
glCallLists((GLsizei)Text.size(), GL_UNSIGNED_BYTE, Text.c_str()); // draws the display list text
|
||||||
glPopAttrib(); // pops the display list bits
|
glPopAttrib(); // pops the display list bits
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ bool TWorld::Init(GLFWwindow *w)
|
|||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glClearDepth( 1.0f ); // ZBuffer Value
|
glClearDepth( 1.0f ); // ZBuffer Value
|
||||||
glClearColor( 51.0f / 255.0f, 106.0f / 255.0f, 85.0f / 255.0f, 1.0f ); // Background Color
|
glClearColor( 51.0f / 255.0f, 102.0f / 255.0f, 85.0f / 255.0f, 1.0f ); // Background Color
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Clear screen and depth buffer
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Clear screen and depth buffer
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
|
||||||
@@ -407,73 +407,46 @@ bool TWorld::Init(GLFWwindow *w)
|
|||||||
glTexCoord2f(0.0f, 1.0f);
|
glTexCoord2f(0.0f, 1.0f);
|
||||||
glVertex2f( -widthratio, 1.0f ); // top left of the texture and quad
|
glVertex2f( -widthratio, 1.0f ); // top left of the texture and quad
|
||||||
glEnd();
|
glEnd();
|
||||||
//~logo; Ra: to jest bez sensu zapis
|
|
||||||
glColor3f(0.0f, 0.0f, 1.0f);
|
glColor3f(0.0f, 0.0f, 0.0f);
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f(-0.85f * widthratio, -0.25f);
|
||||||
{
|
glPrint("Uruchamianie / Initializing...");
|
||||||
glRasterPos2f(-0.85f * widthratio, -0.25f);
|
glfwSwapBuffers( window );
|
||||||
glPrint("Uruchamianie / Initializing...");
|
|
||||||
glRasterPos2f(-0.85f * widthratio, -0.30f);
|
|
||||||
glPrint("Dzwiek / Sound...");
|
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
/*-----------------------Sound Initialization-----------------------*/
|
/*-----------------------Sound Initialization-----------------------*/
|
||||||
|
glRasterPos2f( -0.85f * widthratio, -0.30f );
|
||||||
|
glPrint( "Dzwiek / Sound..." );
|
||||||
|
|
||||||
TSoundsManager::Init(glfwGetWin32Window(window));
|
TSoundsManager::Init( glfwGetWin32Window( window ) );
|
||||||
|
|
||||||
// TSoundsManager::LoadSounds( "" );
|
|
||||||
/*---------------------Sound Initialization End---------------------*/
|
|
||||||
WriteLog("Sound Init OK");
|
WriteLog("Sound Init OK");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f(-0.25f * widthratio, -0.30f);
|
||||||
{
|
glPrint("OK.");
|
||||||
glRasterPos2f(-0.25f * widthratio, -0.30f);
|
glfwSwapBuffers( window );
|
||||||
glPrint("OK.");
|
/*---------------------Sound Initialization End---------------------*/
|
||||||
}
|
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
Paused = true;
|
|
||||||
WriteLog("Textures init");
|
WriteLog("Textures init");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f(-0.85f * widthratio, -0.35f);
|
||||||
{
|
glPrint("Tekstury / Textures...");
|
||||||
glRasterPos2f(-0.85f * widthratio, -0.35f);
|
glfwSwapBuffers( window );
|
||||||
glPrint("Tekstury / Textures...");
|
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
WriteLog("Textures init OK");
|
WriteLog("Textures init OK");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.25f * widthratio, -0.35f );
|
||||||
{
|
glPrint("OK.");
|
||||||
glRasterPos2f( -0.25f * widthratio, -0.35f );
|
glfwSwapBuffers( window );
|
||||||
glPrint("OK.");
|
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
WriteLog("Models init");
|
WriteLog("Models init");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.85f * widthratio, -0.40f );
|
||||||
{
|
glPrint("Modele / Models...");
|
||||||
glRasterPos2f( -0.85f * widthratio, -0.40f );
|
glfwSwapBuffers( window );
|
||||||
glPrint("Modele / Models...");
|
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
// McZapkie: dodalem sciezke zeby mozna bylo definiowac skad brac modele ale to malo eleganckie
|
|
||||||
// TModelsManager::LoadModels(asModelsPatch);
|
|
||||||
TModelsManager::Init();
|
TModelsManager::Init();
|
||||||
WriteLog("Models init OK");
|
WriteLog("Models init OK");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.25f * widthratio, -0.40f );
|
||||||
{
|
glPrint("OK.");
|
||||||
glRasterPos2f( -0.25f * widthratio, -0.40f );
|
glfwSwapBuffers( window );
|
||||||
glPrint("OK.");
|
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
WriteLog("Ground init");
|
WriteLog("Ground init");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.85f * widthratio, -0.45f );
|
||||||
{
|
glPrint("Sceneria / Scenery (please wait)...");
|
||||||
glRasterPos2f( -0.85f * widthratio, -0.45f );
|
glfwSwapBuffers( window );
|
||||||
glPrint("Sceneria / Scenery (please wait)...");
|
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
#ifndef EU07_USE_OLD_LIGHTING_MODEL
|
#ifndef EU07_USE_OLD_LIGHTING_MODEL
|
||||||
// setup lighting
|
// setup lighting
|
||||||
@@ -496,12 +469,10 @@ bool TWorld::Init(GLFWwindow *w)
|
|||||||
// Global::tSinceStart= 0;
|
// Global::tSinceStart= 0;
|
||||||
Environment.init();
|
Environment.init();
|
||||||
WriteLog("Ground init OK");
|
WriteLog("Ground init OK");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.25f * widthratio, -0.45f );
|
||||||
{
|
glColor3f( 0.0f, 0.0f, 0.0f );
|
||||||
glRasterPos2f( -0.25f * widthratio, -0.45f );
|
glPrint( "OK." );
|
||||||
glPrint("OK.");
|
glfwSwapBuffers( window );
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
// TTrack *Track=Ground.FindGroundNode("train_start",TP_TRACK)->pTrack;
|
// TTrack *Track=Ground.FindGroundNode("train_start",TP_TRACK)->pTrack;
|
||||||
|
|
||||||
@@ -513,12 +484,10 @@ bool TWorld::Init(GLFWwindow *w)
|
|||||||
Camera.Init(Global::pFreeCameraInit[0], Global::pFreeCameraInitAngle[0]);
|
Camera.Init(Global::pFreeCameraInit[0], Global::pFreeCameraInitAngle[0]);
|
||||||
|
|
||||||
char buff[255] = "Player train init: ";
|
char buff[255] = "Player train init: ";
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.85f * widthratio, -0.50f );
|
||||||
{
|
glColor3f( 0.0f, 0.0f, 0.0f );
|
||||||
glRasterPos2f( -0.85f * widthratio, -0.50f );
|
glPrint( "Przygotowanie kabiny do sterowania..." );
|
||||||
glPrint("Przygotowanie kabiny do sterowania...");
|
glfwSwapBuffers( window );
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
|
|
||||||
strcat(buff, Global::asHumanCtrlVehicle.c_str());
|
strcat(buff, Global::asHumanCtrlVehicle.c_str());
|
||||||
WriteLog(buff);
|
WriteLog(buff);
|
||||||
@@ -534,11 +503,9 @@ bool TWorld::Init(GLFWwindow *w)
|
|||||||
mvControlled = Controlled->ControlledFind()->MoverParameters;
|
mvControlled = Controlled->ControlledFind()->MoverParameters;
|
||||||
Global::pUserDynamic = Controlled; // renerowanie pojazdu względem kabiny
|
Global::pUserDynamic = Controlled; // renerowanie pojazdu względem kabiny
|
||||||
WriteLog("Player train init OK");
|
WriteLog("Player train init OK");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.25f * widthratio, -0.50f );
|
||||||
{
|
glColor3f( 0.0f, 0.0f, 0.0f );
|
||||||
glRasterPos2f( -0.25f * widthratio, -0.50f );
|
glPrint( "OK." );
|
||||||
glPrint("OK.");
|
|
||||||
}
|
|
||||||
FollowView();
|
FollowView();
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
@@ -546,12 +513,10 @@ bool TWorld::Init(GLFWwindow *w)
|
|||||||
{
|
{
|
||||||
Error("Player train init failed!");
|
Error("Player train init failed!");
|
||||||
FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie
|
FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.85f * widthratio, -0.50f );
|
||||||
{
|
glColor3f( 0.0f, 0.0f, 0.0f );
|
||||||
glRasterPos2f( -0.85f * widthratio, -0.50f );
|
glPrint( "Blad inicjalizacji sterowanego pojazdu!" );
|
||||||
glPrint("Blad inicjalizacji sterowanego pojazdu!");
|
glfwSwapBuffers( window );
|
||||||
}
|
|
||||||
glfwSwapBuffers(window);
|
|
||||||
Controlled = NULL;
|
Controlled = NULL;
|
||||||
mvControlled = NULL;
|
mvControlled = NULL;
|
||||||
Camera.Type = tp_Free;
|
Camera.Type = tp_Free;
|
||||||
@@ -562,11 +527,9 @@ bool TWorld::Init(GLFWwindow *w)
|
|||||||
if (Global::asHumanCtrlVehicle != "ghostview")
|
if (Global::asHumanCtrlVehicle != "ghostview")
|
||||||
{
|
{
|
||||||
Error("Player train not exist!");
|
Error("Player train not exist!");
|
||||||
if (Global::detonatoryOK)
|
glRasterPos2f( -0.85f * widthratio, -0.55f );
|
||||||
{
|
glColor3f( 0.0f, 0.0f, 0.0f );
|
||||||
glRasterPos2f( -0.85f * widthratio, -0.55f );
|
glPrint( "Wybrany pojazd nie istnieje w scenerii!" );
|
||||||
glPrint("Wybrany pojazd nie istnieje w scenerii!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie
|
FreeFlyModeFlag = true; // Ra: automatycznie włączone latanie
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
@@ -666,11 +629,11 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
case GLFW_KEY_F1: {
|
case GLFW_KEY_F1: {
|
||||||
if( DebugModeFlag ) {
|
if( DebugModeFlag ) {
|
||||||
// additional time speedup keys in debug mode
|
// additional time speedup keys in debug mode
|
||||||
if(Global::ctrlState) {
|
if (Global::ctrlState) {
|
||||||
// ctrl-f3
|
// ctrl-f3
|
||||||
GlobalTime->UpdateMTableTime( 20.0 * 60.0 );
|
GlobalTime->UpdateMTableTime( 20.0 * 60.0 );
|
||||||
}
|
}
|
||||||
else if(Global::shiftState) {
|
else if (Global::shiftState) {
|
||||||
// shift-f3
|
// shift-f3
|
||||||
GlobalTime->UpdateMTableTime( 5.0 * 60.0 );
|
GlobalTime->UpdateMTableTime( 5.0 * 60.0 );
|
||||||
}
|
}
|
||||||
@@ -708,7 +671,8 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GLFW_KEY_F4: {
|
case GLFW_KEY_F4: {
|
||||||
InOutKey();
|
|
||||||
|
InOutKey( !Global::shiftState ); // distant view with Shift, short distance step out otherwise
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GLFW_KEY_F5: {
|
case GLFW_KEY_F5: {
|
||||||
@@ -721,7 +685,7 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
// przyspieszenie symulacji do testowania scenerii... uwaga na FPS!
|
// przyspieszenie symulacji do testowania scenerii... uwaga na FPS!
|
||||||
if( DebugModeFlag ) {
|
if( DebugModeFlag ) {
|
||||||
|
|
||||||
if( Global::ctrlState ) { Global::fTimeSpeed = (Global::shiftState ? 60.0 : 20.0 ); }
|
if( Global::ctrlState ) { Global::fTimeSpeed = ( Global::shiftState ? 60.0 : 20.0 ); }
|
||||||
else { Global::fTimeSpeed = ( Global::shiftState ? 5.0 : 1.0 ); }
|
else { Global::fTimeSpeed = ( Global::shiftState ? 5.0 : 1.0 ); }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -740,7 +704,7 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
if( Global::iTextMode == cKey ) {
|
if( Global::iTextMode == cKey ) {
|
||||||
Global::iTextMode =
|
Global::iTextMode =
|
||||||
( Global::iPause && ( cKey != GLFW_KEY_F1 ) ?
|
( Global::iPause && ( cKey != GLFW_KEY_F1 ) ?
|
||||||
GLFW_KEY_F1 :
|
GLFW_KEY_F1 :
|
||||||
0 ); // wyłączenie napisów, chyba że pauza
|
0 ); // wyłączenie napisów, chyba że pauza
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -824,7 +788,7 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
if (temp)
|
if (temp)
|
||||||
{
|
{
|
||||||
if (Global::shiftState ? temp->MoverParameters->IncBrakeMult() :
|
if (Global::shiftState ? temp->MoverParameters->IncBrakeMult() :
|
||||||
temp->MoverParameters->DecBrakeMult())
|
temp->MoverParameters->DecBrakeMult())
|
||||||
if (Train)
|
if (Train)
|
||||||
{ // dźwięk oczywiście jest w kabinie
|
{ // dźwięk oczywiście jest w kabinie
|
||||||
Train->dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
Train->dsbSwitch->SetVolume(DSBVOLUME_MAX);
|
||||||
@@ -925,7 +889,7 @@ void TWorld::OnMouseMove(double x, double y)
|
|||||||
Camera.OnCursorMove(x * Global::fMouseXScale / Global::ZoomFactor, -y * Global::fMouseYScale / Global::ZoomFactor);
|
Camera.OnCursorMove(x * Global::fMouseXScale / Global::ZoomFactor, -y * Global::fMouseYScale / Global::ZoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TWorld::InOutKey()
|
void TWorld::InOutKey( bool const Near )
|
||||||
{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie
|
{ // przełączenie widoku z kabiny na zewnętrzny i odwrotnie
|
||||||
FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku
|
FreeFlyModeFlag = !FreeFlyModeFlag; // zmiana widoku
|
||||||
if (FreeFlyModeFlag)
|
if (FreeFlyModeFlag)
|
||||||
@@ -935,7 +899,7 @@ void TWorld::InOutKey()
|
|||||||
{ // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0));
|
{ // Train->Dynamic()->ABuSetModelShake(vector3(0,0,0));
|
||||||
Train->Silence(); // wyłączenie dźwięków kabiny
|
Train->Silence(); // wyłączenie dźwięków kabiny
|
||||||
Train->Dynamic()->bDisplayCab = false;
|
Train->Dynamic()->bDisplayCab = false;
|
||||||
DistantView();
|
DistantView( Near );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -955,26 +919,39 @@ void TWorld::InOutKey()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void TWorld::DistantView()
|
// places camera outside the controlled vehicle, or nearest if nothing is under control
|
||||||
|
// depending on provided switch the view is placed right outside, or at medium distance
|
||||||
|
void TWorld::DistantView( bool const Near )
|
||||||
{ // ustawienie widoku pojazdu z zewnątrz
|
{ // ustawienie widoku pojazdu z zewnątrz
|
||||||
if (Controlled) // jest pojazd do prowadzenia?
|
|
||||||
{ // na prowadzony
|
TDynamicObject const *vehicle{ nullptr };
|
||||||
|
if( nullptr != Controlled ) { vehicle = Controlled; }
|
||||||
|
else if( nullptr != pDynamicNearest ) { vehicle = pDynamicNearest; }
|
||||||
|
else { return; }
|
||||||
|
|
||||||
|
auto const cab =
|
||||||
|
( vehicle->MoverParameters->ActiveCab == 0 ?
|
||||||
|
1 :
|
||||||
|
vehicle->MoverParameters->ActiveCab );
|
||||||
|
auto const left = vehicle->VectorLeft() * cab;
|
||||||
|
|
||||||
|
if( true == Near ) {
|
||||||
|
|
||||||
Camera.Pos =
|
Camera.Pos =
|
||||||
Controlled->GetPosition() +
|
vector3( Camera.Pos.x, vehicle->GetPosition().y, Camera.Pos.z )
|
||||||
(Controlled->MoverParameters->ActiveCab >= 0 ? 30 : -30) * Controlled->VectorFront() +
|
+ left * vehicle->GetWidth()
|
||||||
vector3(0, 5, 0);
|
+ vector3( 1.25 * left.x, 1.6, 1.25 * left.z );
|
||||||
Camera.LookAt = Controlled->GetPosition();
|
|
||||||
Camera.RaLook(); // jednorazowe przestawienie kamery
|
|
||||||
}
|
}
|
||||||
else if (pDynamicNearest) // jeśli jest pojazd wykryty blisko
|
else {
|
||||||
{ // patrzenie na najbliższy pojazd
|
|
||||||
Camera.Pos = pDynamicNearest->GetPosition() +
|
Camera.Pos =
|
||||||
(pDynamicNearest->MoverParameters->ActiveCab >= 0 ? 30 : -30) *
|
vehicle->GetPosition()
|
||||||
pDynamicNearest->VectorFront() +
|
+ vehicle->VectorFront() * vehicle->MoverParameters->ActiveCab * 50.0
|
||||||
vector3(0, 5, 0);
|
+ vector3( -10.0 * left.x, 1.6, -10.0 * left.z );
|
||||||
Camera.LookAt = pDynamicNearest->GetPosition();
|
|
||||||
Camera.RaLook(); // jednorazowe przestawienie kamery
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Camera.LookAt = vehicle->GetPosition();
|
||||||
|
Camera.RaLook(); // jednorazowe przestawienie kamery
|
||||||
};
|
};
|
||||||
|
|
||||||
void TWorld::FollowView(bool wycisz)
|
void TWorld::FollowView(bool wycisz)
|
||||||
@@ -1130,20 +1107,7 @@ bool TWorld::Update()
|
|||||||
int n = int(iter); // ile kroków jako int
|
int n = int(iter); // ile kroków jako int
|
||||||
fTimeBuffer -= iter * fMaxDt; // reszta czasu na potem (do bufora)
|
fTimeBuffer -= iter * fMaxDt; // reszta czasu na potem (do bufora)
|
||||||
if (n > 20)
|
if (n > 20)
|
||||||
n = 20; // Ra: jeżeli FPS jest zatrważająco niski, to fizyka nie może zająć całkowicie
|
n = 20; // Ra: jeżeli FPS jest zatrważająco niski, to fizyka nie może zająć całkowicie procesora
|
||||||
// procesora
|
|
||||||
#if 0
|
|
||||||
Ground.UpdatePhys(fMaxDt,n); //Ra: teraz czas kroku jest (względnie) stały
|
|
||||||
if (DebugModeFlag)
|
|
||||||
if (Global::bActive) //nie przyspieszać, gdy jedzie w tle :)
|
|
||||||
if (GetAsyncKeyState(GLFW_KEY_ESCAPE)<0)
|
|
||||||
{//yB dodał przyspieszacz fizyki
|
|
||||||
Ground.UpdatePhys(fMaxDt,n);
|
|
||||||
Ground.UpdatePhys(fMaxDt,n);
|
|
||||||
Ground.UpdatePhys(fMaxDt,n);
|
|
||||||
Ground.UpdatePhys(fMaxDt,n); //w sumie 5 razy
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// awaria PoKeys mogła włączyć pauzę - przekazać informację
|
// awaria PoKeys mogła włączyć pauzę - przekazać informację
|
||||||
if (Global::iMultiplayer) // dajemy znać do serwera o wykonaniu
|
if (Global::iMultiplayer) // dajemy znać do serwera o wykonaniu
|
||||||
@@ -1216,7 +1180,7 @@ TWorld::Update_Camera( double const Deltatime )
|
|||||||
{
|
{
|
||||||
// Console::Update(); //tu jest zależne od FPS, co nie jest korzystne
|
// Console::Update(); //tu jest zależne od FPS, co nie jest korzystne
|
||||||
|
|
||||||
if( glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS ) {
|
if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_LEFT ) == GLFW_PRESS ) {
|
||||||
Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe
|
Camera.Reset(); // likwidacja obrotów - patrzy horyzontalnie na południe
|
||||||
// if (!FreeFlyModeFlag) //jeśli wewnątrz - patrzymy do tyłu
|
// if (!FreeFlyModeFlag) //jeśli wewnątrz - patrzymy do tyłu
|
||||||
// Camera.LookAt=Train->pMechPosition-Normalize(Train->GetDirection())*10;
|
// Camera.LookAt=Train->pMechPosition-Normalize(Train->GetDirection())*10;
|
||||||
@@ -1242,14 +1206,14 @@ TWorld::Update_Camera( double const Deltatime )
|
|||||||
if( FreeFlyModeFlag )
|
if( FreeFlyModeFlag )
|
||||||
Camera.RaLook(); // jednorazowe przestawienie kamery
|
Camera.RaLook(); // jednorazowe przestawienie kamery
|
||||||
}
|
}
|
||||||
else if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS) { //||Console::Pressed(VK_F4))
|
else if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_RIGHT ) == GLFW_PRESS ) { //||Console::Pressed(VK_F4))
|
||||||
FollowView( false ); // bez wyciszania dźwięków
|
FollowView( false ); // bez wyciszania dźwięków
|
||||||
}
|
}
|
||||||
else if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS) {
|
else if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_MIDDLE ) == GLFW_PRESS ) {
|
||||||
// middle mouse button controls zoom.
|
// middle mouse button controls zoom.
|
||||||
Global::ZoomFactor = std::min( 4.5f, Global::ZoomFactor + 15.0f * static_cast<float>(Deltatime) );
|
Global::ZoomFactor = std::min( 4.5f, Global::ZoomFactor + 15.0f * static_cast<float>( Deltatime ) );
|
||||||
}
|
}
|
||||||
else if(glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_MIDDLE) != GLFW_PRESS) {
|
else if( glfwGetMouseButton( window, GLFW_MOUSE_BUTTON_MIDDLE ) != GLFW_PRESS ) {
|
||||||
// reset zoom level if the button is no longer held down.
|
// reset zoom level if the button is no longer held down.
|
||||||
// NOTE: yes, this is terrible way to go about it. it'll do for now.
|
// NOTE: yes, this is terrible way to go about it. it'll do for now.
|
||||||
Global::ZoomFactor = std::max( 1.0f, Global::ZoomFactor - 15.0f * static_cast<float>( Deltatime ) );
|
Global::ZoomFactor = std::max( 1.0f, Global::ZoomFactor - 15.0f * static_cast<float>( Deltatime ) );
|
||||||
@@ -1276,15 +1240,6 @@ TWorld::Update_Camera( double const Deltatime )
|
|||||||
Console::Pressed( Global::Keys[ k_MechRight ] ) ) :
|
Console::Pressed( Global::Keys[ k_MechRight ] ) ) :
|
||||||
false ) { // jeśli lusterko lewe albo prawe (bez rzucania na razie)
|
false ) { // jeśli lusterko lewe albo prawe (bez rzucania na razie)
|
||||||
bool lr = Console::Pressed( Global::Keys[ k_MechLeft ] );
|
bool lr = Console::Pressed( Global::Keys[ k_MechLeft ] );
|
||||||
#if 0
|
|
||||||
Camera.Pos = Train->MirrorPosition( lr ); //robocza wartość
|
|
||||||
if( Controlled->MoverParameters->ActiveCab<0 ) lr = !lr; //w drugiej kabinie odwrotnie jest środek
|
|
||||||
Camera.LookAt = Controlled->GetPosition() + vector3( lr ? 2.0 : -2.0, Camera.Pos.y, 0 ); //trochę na zewnątrz, użyć szerokości pojazdu
|
|
||||||
//Camera.LookAt=Train->pMechPosition+Train->GetDirection()*Train->Dynamic()->MoverParameters->ActiveCab;
|
|
||||||
Camera.Pos += Controlled->GetPosition();
|
|
||||||
//Camera.RaLook(); //jednorazowe przestawienie kamery
|
|
||||||
Camera.Yaw = 0; //odchylenie na bok od Camera.LookAt
|
|
||||||
#else
|
|
||||||
// Camera.Yaw powinno być wyzerowane, aby po powrocie patrzeć do przodu
|
// Camera.Yaw powinno być wyzerowane, aby po powrocie patrzeć do przodu
|
||||||
Camera.Pos =
|
Camera.Pos =
|
||||||
Controlled->GetPosition() + Train->MirrorPosition( lr ); // pozycja lusterka
|
Controlled->GetPosition() + Train->MirrorPosition( lr ); // pozycja lusterka
|
||||||
@@ -1305,7 +1260,6 @@ TWorld::Update_Camera( double const Deltatime )
|
|||||||
Global::SetCameraRotation( M_PI -
|
Global::SetCameraRotation( M_PI -
|
||||||
modelrotate ); // tu już trzeba uwzględnić lusterka
|
modelrotate ); // tu już trzeba uwzględnić lusterka
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
Camera.Roll =
|
Camera.Roll =
|
||||||
atan( Train->pMechShake.x * Train->fMechRoll ); // hustanie kamery na boki
|
atan( Train->pMechShake.x * Train->fMechRoll ); // hustanie kamery na boki
|
||||||
Camera.Pitch =
|
Camera.Pitch =
|
||||||
@@ -1463,7 +1417,7 @@ bool TWorld::Render()
|
|||||||
glMatrixMode( GL_PROJECTION ); // select the Projection Matrix
|
glMatrixMode( GL_PROJECTION ); // select the Projection Matrix
|
||||||
glLoadIdentity(); // reset the Projection Matrix
|
glLoadIdentity(); // reset the Projection Matrix
|
||||||
// calculate the aspect ratio of the window
|
// calculate the aspect ratio of the window
|
||||||
gluPerspective( Global::FieldOfView / Global::ZoomFactor, (GLdouble)Global::ScreenWidth / (GLdouble)Global::ScreenHeight, 0.1f * Global::ZoomFactor, 2500.0f * Global::ZoomFactor );
|
gluPerspective( Global::FieldOfView / Global::ZoomFactor, (GLdouble)Global::ScreenWidth / std::max((GLdouble)Global::ScreenHeight, 1.0), 0.1f * Global::ZoomFactor, 2500.0f * Global::ZoomFactor );
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@@ -1765,7 +1719,7 @@ TWorld::Render_UI() {
|
|||||||
glMatrixMode( GL_PROJECTION ); // select the Projection Matrix
|
glMatrixMode( GL_PROJECTION ); // select the Projection Matrix
|
||||||
glLoadIdentity(); // reset the Projection Matrix
|
glLoadIdentity(); // reset the Projection Matrix
|
||||||
// calculate the aspect ratio of the window
|
// calculate the aspect ratio of the window
|
||||||
gluPerspective( 45.0f, (GLdouble)Global::ScreenWidth / (GLdouble)Global::ScreenHeight, 0.2f, 2500.0f );
|
gluPerspective( 45.0f, (GLdouble)Global::ScreenWidth / std::max((GLdouble)Global::ScreenHeight, 1.0), 0.2f, 2500.0f );
|
||||||
glMatrixMode( GL_MODELVIEW ); // Select The Modelview Matrix
|
glMatrixMode( GL_MODELVIEW ); // Select The Modelview Matrix
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
@@ -1931,7 +1885,7 @@ TWorld::Render_UI() {
|
|||||||
glTranslatef( 0.0f, 0.0f, -0.50f );
|
glTranslatef( 0.0f, 0.0f, -0.50f );
|
||||||
|
|
||||||
if( Global::iTextMode == GLFW_KEY_F1 ) { // tekst pokazywany po wciśnięciu [F1]
|
if( Global::iTextMode == GLFW_KEY_F1 ) { // tekst pokazywany po wciśnięciu [F1]
|
||||||
// Global::iViewMode=GLFW_KEY_F1;
|
// Global::iViewMode=VK_F1;
|
||||||
glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym
|
glColor3f( 1.0f, 1.0f, 1.0f ); // a, damy białym
|
||||||
OutText1 =
|
OutText1 =
|
||||||
"Time: "
|
"Time: "
|
||||||
@@ -2291,7 +2245,7 @@ TWorld::Render_UI() {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
else if( Global::iTextMode == GLFW_KEY_F10 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy
|
else if( Global::iTextMode == GLFW_KEY_F10 ) { // tu mozna dodac dopisywanie do logu przebiegu lokomotywy
|
||||||
// Global::iViewMode=GLFW_KEY_F10;
|
// Global::iViewMode=VK_F10;
|
||||||
// return false;
|
// return false;
|
||||||
OutText1 = ( "To quit press [Y] key." );
|
OutText1 = ( "To quit press [Y] key." );
|
||||||
OutText3 = ( "Aby zakonczyc program, przycisnij klawisz [Y]." );
|
OutText3 = ( "Aby zakonczyc program, przycisnij klawisz [Y]." );
|
||||||
@@ -2488,9 +2442,9 @@ TWorld::Render_UI() {
|
|||||||
// ABu 150205: prosty help, zeby sie na forum nikt nie pytal, jak ma ruszyc :)
|
// ABu 150205: prosty help, zeby sie na forum nikt nie pytal, jak ma ruszyc :)
|
||||||
|
|
||||||
if( Global::detonatoryOK ) {
|
if( Global::detonatoryOK ) {
|
||||||
// if (Console::Pressed(GLFW_KEY_F9)) ShowHints(); //to nie działa prawidłowo - prosili wyłączyć
|
// if (Console::Pressed(VK_F9)) ShowHints(); //to nie działa prawidłowo - prosili wyłączyć
|
||||||
if( Global::iTextMode == GLFW_KEY_F9 ) { // informacja o wersji, sposobie wyświetlania i błędach OpenGL
|
if( Global::iTextMode == GLFW_KEY_F9 ) { // informacja o wersji, sposobie wyświetlania i błędach OpenGL
|
||||||
// Global::iViewMode=GLFW_KEY_F9;
|
// Global::iViewMode=VK_F9;
|
||||||
OutText1 = Global::asVersion; // informacja o wersji
|
OutText1 = Global::asVersion; // informacja o wersji
|
||||||
OutText2 = std::string( "Rendering mode: " ) + ( Global::bUseVBO ? "VBO" : "Display Lists" );
|
OutText2 = std::string( "Rendering mode: " ) + ( Global::bUseVBO ? "VBO" : "Display Lists" );
|
||||||
if( Global::iMultiplayer )
|
if( Global::iMultiplayer )
|
||||||
@@ -2974,6 +2928,8 @@ world_environment::update() {
|
|||||||
void
|
void
|
||||||
world_environment::render() {
|
world_environment::render() {
|
||||||
|
|
||||||
|
GfxRenderer.Bind( 0 );
|
||||||
|
|
||||||
::glDisable( GL_LIGHTING );
|
::glDisable( GL_LIGHTING );
|
||||||
::glDisable( GL_FOG );
|
::glDisable( GL_FOG );
|
||||||
::glDisable( GL_DEPTH_TEST );
|
::glDisable( GL_DEPTH_TEST );
|
||||||
|
|||||||
12
World.h
12
World.h
@@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "stars.h"
|
#include "stars.h"
|
||||||
#include "skydome.h"
|
#include "skydome.h"
|
||||||
#include "mczapkie/mover.h"
|
#include "mczapkie/mover.h"
|
||||||
|
#include "glfw/glfw3.h"
|
||||||
|
|
||||||
// wrapper for environment elements -- sky, sun, stars, clouds etc
|
// wrapper for environment elements -- sky, sun, stars, clouds etc
|
||||||
class world_environment {
|
class world_environment {
|
||||||
@@ -36,14 +37,15 @@ private:
|
|||||||
|
|
||||||
class TWorld
|
class TWorld
|
||||||
{
|
{
|
||||||
void InOutKey();
|
void InOutKey( bool const Near = true );
|
||||||
void FollowView(bool wycisz = true);
|
void FollowView(bool wycisz = true);
|
||||||
void DistantView();
|
void DistantView( bool const Near = false );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Init(GLFWwindow *w);
|
bool Init( GLFWwindow *w );
|
||||||
|
bool InitPerformed() { return m_init; }
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
GLvoid glPrint(const char *fmt);
|
GLvoid glPrint(std::string const &Text);
|
||||||
void OnKeyDown(int cKey);
|
void OnKeyDown(int cKey);
|
||||||
void OnKeyUp(int cKey);
|
void OnKeyUp(int cKey);
|
||||||
// void UpdateWindow();
|
// void UpdateWindow();
|
||||||
@@ -69,7 +71,7 @@ class TWorld
|
|||||||
world_environment Environment;
|
world_environment Environment;
|
||||||
TTrain *Train;
|
TTrain *Train;
|
||||||
TDynamicObject *pDynamicNearest;
|
TDynamicObject *pDynamicNearest;
|
||||||
bool Paused;
|
bool Paused{ true };
|
||||||
GLuint base; // numer DL dla znaków w napisach
|
GLuint base; // numer DL dla znaków w napisach
|
||||||
texture_manager::size_type light; // numer tekstury dla smugi
|
texture_manager::size_type light; // numer tekstury dla smugi
|
||||||
TEvent *KeyEvents[10]; // eventy wyzwalane z klawiaury
|
TEvent *KeyEvents[10]; // eventy wyzwalane z klawiaury
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "lightarray.h"
|
#include "lightarray.h"
|
||||||
#include "dynobj.h"
|
#include "dynobj.h"
|
||||||
|
#include "driver.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
light_array::insert( TDynamicObject const *Owner ) {
|
light_array::insert( TDynamicObject const *Owner ) {
|
||||||
@@ -64,7 +65,24 @@ light_array::update() {
|
|||||||
( ( lightbits & 4 ) ? 1 : 0 ) +
|
( ( lightbits & 4 ) ? 1 : 0 ) +
|
||||||
( ( lightbits & 16 ) ? 1 : 0 );
|
( ( lightbits & 16 ) ? 1 : 0 );
|
||||||
|
|
||||||
light.intensity = 0.15f * light.count; // TODO: intensity can be affected further by dim switch or other factors
|
if( light.count > 0 ) {
|
||||||
|
// TODO: intensity can be affected further by dim switch or other factors
|
||||||
|
light.intensity = std::max( 0.0f, std::log( (float)light.count + 1.0f ) );
|
||||||
|
// light.intensity = std::max( 0.0f, std::log( (float)light.count + 3.0f ) );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
light.intensity = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// crude catch for unmanned modules which share the light state with the controlled unit.
|
||||||
|
// why don't they get their own light bits btw ._.
|
||||||
|
// TODO, TBD: have separate light bits for each vehicle, so this override isn't necessary
|
||||||
|
if( ( light.owner->Controller == AIdriver )
|
||||||
|
&& ( light.owner->Mechanik == nullptr ) ) {
|
||||||
|
|
||||||
|
light.intensity = 0.0f;
|
||||||
|
light.count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// with battery off the lights are off
|
// with battery off the lights are off
|
||||||
|
|||||||
10
renderer.cpp
10
renderer.cpp
@@ -23,8 +23,8 @@ opengl_renderer::Init() {
|
|||||||
light.id = GL_LIGHT1 + idx;
|
light.id = GL_LIGHT1 + idx;
|
||||||
|
|
||||||
light.position[ 3 ] = 1.0f;
|
light.position[ 3 ] = 1.0f;
|
||||||
::glLightf( light.id, GL_SPOT_CUTOFF, 20.0f );
|
::glLightf( light.id, GL_SPOT_CUTOFF, 7.5f );
|
||||||
::glLightf( light.id, GL_SPOT_EXPONENT, 10.0f );
|
::glLightf( light.id, GL_SPOT_EXPONENT, 7.5f );
|
||||||
::glLightf( light.id, GL_CONSTANT_ATTENUATION, 0.0f );
|
::glLightf( light.id, GL_CONSTANT_ATTENUATION, 0.0f );
|
||||||
::glLightf( light.id, GL_LINEAR_ATTENUATION, 0.035f );
|
::glLightf( light.id, GL_LINEAR_ATTENUATION, 0.035f );
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ opengl_renderer::Update_Lights( light_array const &Lights ) {
|
|||||||
renderlight->ambient[ 1 ] = scenelight.color.y * scenelight.intensity;
|
renderlight->ambient[ 1 ] = scenelight.color.y * scenelight.intensity;
|
||||||
renderlight->ambient[ 2 ] = scenelight.color.z * scenelight.intensity;
|
renderlight->ambient[ 2 ] = scenelight.color.z * scenelight.intensity;
|
||||||
|
|
||||||
::glLightf( renderlight->id, GL_LINEAR_ATTENUATION, 0.3f / std::pow( scenelight.count, 2 ) );
|
::glLightf( renderlight->id, GL_LINEAR_ATTENUATION, (0.25f * scenelight.count) / std::pow( scenelight.count, 2 ) );
|
||||||
::glEnable( renderlight->id );
|
::glEnable( renderlight->id );
|
||||||
|
|
||||||
renderlight->apply_intensity();
|
renderlight->apply_intensity();
|
||||||
@@ -85,9 +85,9 @@ opengl_renderer::Update_Lights( light_array const &Lights ) {
|
|||||||
void
|
void
|
||||||
opengl_renderer::Disable_Lights() {
|
opengl_renderer::Disable_Lights() {
|
||||||
|
|
||||||
for( int idx = 0; idx < m_lights.size() + 1; ++idx ) {
|
for( size_t idx = 0; idx < m_lights.size() + 1; ++idx ) {
|
||||||
|
|
||||||
::glDisable( GL_LIGHT0 + idx );
|
::glDisable( GL_LIGHT0 + (int)idx );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
112
skydome.cpp
112
skydome.cpp
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "GL/glew.h"
|
|
||||||
#include "skydome.h"
|
#include "skydome.h"
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
|
||||||
@@ -79,33 +78,45 @@ void CSkyDome::Generate() {
|
|||||||
float const offset = 0.1f * radius; // horizontal offset, a cheap way to prevent a gap between ground and horizon
|
float const offset = 0.1f * radius; // horizontal offset, a cheap way to prevent a gap between ground and horizon
|
||||||
|
|
||||||
// create geometry chunk
|
// create geometry chunk
|
||||||
int const latitudes = m_tesselation / 2;
|
int const latitudes = m_tesselation / 2 / 2; // half-sphere only
|
||||||
int const longitudes = m_tesselation;
|
int const longitudes = m_tesselation;
|
||||||
|
|
||||||
for( int i = 0; i < latitudes; ++i ) {
|
std::uint16_t index = 0;
|
||||||
|
|
||||||
float lat0 = M_PI * ( -0.5f + (float)( i ) / latitudes );
|
for( int i = 0; i <= latitudes; ++i ) {
|
||||||
float z0 = std::sin( lat0 );
|
|
||||||
float zr0 = std::cos( lat0 );
|
|
||||||
|
|
||||||
float lat1 = M_PI * ( -0.5f + (float)( i + 1 ) / latitudes );
|
float const latitude = M_PI * ( -0.5f + (float)( i ) / latitudes / 2 ); // half-sphere only
|
||||||
float z1 = std::sin( lat1 );
|
float const z = std::sin( latitude );
|
||||||
float zr1 = std::cos( lat1 );
|
float const zr = std::cos( latitude );
|
||||||
|
|
||||||
// quad strip
|
for( int j = 0; j <= longitudes; ++j ) {
|
||||||
for( int j = 0; j <= longitudes / 2; ++j ) {
|
|
||||||
|
|
||||||
float longitude = 2.0 * M_PI * (float)( j ) / longitudes;
|
float const longitude = 2.0 * M_PI * (float)( j ) / longitudes;
|
||||||
float x = std::cos( longitude );
|
float const x = std::cos( longitude );
|
||||||
float y = std::sin( longitude );
|
float const y = std::sin( longitude );
|
||||||
|
/*
|
||||||
|
m_vertices.emplace_back( float3( x * zr, y * zr - offset, z ) * radius );
|
||||||
|
// we aren't using normals, but the code is left here in case it's ever needed
|
||||||
|
// m_normals.emplace_back( float3( x * zr, -y * zr, -z ) );
|
||||||
|
*/
|
||||||
|
// cartesian to opengl swap: -x, -z, -y
|
||||||
|
m_vertices.emplace_back( float3( -x * zr, -z - offset, -y * zr ) * radius );
|
||||||
|
m_colours.emplace_back( float3( 0.75f, 0.75f, 0.75f ) ); // placeholder
|
||||||
|
|
||||||
m_vertices.emplace_back( float3( x * zr0, y * zr0 - offset, z0 ) * radius );
|
if( (i == 0) || (j == 0) ) {
|
||||||
// m_normals.emplace_back( float3( -x * zr0, -y * zr0, -z0 ) );
|
// initial edge of the dome, don't start indices yet
|
||||||
m_colours.emplace_back( float3( 0.75f, 0.75f, 0.75f ) );
|
++index;
|
||||||
|
}
|
||||||
m_vertices.emplace_back( float3( x * zr1, y * zr1 - offset, z1 ) * radius );
|
else {
|
||||||
// m_normals.emplace_back( float3( -x * zr1, -y * zr1, -z1 ) );
|
// indices for two triangles, formed between current and previous latitude
|
||||||
m_colours.emplace_back( float3( 0.75f, 0.75f, 0.75f ) );
|
m_indices.emplace_back( index - 1 - (longitudes + 1) );
|
||||||
|
m_indices.emplace_back( index - 1 );
|
||||||
|
m_indices.emplace_back( index );
|
||||||
|
m_indices.emplace_back( index );
|
||||||
|
m_indices.emplace_back( index - ( longitudes + 1 ) );
|
||||||
|
m_indices.emplace_back( index - 1 - ( longitudes + 1 ) );
|
||||||
|
++index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,26 +134,36 @@ void CSkyDome::Update( Math3D::vector3 const &Sun ) {
|
|||||||
// render skydome to screen
|
// render skydome to screen
|
||||||
void CSkyDome::Render() {
|
void CSkyDome::Render() {
|
||||||
|
|
||||||
int const latitudes = m_tesselation / 2;
|
if( m_vertexbuffer == -1 ) {
|
||||||
int const longitudes = m_tesselation;
|
// build the buffers
|
||||||
int idx = 0;
|
::glGenBuffers( 1, &m_vertexbuffer );
|
||||||
|
::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer );
|
||||||
|
::glBufferData( GL_ARRAY_BUFFER, m_vertices.size() * sizeof( float3 ), m_vertices.data(), GL_STATIC_DRAW );
|
||||||
|
|
||||||
for( int i = 0; i < latitudes; ++i ) {
|
::glGenBuffers( 1, &m_coloursbuffer );
|
||||||
|
::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer );
|
||||||
|
::glBufferData( GL_ARRAY_BUFFER, m_colours.size() * sizeof( float3 ), m_colours.data(), GL_DYNAMIC_DRAW );
|
||||||
|
|
||||||
::glBegin( GL_QUAD_STRIP );
|
::glGenBuffers( 1, &m_indexbuffer );
|
||||||
for( int j = 0; j <= longitudes / 2; ++j ) {
|
::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer );
|
||||||
|
::glBufferData( GL_ELEMENT_ARRAY_BUFFER, m_indices.size() * sizeof( unsigned short ), m_indices.data(), GL_STATIC_DRAW );
|
||||||
::glColor3f( m_colours[ idx ].x, m_colours[ idx ].y, m_colours[ idx ].z );
|
// NOTE: vertex and index source data is superfluous past this point, but, eh
|
||||||
// ::glNormal3f( m_normals[ idx ].x, m_normals[ idx ].y, m_normals[ idx ].z );
|
|
||||||
::glVertex3f( m_vertices[ idx ].x, m_vertices[ idx ].y, m_vertices[ idx ].z );
|
|
||||||
++idx;
|
|
||||||
::glColor3f( m_colours[ idx ].x, m_colours[ idx ].y, m_colours[ idx ].z );
|
|
||||||
// ::glNormal3f( m_normals[ idx ].x, m_normals[ idx ].y, m_normals[ idx ].z );
|
|
||||||
::glVertex3f( m_vertices[ idx ].x, m_vertices[ idx ].y, m_vertices[ idx ].z );
|
|
||||||
++idx;
|
|
||||||
}
|
|
||||||
glEnd();
|
|
||||||
}
|
}
|
||||||
|
// begin
|
||||||
|
::glEnableClientState( GL_VERTEX_ARRAY );
|
||||||
|
::glEnableClientState( GL_COLOR_ARRAY );
|
||||||
|
// positions
|
||||||
|
::glBindBuffer( GL_ARRAY_BUFFER, m_vertexbuffer );
|
||||||
|
::glVertexPointer( 3, GL_FLOAT, sizeof( float3 ), reinterpret_cast<void const*>( 0 ) );
|
||||||
|
// colours
|
||||||
|
::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer );
|
||||||
|
::glColorPointer( 3, GL_FLOAT, sizeof( float3 ), reinterpret_cast<void const*>( 0 ) );
|
||||||
|
// indices
|
||||||
|
::glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_indexbuffer );
|
||||||
|
::glDrawElements( GL_TRIANGLES, static_cast<GLsizei>( m_indices.size() ), GL_UNSIGNED_SHORT, reinterpret_cast<void const*>( 0 ) );
|
||||||
|
// cleanup
|
||||||
|
::glDisableClientState( GL_COLOR_ARRAY );
|
||||||
|
::glDisableClientState( GL_VERTEX_ARRAY );
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************//
|
//******************************************************************************//
|
||||||
@@ -329,16 +350,23 @@ void CSkyDome::RebuildColors() {
|
|||||||
color.y = 0.65f * color.z;
|
color.y = 0.65f * color.z;
|
||||||
color = color * ( 1.15f - vertex.y ); // simple gradient, darkening towards the top
|
color = color * ( 1.15f - vertex.y ); // simple gradient, darkening towards the top
|
||||||
}
|
}
|
||||||
|
|
||||||
// save
|
// save
|
||||||
m_colours[ i ] = color;
|
m_colours[ i ] = color;
|
||||||
averagecolor += color;
|
averagecolor += color * 8.0f; // save for edge cases each vertex goes in 8 triangles
|
||||||
}
|
}
|
||||||
|
// NOTE: average reduced to 25% makes nice tint value for clouds lit from behind
|
||||||
m_averagecolour = averagecolor / m_vertices.size();
|
// down the road we could interpolate between it and full strength average, to improve accuracy of cloud appearance
|
||||||
|
m_averagecolour = averagecolor / m_indices.size();
|
||||||
m_averagecolour.x = std::max( m_averagecolour.x, 0.0f );
|
m_averagecolour.x = std::max( m_averagecolour.x, 0.0f );
|
||||||
m_averagecolour.y = std::max( m_averagecolour.y, 0.0f );
|
m_averagecolour.y = std::max( m_averagecolour.y, 0.0f );
|
||||||
m_averagecolour.z = std::max( m_averagecolour.z, 0.0f );
|
m_averagecolour.z = std::max( m_averagecolour.z, 0.0f );
|
||||||
|
|
||||||
|
if( m_coloursbuffer != -1 ) {
|
||||||
|
// the colour buffer was already initialized, so on this run we update its content
|
||||||
|
::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer );
|
||||||
|
::glBufferSubData( GL_ARRAY_BUFFER, 0, m_colours.size() * sizeof( float3 ), m_colours.data() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************//
|
//******************************************************************************//
|
||||||
|
|||||||
@@ -42,8 +42,12 @@ private:
|
|||||||
// data
|
// data
|
||||||
int const m_tesselation;
|
int const m_tesselation;
|
||||||
std::vector<float3> m_vertices;
|
std::vector<float3> m_vertices;
|
||||||
|
std::vector<std::uint16_t> m_indices;
|
||||||
// std::vector<float3> m_normals;
|
// std::vector<float3> m_normals;
|
||||||
std::vector<float3> m_colours;
|
std::vector<float3> m_colours;
|
||||||
|
GLuint m_vertexbuffer{ (GLuint)-1 };
|
||||||
|
GLuint m_indexbuffer{ (GLuint)-1 };
|
||||||
|
GLuint m_coloursbuffer{ (GLuint)-1 };
|
||||||
|
|
||||||
static float m_distributionluminance[ 5 ][ 2 ];
|
static float m_distributionluminance[ 5 ][ 2 ];
|
||||||
static float m_distributionxcomp[ 5 ][ 2 ];
|
static float m_distributionxcomp[ 5 ][ 2 ];
|
||||||
|
|||||||
5
stdafx.h
5
stdafx.h
@@ -59,7 +59,10 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
#include "GL/glew.h"
|
#include "GL/glew.h"
|
||||||
|
#ifdef _WINDOWS
|
||||||
#include "GL/wglew.h"
|
#include "GL/wglew.h"
|
||||||
|
#define GLFW_DLL
|
||||||
|
#endif
|
||||||
|
#define GLFW_INCLUDE_GLU
|
||||||
//m7todo: jest tu bo nie chcia³o mi siê wpychaæ do wszystkich plików
|
//m7todo: jest tu bo nie chcia³o mi siê wpychaæ do wszystkich plików
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
25
windows.cpp
25
windows.cpp
@@ -1,4 +1,5 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
#pragma warning (disable: 4091)
|
#pragma warning (disable: 4091)
|
||||||
#include <dbghelp.h>
|
#include <dbghelp.h>
|
||||||
@@ -44,3 +45,27 @@ LONG CALLBACK unhandled_handler(::EXCEPTION_POINTERS* e)
|
|||||||
|
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWND Hwnd;
|
||||||
|
WNDPROC BaseWindowProc;
|
||||||
|
PCOPYDATASTRUCT pDane;
|
||||||
|
extern TWorld World;
|
||||||
|
|
||||||
|
LRESULT APIENTRY WndProc( HWND hWnd, // handle for this window
|
||||||
|
UINT uMsg, // message for this window
|
||||||
|
WPARAM wParam, // additional message information
|
||||||
|
LPARAM lParam) // additional message information
|
||||||
|
{
|
||||||
|
switch( uMsg ) // check for windows messages
|
||||||
|
{
|
||||||
|
case WM_COPYDATA: {
|
||||||
|
// obsługa danych przesłanych przez program sterujący
|
||||||
|
pDane = (PCOPYDATASTRUCT)lParam;
|
||||||
|
if( pDane->dwData == 'EU07' ) // sygnatura danych
|
||||||
|
World.OnCommandGet( (DaneRozkaz *)( pDane->lpData ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// pass all unhandled messages to DefWindowProc
|
||||||
|
return CallWindowProc( BaseWindowProc, Hwnd, uMsg, wParam, lParam );
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user