mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02:00
camera-centric rendering, initial implementation
This commit is contained in:
@@ -606,16 +606,16 @@ int TAnimModel::Flags()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// 2011-03-16 funkcje renderowania z możliwością pochylania obiektów
|
// 2011-03-16 funkcje renderowania z możliwością pochylania obiektów
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TAnimModel::Render( vector3 *vPosition ) {
|
void TAnimModel::Render( vector3 const &Position ) {
|
||||||
RaAnimate(); // jednorazowe przeliczenie animacji
|
RaAnimate(); // jednorazowe przeliczenie animacji
|
||||||
RaPrepare();
|
RaPrepare();
|
||||||
if( pModel ) // renderowanie rekurencyjne submodeli
|
if( pModel ) // renderowanie rekurencyjne submodeli
|
||||||
GfxRenderer.Render( pModel, Material(), *vPosition, vAngle );
|
GfxRenderer.Render( pModel, Material(), Position, vAngle );
|
||||||
};
|
};
|
||||||
void TAnimModel::RenderAlpha( vector3 *vPosition ) {
|
void TAnimModel::RenderAlpha( vector3 const &Position ) {
|
||||||
RaPrepare();
|
RaPrepare();
|
||||||
if( pModel ) // renderowanie rekurencyjne submodeli
|
if( pModel ) // renderowanie rekurencyjne submodeli
|
||||||
GfxRenderer.Render_Alpha( pModel, Material(), *vPosition, vAngle );
|
GfxRenderer.Render_Alpha( pModel, Material(), Position, vAngle );
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -161,8 +161,8 @@ class TAnimModel
|
|||||||
bool Load(cParser *parser, bool ter = false);
|
bool Load(cParser *parser, bool ter = false);
|
||||||
TAnimContainer * AddContainer(char *pName);
|
TAnimContainer * AddContainer(char *pName);
|
||||||
TAnimContainer * GetContainer(char *pName);
|
TAnimContainer * GetContainer(char *pName);
|
||||||
void Render( vector3 *vPosition );
|
void Render( vector3 const &Position );
|
||||||
void RenderAlpha( vector3 *vPosition );
|
void RenderAlpha( vector3 const &Position );
|
||||||
int Flags();
|
int Flags();
|
||||||
void RaAnglesSet(double a, double b, double c)
|
void RaAnglesSet(double a, double b, double c)
|
||||||
{
|
{
|
||||||
|
|||||||
16
Camera.cpp
16
Camera.cpp
@@ -410,21 +410,21 @@ bool TCamera::SetMatrix()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TCamera::SetMatrix( glm::mat4 &Matrix ) {
|
bool TCamera::SetMatrix( glm::dmat4 &Matrix ) {
|
||||||
|
|
||||||
Matrix = glm::rotate( Matrix, (float)-Roll, glm::vec3( 0.0f, 0.0f, 1.0f ) ); // po wyłączeniu tego kręci się pojazd, a sceneria nie
|
Matrix = glm::rotate( Matrix, -Roll, glm::dvec3( 0.0, 0.0, 1.0 ) ); // po wyłączeniu tego kręci się pojazd, a sceneria nie
|
||||||
Matrix = glm::rotate( Matrix, (float)-Pitch, glm::vec3( 1.0f, 0.0f, 0.0f ) );
|
Matrix = glm::rotate( Matrix, -Pitch, glm::dvec3( 1.0, 0.0, 0.0 ) );
|
||||||
Matrix = glm::rotate( Matrix, (float)-Yaw, glm::vec3( 0.0f, 1.0f, 0.0f ) ); // w zewnętrznym widoku: kierunek patrzenia
|
Matrix = glm::rotate( Matrix, -Yaw, glm::dvec3( 0.0, 1.0, 0.0 ) ); // w zewnętrznym widoku: kierunek patrzenia
|
||||||
|
|
||||||
if( Type == tp_Follow ) {
|
if( Type == tp_Follow ) {
|
||||||
|
|
||||||
Matrix *= glm::lookAt(
|
Matrix *= glm::lookAt(
|
||||||
glm::vec3( Pos.x, Pos.y, Pos.z ),
|
glm::dvec3( Pos.x, Pos.y, Pos.z ),
|
||||||
glm::vec3( LookAt.x, LookAt.y, LookAt.z ),
|
glm::dvec3( LookAt.x, LookAt.y, LookAt.z ),
|
||||||
glm::vec3( vUp.x, vUp.y, vUp.z ) );
|
glm::dvec3( vUp.x, vUp.y, vUp.z ) );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Matrix = glm::translate( Matrix, glm::vec3( -Pos.x, -Pos.y, -Pos.z ) ); // nie zmienia kierunku patrzenia
|
Matrix = glm::translate( Matrix, glm::dvec3( -Pos.x, -Pos.y, -Pos.z ) ); // nie zmienia kierunku patrzenia
|
||||||
}
|
}
|
||||||
|
|
||||||
Global::SetCameraPosition( Pos ); // było +pOffset
|
Global::SetCameraPosition( Pos ); // było +pOffset
|
||||||
|
|||||||
2
Camera.h
2
Camera.h
@@ -58,7 +58,7 @@ class TCamera
|
|||||||
void Update();
|
void Update();
|
||||||
vector3 GetDirection();
|
vector3 GetDirection();
|
||||||
bool SetMatrix();
|
bool SetMatrix();
|
||||||
bool SetMatrix(glm::mat4 &Matrix);
|
bool SetMatrix(glm::dmat4 &Matrix);
|
||||||
void SetCabMatrix( vector3 &p );
|
void SetCabMatrix( vector3 &p );
|
||||||
void RaLook();
|
void RaLook();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|||||||
144
Ground.cpp
144
Ground.cpp
@@ -248,43 +248,6 @@ void TGroundNode::InitNormals()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TGroundNode::MoveMe(vector3 pPosition)
|
|
||||||
{ // przesuwanie obiektów scenerii o wektor w celu redukcji trzęsienia
|
|
||||||
pCenter += pPosition;
|
|
||||||
switch (iType)
|
|
||||||
{
|
|
||||||
case TP_TRACTION:
|
|
||||||
hvTraction->pPoint1 += pPosition;
|
|
||||||
hvTraction->pPoint2 += pPosition;
|
|
||||||
hvTraction->pPoint3 += pPosition;
|
|
||||||
hvTraction->pPoint4 += pPosition;
|
|
||||||
hvTraction->Optimize();
|
|
||||||
break;
|
|
||||||
case TP_MODEL:
|
|
||||||
case TP_DYNAMIC:
|
|
||||||
case TP_MEMCELL:
|
|
||||||
case TP_EVLAUNCH:
|
|
||||||
break;
|
|
||||||
case TP_TRACK:
|
|
||||||
pTrack->MoveMe(pPosition);
|
|
||||||
break;
|
|
||||||
case TP_SOUND: // McZapkie - dzwiek zapetlony w zaleznosci od odleglosci
|
|
||||||
tsStaticSound->vSoundPosition += pPosition;
|
|
||||||
break;
|
|
||||||
case GL_LINES:
|
|
||||||
case GL_LINE_STRIP:
|
|
||||||
case GL_LINE_LOOP:
|
|
||||||
for (int i = 0; i < iNumPts; i++)
|
|
||||||
Points[i] += pPosition;
|
|
||||||
ResourceManager::Unregister(this);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
for (int i = 0; i < iNumVerts; i++)
|
|
||||||
Vertices[i].Point += pPosition;
|
|
||||||
ResourceManager::Unregister(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TGroundNode::RaRenderVBO()
|
void TGroundNode::RaRenderVBO()
|
||||||
{ // renderowanie z domyslnego bufora VBO
|
{ // renderowanie z domyslnego bufora VBO
|
||||||
glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]);
|
glColor3ub(Diffuse[0], Diffuse[1], Diffuse[2]);
|
||||||
@@ -309,7 +272,10 @@ void TGroundNode::Compile(bool many)
|
|||||||
{
|
{
|
||||||
glBegin(iType);
|
glBegin(iType);
|
||||||
for (int i = 0; i < iNumPts; ++i)
|
for (int i = 0; i < iNumPts; ++i)
|
||||||
glVertex3dv(&Points[i].x);
|
glVertex3d(
|
||||||
|
Points[i].x - m_rootposition.x,
|
||||||
|
Points[i].y - m_rootposition.y,
|
||||||
|
Points[i].z - m_rootposition.z );
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
else if (iType == GL_TRIANGLE_STRIP || iType == GL_TRIANGLE_FAN || iType == GL_TRIANGLES)
|
else if (iType == GL_TRIANGLE_STRIP || iType == GL_TRIANGLE_FAN || iType == GL_TRIANGLES)
|
||||||
@@ -323,9 +289,14 @@ void TGroundNode::Compile(bool many)
|
|||||||
for (int i = 0; i < iNumVerts; ++i)
|
for (int i = 0; i < iNumVerts; ++i)
|
||||||
{
|
{
|
||||||
glNormal3dv(&Vertices[i].Normal.x);
|
glNormal3dv(&Vertices[i].Normal.x);
|
||||||
glTexCoord2f(Vertices[i].tu, Vertices[i].tv);
|
glTexCoord2f(
|
||||||
glVertex3dv(&Vertices[i].Point.x);
|
Vertices[i].tu,
|
||||||
};
|
Vertices[i].tv);
|
||||||
|
glVertex3d(
|
||||||
|
Points[i].x - m_rootposition.x,
|
||||||
|
Points[i].y - m_rootposition.y,
|
||||||
|
Points[i].z - m_rootposition.z );
|
||||||
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
else if (iType == TP_MESH)
|
else if (iType == TP_MESH)
|
||||||
@@ -408,6 +379,9 @@ void TSubRect::NodeAdd(TGroundNode *Node)
|
|||||||
// nRenderAlpha - lista grup renderowanych z własnych VBO albo DL z przezroczystością
|
// nRenderAlpha - lista grup renderowanych z własnych VBO albo DL z przezroczystością
|
||||||
// nRenderWires - lista grup renderowanych z własnych VBO albo DL - druty i linie
|
// nRenderWires - lista grup renderowanych z własnych VBO albo DL - druty i linie
|
||||||
// nMeshed - obiekty do pogrupowania wg tekstur
|
// nMeshed - obiekty do pogrupowania wg tekstur
|
||||||
|
|
||||||
|
Node->m_rootposition = Math3D::vector3( m_area.center.x, m_area.center.y, m_area.center.z ) ;
|
||||||
|
|
||||||
switch (Node->iType)
|
switch (Node->iType)
|
||||||
{
|
{
|
||||||
case TP_SOUND: // te obiekty są sprawdzanie niezależnie od kierunku patrzenia
|
case TP_SOUND: // te obiekty są sprawdzanie niezależnie od kierunku patrzenia
|
||||||
@@ -418,11 +392,11 @@ void TSubRect::NodeAdd(TGroundNode *Node)
|
|||||||
case TP_TRACK: // TODO: tory z cieniem (tunel, canyon) też dać bez łączenia?
|
case TP_TRACK: // TODO: tory z cieniem (tunel, canyon) też dać bez łączenia?
|
||||||
++iTracks; // jeden tor więcej
|
++iTracks; // jeden tor więcej
|
||||||
Node->pTrack->RaOwnerSet(this); // do którego sektora ma zgłaszać animację
|
Node->pTrack->RaOwnerSet(this); // do którego sektora ma zgłaszać animację
|
||||||
// if (Global::bUseVBO?false:!Node->pTrack->IsGroupable())
|
if( ( true == Global::bUseVBO )
|
||||||
if (Global::bUseVBO ? true :
|
|| ( false == Node->pTrack->IsGroupable() ) ) {
|
||||||
!Node->pTrack->IsGroupable()) // TODO: tymczasowo dla VBO wyłączone
|
// tory ruchome nie są grupowane przy Display Lists (wymagają odświeżania DL)
|
||||||
RaNodeAdd(
|
RaNodeAdd( Node );
|
||||||
Node); // tory ruchome nie są grupowane przy Display Lists (wymagają odświeżania DL)
|
}
|
||||||
else
|
else
|
||||||
{ // tory nieruchome mogą być pogrupowane wg tekstury, przy VBO wszystkie
|
{ // tory nieruchome mogą być pogrupowane wg tekstury, przy VBO wszystkie
|
||||||
Node->TextureID = Node->pTrack->TextureGet(0); // pobranie tekstury do sortowania
|
Node->TextureID = Node->pTrack->TextureGet(0); // pobranie tekstury do sortowania
|
||||||
@@ -800,9 +774,9 @@ void TSubRect::LoadNodes()
|
|||||||
case GL_TRIANGLES:
|
case GL_TRIANGLES:
|
||||||
for (i = 0; i < n->iNumVerts; ++i)
|
for (i = 0; i < n->iNumVerts; ++i)
|
||||||
{ // Ra: trójkąty można od razu wczytywać do takich tablic... to może poczekać
|
{ // Ra: trójkąty można od razu wczytywać do takich tablic... to może poczekać
|
||||||
m_pVNT[n->iVboPtr + i].x = n->Vertices[i].Point.x;
|
m_pVNT[n->iVboPtr + i].x = n->Vertices[i].Point.x - n->m_rootposition.x;
|
||||||
m_pVNT[n->iVboPtr + i].y = n->Vertices[i].Point.y;
|
m_pVNT[n->iVboPtr + i].y = n->Vertices[i].Point.y - n->m_rootposition.y;
|
||||||
m_pVNT[n->iVboPtr + i].z = n->Vertices[i].Point.z;
|
m_pVNT[n->iVboPtr + i].z = n->Vertices[i].Point.z - n->m_rootposition.z;
|
||||||
m_pVNT[n->iVboPtr + i].nx = n->Vertices[i].Normal.x;
|
m_pVNT[n->iVboPtr + i].nx = n->Vertices[i].Normal.x;
|
||||||
m_pVNT[n->iVboPtr + i].ny = n->Vertices[i].Normal.y;
|
m_pVNT[n->iVboPtr + i].ny = n->Vertices[i].Normal.y;
|
||||||
m_pVNT[n->iVboPtr + i].nz = n->Vertices[i].Normal.z;
|
m_pVNT[n->iVboPtr + i].nz = n->Vertices[i].Normal.z;
|
||||||
@@ -815,9 +789,9 @@ void TSubRect::LoadNodes()
|
|||||||
case GL_LINE_LOOP:
|
case GL_LINE_LOOP:
|
||||||
for (i = 0; i < n->iNumPts; ++i)
|
for (i = 0; i < n->iNumPts; ++i)
|
||||||
{
|
{
|
||||||
m_pVNT[n->iVboPtr + i].x = n->Points[i].x;
|
m_pVNT[n->iVboPtr + i].x = n->Points[i].x - n->m_rootposition.x;
|
||||||
m_pVNT[n->iVboPtr + i].y = n->Points[i].y;
|
m_pVNT[n->iVboPtr + i].y = n->Points[i].y - n->m_rootposition.y;
|
||||||
m_pVNT[n->iVboPtr + i].z = n->Points[i].z;
|
m_pVNT[n->iVboPtr + i].z = n->Points[i].z - n->m_rootposition.z;
|
||||||
// miejsce w tablicach normalnych i teksturowania się marnuje...
|
// miejsce w tablicach normalnych i teksturowania się marnuje...
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -833,7 +807,7 @@ void TSubRect::LoadNodes()
|
|||||||
case TP_TRACTION:
|
case TP_TRACTION:
|
||||||
if( n->iNumVerts ) { // druty mogą być niewidoczne...?
|
if( n->iNumVerts ) { // druty mogą być niewidoczne...?
|
||||||
#ifdef EU07_USE_OLD_VERTEXBUFFER
|
#ifdef EU07_USE_OLD_VERTEXBUFFER
|
||||||
n->hvTraction->RaArrayFill( m_pVNT + n->iVboPtr );
|
n->hvTraction->RaArrayFill( m_pVNT + n->iVboPtr, n->m_rootposition );
|
||||||
#else
|
#else
|
||||||
n->hvTraction->RaArrayFill( m_pVNT.data() + n->iVboPtr );
|
n->hvTraction->RaArrayFill( m_pVNT.data() + n->iVboPtr );
|
||||||
#endif
|
#endif
|
||||||
@@ -960,12 +934,14 @@ TGroundRect::Init() {
|
|||||||
float const subrectsize = 1000.0f / iNumSubRects;
|
float const subrectsize = 1000.0f / iNumSubRects;
|
||||||
for( int column = 0; column < iNumSubRects; ++column ) {
|
for( int column = 0; column < iNumSubRects; ++column ) {
|
||||||
for( int row = 0; row < iNumSubRects; ++row ) {
|
for( int row = 0; row < iNumSubRects; ++row ) {
|
||||||
auto &area = FastGetRect(column, row)->m_area;
|
auto &area = SafeGetRect(column, row)->m_area;
|
||||||
area.center =
|
area.center =
|
||||||
m_area.center
|
m_area.center
|
||||||
- float3( 500.0f, 0.0f, 500.0f ) // 'upper left' corner of rectangle
|
- glm::vec3( 500.0f, 0.0f, 500.0f ) // 'upper left' corner of rectangle
|
||||||
+ float3( subrectsize * 0.5f, 0.0f, subrectsize * 0.5f ) // center of sub-rectangle
|
+ glm::vec3( subrectsize * 0.5f, 0.0f, subrectsize * 0.5f ) // center of sub-rectangle
|
||||||
+ float3( subrectsize * column, 0.0f, subrectsize * row );
|
+ glm::vec3( subrectsize * column, 0.0f, subrectsize * row );
|
||||||
|
// NOTE: the actual coordinates get swapped, as they're swapped in rest of the code :x
|
||||||
|
area.center = glm::vec3( area.center.z, area.center.y, area.center.x );
|
||||||
area.radius = subrectsize * M_SQRT2;
|
area.radius = subrectsize * M_SQRT2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1051,17 +1027,17 @@ TGround::TGround()
|
|||||||
|
|
||||||
// set bounding area information for ground rectangles
|
// set bounding area information for ground rectangles
|
||||||
float const rectsize = 1000.0f;
|
float const rectsize = 1000.0f;
|
||||||
float3 const worldcenter( 0.0f, 0.0f, 0.0f );
|
glm::vec3 const worldcenter( 0.0f, 0.0f, 0.0f );
|
||||||
for( int column = 0; column < iNumRects; ++column ) {
|
for( int column = 0; column < iNumRects; ++column ) {
|
||||||
for( int row = 0; row < iNumRects; ++row ) {
|
for( int row = 0; row < iNumRects; ++row ) {
|
||||||
auto &area = Rects[ column ][ row ].m_area;
|
auto &area = Rects[ column ][ row ].m_area;
|
||||||
// NOTE: in current implementation triangles can stick out to ~200m from the area, so we add extra padding
|
// NOTE: in current implementation triangles can stick out to ~200m from the area, so we add extra padding
|
||||||
area.radius = 200.0f + rectsize * 0.5f * M_SQRT2;
|
area.radius = ( rectsize * 0.5f * M_SQRT2 ) + 200.0f;
|
||||||
area.center =
|
area.center =
|
||||||
worldcenter
|
worldcenter
|
||||||
- float3( (iNumRects / 2) * rectsize, 0.0f, (iNumRects / 2) * rectsize ) // 'upper left' corner of the world
|
- glm::vec3( (iNumRects / 2) * rectsize, 0.0f, (iNumRects / 2) * rectsize ) // 'upper left' corner of the world
|
||||||
+ float3( rectsize * 0.5f, 0.0f, rectsize * 0.5f ) // center of the rectangle
|
+ glm::vec3( rectsize * 0.5f, 0.0f, rectsize * 0.5f ) // center of the rectangle
|
||||||
+ float3( rectsize * column, 0.0f, rectsize * row );
|
+ glm::vec3( rectsize * column, 0.0f, rectsize * row );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1995,39 +1971,38 @@ void TGround::FirstInit()
|
|||||||
gr->RaNodeAdd(&Current->nNode[j]);
|
gr->RaNodeAdd(&Current->nNode[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if
|
else if( ( Current->iType != GL_TRIANGLES )
|
||||||
// ((Current->iType!=GL_TRIANGLES)&&(Current->iType!=GL_TRIANGLE_STRIP)?true
|
|| ( Current->iFlags & 0x20 )
|
||||||
// //~czy trójkąt?
|
|| ( Current->fSquareMinRadius != 0.0 )
|
||||||
else if ((Current->iType != GL_TRIANGLES) ?
|
|| ( Current->fSquareRadius <= 90000.0 ) ) {
|
||||||
true //~czy trójkąt?
|
// add to sub-rectangle
|
||||||
:
|
|
||||||
(Current->iFlags & 0x20) ?
|
|
||||||
true //~czy teksturę ma nieprzezroczystą?
|
|
||||||
:
|
|
||||||
(Current->fSquareMinRadius != 0.0) ?
|
|
||||||
true //~czy widoczny z bliska?
|
|
||||||
:
|
|
||||||
(Current->fSquareRadius <= 90000.0)) //~czy widoczny z daleka?
|
|
||||||
GetSubRect( Current->pCenter.x, Current->pCenter.z )->NodeAdd( Current );
|
GetSubRect( Current->pCenter.x, Current->pCenter.z )->NodeAdd( Current );
|
||||||
else // dodajemy do kwadratu kilometrowego
|
}
|
||||||
|
else {
|
||||||
|
// dodajemy do kwadratu kilometrowego
|
||||||
GetRect( Current->pCenter.x, Current->pCenter.z )->NodeAdd( Current );
|
GetRect( Current->pCenter.x, Current->pCenter.z )->NodeAdd( Current );
|
||||||
}
|
}
|
||||||
// if (Current->iType!=TP_DYNAMIC)
|
}
|
||||||
// GetSubRect(Current->pCenter.x,Current->pCenter.z)->AddNode(Current);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < iNumRects; ++i)
|
for (i = 0; i < iNumRects; ++i)
|
||||||
for (j = 0; j < iNumRects; ++j)
|
for (j = 0; j < iNumRects; ++j)
|
||||||
Rects[i][j].Optimize(); // optymalizacja obiektów w sektorach
|
Rects[i][j].Optimize(); // optymalizacja obiektów w sektorach
|
||||||
|
|
||||||
WriteLog("InitNormals OK");
|
WriteLog("InitNormals OK");
|
||||||
|
|
||||||
InitTracks(); //łączenie odcinków ze sobą i przyklejanie eventów
|
InitTracks(); //łączenie odcinków ze sobą i przyklejanie eventów
|
||||||
WriteLog("InitTracks OK");
|
WriteLog("InitTracks OK");
|
||||||
|
|
||||||
InitTraction(); //łączenie drutów ze sobą
|
InitTraction(); //łączenie drutów ze sobą
|
||||||
WriteLog("InitTraction OK");
|
WriteLog("InitTraction OK");
|
||||||
|
|
||||||
InitEvents();
|
InitEvents();
|
||||||
WriteLog("InitEvents OK");
|
WriteLog("InitEvents OK");
|
||||||
|
|
||||||
InitLaunchers();
|
InitLaunchers();
|
||||||
WriteLog("InitLaunchers OK");
|
WriteLog("InitLaunchers OK");
|
||||||
|
|
||||||
WriteLog("FirstInit is done");
|
WriteLog("FirstInit is done");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2077,13 +2052,14 @@ bool TGround::Init(std::string File)
|
|||||||
}
|
}
|
||||||
else if ( ( LastNode->iType == TP_TRACTION ) && ( false == Global::bLoadTraction ) )
|
else if ( ( LastNode->iType == TP_TRACTION ) && ( false == Global::bLoadTraction ) )
|
||||||
SafeDelete(LastNode); // usuwamy druty, jeśli wyłączone
|
SafeDelete(LastNode); // usuwamy druty, jeśli wyłączone
|
||||||
|
|
||||||
if (LastNode) // dopiero na koniec dopisujemy do tablic
|
if (LastNode) // dopiero na koniec dopisujemy do tablic
|
||||||
if (LastNode->iType != TP_DYNAMIC)
|
if (LastNode->iType != TP_DYNAMIC)
|
||||||
{ // jeśli nie jest pojazdem
|
{ // jeśli nie jest pojazdem
|
||||||
LastNode->nNext = nRootOfType[LastNode->iType]; // ostatni dodany dołączamy
|
// ostatni dodany dołączamy na końcu nowego
|
||||||
// na końcu nowego
|
LastNode->nNext = nRootOfType[LastNode->iType];
|
||||||
nRootOfType[LastNode->iType] =
|
// ustawienie nowego na początku listy
|
||||||
LastNode; // ustawienie nowego na początku listy
|
nRootOfType[LastNode->iType] = LastNode;
|
||||||
iNumNodes++;
|
iNumNodes++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2437,10 +2413,6 @@ bool TGround::Init(std::string File)
|
|||||||
else // jak liczba to na pewno błąd
|
else // jak liczba to na pewno błąd
|
||||||
Error("Unrecognized command: " + str);
|
Error("Unrecognized command: " + str);
|
||||||
}
|
}
|
||||||
/* else if (str == "")
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
// LastNode=NULL;
|
|
||||||
|
|
||||||
token = "";
|
token = "";
|
||||||
parser.getTokens();
|
parser.getTokens();
|
||||||
|
|||||||
14
Ground.h
14
Ground.h
@@ -122,19 +122,20 @@ public:
|
|||||||
TGroundNode *nNode; // obiekt renderujący grupowo ma tu wskaźnik na listę obiektów
|
TGroundNode *nNode; // obiekt renderujący grupowo ma tu wskaźnik na listę obiektów
|
||||||
};
|
};
|
||||||
std::string asName; // nazwa (nie zawsze ma znaczenie)
|
std::string asName; // nazwa (nie zawsze ma znaczenie)
|
||||||
|
|
||||||
|
vector3 pCenter; // współrzędne środka do przydzielenia sektora
|
||||||
|
vector3 m_rootposition; // position of the ground (sub)rectangle holding the node, in the 3d world
|
||||||
|
// visualization-related data
|
||||||
|
// TODO: wrap these in a struct, when cleaning objects up
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
int iNumVerts; // dla trójkątów
|
int iNumVerts; // dla trójkątów
|
||||||
int iNumPts; // dla linii
|
int iNumPts; // dla linii
|
||||||
int iCount; // dla terenu
|
int iCount; // dla terenu
|
||||||
// int iState; //Ra: nie używane - dźwięki zapętlone
|
|
||||||
};
|
};
|
||||||
vector3 pCenter; // współrzędne środka do przydzielenia sektora
|
|
||||||
|
|
||||||
double fLineThickness; // McZapkie-120702: grubosc linii
|
double fLineThickness; // McZapkie-120702: grubosc linii
|
||||||
double fSquareRadius; // kwadrat widoczności do
|
double fSquareRadius; // kwadrat widoczności do
|
||||||
double fSquareMinRadius; // kwadrat widoczności od
|
double fSquareMinRadius; // kwadrat widoczności od
|
||||||
// TGroundNode *nMeshGroup; //Ra: obiekt grupujący trójkąty w TSubRect dla tekstury
|
|
||||||
int iVersion; // wersja siatki (do wykonania rekompilacji)
|
int iVersion; // wersja siatki (do wykonania rekompilacji)
|
||||||
// union ?
|
// union ?
|
||||||
GLuint DisplayListID; // numer siatki DisplayLists
|
GLuint DisplayListID; // numer siatki DisplayLists
|
||||||
@@ -144,6 +145,7 @@ public:
|
|||||||
int iFlags; // tryb przezroczystości: 0x10-nieprz.,0x20-przezroczysty,0x30-mieszany
|
int iFlags; // tryb przezroczystości: 0x10-nieprz.,0x20-przezroczysty,0x30-mieszany
|
||||||
int Ambient[4], Diffuse[4], Specular[4]; // oświetlenie
|
int Ambient[4], Diffuse[4], Specular[4]; // oświetlenie
|
||||||
bool bVisible;
|
bool bVisible;
|
||||||
|
|
||||||
TGroundNode *nNext; // lista wszystkich w scenerii, ostatni na początku
|
TGroundNode *nNext; // lista wszystkich w scenerii, ostatni na początku
|
||||||
TGroundNode *nNext2; // lista obiektów w sektorze
|
TGroundNode *nNext2; // lista obiektów w sektorze
|
||||||
TGroundNode *nNext3; // lista obiektów renderowanych we wspólnym cyklu
|
TGroundNode *nNext3; // lista obiektów renderowanych we wspólnym cyklu
|
||||||
@@ -154,8 +156,6 @@ public:
|
|||||||
void InitCenter(); // obliczenie współrzędnych środka
|
void InitCenter(); // obliczenie współrzędnych środka
|
||||||
void InitNormals();
|
void InitNormals();
|
||||||
|
|
||||||
void MoveMe(vector3 pPosition); // przesuwanie (nie działa)
|
|
||||||
|
|
||||||
// bool Disable();
|
// bool Disable();
|
||||||
inline TGroundNode * Find(const std::string &asNameToFind, TGroundNodeType iNodeType)
|
inline TGroundNode * Find(const std::string &asNameToFind, TGroundNodeType iNodeType)
|
||||||
{ // wyszukiwanie czołgowe z typem
|
{ // wyszukiwanie czołgowe z typem
|
||||||
@@ -177,7 +177,7 @@ public:
|
|||||||
|
|
||||||
struct bounding_area {
|
struct bounding_area {
|
||||||
|
|
||||||
float3 center; // mid point of the rectangle
|
glm::vec3 center; // mid point of the rectangle
|
||||||
float radius{ 0.0f }; // radius of the bounding sphere
|
float radius{ 0.0f }; // radius of the bounding sphere
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
34
Segment.cpp
34
Segment.cpp
@@ -319,7 +319,7 @@ vector3 TSegment::FastGetPoint(double t)
|
|||||||
return (bCurve ? RaInterpolate(t) : ((1.0 - t) * Point1 + (t)*Point2));
|
return (bCurve ? RaInterpolate(t) : ((1.0 - t) * Point1 + (t)*Point2));
|
||||||
}
|
}
|
||||||
|
|
||||||
int TSegment::RenderLoft( CVertNormTex* &Output, const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale, int iSkip, int iEnd, double fOffsetX, bool Onlypositions, vector3 **p, bool bRender)
|
int TSegment::RenderLoft( CVertNormTex* &Output, Math3D::vector3 const &Origin, const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale, int iSkip, int iEnd, double fOffsetX, vector3 **p, bool bRender)
|
||||||
{ // generowanie trójkątów dla odcinka trajektorii ruchu
|
{ // generowanie trójkątów dla odcinka trajektorii ruchu
|
||||||
// standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku
|
// standardowo tworzy triangle_strip dla prostego albo ich zestaw dla łuku
|
||||||
// po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli
|
// po modyfikacji - dla ujemnego (iNumShapePoints) w dodatkowych polach tabeli
|
||||||
@@ -368,12 +368,10 @@ int TSegment::RenderLoft( CVertNormTex* &Output, const vector6 *ShapePoints, int
|
|||||||
jmm2 = 0.0;
|
jmm2 = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( false == Onlypositions ) {
|
|
||||||
while( tv1 < 0.0 ) {
|
while( tv1 < 0.0 ) {
|
||||||
tv1 += 1.0;
|
tv1 += 1.0;
|
||||||
}
|
}
|
||||||
tv2 = tv1 - step / fTextureLength; // mapowanie na końcu segmentu
|
tv2 = tv1 - step / fTextureLength; // mapowanie na końcu segmentu
|
||||||
}
|
|
||||||
|
|
||||||
t = fTsBuffer[ i ]; // szybsze od GetTFromS(s);
|
t = fTsBuffer[ i ]; // szybsze od GetTFromS(s);
|
||||||
pos2 = FastGetPoint( t );
|
pos2 = FastGetPoint( t );
|
||||||
@@ -389,30 +387,25 @@ int TSegment::RenderLoft( CVertNormTex* &Output, const vector6 *ShapePoints, int
|
|||||||
for( int j = 0; j < iNumShapePoints; ++j ) {
|
for( int j = 0; j < iNumShapePoints; ++j ) {
|
||||||
pt = parallel1 * ( jmm1 * ( ShapePoints[ j ].x - fOffsetX ) + m1 * ShapePoints[ j + iNumShapePoints ].x ) + pos1;
|
pt = parallel1 * ( jmm1 * ( ShapePoints[ j ].x - fOffsetX ) + m1 * ShapePoints[ j + iNumShapePoints ].x ) + pos1;
|
||||||
pt.y += jmm1 * ShapePoints[ j ].y + m1 * ShapePoints[ j + iNumShapePoints ].y;
|
pt.y += jmm1 * ShapePoints[ j ].y + m1 * ShapePoints[ j + iNumShapePoints ].y;
|
||||||
if( false == Onlypositions ) {
|
pt -= Origin;
|
||||||
norm = ( jmm1 * ShapePoints[ j ].n.x + m1 * ShapePoints[ j + iNumShapePoints ].n.x ) * parallel1;
|
norm = ( jmm1 * ShapePoints[ j ].n.x + m1 * ShapePoints[ j + iNumShapePoints ].n.x ) * parallel1;
|
||||||
norm.y += jmm1 * ShapePoints[ j ].n.y + m1 * ShapePoints[ j + iNumShapePoints ].n.y;
|
norm.y += jmm1 * ShapePoints[ j ].n.y + m1 * ShapePoints[ j + iNumShapePoints ].n.y;
|
||||||
}
|
|
||||||
if( bRender ) { // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
if( bRender ) { // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
||||||
if( Output == nullptr ) {
|
if( Output == nullptr ) {
|
||||||
// immediate mode
|
// immediate mode
|
||||||
if( false == Onlypositions ) {
|
|
||||||
::glNormal3f( norm.x, norm.y, norm.z );
|
::glNormal3f( norm.x, norm.y, norm.z );
|
||||||
::glTexCoord2f( (jmm1 * ShapePoints[ j ].z + m1 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale, tv1 );
|
::glTexCoord2f( (jmm1 * ShapePoints[ j ].z + m1 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale, tv1 );
|
||||||
}
|
|
||||||
::glVertex3f( pt.x, pt.y, pt.z ); // pt nie mamy gdzie zapamiętać?
|
::glVertex3f( pt.x, pt.y, pt.z ); // pt nie mamy gdzie zapamiętać?
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Output->x = pt.x;
|
Output->x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->z = pt.z;
|
||||||
if( false == Onlypositions ) {
|
|
||||||
Output->nx = norm.x;
|
Output->nx = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->ny = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->nz = norm.z;
|
||||||
Output->u = (jmm1 * ShapePoints[ j ].z + m1 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
Output->u = (jmm1 * ShapePoints[ j ].z + m1 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
||||||
Output->v = tv1;
|
Output->v = tv1;
|
||||||
}
|
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
@@ -427,30 +420,25 @@ int TSegment::RenderLoft( CVertNormTex* &Output, const vector6 *ShapePoints, int
|
|||||||
// dla trapezu drugi koniec ma inne współrzędne
|
// dla trapezu drugi koniec ma inne współrzędne
|
||||||
pt = parallel2 * ( jmm2 * ( ShapePoints[ j ].x - fOffsetX ) + m2 * ShapePoints[ j + iNumShapePoints ].x ) + pos2;
|
pt = parallel2 * ( jmm2 * ( ShapePoints[ j ].x - fOffsetX ) + m2 * ShapePoints[ j + iNumShapePoints ].x ) + pos2;
|
||||||
pt.y += jmm2 * ShapePoints[ j ].y + m2 * ShapePoints[ j + iNumShapePoints ].y;
|
pt.y += jmm2 * ShapePoints[ j ].y + m2 * ShapePoints[ j + iNumShapePoints ].y;
|
||||||
if( false == Onlypositions ) {
|
pt -= Origin;
|
||||||
norm = ( jmm1 * ShapePoints[ j ].n.x + m1 * ShapePoints[ j + iNumShapePoints ].n.x ) * parallel2;
|
norm = ( jmm1 * ShapePoints[ j ].n.x + m1 * ShapePoints[ j + iNumShapePoints ].n.x ) * parallel2;
|
||||||
norm.y += jmm1 * ShapePoints[ j ].n.y + m1 * ShapePoints[ j + iNumShapePoints ].n.y;
|
norm.y += jmm1 * ShapePoints[ j ].n.y + m1 * ShapePoints[ j + iNumShapePoints ].n.y;
|
||||||
}
|
|
||||||
if( bRender ) { // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
if( bRender ) { // skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
||||||
if( Output == nullptr ) {
|
if( Output == nullptr ) {
|
||||||
// immediate mode
|
// immediate mode
|
||||||
if( false == Onlypositions ) {
|
|
||||||
::glNormal3f( norm.x, norm.y, norm.z );
|
::glNormal3f( norm.x, norm.y, norm.z );
|
||||||
::glTexCoord2f( (jmm2 * ShapePoints[ j ].z + m2 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale, tv2 );
|
::glTexCoord2f( (jmm2 * ShapePoints[ j ].z + m2 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale, tv2 );
|
||||||
}
|
|
||||||
::glVertex3f( pt.x, pt.y, pt.z );
|
::glVertex3f( pt.x, pt.y, pt.z );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Output->x = pt.x;
|
Output->x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->z = pt.z;
|
||||||
if( false == Onlypositions ) {
|
|
||||||
Output->nx = norm.x;
|
Output->nx = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->ny = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->nz = norm.z;
|
||||||
Output->u = (jmm2 * ShapePoints[ j ].z + m2 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
Output->u = (jmm2 * ShapePoints[ j ].z + m2 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
||||||
Output->v = tv2;
|
Output->v = tv2;
|
||||||
}
|
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
@@ -470,58 +458,48 @@ int TSegment::RenderLoft( CVertNormTex* &Output, const vector6 *ShapePoints, int
|
|||||||
//łuk z jednym profilem
|
//łuk z jednym profilem
|
||||||
pt = parallel1 * ( ShapePoints[ j ].x - fOffsetX ) + pos1;
|
pt = parallel1 * ( ShapePoints[ j ].x - fOffsetX ) + pos1;
|
||||||
pt.y += ShapePoints[ j ].y;
|
pt.y += ShapePoints[ j ].y;
|
||||||
if( false == Onlypositions ) {
|
pt -= Origin;
|
||||||
norm = ShapePoints[ j ].n.x * parallel1;
|
norm = ShapePoints[ j ].n.x * parallel1;
|
||||||
norm.y += ShapePoints[ j ].n.y;
|
norm.y += ShapePoints[ j ].n.y;
|
||||||
}
|
|
||||||
if( Output == nullptr ) {
|
if( Output == nullptr ) {
|
||||||
// immediate mode
|
// immediate mode
|
||||||
if( false == Onlypositions ) {
|
|
||||||
::glNormal3f( norm.x, norm.y, norm.z );
|
::glNormal3f( norm.x, norm.y, norm.z );
|
||||||
::glTexCoord2f( ShapePoints[ j ].z / Texturescale, tv1 );
|
::glTexCoord2f( ShapePoints[ j ].z / Texturescale, tv1 );
|
||||||
}
|
|
||||||
::glVertex3f( pt.x, pt.y, pt.z ); // punkt na początku odcinka
|
::glVertex3f( pt.x, pt.y, pt.z ); // punkt na początku odcinka
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Output->x = pt.x;
|
Output->x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->z = pt.z;
|
||||||
if( false == Onlypositions ) {
|
|
||||||
Output->nx = norm.x;
|
Output->nx = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->ny = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->nz = norm.z;
|
||||||
Output->u = ShapePoints[ j ].z / Texturescale;
|
Output->u = ShapePoints[ j ].z / Texturescale;
|
||||||
Output->v = tv1;
|
Output->v = tv1;
|
||||||
}
|
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
|
|
||||||
pt = parallel2 * ShapePoints[ j ].x + pos2;
|
pt = parallel2 * ShapePoints[ j ].x + pos2;
|
||||||
pt.y += ShapePoints[ j ].y;
|
pt.y += ShapePoints[ j ].y;
|
||||||
if( false == Onlypositions ) {
|
pt -= Origin;
|
||||||
norm = ShapePoints[ j ].n.x * parallel2;
|
norm = ShapePoints[ j ].n.x * parallel2;
|
||||||
norm.y += ShapePoints[ j ].n.y;
|
norm.y += ShapePoints[ j ].n.y;
|
||||||
}
|
|
||||||
if( Output == nullptr ) {
|
if( Output == nullptr ) {
|
||||||
// immediate mode
|
// immediate mode
|
||||||
if( false == Onlypositions ) {
|
|
||||||
::glNormal3f( norm.x, norm.y, norm.z );
|
::glNormal3f( norm.x, norm.y, norm.z );
|
||||||
::glTexCoord2f( ShapePoints[ j ].z / Texturescale, tv2 );
|
::glTexCoord2f( ShapePoints[ j ].z / Texturescale, tv2 );
|
||||||
}
|
|
||||||
::glVertex3f( pt.x, pt.y, pt.z ); // punkt na końcu odcinka
|
::glVertex3f( pt.x, pt.y, pt.z ); // punkt na końcu odcinka
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Output->x = pt.x;
|
Output->x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->z = pt.z;
|
||||||
if( false == Onlypositions ) {
|
|
||||||
Output->nx = norm.x;
|
Output->nx = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->ny = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->nz = norm.z;
|
||||||
Output->u = ShapePoints[ j ].z / Texturescale;
|
Output->u = ShapePoints[ j ].z / Texturescale;
|
||||||
Output->v = tv2;
|
Output->v = tv2;
|
||||||
}
|
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
@@ -534,10 +512,8 @@ int TSegment::RenderLoft( CVertNormTex* &Output, const vector6 *ShapePoints, int
|
|||||||
}
|
}
|
||||||
pos1 = pos2;
|
pos1 = pos2;
|
||||||
parallel1 = parallel2;
|
parallel1 = parallel2;
|
||||||
if( false == Onlypositions ) {
|
|
||||||
tv1 = tv2;
|
tv1 = tv2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return vertexcount;
|
return vertexcount;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class TSegment
|
|||||||
r1 = fRoll1;
|
r1 = fRoll1;
|
||||||
r2 = fRoll2;
|
r2 = fRoll2;
|
||||||
}
|
}
|
||||||
int RenderLoft( CVertNormTex* &Output, const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale = 1.0, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0, bool Onlypositions = false, vector3 **p = nullptr, bool bRender = true);
|
int RenderLoft( CVertNormTex* &Output, Math3D::vector3 const &Origin, vector6 const *ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale = 1.0, int iSkip = 0, int iEnd = 0, double fOffsetX = 0.0, vector3 **p = nullptr, bool bRender = true);
|
||||||
void Render();
|
void Render();
|
||||||
inline double GetLength()
|
inline double GetLength()
|
||||||
{
|
{
|
||||||
|
|||||||
153
Track.cpp
153
Track.cpp
@@ -1090,6 +1090,9 @@ void TTrack::Compile(GLuint tex)
|
|||||||
hypot2 = hypot1;
|
hypot2 = hypot1;
|
||||||
normal2 = normal1;
|
normal2 = normal1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto const origin = pMyNode->m_rootposition;
|
||||||
|
|
||||||
double roll1, roll2;
|
double roll1, roll2;
|
||||||
switch (iCategoryFlag & 15)
|
switch (iCategoryFlag & 15)
|
||||||
{
|
{
|
||||||
@@ -1216,15 +1219,15 @@ void TTrack::Compile(GLuint tex)
|
|||||||
}
|
}
|
||||||
if (!tex)
|
if (!tex)
|
||||||
GfxRenderer.Bind( TextureID2 );
|
GfxRenderer.Bind( TextureID2 );
|
||||||
Segment->RenderLoft( immediate, bpts1, iTrapezoid ? -4 : 4, fTexLength);
|
Segment->RenderLoft( immediate, origin, bpts1, iTrapezoid ? -4 : 4, fTexLength);
|
||||||
}
|
}
|
||||||
if (TextureID1)
|
if (TextureID1)
|
||||||
if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex)
|
if (tex ? TextureID1 == tex : true) // jeśli pasuje do grupy (tex)
|
||||||
{ // szyny
|
{ // szyny
|
||||||
if (!tex)
|
if (!tex)
|
||||||
GfxRenderer.Bind( TextureID1 );
|
GfxRenderer.Bind( TextureID1 );
|
||||||
Segment->RenderLoft( immediate, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
Segment->RenderLoft( immediate, origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
||||||
Segment->RenderLoft( immediate, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
Segment->RenderLoft( immediate, origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tt_Switch: // dla zwrotnicy dwa razy szyny
|
case tt_Switch: // dla zwrotnicy dwa razy szyny
|
||||||
@@ -1252,31 +1255,31 @@ void TTrack::Compile(GLuint tex)
|
|||||||
{ // zwrotnica prawa
|
{ // zwrotnica prawa
|
||||||
if( TextureID1 ) {
|
if( TextureID1 ) {
|
||||||
GfxRenderer.Bind( TextureID1 );
|
GfxRenderer.Bind( TextureID1 );
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, SwitchExtension->fOffset2 ); // prawa iglica
|
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, origin, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, SwitchExtension->fOffset2 ); // prawa iglica
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, rpts1, nnumPts, fTexLength, 1.0, 2 ); // prawa szyna za iglicą
|
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, origin, rpts1, nnumPts, fTexLength, 1.0, 2 ); // prawa szyna za iglicą
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, rpts2, nnumPts, fTexLength ); // lewa szyna normalnie cała
|
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, origin, rpts2, nnumPts, fTexLength ); // lewa szyna normalnie cała
|
||||||
}
|
}
|
||||||
if( TextureID2 ) {
|
if( TextureID2 ) {
|
||||||
GfxRenderer.Bind( TextureID2 );
|
GfxRenderer.Bind( TextureID2 );
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, rpts1, nnumPts, fTexLength ); // prawa szyna normalna cała
|
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, origin, rpts1, nnumPts, fTexLength ); // prawa szyna normalna cała
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -fMaxOffset + SwitchExtension->fOffset1 ); // lewa iglica
|
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, origin, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -fMaxOffset + SwitchExtension->fOffset1 ); // lewa iglica
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, rpts2, nnumPts, fTexLength, 1.0, 2 ); // lewa szyna za iglicą
|
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, origin, rpts2, nnumPts, fTexLength, 1.0, 2 ); // lewa szyna za iglicą
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // lewa kiedyś działała lepiej niż prawa
|
{ // lewa kiedyś działała lepiej niż prawa
|
||||||
if( TextureID1 ) {
|
if( TextureID1 ) {
|
||||||
GfxRenderer.Bind( TextureID1 );
|
GfxRenderer.Bind( TextureID1 );
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, rpts1, nnumPts, fTexLength ); // prawa szyna normalna cała
|
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, origin, rpts1, nnumPts, fTexLength ); // prawa szyna normalna cała
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -SwitchExtension->fOffset2 ); // lewa iglica
|
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, origin, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -SwitchExtension->fOffset2 ); // lewa iglica
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, rpts2, nnumPts, fTexLength, 1.0, 2 ); // lewa szyna za iglicą
|
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, origin, rpts2, nnumPts, fTexLength, 1.0, 2 ); // lewa szyna za iglicą
|
||||||
}
|
}
|
||||||
if( TextureID2 ) {
|
if( TextureID2 ) {
|
||||||
// nie wiadomo, czy OpenGL to optymalizuje
|
// nie wiadomo, czy OpenGL to optymalizuje
|
||||||
GfxRenderer.Bind( TextureID2 );
|
GfxRenderer.Bind( TextureID2 );
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, fMaxOffset - SwitchExtension->fOffset1 ); // prawa iglica
|
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, origin, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, fMaxOffset - SwitchExtension->fOffset1 ); // prawa iglica
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, rpts1, nnumPts, fTexLength, 1.0, 2 ); // prawa szyna za iglicą
|
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, origin, rpts1, nnumPts, fTexLength, 1.0, 2 ); // prawa szyna za iglicą
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, rpts2, nnumPts, fTexLength ); // lewa szyna normalnie cała
|
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, origin, rpts2, nnumPts, fTexLength ); // lewa szyna normalnie cała
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1315,7 +1318,7 @@ void TTrack::Compile(GLuint tex)
|
|||||||
{ // tworzenie trójkątów nawierzchni szosy
|
{ // tworzenie trójkątów nawierzchni szosy
|
||||||
if (!tex)
|
if (!tex)
|
||||||
GfxRenderer.Bind( TextureID1 );
|
GfxRenderer.Bind( TextureID1 );
|
||||||
Segment->RenderLoft( immediate, bpts1, iTrapezoid ? -2 : 2, fTexLength);
|
Segment->RenderLoft( immediate, origin, bpts1, iTrapezoid ? -2 : 2, fTexLength);
|
||||||
}
|
}
|
||||||
if (TextureID2)
|
if (TextureID2)
|
||||||
if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex)
|
if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex)
|
||||||
@@ -1399,16 +1402,16 @@ void TTrack::Compile(GLuint tex)
|
|||||||
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
|
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
|
||||||
// odcinka
|
// odcinka
|
||||||
if ((fTexHeight1 >= 0.0) ? true : (slop != 0.0))
|
if ((fTexHeight1 >= 0.0) ? true : (slop != 0.0))
|
||||||
Segment->RenderLoft( immediate, rpts1, -3, fTexLength); // tylko jeśli jest z prawej
|
Segment->RenderLoft( immediate, origin, rpts1, -3, fTexLength); // tylko jeśli jest z prawej
|
||||||
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0))
|
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0))
|
||||||
Segment->RenderLoft( immediate, rpts2, -3, fTexLength); // tylko jeśli jest z lewej
|
Segment->RenderLoft( immediate, origin, rpts2, -3, fTexLength); // tylko jeśli jest z lewej
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // pobocza zwykłe, brak przechyłki
|
{ // pobocza zwykłe, brak przechyłki
|
||||||
if ((fTexHeight1 >= 0.0) ? true : (slop != 0.0))
|
if ((fTexHeight1 >= 0.0) ? true : (slop != 0.0))
|
||||||
Segment->RenderLoft( immediate, rpts1, 3, fTexLength);
|
Segment->RenderLoft( immediate, origin, rpts1, 3, fTexLength);
|
||||||
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0))
|
if ((fTexHeight1 >= 0.0) ? true : (side != 0.0))
|
||||||
Segment->RenderLoft( immediate, rpts2, 3, fTexLength);
|
Segment->RenderLoft( immediate, origin, rpts2, 3, fTexLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1551,19 +1554,19 @@ void TTrack::Compile(GLuint tex)
|
|||||||
if (SwitchExtension->iRoads == 4)
|
if (SwitchExtension->iRoads == 4)
|
||||||
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
|
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
||||||
SwitchExtension->Segments[ 2 ]->RenderLoft( immediate, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 2 ]->RenderLoft( immediate, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
SwitchExtension->Segments[ 3 ]->RenderLoft( immediate, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 3 ]->RenderLoft( immediate, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
SwitchExtension->Segments[ 4 ]->RenderLoft( immediate, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 4 ]->RenderLoft( immediate, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
SwitchExtension->Segments[ 5 ]->RenderLoft( immediate, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 5 ]->RenderLoft( immediate, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// to będzie ewentualnie dla prostego na skrzyżowaniu trzech dróg
|
// to będzie ewentualnie dla prostego na skrzyżowaniu trzech dróg
|
||||||
{ // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe
|
{ // punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
||||||
SwitchExtension->Segments[ 2 ]->RenderLoft( immediate, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render ); // z P2 do P4
|
SwitchExtension->Segments[ 2 ]->RenderLoft( immediate, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P2 do P4
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render ); // z P4 do P3=P1 (odwrócony)
|
SwitchExtension->Segments[ 1 ]->RenderLoft( immediate, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P4 do P3=P1 (odwrócony)
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render ); // z P1 do P2
|
SwitchExtension->Segments[ 0 ]->RenderLoft( immediate, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P1 do P2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1628,7 +1631,7 @@ void TTrack::Compile(GLuint tex)
|
|||||||
{
|
{
|
||||||
if (!tex)
|
if (!tex)
|
||||||
GfxRenderer.Bind( TextureID1 );
|
GfxRenderer.Bind( TextureID1 );
|
||||||
Segment->RenderLoft( immediate, bpts1, numPts, fTexLength);
|
Segment->RenderLoft( immediate, origin, bpts1, numPts, fTexLength);
|
||||||
}
|
}
|
||||||
if (TextureID2)
|
if (TextureID2)
|
||||||
if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex)
|
if (tex ? TextureID2 == tex : true) // jeśli pasuje do grupy (tex)
|
||||||
@@ -1640,8 +1643,8 @@ void TTrack::Compile(GLuint tex)
|
|||||||
vector6(-rozp, -fTexHeight1, 0.0)}; // Ra: po kiego 0.1?
|
vector6(-rozp, -fTexHeight1, 0.0)}; // Ra: po kiego 0.1?
|
||||||
if (!tex)
|
if (!tex)
|
||||||
GfxRenderer.Bind( TextureID2 ); // brzeg rzeki
|
GfxRenderer.Bind( TextureID2 ); // brzeg rzeki
|
||||||
Segment->RenderLoft( immediate, rpts1, 3, fTexLength);
|
Segment->RenderLoft( immediate, origin, rpts1, 3, fTexLength );
|
||||||
Segment->RenderLoft( immediate, rpts2, 3, fTexLength);
|
Segment->RenderLoft( immediate, origin, rpts2, 3, fTexLength );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1858,6 +1861,9 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
hypot2 = hypot1;
|
hypot2 = hypot1;
|
||||||
normal2 = normal1;
|
normal2 = normal1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto const origin = pMyNode->m_rootposition;
|
||||||
|
|
||||||
double roll1, roll2;
|
double roll1, roll2;
|
||||||
switch (iCategoryFlag & 15)
|
switch (iCategoryFlag & 15)
|
||||||
{
|
{
|
||||||
@@ -1959,12 +1965,12 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 0.5 + map12, -normal1.x, -normal1.y, 0.0); // prawy skos
|
bpts1[3] = vector6(-rozp, -fTexHeight1 - 0.18, 0.5 + map12, -normal1.x, -normal1.y, 0.0); // prawy skos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Segment->RenderLoft(Vert, bpts1, iTrapezoid ? -4 : 4, fTexLength);
|
Segment->RenderLoft(Vert, origin, bpts1, iTrapezoid ? -4 : 4, fTexLength);
|
||||||
}
|
}
|
||||||
if (TextureID1)
|
if (TextureID1)
|
||||||
{ // szyny - generujemy dwie, najwyżej rysować się będzie jedną
|
{ // szyny - generujemy dwie, najwyżej rysować się będzie jedną
|
||||||
Segment->RenderLoft(Vert, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
Segment->RenderLoft(Vert, origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
||||||
Segment->RenderLoft(Vert, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
Segment->RenderLoft(Vert, origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tt_Switch: // dla zwrotnicy dwa razy szyny
|
case tt_Switch: // dla zwrotnicy dwa razy szyny
|
||||||
@@ -1989,32 +1995,32 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
if (SwitchExtension->RightSwitch)
|
if (SwitchExtension->RightSwitch)
|
||||||
{ // nowa wersja z SPKS, ale odwrotnie lewa/prawa
|
{ // nowa wersja z SPKS, ale odwrotnie lewa/prawa
|
||||||
if( TextureID1 ) {
|
if( TextureID1 ) {
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, rpts2, nnumPts, fTexLength );
|
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, origin, rpts2, nnumPts, fTexLength );
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, rpts1, nnumPts, fTexLength, 1.0, 2 );
|
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, origin, rpts1, nnumPts, fTexLength, 1.0, 2 );
|
||||||
|
|
||||||
SwitchExtension->iLeftVBO = Vert - Start; // indeks lewej iglicy
|
SwitchExtension->iLeftVBO = Vert - Start; // indeks lewej iglicy
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, SwitchExtension->fOffset2 );
|
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, origin, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, SwitchExtension->fOffset2 );
|
||||||
}
|
}
|
||||||
if( TextureID2 ) {
|
if( TextureID2 ) {
|
||||||
SwitchExtension->iRightVBO = Vert - Start; // indeks prawej iglicy
|
SwitchExtension->iRightVBO = Vert - Start; // indeks prawej iglicy
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -fMaxOffset + SwitchExtension->fOffset1 );
|
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, origin, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -fMaxOffset + SwitchExtension->fOffset1 );
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, rpts2, nnumPts, fTexLength, 1.0, 2 );
|
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, origin, rpts2, nnumPts, fTexLength, 1.0, 2 );
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, rpts1, nnumPts, fTexLength );
|
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, origin, rpts1, nnumPts, fTexLength );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // lewa działa lepiej niż prawa
|
{ // lewa działa lepiej niż prawa
|
||||||
if( TextureID1 ) {
|
if( TextureID1 ) {
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, rpts1, nnumPts, fTexLength ); // lewa szyna normalna cała
|
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, origin, rpts1, nnumPts, fTexLength ); // lewa szyna normalna cała
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, rpts2, nnumPts, fTexLength, 1.0, 2 ); // prawa szyna za iglicą
|
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, origin, rpts2, nnumPts, fTexLength, 1.0, 2 ); // prawa szyna za iglicą
|
||||||
SwitchExtension->iLeftVBO = Vert - Start; // indeks lewej iglicy
|
SwitchExtension->iLeftVBO = Vert - Start; // indeks lewej iglicy
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -SwitchExtension->fOffset2 ); // prawa iglica
|
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, origin, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -SwitchExtension->fOffset2 ); // prawa iglica
|
||||||
}
|
}
|
||||||
if( TextureID2 ) {
|
if( TextureID2 ) {
|
||||||
SwitchExtension->iRightVBO = Vert - Start; // indeks prawej iglicy
|
SwitchExtension->iRightVBO = Vert - Start; // indeks prawej iglicy
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, fMaxOffset - SwitchExtension->fOffset1 ); // lewa iglica
|
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, origin, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, fMaxOffset - SwitchExtension->fOffset1 ); // lewa iglica
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, rpts1, nnumPts, fTexLength, 1.0, 2 ); // lewa szyna za iglicą
|
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, origin, rpts1, nnumPts, fTexLength, 1.0, 2 ); // lewa szyna za iglicą
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, rpts2, nnumPts, fTexLength ); // prawa szyna normalnie cała
|
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, origin, rpts2, nnumPts, fTexLength ); // prawa szyna normalnie cała
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2049,7 +2055,7 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
}
|
}
|
||||||
if (TextureID1) // jeśli podana była tekstura, generujemy trójkąty
|
if (TextureID1) // jeśli podana była tekstura, generujemy trójkąty
|
||||||
{ // tworzenie trójkątów nawierzchni szosy
|
{ // tworzenie trójkątów nawierzchni szosy
|
||||||
Segment->RenderLoft(Vert, bpts1, iTrapezoid ? -2 : 2, fTexLength);
|
Segment->RenderLoft(Vert, origin, bpts1, iTrapezoid ? -2 : 2, fTexLength);
|
||||||
}
|
}
|
||||||
if (TextureID2)
|
if (TextureID2)
|
||||||
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?)
|
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w Midtown Madness 2?)
|
||||||
@@ -2130,18 +2136,18 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
|
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony
|
||||||
// odcinka
|
// odcinka
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) {
|
||||||
Segment->RenderLoft( Vert, rpts1, -3, fTexLength ); // tylko jeśli jest z prawej
|
Segment->RenderLoft( Vert, origin, rpts1, -3, fTexLength ); // tylko jeśli jest z prawej
|
||||||
}
|
}
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
||||||
Segment->RenderLoft( Vert, rpts2, -3, fTexLength ); // tylko jeśli jest z lewej
|
Segment->RenderLoft( Vert, origin, rpts2, -3, fTexLength ); // tylko jeśli jest z lewej
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // pobocza zwykłe, brak przechyłki
|
else { // pobocza zwykłe, brak przechyłki
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( slop != 0.0 ) ) {
|
||||||
Segment->RenderLoft( Vert, rpts1, 3, fTexLength );
|
Segment->RenderLoft( Vert, origin, rpts1, 3, fTexLength );
|
||||||
}
|
}
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
||||||
Segment->RenderLoft( Vert, rpts2, 3, fTexLength );
|
Segment->RenderLoft( Vert, origin, rpts2, 3, fTexLength );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2266,18 +2272,18 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
if (SwitchExtension->iRoads == 4)
|
if (SwitchExtension->iRoads == 4)
|
||||||
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
|
{ // pobocza do trapezowatej nawierzchni - dodatkowe punkty z drugiej strony odcinka
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
||||||
SwitchExtension->Segments[ 2 ]->RenderLoft( Vert, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 2 ]->RenderLoft( Vert, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
SwitchExtension->Segments[ 3 ]->RenderLoft( Vert, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 3 ]->RenderLoft( Vert, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
SwitchExtension->Segments[ 4 ]->RenderLoft( Vert, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 4 ]->RenderLoft( Vert, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
SwitchExtension->Segments[ 5 ]->RenderLoft( Vert, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render );
|
SwitchExtension->Segments[ 5 ]->RenderLoft( Vert, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe
|
// punkt 3 pokrywa się z punktem 1, jak w zwrotnicy; połączenie 1->2 nie musi być prostoliniowe
|
||||||
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
if( ( fTexHeight1 >= 0.0 ) || ( side != 0.0 ) ) {
|
||||||
SwitchExtension->Segments[ 2 ]->RenderLoft( Vert, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render ); // z P2 do P4
|
SwitchExtension->Segments[ 2 ]->RenderLoft( Vert, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P2 do P4
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render ); // z P4 do P3=P1 (odwrócony)
|
SwitchExtension->Segments[ 1 ]->RenderLoft( Vert, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P4 do P3=P1 (odwrócony)
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, false, &b, render ); // z P1 do P2
|
SwitchExtension->Segments[ 0 ]->RenderLoft( Vert, origin, rpts2, -3, fTexLength, 1.0, 0, 0, 0.0, &b, render ); // z P1 do P2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2297,17 +2303,17 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
Vert->nz = 0.0;
|
Vert->nz = 0.0;
|
||||||
Vert->u = 0.5;
|
Vert->u = 0.5;
|
||||||
Vert->v = 0.5;
|
Vert->v = 0.5;
|
||||||
Vert->x = oxz.x;
|
Vert->x = oxz.x - origin.x;
|
||||||
Vert->y = oxz.y;
|
Vert->y = oxz.y - origin.y;
|
||||||
Vert->z = oxz.z;
|
Vert->z = oxz.z - origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
// ...and add one extra vertex to close the fan...
|
// ...and add one extra vertex to close the fan...
|
||||||
Vert->nx = 0.0;
|
Vert->nx = 0.0;
|
||||||
Vert->ny = 1.0;
|
Vert->ny = 1.0;
|
||||||
Vert->nz = 0.0;
|
Vert->nz = 0.0;
|
||||||
// mapowanie we współrzędnych scenerii
|
// mapowanie we współrzędnych scenerii
|
||||||
u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x ) / fTexLength;
|
u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x + origin.x ) / fTexLength;
|
||||||
v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z ) / ( fTexRatio1 * fTexLength );
|
v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z + origin.z ) / ( fTexRatio1 * fTexLength );
|
||||||
Vert->u = cosa0 * u + sina0 * v + 0.5;
|
Vert->u = cosa0 * u + sina0 * v + 0.5;
|
||||||
Vert->v = -sina0 * u + cosa0 * v + 0.5;
|
Vert->v = -sina0 * u + cosa0 * v + 0.5;
|
||||||
Vert->x = SwitchExtension->vPoints[ 0 ].x;
|
Vert->x = SwitchExtension->vPoints[ 0 ].x;
|
||||||
@@ -2321,8 +2327,8 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
Vert->ny = 1.0;
|
Vert->ny = 1.0;
|
||||||
Vert->nz = 0.0;
|
Vert->nz = 0.0;
|
||||||
// mapowanie we współrzędnych scenerii
|
// mapowanie we współrzędnych scenerii
|
||||||
u = (SwitchExtension->vPoints[i].x - oxz.x) / fTexLength;
|
u = (SwitchExtension->vPoints[i].x - oxz.x + origin.x ) / fTexLength;
|
||||||
v = (SwitchExtension->vPoints[i].z - oxz.z) / (fTexRatio1 * fTexLength);
|
v = (SwitchExtension->vPoints[i].z - oxz.z + origin.z ) / (fTexRatio1 * fTexLength);
|
||||||
Vert->u = cosa0 * u + sina0 * v + 0.5;
|
Vert->u = cosa0 * u + sina0 * v + 0.5;
|
||||||
Vert->v = -sina0 * u + cosa0 * v + 0.5;
|
Vert->v = -sina0 * u + cosa0 * v + 0.5;
|
||||||
Vert->x = SwitchExtension->vPoints[ i ].x;
|
Vert->x = SwitchExtension->vPoints[ i ].x;
|
||||||
@@ -2368,7 +2374,7 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
}
|
}
|
||||||
if (TextureID1) // jeśli podana była tekstura, generujemy trójkąty
|
if (TextureID1) // jeśli podana była tekstura, generujemy trójkąty
|
||||||
{ // tworzenie trójkątów nawierzchni szosy
|
{ // tworzenie trójkątów nawierzchni szosy
|
||||||
Segment->RenderLoft(Vert, bpts1, iTrapezoid ? -2 : 2, fTexLength);
|
Segment->RenderLoft(Vert, origin, bpts1, iTrapezoid ? -2 : 2, fTexLength);
|
||||||
}
|
}
|
||||||
if (TextureID2)
|
if (TextureID2)
|
||||||
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w
|
{ // pobocze drogi - poziome przy przechyłce (a może krawężnik i chodnik zrobić jak w
|
||||||
@@ -2390,13 +2396,13 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0);
|
rpts2[3] = vector6(bpts1[3].x, bpts1[3].y, 1.0);
|
||||||
rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5);
|
rpts2[4] = vector6(bpts1[3].x - side2, bpts1[3].y, 0.5);
|
||||||
rpts2[5] = vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego pobocza
|
rpts2[5] = vector6(-rozp2, -fTexHeight2, 0.0); // prawy brzeg prawego pobocza
|
||||||
Segment->RenderLoft(Vert, rpts1, -3, fTexLength);
|
Segment->RenderLoft(Vert, origin, rpts1, -3, fTexLength);
|
||||||
Segment->RenderLoft(Vert, rpts2, -3, fTexLength);
|
Segment->RenderLoft(Vert, origin, rpts2, -3, fTexLength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // pobocza zwykłe, brak przechyłki
|
{ // pobocza zwykłe, brak przechyłki
|
||||||
Segment->RenderLoft(Vert, rpts1, 3, fTexLength);
|
Segment->RenderLoft(Vert, origin, rpts1, 3, fTexLength);
|
||||||
Segment->RenderLoft(Vert, rpts2, 3, fTexLength);
|
Segment->RenderLoft(Vert, origin, rpts2, 3, fTexLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2884,13 +2890,14 @@ TTrack * TTrack::RaAnimate(GLuint const Vertexbuffer)
|
|||||||
bladesbuffer.data() );
|
bladesbuffer.data() );
|
||||||
*/
|
*/
|
||||||
auto bladevertices = bladesbuffer.data();
|
auto bladevertices = bladesbuffer.data();
|
||||||
|
auto const origin = pMyNode->m_rootposition;
|
||||||
if( SwitchExtension->RightSwitch ) { // nowa wersja z SPKS, ale odwrotnie lewa/prawa
|
if( SwitchExtension->RightSwitch ) { // nowa wersja z SPKS, ale odwrotnie lewa/prawa
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( bladevertices, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, SwitchExtension->fOffset2 /*, true*/ );
|
SwitchExtension->Segments[ 0 ]->RenderLoft( bladevertices, origin, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, SwitchExtension->fOffset2 /*, true*/ );
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( bladevertices, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -fMaxOffset + SwitchExtension->fOffset1 /*, true*/ );
|
SwitchExtension->Segments[ 1 ]->RenderLoft( bladevertices, origin, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -fMaxOffset + SwitchExtension->fOffset1 /*, true*/ );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SwitchExtension->Segments[ 0 ]->RenderLoft( bladevertices, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -SwitchExtension->fOffset2 /*, true*/ ); // prawa iglica
|
SwitchExtension->Segments[ 0 ]->RenderLoft( bladevertices, origin, rpts4, -nnumPts, fTexLength, 1.0, 0, 2, -SwitchExtension->fOffset2 /*, true*/ ); // prawa iglica
|
||||||
SwitchExtension->Segments[ 1 ]->RenderLoft( bladevertices, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, fMaxOffset - SwitchExtension->fOffset1 /*, true*/ ); // lewa iglica
|
SwitchExtension->Segments[ 1 ]->RenderLoft( bladevertices, origin, rpts3, -nnumPts, fTexLength, 1.0, 0, 2, fMaxOffset - SwitchExtension->fOffset1 /*, true*/ ); // lewa iglica
|
||||||
}
|
}
|
||||||
// push back updated geometry
|
// push back updated geometry
|
||||||
::glBufferSubData(
|
::glBufferSubData(
|
||||||
|
|||||||
99
Traction.cpp
99
Traction.cpp
@@ -324,7 +324,7 @@ int TTraction::RaArrayPrepare()
|
|||||||
return iLines;
|
return iLines;
|
||||||
};
|
};
|
||||||
|
|
||||||
int TTraction::RaArrayFill(CVertNormTex *Vert)
|
int TTraction::RaArrayFill(CVertNormTex *Vert, Math3D::vector3 const &Origin)
|
||||||
{ // wypełnianie tablic VBO
|
{ // wypełnianie tablic VBO
|
||||||
int debugvertexcount{ 0 };
|
int debugvertexcount{ 0 };
|
||||||
|
|
||||||
@@ -332,14 +332,14 @@ int TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
if (Wires == 2)
|
if (Wires == 2)
|
||||||
WireOffset = 0;
|
WireOffset = 0;
|
||||||
// jezdny
|
// jezdny
|
||||||
Vert->x = pPoint1.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
Vert->x = pPoint1.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - Origin.x;
|
||||||
Vert->y = pPoint1.y;
|
Vert->y = pPoint1.y - Origin.y;
|
||||||
Vert->z = pPoint1.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
Vert->z = pPoint1.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
Vert->x = pPoint2.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
Vert->x = pPoint2.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - Origin.x;
|
||||||
Vert->y = pPoint2.y;
|
Vert->y = pPoint2.y - Origin.y;
|
||||||
Vert->z = pPoint2.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
Vert->z = pPoint2.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
// Nie wiem co 'Marcin
|
// Nie wiem co 'Marcin
|
||||||
@@ -355,9 +355,9 @@ int TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
// Przewod nosny 'Marcin
|
// Przewod nosny 'Marcin
|
||||||
if (Wires > 1)
|
if (Wires > 1)
|
||||||
{ // lina nośna w kawałkach
|
{ // lina nośna w kawałkach
|
||||||
Vert->x = pPoint3.x;
|
Vert->x = pPoint3.x - Origin.x;
|
||||||
Vert->y = pPoint3.y;
|
Vert->y = pPoint3.y - Origin.y;
|
||||||
Vert->z = pPoint3.z;
|
Vert->z = pPoint3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
for (int i = 0; i < iNumSections - 1; ++i)
|
for (int i = 0; i < iNumSections - 1; ++i)
|
||||||
@@ -367,31 +367,31 @@ int TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
if( ( Wires < 4 )
|
if( ( Wires < 4 )
|
||||||
|| ( ( i != 0 )
|
|| ( ( i != 0 )
|
||||||
&& ( i != iNumSections - 2 ) ) ) {
|
&& ( i != iNumSections - 2 ) ) ) {
|
||||||
Vert->x = pt3.x;
|
Vert->x = pt3.x - Origin.x;
|
||||||
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference;
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - Origin.y;
|
||||||
Vert->z = pt3.z;
|
Vert->z = pt3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
}
|
}
|
||||||
f += step;
|
f += step;
|
||||||
}
|
}
|
||||||
Vert->x = pPoint4.x;
|
Vert->x = pPoint4.x - Origin.x;
|
||||||
Vert->y = pPoint4.y;
|
Vert->y = pPoint4.y - Origin.y;
|
||||||
Vert->z = pPoint4.z;
|
Vert->z = pPoint4.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
}
|
}
|
||||||
// Drugi przewod jezdny 'Winger
|
// Drugi przewod jezdny 'Winger
|
||||||
if (Wires > 2)
|
if (Wires > 2)
|
||||||
{
|
{
|
||||||
Vert->x = pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
Vert->x = pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x;
|
||||||
Vert->y = pPoint1.y;
|
Vert->y = pPoint1.y - Origin.y;
|
||||||
Vert->z = pPoint1.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
Vert->z = pPoint1.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
Vert->x = pPoint2.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset;
|
Vert->x = pPoint2.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset - Origin.x;
|
||||||
Vert->y = pPoint2.y;
|
Vert->y = pPoint2.y - Origin.y;
|
||||||
Vert->z = pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset;
|
Vert->z = pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
}
|
}
|
||||||
@@ -399,28 +399,29 @@ int TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
f = step;
|
f = step;
|
||||||
|
|
||||||
if( Wires == 4 ) {
|
if( Wires == 4 ) {
|
||||||
Vert->x = pPoint3.x;
|
Vert->x = pPoint3.x - Origin.x;
|
||||||
Vert->y = pPoint3.y - 0.65f * fHeightDifference;
|
Vert->y = pPoint3.y - 0.65f * fHeightDifference - Origin.y;
|
||||||
Vert->z = pPoint3.z;
|
Vert->z = pPoint3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
for( int i = 0; i < iNumSections - 1; ++i ) {
|
for( int i = 0; i < iNumSections - 1; ++i ) {
|
||||||
pt3 = pPoint3 + v1 * f;
|
pt3 = pPoint3 + v1 * f;
|
||||||
t = ( 1 - std::fabs( f - mid ) * 2 );
|
t = ( 1 - std::fabs( f - mid ) * 2 );
|
||||||
Vert->x = pt3.x;
|
Vert->x = pt3.x - Origin.x;
|
||||||
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - (
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - (
|
||||||
( ( i == 0 )
|
( ( i == 0 )
|
||||||
|| ( i == iNumSections - 2 ) ) ?
|
|| ( i == iNumSections - 2 ) ) ?
|
||||||
0.25f * fHeightDifference :
|
0.25f * fHeightDifference :
|
||||||
0.05 );
|
0.05 )
|
||||||
Vert->z = pt3.z;
|
- Origin.y;
|
||||||
|
Vert->z = pt3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
f += step;
|
f += step;
|
||||||
}
|
}
|
||||||
Vert->x = pPoint4.x;
|
Vert->x = pPoint4.x - Origin.x;
|
||||||
Vert->y = pPoint4.y - 0.65f * fHeightDifference;
|
Vert->y = pPoint4.y - 0.65f * fHeightDifference - Origin.y;
|
||||||
Vert->z = pPoint4.z;
|
Vert->z = pPoint4.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
}
|
}
|
||||||
@@ -439,40 +440,40 @@ int TTraction::RaArrayFill(CVertNormTex *Vert)
|
|||||||
t = (1 - std::fabs(f - mid) * 2);
|
t = (1 - std::fabs(f - mid) * 2);
|
||||||
|
|
||||||
if( ( i % 2 ) == 0 ) {
|
if( ( i % 2 ) == 0 ) {
|
||||||
Vert->x = pt3.x;
|
Vert->x = pt3.x - Origin.x;
|
||||||
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 );
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - Origin.y;
|
||||||
Vert->z = pt3.z;
|
Vert->z = pt3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
Vert->x = pt4.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
Vert->x = pt4.x - ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - Origin.x;
|
||||||
Vert->y = pt4.y;
|
Vert->y = pt4.y - Origin.y;
|
||||||
Vert->z = pt4.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
Vert->z = pt4.z - ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Vert->x = pt3.x;
|
Vert->x = pt3.x - Origin.x;
|
||||||
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 );
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - ( ( i == 0 ) || ( i == iNumSections - 2 ) ? flo : flo1 ) - Origin.y;
|
||||||
Vert->z = pt3.z;
|
Vert->z = pt3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
Vert->x = pt4.x + ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset;
|
Vert->x = pt4.x + ( pPoint2.z / ddp - pPoint1.z / ddp ) * WireOffset - Origin.x;
|
||||||
Vert->y = pt4.y;
|
Vert->y = pt4.y - Origin.y;
|
||||||
Vert->z = pt4.z + ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset;
|
Vert->z = pt4.z + ( -pPoint2.x / ddp + pPoint1.x / ddp ) * WireOffset - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
}
|
}
|
||||||
if( ( ( Wires == 4 )
|
if( ( ( Wires == 4 )
|
||||||
&& ( ( i == 1 )
|
&& ( ( i == 1 )
|
||||||
|| ( i == iNumSections - 3 ) ) ) ) {
|
|| ( i == iNumSections - 3 ) ) ) ) {
|
||||||
Vert->x = pt3.x;
|
Vert->x = pt3.x - Origin.x;
|
||||||
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - 0.05;
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - 0.05 - Origin.y;
|
||||||
Vert->z = pt3.z;
|
Vert->z = pt3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
Vert->x = pt3.x;
|
Vert->x = pt3.x - Origin.x;
|
||||||
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference;
|
Vert->y = pt3.y - std::sqrt( t ) * fHeightDifference - Origin.y;
|
||||||
Vert->z = pt3.z;
|
Vert->z = pt3.z - Origin.z;
|
||||||
++Vert;
|
++Vert;
|
||||||
++debugvertexcount;
|
++debugvertexcount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class TTraction
|
|||||||
// virtual void SelectedRender();
|
// virtual void SelectedRender();
|
||||||
void RenderDL(float mgn);
|
void RenderDL(float mgn);
|
||||||
int RaArrayPrepare();
|
int RaArrayPrepare();
|
||||||
int RaArrayFill(CVertNormTex *Vert);
|
int RaArrayFill( CVertNormTex *Vert, Math3D::vector3 const &Origin );
|
||||||
void RenderVBO(float mgn, int iPtr);
|
void RenderVBO(float mgn, int iPtr);
|
||||||
int TestPoint(Math3D::vector3 *Point);
|
int TestPoint(Math3D::vector3 *Point);
|
||||||
void Connect(int my, TTraction *with, int to);
|
void Connect(int my, TTraction *with, int to);
|
||||||
|
|||||||
@@ -1276,6 +1276,8 @@ TWorld::Render_Cab() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::glEnable( GL_LIGHTING ); // po renderowaniu drutów może być to wyłączone. TODO: have the wires render take care of its own shit
|
||||||
|
/*
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
vector3 pos = dynamic->GetPosition(); // wszpółrzędne pojazdu z kabiną
|
vector3 pos = dynamic->GetPosition(); // wszpółrzędne pojazdu z kabiną
|
||||||
// glTranslatef(pos.x,pos.y,pos.z); //przesunięcie o wektor (tak było i trzęsło)
|
// glTranslatef(pos.x,pos.y,pos.z); //przesunięcie o wektor (tak było i trzęsło)
|
||||||
@@ -1284,7 +1286,11 @@ TWorld::Render_Cab() {
|
|||||||
glLoadIdentity(); // zacząć od macierzy jedynkowej
|
glLoadIdentity(); // zacząć od macierzy jedynkowej
|
||||||
Camera.SetCabMatrix( pos ); // widok z kamery po przesunięciu
|
Camera.SetCabMatrix( pos ); // widok z kamery po przesunięciu
|
||||||
glMultMatrixd( dynamic->mMatrix.getArray() ); // ta macierz nie ma przesunięcia
|
glMultMatrixd( dynamic->mMatrix.getArray() ); // ta macierz nie ma przesunięcia
|
||||||
glEnable( GL_LIGHTING ); // po renderowaniu drutów może być to wyłączone. TODO: have the wires render take care of its own shit
|
*/
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const originoffset = dynamic->GetPosition() - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
::glMultMatrixd( dynamic->mMatrix.getArray() );
|
||||||
|
|
||||||
if( dynamic->mdKabina ) // bo mogła zniknąć przy przechodzeniu do innego pojazdu
|
if( dynamic->mdKabina ) // bo mogła zniknąć przy przechodzeniu do innego pojazdu
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ public:
|
|||||||
calculate(glm::mat4 const &Projection, glm::mat4 const &Modelview);
|
calculate(glm::mat4 const &Projection, glm::mat4 const &Modelview);
|
||||||
// returns true if specified point is inside of the frustum
|
// returns true if specified point is inside of the frustum
|
||||||
inline
|
inline
|
||||||
|
bool
|
||||||
|
point_inside( glm::vec3 const &Point ) const { return point_inside( Point.x, Point.y, Point.z ); }
|
||||||
|
inline
|
||||||
bool
|
bool
|
||||||
point_inside( float3 const &Point ) const { return point_inside( Point.x, Point.y, Point.z ); }
|
point_inside( float3 const &Point ) const { return point_inside( Point.x, Point.y, Point.z ); }
|
||||||
inline
|
inline
|
||||||
@@ -36,6 +39,9 @@ public:
|
|||||||
point_inside( float const X, float const Y, float const Z ) const;
|
point_inside( float const X, float const Y, float const Z ) const;
|
||||||
// tests if the sphere is in frustum, returns the distance between origin and sphere centre
|
// tests if the sphere is in frustum, returns the distance between origin and sphere centre
|
||||||
inline
|
inline
|
||||||
|
float
|
||||||
|
sphere_inside( glm::vec3 const &Center, float const Radius ) const { return sphere_inside( Center.x, Center.y, Center.z, Radius ); }
|
||||||
|
inline
|
||||||
float
|
float
|
||||||
sphere_inside( float3 const &Center, float const Radius ) const { return sphere_inside( Center.x, Center.y, Center.z, Radius ); }
|
sphere_inside( float3 const &Center, float const Radius ) const { return sphere_inside( Center.x, Center.y, Center.z, Radius ); }
|
||||||
inline
|
inline
|
||||||
@@ -45,6 +51,9 @@ public:
|
|||||||
sphere_inside( float const X, float const Y, float const Z, float const Radius ) const;
|
sphere_inside( float const X, float const Y, float const Z, float const Radius ) const;
|
||||||
// returns true if specified cube is inside of the frustum. Size = half of the length
|
// returns true if specified cube is inside of the frustum. Size = half of the length
|
||||||
inline
|
inline
|
||||||
|
bool
|
||||||
|
cube_inside( glm::vec3 const &Center, float const Size ) const { return cube_inside( Center.x, Center.y, Center.z, Size ); }
|
||||||
|
inline
|
||||||
bool
|
bool
|
||||||
cube_inside( float3 const &Center, float const Size ) const { return cube_inside( Center.x, Center.y, Center.z, Size ); }
|
cube_inside( float3 const &Center, float const Size ) const { return cube_inside( Center.x, Center.y, Center.z, Size ); }
|
||||||
inline
|
inline
|
||||||
|
|||||||
155
renderer.cpp
155
renderer.cpp
@@ -142,9 +142,16 @@ opengl_renderer::Render() {
|
|||||||
::glLoadIdentity();
|
::glLoadIdentity();
|
||||||
|
|
||||||
if( World.InitPerformed() ) {
|
if( World.InitPerformed() ) {
|
||||||
|
/*
|
||||||
World.Camera.SetMatrix();
|
World.Camera.SetMatrix();
|
||||||
m_camera.update_frustum();
|
m_camera.update_frustum();
|
||||||
|
*/
|
||||||
|
glm::dmat4 worldcamera;
|
||||||
|
World.Camera.SetMatrix( worldcamera );
|
||||||
|
m_camera.update_frustum( OpenGLMatrices.data( GL_PROJECTION ), worldcamera );
|
||||||
|
// frustum tests are performed in 'world space' but after we set up frustum
|
||||||
|
// we no longer need camera translation, only rotation
|
||||||
|
::glMultMatrixd( glm::value_ptr( glm::dmat4( glm::dmat3( worldcamera ))));
|
||||||
|
|
||||||
Render( &World.Environment );
|
Render( &World.Environment );
|
||||||
Render( &World.Ground );
|
Render( &World.Ground );
|
||||||
@@ -178,11 +185,12 @@ opengl_renderer::Render( world_environment *Environment ) {
|
|||||||
/*
|
/*
|
||||||
::glTranslatef( Global::pCameraPosition.x, Global::pCameraPosition.y, Global::pCameraPosition.z );
|
::glTranslatef( Global::pCameraPosition.x, Global::pCameraPosition.y, Global::pCameraPosition.z );
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
glm::mat4 worldcamera;
|
glm::mat4 worldcamera;
|
||||||
World.Camera.SetMatrix( worldcamera );
|
World.Camera.SetMatrix( worldcamera );
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glMultMatrixf( glm::value_ptr( glm::mat4( glm::mat3( worldcamera ) ) ) );
|
glMultMatrixf( glm::value_ptr( glm::mat4( glm::mat3( worldcamera ) ) ) );
|
||||||
|
*/
|
||||||
// setup fog
|
// setup fog
|
||||||
if( Global::fFogEnd > 0 ) {
|
if( Global::fFogEnd > 0 ) {
|
||||||
// fog setup
|
// fog setup
|
||||||
@@ -294,12 +302,16 @@ opengl_renderer::Render( world_environment *Environment ) {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
opengl_renderer::Render( TGround *Ground ) {
|
opengl_renderer::Render( TGround *Ground ) {
|
||||||
/*
|
|
||||||
glDisable( GL_BLEND );
|
|
||||||
glAlphaFunc( GL_GREATER, 0.50f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
|
|
||||||
glEnable( GL_LIGHTING );
|
|
||||||
glColor3f( 1.0f, 1.0f, 1.0f );
|
|
||||||
|
|
||||||
|
::glEnable( GL_LIGHTING );
|
||||||
|
::glDisable( GL_BLEND );
|
||||||
|
::glAlphaFunc( GL_GREATER, 0.50f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
|
||||||
|
::glColor3f( 1.0f, 1.0f, 1.0f );
|
||||||
|
|
||||||
|
++TGroundRect::iFrameNumber; // zwięszenie licznika ramek (do usuwniania nadanimacji)
|
||||||
|
|
||||||
|
Update_Lights( Ground->m_lights );
|
||||||
|
/*
|
||||||
glm::vec3 const cameraposition( Global::pCameraPosition.x, Global::pCameraPosition.y, Global::pCameraPosition.z );
|
glm::vec3 const cameraposition( Global::pCameraPosition.x, Global::pCameraPosition.y, Global::pCameraPosition.z );
|
||||||
int const camerax = static_cast<int>( std::floor( cameraposition.x / 1000.0f ) + iNumRects / 2 );
|
int const camerax = static_cast<int>( std::floor( cameraposition.x / 1000.0f ) + iNumRects / 2 );
|
||||||
int const cameraz = static_cast<int>( std::floor( cameraposition.z / 1000.0f ) + iNumRects / 2 );
|
int const cameraz = static_cast<int>( std::floor( cameraposition.z / 1000.0f ) + iNumRects / 2 );
|
||||||
@@ -317,15 +329,6 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
::glEnable( GL_LIGHTING );
|
|
||||||
::glDisable( GL_BLEND );
|
|
||||||
::glAlphaFunc( GL_GREATER, 0.50f ); // im mniejsza wartość, tym większa ramka, domyślnie 0.1f
|
|
||||||
::glColor3f( 1.0f, 1.0f, 1.0f );
|
|
||||||
|
|
||||||
++TGroundRect::iFrameNumber; // zwięszenie licznika ramek (do usuwniania nadanimacji)
|
|
||||||
|
|
||||||
Update_Lights( Ground->m_lights );
|
|
||||||
|
|
||||||
Ground->CameraDirection.x = std::sin( Global::pCameraRotation ); // wektor kierunkowy
|
Ground->CameraDirection.x = std::sin( Global::pCameraRotation ); // wektor kierunkowy
|
||||||
Ground->CameraDirection.z = std::cos( Global::pCameraRotation );
|
Ground->CameraDirection.z = std::cos( Global::pCameraRotation );
|
||||||
TGroundNode *node;
|
TGroundNode *node;
|
||||||
@@ -354,6 +357,16 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// renderowanie progresywne - zależne od FPS oraz kierunku patrzenia
|
// renderowanie progresywne - zależne od FPS oraz kierunku patrzenia
|
||||||
|
// pre-calculate camera view span
|
||||||
|
double const fieldofviewcosine =
|
||||||
|
std::cos(
|
||||||
|
std::max(
|
||||||
|
// vertical...
|
||||||
|
Global::FieldOfView / Global::ZoomFactor,
|
||||||
|
// ...or horizontal, whichever is bigger
|
||||||
|
Global::FieldOfView / Global::ZoomFactor
|
||||||
|
* std::max( 1.0f, (float)Global::ScreenWidth ) / std::max( 1.0f, (float)Global::ScreenHeight ) ) );
|
||||||
|
|
||||||
Ground->iRendered = 0; // ilość renderowanych sektorów
|
Ground->iRendered = 0; // ilość renderowanych sektorów
|
||||||
Math3D::vector3 direction;
|
Math3D::vector3 direction;
|
||||||
for( k = 0; k < Global::iSegmentsRendered; ++k ) // sektory w kolejności odległości
|
for( k = 0; k < Global::iSegmentsRendered; ++k ) // sektory w kolejności odległości
|
||||||
@@ -369,10 +382,16 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
if( Math3D::LengthSquared3( direction ) > 5 ) // te blisko są zawsze wyświetlane
|
if( Math3D::LengthSquared3( direction ) > 5 ) // te blisko są zawsze wyświetlane
|
||||||
{
|
{
|
||||||
direction = Math3D::SafeNormalize( direction ); // normalizacja
|
direction = Math3D::SafeNormalize( direction ); // normalizacja
|
||||||
if( Ground->CameraDirection.x * direction.x + Ground->CameraDirection.z * direction.z < 0.55 )
|
if( Ground->CameraDirection.x * direction.x + Ground->CameraDirection.z * direction.z < 0.5 )
|
||||||
continue; // pomijanie sektorów poza kątem patrzenia
|
continue; // pomijanie sektorów poza kątem patrzenia
|
||||||
}
|
}
|
||||||
// kwadrat kilometrowy nie zawsze, bo szkoda FPS
|
// kwadrat kilometrowy nie zawsze, bo szkoda FPS
|
||||||
|
// TODO: unify all math objects
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const &cellorigin = Ground->Rects[ ( i + c ) / iNumSubRects ][ ( j + r ) / iNumSubRects ].m_area.center;
|
||||||
|
auto const originoffset = Math3D::vector3( cellorigin.x, cellorigin.y, cellorigin.z ) - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
|
||||||
if( Global::bUseVBO ) {
|
if( Global::bUseVBO ) {
|
||||||
// vbo render path
|
// vbo render path
|
||||||
Ground->Rects[ ( i + c ) / iNumSubRects ][ ( j + r ) / iNumSubRects ].RenderVBO();
|
Ground->Rects[ ( i + c ) / iNumSubRects ][ ( j + r ) / iNumSubRects ].RenderVBO();
|
||||||
@@ -381,6 +400,8 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
// display list render path
|
// display list render path
|
||||||
Ground->Rects[ ( i + c ) / iNumSubRects ][ ( j + r ) / iNumSubRects ].RenderDL();
|
Ground->Rects[ ( i + c ) / iNumSubRects ][ ( j + r ) / iNumSubRects ].RenderDL();
|
||||||
}
|
}
|
||||||
|
::glPopMatrix();
|
||||||
|
|
||||||
if( ( tmp = Ground->FastGetSubRect( i + c, j + r ) ) != nullptr ) {
|
if( ( tmp = Ground->FastGetSubRect( i + c, j + r ) ) != nullptr ) {
|
||||||
if( tmp->iNodeCount ) {
|
if( tmp->iNodeCount ) {
|
||||||
// o ile są jakieś obiekty, bo po co puste sektory przelatywać
|
// o ile są jakieś obiekty, bo po co puste sektory przelatywać
|
||||||
@@ -389,16 +410,15 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
}
|
}
|
||||||
} while( ( i < 0 ) || ( j < 0 ) ); // są 4 przypadki, oprócz i=j=0
|
} while( ( i < 0 ) || ( j < 0 ) ); // są 4 przypadki, oprócz i=j=0
|
||||||
}
|
}
|
||||||
|
|
||||||
// dodać renderowanie terenu z E3D - jedno VBO jest używane dla całego modelu, chyba że jest ich więcej
|
// dodać renderowanie terenu z E3D - jedno VBO jest używane dla całego modelu, chyba że jest ich więcej
|
||||||
if( Global::bUseVBO ) {
|
if( Global::bUseVBO ) {
|
||||||
if( Global::pTerrainCompact ) {
|
if( Global::pTerrainCompact ) {
|
||||||
Global::pTerrainCompact->TerrainRenderVBO( TGroundRect::iFrameNumber );
|
Global::pTerrainCompact->TerrainRenderVBO( TGroundRect::iFrameNumber );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// renderowanie nieprzezroczystych
|
// renderowanie nieprzezroczystych
|
||||||
for( i = 0; i < Ground->iRendered; ++i ) {
|
for( i = 0; i < Ground->iRendered; ++i ) {
|
||||||
|
|
||||||
if( Global::bUseVBO ) {
|
if( Global::bUseVBO ) {
|
||||||
// vbo render path
|
// vbo render path
|
||||||
Ground->pRendered[ i ]->RenderVBO();
|
Ground->pRendered[ i ]->RenderVBO();
|
||||||
@@ -408,10 +428,8 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
Ground->pRendered[ i ]->RenderDL();
|
Ground->pRendered[ i ]->RenderDL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// regular render takes care of all solid geometry present in the scene, thus we can launch alpha parts render here
|
// regular render takes care of all solid geometry present in the scene, thus we can launch alpha parts render here
|
||||||
return Render_Alpha( Ground );
|
return Render_Alpha( Ground );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -436,22 +454,30 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
switch (Node->iType)
|
switch (Node->iType)
|
||||||
{
|
{
|
||||||
case TP_TRACK: {
|
case TP_TRACK: {
|
||||||
|
|
||||||
|
if( Global::bUseVBO && ( Node->iNumVerts <= 0 ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// setup
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
|
||||||
// TODO: unify the render code after generic buffers are in place
|
// TODO: unify the render code after generic buffers are in place
|
||||||
if( Global::bUseVBO ) {
|
if( Global::bUseVBO ) {
|
||||||
if( Node->iNumVerts ) {
|
// vbo render path
|
||||||
Node->pTrack->RaRenderVBO( Node->iVboPtr );
|
Node->pTrack->RaRenderVBO( Node->iVboPtr );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
// display list render path
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Node->pTrack->Render();
|
Node->pTrack->Render();
|
||||||
}
|
}
|
||||||
|
// post-render cleanup
|
||||||
|
::glPopMatrix();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case TP_MODEL: {
|
case TP_MODEL: {
|
||||||
Node->Model->Render( &Node->pCenter );
|
Node->Model->Render( Node->pCenter - Global::pCameraPosition );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case TP_MEMCELL: {
|
case TP_MEMCELL: {
|
||||||
@@ -480,6 +506,9 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
// wszelkie linie są rysowane na samym końcu
|
// wszelkie linie są rysowane na samym końcu
|
||||||
if( Node->iNumPts ) {
|
if( Node->iNumPts ) {
|
||||||
// setup
|
// setup
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
// w zaleznosci od koloru swiatla
|
// w zaleznosci od koloru swiatla
|
||||||
::glColor4ub(
|
::glColor4ub(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 0 ] * Global::DayLight.ambient[ 0 ] ) ),
|
static_cast<GLubyte>( std::floor( Node->Diffuse[ 0 ] * Global::DayLight.ambient[ 0 ] ) ),
|
||||||
@@ -497,6 +526,9 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
else {
|
else {
|
||||||
::glCallList( Node->DisplayListID );
|
::glCallList( Node->DisplayListID );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// post-render cleanup
|
||||||
|
::glPopMatrix();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -505,7 +537,17 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// GL_TRIANGLE etc
|
// GL_TRIANGLE etc
|
||||||
|
if( ( Global::bUseVBO ?
|
||||||
|
Node->iVboPtr < 0 :
|
||||||
|
Node->DisplayListID == 0 ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// setup
|
// setup
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
|
||||||
::glColor3ub(
|
::glColor3ub(
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 0 ] ),
|
static_cast<GLubyte>( Node->Diffuse[ 0 ] ),
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 1 ] ),
|
static_cast<GLubyte>( Node->Diffuse[ 1 ] ),
|
||||||
@@ -517,22 +559,16 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
// TODO: unify the render code after generic buffers are in place
|
// TODO: unify the render code after generic buffers are in place
|
||||||
if( Global::bUseVBO ) {
|
if( Global::bUseVBO ) {
|
||||||
// vbo render path
|
// vbo render path
|
||||||
if( Node->iVboPtr >= 0 ) {
|
|
||||||
::glDrawArrays( Node->iType, Node->iVboPtr, Node->iNumVerts );
|
::glDrawArrays( Node->iType, Node->iVboPtr, Node->iNumVerts );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
// display list render path
|
// display list render path
|
||||||
if( Node->DisplayListID != 0 ) {
|
|
||||||
::glCallList( Node->DisplayListID );
|
::glCallList( Node->DisplayListID );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return false;
|
// post-render cleanup
|
||||||
}
|
::glPopMatrix();
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,11 +586,11 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
|
|||||||
|
|
||||||
// setup
|
// setup
|
||||||
TSubModel::iInstance = ( size_t )this; //żeby nie robić cudzych animacji
|
TSubModel::iInstance = ( size_t )this; //żeby nie robić cudzych animacji
|
||||||
double squaredistance = SquareMagnitude( ( Global::pCameraPosition - Dynamic->vPosition ) / Global::ZoomFactor );
|
auto const originoffset = Dynamic->vPosition - Global::pCameraPosition;
|
||||||
|
double const squaredistance = SquareMagnitude( originoffset / Global::ZoomFactor );
|
||||||
Dynamic->ABuLittleUpdate( squaredistance ); // ustawianie zmiennych submodeli dla wspólnego modelu
|
Dynamic->ABuLittleUpdate( squaredistance ); // ustawianie zmiennych submodeli dla wspólnego modelu
|
||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
/*
|
||||||
if( Dynamic == Global::pUserDynamic ) {
|
if( Dynamic == Global::pUserDynamic ) {
|
||||||
//specjalne ustawienie, aby nie trzęsło
|
//specjalne ustawienie, aby nie trzęsło
|
||||||
//tu trzeba by ustawić animacje na modelu zewnętrznym
|
//tu trzeba by ustawić animacje na modelu zewnętrznym
|
||||||
@@ -563,7 +599,8 @@ opengl_renderer::Render( TDynamicObject *Dynamic ) {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
::glTranslated( Dynamic->vPosition.x, Dynamic->vPosition.y, Dynamic->vPosition.z ); // standardowe przesunięcie względem początku scenerii
|
::glTranslated( Dynamic->vPosition.x, Dynamic->vPosition.y, Dynamic->vPosition.z ); // standardowe przesunięcie względem początku scenerii
|
||||||
|
*/
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
::glMultMatrixd( Dynamic->mMatrix.getArray() );
|
::glMultMatrixd( Dynamic->mMatrix.getArray() );
|
||||||
|
|
||||||
if( Dynamic->fShade > 0.0f ) {
|
if( Dynamic->fShade > 0.0f ) {
|
||||||
@@ -666,7 +703,7 @@ opengl_renderer::Render( TModel3d *Model, material_data const *Material, Math3D:
|
|||||||
if( Angle.z != 0.0 )
|
if( Angle.z != 0.0 )
|
||||||
::glRotated( Angle.z, 0.0, 0.0, 1.0 );
|
::glRotated( Angle.z, 0.0, 0.0, 1.0 );
|
||||||
|
|
||||||
auto const result = Render( Model, Material, SquareMagnitude( Position - Global::GetCameraPosition() ) );
|
auto const result = Render( Model, Material, SquareMagnitude( Position / Global::ZoomFactor ) ); // position is effectively camera offset
|
||||||
|
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
|
|
||||||
@@ -932,12 +969,19 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
case TP_TRACTION: {
|
case TP_TRACTION: {
|
||||||
// TODO: unify the render code after generic buffers are in place
|
// TODO: unify the render code after generic buffers are in place
|
||||||
if( Node->bVisible ) {
|
if( Node->bVisible ) {
|
||||||
|
// setup
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
// render
|
||||||
if( Global::bUseVBO ) {
|
if( Global::bUseVBO ) {
|
||||||
Node->hvTraction->RenderVBO( distancesquared, Node->iVboPtr );
|
Node->hvTraction->RenderVBO( distancesquared, Node->iVboPtr );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Node->hvTraction->RenderDL( distancesquared );
|
Node->hvTraction->RenderDL( distancesquared );
|
||||||
}
|
}
|
||||||
|
// post-render cleanup
|
||||||
|
::glPopMatrix();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -945,7 +989,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case TP_MODEL: {
|
case TP_MODEL: {
|
||||||
Node->Model->RenderAlpha( &Node->pCenter );
|
Node->Model->RenderAlpha( Node->pCenter - Global::pCameraPosition );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -980,6 +1024,9 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
// wszelkie linie są rysowane na samym końcu
|
// wszelkie linie są rysowane na samym końcu
|
||||||
if( Node->iNumPts ) {
|
if( Node->iNumPts ) {
|
||||||
// setup
|
// setup
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
// w zaleznosci od koloru swiatla
|
// w zaleznosci od koloru swiatla
|
||||||
::glColor4ub(
|
::glColor4ub(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 0 ] * Global::DayLight.ambient[ 0 ] ) ),
|
static_cast<GLubyte>( std::floor( Node->Diffuse[ 0 ] * Global::DayLight.ambient[ 0 ] ) ),
|
||||||
@@ -997,12 +1044,18 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
else {
|
else {
|
||||||
::glCallList( Node->DisplayListID );
|
::glCallList( Node->DisplayListID );
|
||||||
}
|
}
|
||||||
|
// post-render cleanup
|
||||||
|
::glPopMatrix();
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// GL_TRIANGLE etc
|
// GL_TRIANGLE etc
|
||||||
// setup
|
// setup
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
|
||||||
::glColor3ub(
|
::glColor3ub(
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 0 ] ),
|
static_cast<GLubyte>( Node->Diffuse[ 0 ] ),
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 1 ] ),
|
static_cast<GLubyte>( Node->Diffuse[ 1 ] ),
|
||||||
@@ -1024,8 +1077,10 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
::glCallList( Node->DisplayListID );
|
::glCallList( Node->DisplayListID );
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// post-render cleanup
|
// post-render cleanup
|
||||||
|
::glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _PROBLEND
|
#ifdef _PROBLEND
|
||||||
if( ( Node->PROBLEND ) ) // sprawdza, czy w nazwie nie ma @ //Q: 13122011 - Szociu: 27012012
|
if( ( Node->PROBLEND ) ) // sprawdza, czy w nazwie nie ma @ //Q: 13122011 - Szociu: 27012012
|
||||||
{
|
{
|
||||||
@@ -1049,17 +1104,19 @@ opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) {
|
|||||||
|
|
||||||
// setup
|
// setup
|
||||||
TSubModel::iInstance = ( size_t )this; //żeby nie robić cudzych animacji
|
TSubModel::iInstance = ( size_t )this; //żeby nie robić cudzych animacji
|
||||||
double squaredistance = SquareMagnitude( ( Global::pCameraPosition - Dynamic->vPosition ) / Global::ZoomFactor );
|
auto const originoffset = Dynamic->vPosition - Global::pCameraPosition;
|
||||||
|
double const squaredistance = SquareMagnitude( originoffset / Global::ZoomFactor );
|
||||||
Dynamic->ABuLittleUpdate( squaredistance ); // ustawianie zmiennych submodeli dla wspólnego modelu
|
Dynamic->ABuLittleUpdate( squaredistance ); // ustawianie zmiennych submodeli dla wspólnego modelu
|
||||||
|
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
/*
|
||||||
if( Dynamic == Global::pUserDynamic ) { // specjalne ustawienie, aby nie trzęsło
|
if( Dynamic == Global::pUserDynamic ) { // specjalne ustawienie, aby nie trzęsło
|
||||||
::glLoadIdentity(); // zacząć od macierzy jedynkowej
|
::glLoadIdentity(); // zacząć od macierzy jedynkowej
|
||||||
Global::pCamera->SetCabMatrix( Dynamic->vPosition ); // specjalne ustawienie kamery
|
Global::pCamera->SetCabMatrix( Dynamic->vPosition ); // specjalne ustawienie kamery
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::glTranslated( Dynamic->vPosition.x, Dynamic->vPosition.y, Dynamic->vPosition.z ); // standardowe przesunięcie względem początku scenerii
|
::glTranslated( Dynamic->vPosition.x, Dynamic->vPosition.y, Dynamic->vPosition.z ); // standardowe przesunięcie względem początku scenerii
|
||||||
|
*/
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
::glMultMatrixd( Dynamic->mMatrix.getArray() );
|
::glMultMatrixd( Dynamic->mMatrix.getArray() );
|
||||||
|
|
||||||
if( Dynamic->fShade > 0.0f ) {
|
if( Dynamic->fShade > 0.0f ) {
|
||||||
@@ -1161,7 +1218,7 @@ opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, M
|
|||||||
if( Angle.z != 0.0 )
|
if( Angle.z != 0.0 )
|
||||||
::glRotated( Angle.z, 0.0, 0.0, 1.0 );
|
::glRotated( Angle.z, 0.0, 0.0, 1.0 );
|
||||||
|
|
||||||
auto const result = Render_Alpha( Model, Material, SquareMagnitude( Position - Global::GetCameraPosition() ) );
|
auto const result = Render_Alpha( Model, Material, SquareMagnitude( Position / Global::ZoomFactor ) ); // position is effectively camera offset
|
||||||
|
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
|
|
||||||
@@ -1400,7 +1457,7 @@ opengl_renderer::Update_Lights( light_array const &Lights ) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// if the light passed tests so far, it's good enough
|
// if the light passed tests so far, it's good enough
|
||||||
renderlight->set_position( scenelight.position );
|
renderlight->set_position( scenelight.position - Global::pCameraPosition );
|
||||||
renderlight->direction = scenelight.direction;
|
renderlight->direction = scenelight.direction;
|
||||||
|
|
||||||
auto luminance = Global::fLuminance; // TODO: adjust this based on location, e.g. for tunnels
|
auto luminance = Global::fLuminance; // TODO: adjust this based on location, e.g. for tunnels
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public:
|
|||||||
update_frustum() { m_frustum.calculate(); }
|
update_frustum() { m_frustum.calculate(); }
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
update_frustum(glm::mat4 &Projection, glm::mat4 &Modelview) { m_frustum.calculate(Projection, Modelview); }
|
update_frustum(glm::mat4 const &Projection, glm::mat4 const &Modelview) { m_frustum.calculate(Projection, Modelview); }
|
||||||
bool
|
bool
|
||||||
visible( bounding_area const &Area ) const;
|
visible( bounding_area const &Area ) const;
|
||||||
bool
|
bool
|
||||||
|
|||||||
Reference in New Issue
Block a user