Merge branch 'tmj-dev' into nogfx

This commit is contained in:
milek7
2017-08-21 20:40:16 +02:00
14 changed files with 130 additions and 861 deletions

View File

@@ -606,23 +606,8 @@ int TAnimModel::Flags()
return i;
};
//-----------------------------------------------------------------------------
// 2011-03-16 funkcje renderowania z możliwością pochylania obiektów
//-----------------------------------------------------------------------------
#ifdef EU07_USE_OLD_RENDERCODE
void TAnimModel::Render( vector3 const &Position ) {
RaAnimate(); // jednorazowe przeliczenie animacji
RaPrepare();
if( pModel ) // renderowanie rekurencyjne submodeli
GfxRenderer.Render( pModel, Material(), Position, vAngle );
};
void TAnimModel::RenderAlpha( vector3 const &Position ) {
RaPrepare();
if( pModel ) // renderowanie rekurencyjne submodeli
GfxRenderer.Render_Alpha( pModel, Material(), Position, vAngle );
};
#endif
//---------------------------------------------------------------------------
bool TAnimModel::TerrainLoaded()
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
return (this ? pModel != NULL : false);

View File

@@ -164,10 +164,6 @@ class TAnimModel {
bool Load(cParser *parser, bool ter = false);
TAnimContainer * AddContainer(char *pName);
TAnimContainer * GetContainer(char *pName);
#ifdef EU07_USE_OLD_RENDERCODE
void Render( vector3 const &Position );
void RenderAlpha( vector3 const &Position );
#endif
int Flags();
void RaAnglesSet(double a, double b, double c)
{
@@ -178,9 +174,6 @@ class TAnimModel {
bool TerrainLoaded();
int TerrainCount();
TSubModel * TerrainSquare(int n);
#ifdef EU07_USE_OLD_RENDERCODE
void TerrainRenderVBO(int n);
#endif
void AnimationVND(void *pData, double a, double b, double c, double d);
void LightSet(int n, float v);
static void AnimUpdate(double dt);

View File

@@ -187,7 +187,7 @@ void TSpeedPos::CommandCheck()
}
};
bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len, TOrders const &Orders )
bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len )
{ // przeliczenie odległości od punktu (*p), w kierunku (*dir), zaczynając od pojazdu
// dla kolejnych pozycji podawane są współrzędne poprzedniego obiektu w (*p)
vector3 v = vPos - *p; // wektor od poprzedniego obiektu (albo pojazdu) do punktu zmiany
@@ -253,19 +253,6 @@ bool TSpeedPos::Update(vector3 *p, vector3 *dir, double &len, TOrders const &Ord
if( trTrack->iCategoryFlag & 1 ) {
// railways
/*
if( ( iFlags & spElapsed ) == 0 ) {
// jeśli nie wjechał
// TODO: remove this block when the detection of vehicles ahead is working properly
if( false == trTrack->Dynamics.empty() ) {
// to zabronić wjazdu (chyba że ten z przodu też jedzie prosto)
fVelNext = 25.0; // can't force full stop as it can prevent vehicles from leaving the track. slow down should be enough to ensure slow enough movement to stop
if( Global::iWriteLogEnabled & 8 ) {
WriteLog( "Track " + trTrack->NameGet() + " is occupied. Vehicle count: " + std::to_string( trTrack->Dynamics.size() ) + ", distance: " + std::to_string( fDist ) + " m." );
}
}
}
*/
if( iFlags & spSwitch ) {
// jeśli odcinek zmienny
if( ( ( trTrack->GetSwitchState() & 1 ) != 0 ) !=
@@ -701,7 +688,7 @@ void TController::TableCheck(double fDistance)
{ // aktualizacja rekordów z wyjątkiem ostatniego
if (sSpeedTable[i].iFlags & spEnabled) // jeśli pozycja istotna
{
if (sSpeedTable[i].Update(&pos, &dir, len, OrderCurrentGet()))
if(sSpeedTable[i].Update( &pos, &dir, len ))
{
if( Global::iWriteLogEnabled & 8 ) {
WriteLog( "Speed table for " + OwnerName() + " detected switch change at " + sSpeedTable[ i ].trTrack->NameGet() + " (generating fresh trace)" );
@@ -744,7 +731,7 @@ void TController::TableCheck(double fDistance)
}
}
}
sSpeedTable[iLast].Update(&pos, &dir, len, OrderCurrentGet()); // aktualizacja ostatniego
sSpeedTable[iLast].Update( &pos, &dir, len ); // aktualizacja ostatniego
// WriteLog("TableCheck: Upate last track. Dist=" + AnsiString(sSpeedTable[iLast].fDist));
if( sSpeedTable[ iLast ].fDist < fDistance ) {
TableTraceRoute( fDistance, pVehicles[ 1 ] ); // doskanowanie dalszego odcinka
@@ -1736,7 +1723,41 @@ void TController::AutoRewident()
fAccThreshold = -fBrake_a0[BrakeAccTableSize] - 1 * fBrake_a1[BrakeAccTableSize];
fBrakeReaction = 1.00 + fLength*0.005;
}
};
}
double TController::ESMVelocity(bool Main)
{
double fCurrentCoeff = 0.9;
double fFrictionCoeff = 0.85;
double ESMVel = 9999;
int MCPN = mvControlling->MainCtrlActualPos;
int SCPN = mvControlling->ScndCtrlActualPos;
if (Main)
MCPN += 1;
else
SCPN += 1;
if ((mvControlling->RList[MCPN].ScndAct < 255)&&(mvControlling->ScndCtrlActualPos==0))
SCPN = mvControlling->RList[MCPN].ScndAct;
double FrictionMax = mvControlling->Mass*9.81*mvControlling->Adhesive(mvControlling->RunningTrack.friction)*fFrictionCoeff;
double IF = mvControlling->Imax;
double MS = 0;
double Fmax = 0;
for (int i = 0; i < 5; i++)
{
MS = mvControlling->MomentumF(IF, IF, SCPN);
Fmax = MS * mvControlling->RList[MCPN].Bn*mvControlling->RList[MCPN].Mn * 2 / mvControlling->WheelDiameter * mvControlling->Transmision.Ratio;
IF = 0.5*IF*(1 + FrictionMax/Fmax);
}
IF = std::min(IF, mvControlling->Imax*fCurrentCoeff);
double R = mvControlling->RList[MCPN].R + mvControlling->CircuitRes + mvControlling->RList[MCPN].Mn*mvControlling->WindingRes;
double pole = mvControlling->MotorParam[SCPN].fi *
std::max(abs(IF) / (abs(IF) + mvControlling->MotorParam[SCPN].Isat) - mvControlling->MotorParam[SCPN].fi0, 0.0);
double Us = abs(mvControlling->Voltage) - IF*R;
double ns = std::max(0.0, Us / (pole*mvControlling->RList[MCPN].Mn));
ESMVel = ns * mvControlling->WheelDiameter*M_PI*3.6/mvControlling->Transmision.Ratio;
return ESMVel;
}
;
int TController::CheckDirection() {
@@ -2486,51 +2507,64 @@ bool TController::IncSpeed()
(mvControlling->StLinFlag)) // youBy polecił dodać 2012-09-08 v367
// na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe
// (zgaśnie DelayCtrlFlag)
if (Ready || (iDrivigFlags & movePress))
if (fabs(mvControlling->Im) <
(fReady < 0.4 ? mvControlling->Imin : mvControlling->IminLo))
{ // Ra: wywalał nadmiarowy, bo Im może być ujemne; jak nie odhamowany, to nie
// przesadzać z prądem
if ((mvOccupied->Vel <= 30) ||
(mvControlling->Imax > mvControlling->ImaxLo) ||
(fVoltage + fVoltage <
mvControlling->EnginePowerSource.CollectorParameters.MinV +
mvControlling->EnginePowerSource.CollectorParameters.MaxV))
{ // bocznik na szeregowej przy ciezkich bruttach albo przy wysokim rozruchu
// pod górę albo przy niskim napięciu
if (mvControlling->MainCtrlPos ?
mvControlling->RList[mvControlling->MainCtrlPos].R > 0.0 :
true) // oporowa
{
OK = (mvControlling->DelayCtrlFlag ?
true :
mvControlling->IncMainCtrl(1)); // kręcimy nastawnik jazdy
if ((OK) &&
(mvControlling->MainCtrlPos ==
1)) // czekaj na 1 pozycji, zanim się nie włączą liniowe
iDrivigFlags |= moveIncSpeed;
else
iDrivigFlags &= ~moveIncSpeed; // usunięcie flagi czekania
}
else // jeśli bezoporowa (z wyjątekiem 0)
OK = false; // to dać bocznik
}
else
{ // przekroczone 30km/h, można wejść na jazdę równoległą
if (mvControlling->ScndCtrlPos) // jeśli ustawiony bocznik
if (mvControlling->MainCtrlPos <
mvControlling->MainCtrlPosNo - 1) // a nie jest ostatnia pozycja
mvControlling->DecScndCtrl(2); // to bocznik na zero po chamsku
// (ktoś miał to poprawić...)
OK = mvControlling->IncMainCtrl(1);
}
if ((mvControlling->MainCtrlPos > 2) &&
(mvControlling->Im == 0)) // brak prądu na dalszych pozycjach
Need_TryAgain = true; // nie załączona lokomotywa albo wywalił
// nadmiarowy
else if (!OK) // nie da się wrzucić kolejnej pozycji
OK = mvControlling->IncScndCtrl(1); // to dać bocznik
}
if (Ready || (iDrivigFlags & movePress))
{
bool scndctrl = ((mvOccupied->Vel <= 30) ||
(mvControlling->Imax > mvControlling->ImaxLo) ||
(fVoltage + fVoltage <
mvControlling->EnginePowerSource.CollectorParameters.MinV +
mvControlling->EnginePowerSource.CollectorParameters.MaxV) ||
(mvControlling->MainCtrlPos == mvControlling->MainCtrlPosNo));
scndctrl = ((scndctrl) && (mvControlling->MainCtrlPos > 1) && (mvControlling->RList[mvControlling->MainCtrlActualPos].R < 0.01)&& (mvControlling->ScndCtrlPos != mvControlling->ScndCtrlPosNo));
double Vs = 99999;
if((mvControlling->MainCtrlPos != mvControlling->MainCtrlPosNo)||(mvControlling->ScndCtrlPos!=mvControlling->ScndCtrlPosNo))
Vs = ESMVelocity(!scndctrl);
if ((fabs(mvControlling->Im) <
(fReady < 0.4 ? mvControlling->Imin : mvControlling->IminLo))||(mvControlling->Vel>Vs))
{ // Ra: wywalał nadmiarowy, bo Im może być ujemne; jak nie odhamowany, to nie
// przesadzać z prądem
if ((mvOccupied->Vel <= 30) ||
(mvControlling->Imax > mvControlling->ImaxLo) ||
(fVoltage + fVoltage <
mvControlling->EnginePowerSource.CollectorParameters.MinV +
mvControlling->EnginePowerSource.CollectorParameters.MaxV))
{ // bocznik na szeregowej przy ciezkich bruttach albo przy wysokim rozruchu
// pod górę albo przy niskim napięciu
if (mvControlling->MainCtrlPos ?
mvControlling->RList[mvControlling->MainCtrlPos].R > 0.0 :
true) // oporowa
{
OK = (mvControlling->DelayCtrlFlag ?
true :
mvControlling->IncMainCtrl(1)); // kręcimy nastawnik jazdy
if ((OK) &&
(mvControlling->MainCtrlPos ==
1)) // czekaj na 1 pozycji, zanim się nie włączą liniowe
iDrivigFlags |= moveIncSpeed;
else
iDrivigFlags &= ~moveIncSpeed; // usunięcie flagi czekania
}
else // jeśli bezoporowa (z wyjątekiem 0)
OK = false; // to dać bocznik
}
else
{ // przekroczone 30km/h, można wejść na jazdę równoległą
if (mvControlling->ScndCtrlPos) // jeśli ustawiony bocznik
if (mvControlling->MainCtrlPos <
mvControlling->MainCtrlPosNo - 1) // a nie jest ostatnia pozycja
mvControlling->DecScndCtrl(2); // to bocznik na zero po chamsku
// (ktoś miał to poprawić...)
OK = mvControlling->IncMainCtrl(1);
}
if ((mvControlling->MainCtrlPos > 2) &&
(mvControlling->Im == 0)) // brak prądu na dalszych pozycjach
Need_TryAgain = true; // nie załączona lokomotywa albo wywalił
// nadmiarowy
else if (!OK) // nie da się wrzucić kolejnej pozycji
OK = mvControlling->IncScndCtrl(1); // to dać bocznik
}
}
mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania
break;
case Dumb:

View File

@@ -144,7 +144,7 @@ class TSpeedPos
public:
void Clear();
bool Update(vector3 *p, vector3 *dir, double &len, TOrders const &Orders );
bool Update(vector3 *p, vector3 *dir, double &len );
bool Set(TEvent *e, double d, TOrders order = Wait_for_orders);
void Set(TTrack *t, double d, int f);
std::string TableText();
@@ -310,6 +310,7 @@ class TController
void Activation(); // umieszczenie obsady w odpowiednim członie
void ControllingSet(); // znajduje człon do sterowania
void AutoRewident(); // ustawia hamulce w składzie
double ESMVelocity(bool Main);
public:
Mtable::TTrainParameters *Timetable()
{

View File

@@ -639,70 +639,6 @@ basic_vertex *TSubModel::TrianglePtr(int tex, int pos, glm::vec3 const &Ambient,
return s->Vertices + pos; // wskaźnik na wolne miejsce w tabeli wierzchołków
};
*/
#ifdef EU07_USE_OLD_RENDERCODE
void TSubModel::DisplayLists()
{ // utworznie po jednej skompilowanej liście dla
// każdego submodelu
if (eType < TP_ROTATOR)
{
if (iNumVerts > 0)
{
uiDisplayList = glGenLists(1);
glNewList(uiDisplayList, GL_COMPILE);
#ifdef USE_VERTEX_ARRAYS
// ShaXbee-121209: przekazywanie wierzcholkow hurtem
glVertexPointer(3, GL_DOUBLE, sizeof(GLVERTEX), &Vertices[0].Point.x);
glNormalPointer(GL_DOUBLE, sizeof(GLVERTEX), &Vertices[0].Normal.x);
glTexCoordPointer(2, GL_FLOAT, sizeof(GLVERTEX), &Vertices[0].tu);
glDrawArrays(eType, 0, iNumVerts);
#else
glBegin(eType);
for (int i = 0; i < iNumVerts; i++)
{
/*
glNormal3dv(&Vertices[i].Normal.x);
glTexCoord2f(Vertices[i].tu,Vertices[i].tv);
glVertex3dv(&Vertices[i].Point.x);
*/
glNormal3fv(glm::value_ptr(Vertices[i].normal));
glTexCoord2fv(glm::value_ptr(Vertices[i].material));
glVertex3fv(glm::value_ptr(Vertices[i].position));
};
glEnd();
#endif
glEndList();
}
}
else if (eType == TP_FREESPOTLIGHT)
{
uiDisplayList = glGenLists(1);
glNewList(uiDisplayList, GL_COMPILE);
glBegin(GL_POINTS);
glVertex3f( 0.0f, 0.0f, -0.05f ); // shift point towards the viewer, to avoid z-fighting with the light polygons
glEnd();
glEndList();
}
else if (eType == TP_STARS)
{ // punkty świecące dookólnie
uiDisplayList = glGenLists(1);
glNewList(uiDisplayList, GL_COMPILE);
glBegin(GL_POINTS);
for (int i = 0; i < iNumVerts; ++i)
{
glColor3fv(glm::value_ptr(Vertices[i].normal));
glVertex3fv(glm::value_ptr(Vertices[i].position));
};
glEnd();
glEndList();
}
// SafeDeleteArray(Vertices); //przy VBO muszą zostać do załadowania całego
// modelu
if (Child)
Child->DisplayLists();
if (Next)
Next->DisplayLists();
};
#endif
void TSubModel::InitialRotate(bool doit)
{ // konwersja układu współrzędnych na zgodny ze scenerią

650
Train.cpp

File diff suppressed because it is too large Load Diff

View File

@@ -76,9 +76,9 @@ HSVtoRGB( glm::vec3 const &HSV ) {
hh /= 60.0;
int const i = (int)hh;
float const ff = hh - i;
float const p = HSV.z * ( 1.0 - HSV.y );
float const q = HSV.z * ( 1.0 - ( HSV.y * ff ) );
float const t = HSV.z * ( 1.0 - ( HSV.y * ( 1.0 - ff ) ) );
float const p = HSV.z * ( 1.f - HSV.y );
float const q = HSV.z * ( 1.f - ( HSV.y * ff ) );
float const t = HSV.z * ( 1.f - ( HSV.y * ( 1.f - ff ) ) );
switch( i ) {
case 0:

View File

@@ -45,8 +45,8 @@ cMoon::update() {
move();
glm::vec3 position( 0.f, 0.f, -2000.f * Global::fDistanceFactor );
position = glm::rotateX( position, glm::radians<float>( m_body.elevref ) );
position = glm::rotateY( position, glm::radians<float>( -m_body.hrang ) );
position = glm::rotateX( position, glm::radians( static_cast<float>( m_body.elevref ) ) );
position = glm::rotateY( position, glm::radians( static_cast<float>( -m_body.hrang ) ) );
m_position = position;
}
@@ -54,16 +54,16 @@ cMoon::update() {
void
cMoon::render() {
glColor4f( 225.0f/255.0f, 225.0f/255.0f, 255.0f/255.0f, 1.f );
// debug line to locate the sun easier
glBegin( GL_LINES );
glVertex3f( m_position.x, m_position.y, m_position.z );
glVertex3f( m_position.x, 0.0f, m_position.z );
glEnd();
glPushMatrix();
glTranslatef( m_position.x, m_position.y, m_position.z );
gluSphere( moonsphere, /* (float)( Global::ScreenHeight / Global::FieldOfView ) * 0.5 * */ ( m_body.distance / 60.2666 ) * 9.037461, 12, 12 );
glPopMatrix();
::glColor4f( 225.f / 255.f, 225.f / 255.f, 255.f / 255.f, 1.f );
// debug line to locate the moon easier
::glBegin( GL_LINES );
::glVertex3fv( glm::value_ptr( m_position ) );
::glVertex3f( m_position.x, 0.f, m_position.z );
::glEnd();
::glPushMatrix();
::glTranslatef( m_position.x, m_position.y, m_position.z );
::gluSphere( moonsphere, /* (float)( Global::iWindowHeight / Global::FieldOfView ) * 0.5 * */ ( m_body.distance / 60.2666 ) * 9.037461, 12, 12 );
::glPopMatrix();
}
glm::vec3
@@ -85,8 +85,8 @@ float cMoon::getIntensity() {
// calculating intensity of the sun instead, and returning 15% of the value,
// which roughly matches how much sunlight is reflected by the moon
// We alter the intensity further based on current phase of the moon
auto const phasefactor = 1.0f - std::abs( m_phase - 29.53f * 0.5f ) / ( 29.53 * 0.5f );
return (float)( m_body.etr/ 1399.0 ) * phasefactor * 0.15f; // arbitrary scaling factor taken from etrn value
auto const phasefactor = 1.0f - std::abs( m_phase - 29.53f * 0.5f ) / ( 29.53f * 0.5f );
return static_cast<float>( ( m_body.etr/ 1399.0 ) * phasefactor * 0.15 ); // arbitrary scaling factor taken from etrn value
}
void cMoon::setLocation( float const Longitude, float const Latitude ) {

View File

@@ -250,7 +250,6 @@ opengl_renderer::Init( GLFWwindow *Window ) {
}
else {
ErrorLog( "Shadows framebuffer setup failed" );
m_framebuffersupport = false;
Global::RenderShadows = false;
}
::glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch back to primary render target for now

21
sky.cpp
View File

@@ -24,25 +24,4 @@ void TSky::Init() {
}
};
#ifdef EU07_USE_OLD_RENDERCODE
void TSky::Render( glm::vec3 const &Tint )
{
if (mdCloud)
{ // jeśli jest model nieba
// setup
::glEnable( GL_LIGHTING );
GfxRenderer.Disable_Lights();
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, glm::value_ptr(Tint) );
// render
GfxRenderer.Render( mdCloud, nullptr, 100.0 );
GfxRenderer.Render_Alpha( mdCloud, nullptr, 100.0 );
// post-render cleanup
GLfloat noambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
::glLightModelfv( GL_LIGHT_MODEL_AMBIENT, noambient );
::glEnable( GL_LIGHT0 ); // other lights will be enabled during lights update
::glDisable( GL_LIGHTING );
}
};
#endif
//---------------------------------------------------------------------------

3
sky.h
View File

@@ -21,9 +21,6 @@ private:
public:
void Init();
#ifdef EU07_USE_OLD_RENDERCODE
void Render( glm::vec3 const &Tint = glm::vec3(1.0f, 1.0f, 1.0f) );
#endif
};
//---------------------------------------------------------------------------

View File

@@ -15,9 +15,6 @@ public:
// methods:
void init();
#ifdef EU07_USE_OLD_RENDERCODE
void render();
#endif
// constructors:
// deconstructor:

28
sun.cpp
View File

@@ -41,8 +41,8 @@ cSun::update() {
move();
glm::vec3 position( 0.f, 0.f, -2000.f * Global::fDistanceFactor );
position = glm::rotateX( position, glm::radians<float>( m_body.elevref ) );
position = glm::rotateY( position, glm::radians<float>( -m_body.hrang ) );
position = glm::rotateX( position, glm::radians( static_cast<float>( m_body.elevref ) ) );
position = glm::rotateY( position, glm::radians( static_cast<float>( -m_body.hrang ) ) );
m_position = position;
}
@@ -50,23 +50,17 @@ cSun::update() {
void
cSun::render() {
/*
glLightfv(GL_LIGHT0, GL_POSITION, position.getVector() ); // sun
GLfloat LightPosition[]= { 10.0f, 50.0f, -5.0f, 1.0f }; // ambient
glLightfv(GL_LIGHT1, GL_POSITION, LightPosition );
*/
glColor4f( 255.0f/255.0f, 242.0f/255.0f, 231.0f/255.0f, 1.f );
::glColor4f( 255.f / 255.f, 242.f / 255.f, 231.f / 255.f, 1.f );
// debug line to locate the sun easier
glBegin( GL_LINES );
glVertex3f( m_position.x, m_position.y, m_position.z );
glVertex3f( m_position.x, 0.0f, m_position.z );
glEnd();
glPushMatrix();
glTranslatef( m_position.x, m_position.y, m_position.z );
::glBegin( GL_LINES );
::glVertex3fv( glm::value_ptr( m_position ) );
::glVertex3f( m_position.x, 0.f, m_position.z );
::glEnd();
::glPushMatrix();
::glTranslatef( m_position.x, m_position.y, m_position.z );
// radius is a result of scaling true distance down to 2km -- it's scaled by equal ratio
gluSphere( sunsphere, (float)(m_body.distance * 9.359157), 12, 12 );
glPopMatrix();
::gluSphere( sunsphere, m_body.distance * 9.359157, 12, 12 );
::glPopMatrix();
}
glm::vec3

View File

@@ -1,5 +1,5 @@
#pragma once
#define VERSION_MAJOR 17
#define VERSION_MINOR 820
#define VERSION_MINOR 821
#define VERSION_REVISION 0