mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 23:19:19 +02:00
fixed trackbed normal generation
This commit is contained in:
41
AnimModel.h
41
AnimModel.h
@@ -77,16 +77,9 @@ class TAnimContainer
|
|||||||
TAnimContainer();
|
TAnimContainer();
|
||||||
~TAnimContainer();
|
~TAnimContainer();
|
||||||
bool Init(TSubModel *pNewSubModel);
|
bool Init(TSubModel *pNewSubModel);
|
||||||
// std::string inline GetName() { return
|
inline
|
||||||
// std::string(pSubModel?pSubModel->asName.c_str():""); };
|
std::string NameGet() {
|
||||||
// std::string inline GetName() { return std::string(pSubModel?pSubModel->pName:"");
|
return (pSubModel ? pSubModel->pName : ""); };
|
||||||
// };
|
|
||||||
std::string NameGet()
|
|
||||||
{
|
|
||||||
return (pSubModel ? pSubModel->pName : "");
|
|
||||||
};
|
|
||||||
// void SetRotateAnim(vector3 vNewRotateAxis, double fNewDesiredAngle, double
|
|
||||||
// fNewRotateSpeed, bool bResetAngle=false);
|
|
||||||
void SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSpeed);
|
void SetRotateAnim(vector3 vNewRotateAngles, double fNewRotateSpeed);
|
||||||
void SetTranslateAnim(vector3 vNewTranslate, double fNewSpeed);
|
void SetTranslateAnim(vector3 vNewTranslate, double fNewSpeed);
|
||||||
void AnimSetVMD(double fNewSpeed);
|
void AnimSetVMD(double fNewSpeed);
|
||||||
@@ -94,24 +87,20 @@ class TAnimContainer
|
|||||||
void UpdateModel();
|
void UpdateModel();
|
||||||
void UpdateModelIK();
|
void UpdateModelIK();
|
||||||
bool InMovement(); // czy w trakcie animacji?
|
bool InMovement(); // czy w trakcie animacji?
|
||||||
double _fastcall AngleGet()
|
inline
|
||||||
{
|
double AngleGet() {
|
||||||
return vRotateAngles.z;
|
return vRotateAngles.z; }; // jednak ostatnia, T3D ma inny układ
|
||||||
}; // jednak ostatnia, T3D ma inny układ
|
inline
|
||||||
vector3 _fastcall TransGet()
|
vector3 TransGet() {
|
||||||
{
|
return vector3(-vTranslation.x, vTranslation.z, vTranslation.y); }; // zmiana, bo T3D ma inny układ
|
||||||
return vector3(-vTranslation.x, vTranslation.z, vTranslation.y);
|
inline
|
||||||
}; // zmiana, bo T3D ma inny układ
|
void WillBeAnimated() {
|
||||||
void WillBeAnimated()
|
|
||||||
{
|
|
||||||
if (pSubModel)
|
if (pSubModel)
|
||||||
pSubModel->WillBeAnimated();
|
pSubModel->WillBeAnimated(); };
|
||||||
};
|
|
||||||
void EventAssign(TEvent *ev);
|
void EventAssign(TEvent *ev);
|
||||||
TEvent * Event()
|
inline
|
||||||
{
|
TEvent * Event() {
|
||||||
return evDone;
|
return evDone; };
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TAnimAdvanced
|
class TAnimAdvanced
|
||||||
|
|||||||
104
Segment.cpp
104
Segment.cpp
@@ -59,8 +59,8 @@ bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, M
|
|||||||
CPointIn = NewCPointIn;
|
CPointIn = NewCPointIn;
|
||||||
Point2 = NewPoint2;
|
Point2 = NewPoint2;
|
||||||
// poprawienie przechyłki
|
// poprawienie przechyłki
|
||||||
fRoll1 = DegToRad(fNewRoll1); // Ra: przeliczone jest bardziej przydatne do obliczeń
|
fRoll1 = glm::radians(fNewRoll1); // Ra: przeliczone jest bardziej przydatne do obliczeń
|
||||||
fRoll2 = DegToRad(fNewRoll2);
|
fRoll2 = glm::radians(fNewRoll2);
|
||||||
if (Global::bRollFix)
|
if (Global::bRollFix)
|
||||||
{ // Ra: poprawianie przechyłki
|
{ // Ra: poprawianie przechyłki
|
||||||
// Przechyłka powinna być na środku wewnętrznej szyny, a standardowo jest w osi
|
// Przechyłka powinna być na środku wewnętrznej szyny, a standardowo jest w osi
|
||||||
@@ -78,7 +78,7 @@ bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, M
|
|||||||
CPointOut.y += w1; // prosty ma wektory jednostkowe
|
CPointOut.y += w1; // prosty ma wektory jednostkowe
|
||||||
pOwner->MovedUp1(w1); // zwrócić trzeba informację o podwyższeniu podsypki
|
pOwner->MovedUp1(w1); // zwrócić trzeba informację o podwyższeniu podsypki
|
||||||
}
|
}
|
||||||
if (fRoll2 != 0.0)
|
if (fRoll2 != 0.f)
|
||||||
{
|
{
|
||||||
double w2 = std::abs(std::sin(fRoll2) * 0.75); // 0.5*w2+0.0325; //0.75m dla 1.435
|
double w2 = std::abs(std::sin(fRoll2) * 0.75); // 0.5*w2+0.0325; //0.75m dla 1.435
|
||||||
Point2.y += w2; // modyfikacja musi być przed policzeniem dalszych parametrów
|
Point2.y += w2; // modyfikacja musi być przed policzeniem dalszych parametrów
|
||||||
@@ -87,9 +87,9 @@ bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, M
|
|||||||
// zwrócić trzeba informację o podwyższeniu podsypki
|
// zwrócić trzeba informację o podwyższeniu podsypki
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// kąt w planie, żeby nie liczyć wielokrotnie
|
||||||
// Ra: ten kąt jeszcze do przemyślenia jest
|
// Ra: ten kąt jeszcze do przemyślenia jest
|
||||||
fDirection = -atan2(Point2.x - Point1.x,
|
fDirection = -std::atan2(Point2.x - Point1.x, Point2.z - Point1.z);
|
||||||
Point2.z - Point1.z); // kąt w planie, żeby nie liczyć wielokrotnie
|
|
||||||
bCurve = bIsCurve;
|
bCurve = bIsCurve;
|
||||||
if (bCurve)
|
if (bCurve)
|
||||||
{ // przeliczenie współczynników wielomianu, będzie mniej mnożeń i można policzyć pochodne
|
{ // przeliczenie współczynników wielomianu, będzie mniej mnożeń i można policzyć pochodne
|
||||||
@@ -101,10 +101,9 @@ bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, M
|
|||||||
else
|
else
|
||||||
fLength = (Point1 - Point2).Length();
|
fLength = (Point1 - Point2).Length();
|
||||||
fStep = fNewStep;
|
fStep = fNewStep;
|
||||||
if (fLength <= 0)
|
if (fLength <= 0) {
|
||||||
{
|
|
||||||
ErrorLog( "Bad geometry: zero length spline \"" + pOwner->NameGet() + "\" (location: " + to_string( glm::dvec3{ Point1 } ) + ")" );
|
ErrorLog( "Bad geometry: zero length spline \"" + pOwner->NameGet() + "\" (location: " + to_string( glm::dvec3{ Point1 } ) + ")" );
|
||||||
// MessageBox(0,"Length<=0","TSegment::Init",MB_OK);
|
|
||||||
fLength = 0.01; // crude workaround TODO: fix this properly
|
fLength = 0.01; // crude workaround TODO: fix this properly
|
||||||
/*
|
/*
|
||||||
return false; // zerowe nie mogą być
|
return false; // zerowe nie mogą być
|
||||||
@@ -355,7 +354,7 @@ Math3D::vector3 TSegment::FastGetPoint(double const t) const
|
|||||||
interpolate( Point1, Point2, t ) );
|
interpolate( Point1, Point2, t ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin, const vector6 *ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale, int iSkip, int iEnd, double fOffsetX, Math3D::vector3 **p, bool bRender)
|
bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin, const basic_vertex *ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale, int iSkip, int iEnd, float fOffsetX, glm::vec3 **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
|
||||||
@@ -365,13 +364,14 @@ bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin,
|
|||||||
if( !fTsBuffer )
|
if( !fTsBuffer )
|
||||||
return false; // prowizoryczne zabezpieczenie przed wysypem - ustalić faktyczną przyczynę
|
return false; // prowizoryczne zabezpieczenie przed wysypem - ustalić faktyczną przyczynę
|
||||||
|
|
||||||
Math3D::vector3 pos1, pos2, dir, parallel1, parallel2, pt, norm;
|
glm::vec3 pos1, pos2, dir, parallel1, parallel2, pt, norm;
|
||||||
double s, step, fOffset, tv1, tv2, t, fEnd;
|
float s, step, fOffset, tv1, tv2, t, fEnd;
|
||||||
bool const trapez = iNumShapePoints < 0; // sygnalizacja trapezowatości
|
bool const trapez = iNumShapePoints < 0; // sygnalizacja trapezowatości
|
||||||
iNumShapePoints = std::abs( iNumShapePoints );
|
iNumShapePoints = std::abs( iNumShapePoints );
|
||||||
fTextureLength *= Texturescale;
|
float const texturelength = fTextureLength * Texturescale;
|
||||||
|
float const texturescale = Texturescale;
|
||||||
|
|
||||||
double m1, jmm1, m2, jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera)
|
float m1, jmm1, m2, jmm2; // pozycje względne na odcinku 0...1 (ale nie parametr Beziera)
|
||||||
step = fStep;
|
step = fStep;
|
||||||
tv1 = 1.0; // Ra: to by można było wyliczać dla odcinka, wyglądało by lepiej
|
tv1 = 1.0; // Ra: to by można było wyliczać dla odcinka, wyglądało by lepiej
|
||||||
s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć
|
s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć
|
||||||
@@ -379,9 +379,9 @@ bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin,
|
|||||||
t = fTsBuffer[ i ]; // tabela wattości t dla segmentów
|
t = fTsBuffer[ i ]; // tabela wattości t dla segmentów
|
||||||
// BUG: length of spline can be 0, we should skip geometry generation for such cases
|
// BUG: length of spline can be 0, we should skip geometry generation for such cases
|
||||||
fOffset = 0.1 / fLength; // pierwsze 10cm
|
fOffset = 0.1 / fLength; // pierwsze 10cm
|
||||||
pos1 = FastGetPoint( t ); // wektor początku segmentu
|
pos1 = glm::dvec3{ FastGetPoint( t ) - Origin }; // wektor początku segmentu
|
||||||
dir = FastGetDirection( t, fOffset ); // wektor kierunku
|
dir = glm::dvec3{ FastGetDirection( t, fOffset ) }; // wektor kierunku
|
||||||
parallel1 = Normalize( Math3D::vector3( -dir.z, 0.0, dir.x ) ); // wektor poprzeczny
|
parallel1 = glm::normalize( glm::vec3{ -dir.z, 0.f, dir.x } ); // wektor poprzeczny
|
||||||
if( iEnd == 0 )
|
if( iEnd == 0 )
|
||||||
iEnd = iSegCount;
|
iEnd = iSegCount;
|
||||||
fEnd = fLength * double( iEnd ) / double( iSegCount );
|
fEnd = fLength * double( iEnd ) / double( iSegCount );
|
||||||
@@ -406,26 +406,26 @@ bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin,
|
|||||||
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 / texturelength; // mapowanie na końcu segmentu
|
||||||
|
|
||||||
t = fTsBuffer[ i ]; // szybsze od GetTFromS(s);
|
t = fTsBuffer[ i ]; // szybsze od GetTFromS(s);
|
||||||
pos2 = FastGetPoint( t );
|
pos2 = glm::dvec3{ FastGetPoint( t ) - Origin };
|
||||||
dir = FastGetDirection( t, fOffset ); // nowy wektor kierunku
|
dir = glm::dvec3{ FastGetDirection( t, fOffset ) }; // nowy wektor kierunku
|
||||||
parallel2 = Normalize( Math3D::vector3( -dir.z, 0.0, dir.x ) ); // wektor poprzeczny
|
parallel2 = glm::normalize( glm::vec3{ -dir.z, 0.f, dir.x } ); // wektor poprzeczny
|
||||||
|
|
||||||
if( trapez ) {
|
if( trapez ) {
|
||||||
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 ].position.x - fOffsetX ) + m1 * ShapePoints[ j + iNumShapePoints ].position.x ) + pos1;
|
||||||
pt.y += jmm1 * ShapePoints[ j ].y + m1 * ShapePoints[ j + iNumShapePoints ].y;
|
pt.y += jmm1 * ShapePoints[ j ].position.y + m1 * ShapePoints[ j + iNumShapePoints ].position.y;
|
||||||
pt -= Origin;
|
// pt -= Origin;
|
||||||
norm = ( jmm1 * ShapePoints[ j ].n.x + m1 * ShapePoints[ j + iNumShapePoints ].n.x ) * parallel1;
|
norm = ( jmm1 * ShapePoints[ j ].normal.x + m1 * ShapePoints[ j + iNumShapePoints ].normal.x ) * parallel1;
|
||||||
norm.y += jmm1 * ShapePoints[ j ].n.y + m1 * ShapePoints[ j + iNumShapePoints ].n.y;
|
norm.y += jmm1 * ShapePoints[ j ].normal.y + m1 * ShapePoints[ j + iNumShapePoints ].normal.y;
|
||||||
if( bRender ) {
|
if( bRender ) {
|
||||||
// skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
// skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
||||||
Output.emplace_back(
|
Output.emplace_back(
|
||||||
glm::vec3 { pt.x, pt.y, pt.z },
|
pt,
|
||||||
glm::vec3 { norm.x, norm.y, norm.z },
|
glm::normalize( norm ),
|
||||||
glm::vec2 { ( jmm1 * ShapePoints[ j ].z + m1 * ShapePoints[ j + iNumShapePoints ].z ) / Texturescale, tv1 } );
|
glm::vec2 { ( jmm1 * ShapePoints[ j ].texture.x + m1 * ShapePoints[ j + iNumShapePoints ].texture.x ) / texturescale, tv1 } );
|
||||||
}
|
}
|
||||||
if( p ) // jeśli jest wskaźnik do tablicy
|
if( p ) // jeśli jest wskaźnik do tablicy
|
||||||
if( *p )
|
if( *p )
|
||||||
@@ -435,17 +435,17 @@ bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin,
|
|||||||
( *p )++;
|
( *p )++;
|
||||||
} // zapamiętanie brzegu jezdni
|
} // zapamiętanie brzegu jezdni
|
||||||
// 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 ].position.x - fOffsetX ) + m2 * ShapePoints[ j + iNumShapePoints ].position.x ) + pos2;
|
||||||
pt.y += jmm2 * ShapePoints[ j ].y + m2 * ShapePoints[ j + iNumShapePoints ].y;
|
pt.y += jmm2 * ShapePoints[ j ].position.y + m2 * ShapePoints[ j + iNumShapePoints ].position.y;
|
||||||
pt -= Origin;
|
// pt -= Origin;
|
||||||
norm = ( jmm1 * ShapePoints[ j ].n.x + m1 * ShapePoints[ j + iNumShapePoints ].n.x ) * parallel2;
|
norm = ( jmm1 * ShapePoints[ j ].normal.x + m1 * ShapePoints[ j + iNumShapePoints ].normal.x ) * parallel2;
|
||||||
norm.y += jmm1 * ShapePoints[ j ].n.y + m1 * ShapePoints[ j + iNumShapePoints ].n.y;
|
norm.y += jmm1 * ShapePoints[ j ].normal.y + m1 * ShapePoints[ j + iNumShapePoints ].normal.y;
|
||||||
if( bRender ) {
|
if( bRender ) {
|
||||||
// skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
// skrzyżowania podczas łączenia siatek mogą nie renderować poboczy, ale potrzebować punktów
|
||||||
Output.emplace_back(
|
Output.emplace_back(
|
||||||
glm::vec3 { pt.x, pt.y, pt.z },
|
pt,
|
||||||
glm::vec3 { norm.x, norm.y, norm.z },
|
glm::normalize( norm ),
|
||||||
glm::vec2 { ( jmm2 * ShapePoints[ j ].z + m2 * ShapePoints[ j + iNumShapePoints ].z ) / Texturescale, tv2 } );
|
glm::vec2 { ( jmm2 * ShapePoints[ j ].texture.x + m2 * ShapePoints[ j + iNumShapePoints ].texture.x ) / texturescale, tv2 } );
|
||||||
}
|
}
|
||||||
if( p ) // jeśli jest wskaźnik do tablicy
|
if( p ) // jeśli jest wskaźnik do tablicy
|
||||||
if( *p )
|
if( *p )
|
||||||
@@ -460,27 +460,27 @@ bool TSegment::RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin,
|
|||||||
if( bRender ) {
|
if( bRender ) {
|
||||||
for( int j = 0; j < iNumShapePoints; ++j ) {
|
for( int j = 0; j < iNumShapePoints; ++j ) {
|
||||||
//łuk z jednym profilem
|
//łuk z jednym profilem
|
||||||
pt = parallel1 * ( ShapePoints[ j ].x - fOffsetX ) + pos1;
|
pt = parallel1 * ( ShapePoints[ j ].position.x - fOffsetX ) + pos1;
|
||||||
pt.y += ShapePoints[ j ].y;
|
pt.y += ShapePoints[ j ].position.y;
|
||||||
pt -= Origin;
|
// pt -= Origin;
|
||||||
norm = ShapePoints[ j ].n.x * parallel1;
|
norm = ShapePoints[ j ].normal.x * parallel1;
|
||||||
norm.y += ShapePoints[ j ].n.y;
|
norm.y += ShapePoints[ j ].normal.y;
|
||||||
|
|
||||||
Output.emplace_back(
|
Output.emplace_back(
|
||||||
glm::vec3 { pt.x, pt.y, pt.z },
|
pt,
|
||||||
glm::vec3 { norm.x, norm.y, norm.z },
|
glm::normalize( norm ),
|
||||||
glm::vec2 { ShapePoints[ j ].z / Texturescale, tv1 } );
|
glm::vec2 { ShapePoints[ j ].texture.x / texturescale, tv1 } );
|
||||||
|
|
||||||
pt = parallel2 * ShapePoints[ j ].x + pos2;
|
pt = parallel2 * ShapePoints[ j ].position.x + pos2;
|
||||||
pt.y += ShapePoints[ j ].y;
|
pt.y += ShapePoints[ j ].position.y;
|
||||||
pt -= Origin;
|
// pt -= Origin;
|
||||||
norm = ShapePoints[ j ].n.x * parallel2;
|
norm = ShapePoints[ j ].normal.x * parallel2;
|
||||||
norm.y += ShapePoints[ j ].n.y;
|
norm.y += ShapePoints[ j ].normal.y;
|
||||||
|
|
||||||
Output.emplace_back(
|
Output.emplace_back(
|
||||||
glm::vec3 { pt.x, pt.y, pt.z },
|
pt,
|
||||||
glm::vec3 { norm.x, norm.y, norm.z },
|
glm::normalize( norm ),
|
||||||
glm::vec2 { ShapePoints[ j ].z / Texturescale, tv2 } );
|
glm::vec2 { ShapePoints[ j ].texture.x / texturescale, tv2 } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
Segment.h
18
Segment.h
@@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "usefull.h"
|
#include "usefull.h"
|
||||||
|
|
||||||
// 110405 Ra: klasa punktów przekroju z normalnymi
|
// 110405 Ra: klasa punktów przekroju z normalnymi
|
||||||
|
/*
|
||||||
class vector6 : public Math3D::vector3
|
class vector6 : public Math3D::vector3
|
||||||
{ // punkt przekroju wraz z wektorem normalnym
|
{ // punkt przekroju wraz z wektorem normalnym
|
||||||
public:
|
public:
|
||||||
@@ -26,7 +26,6 @@ class vector6 : public Math3D::vector3
|
|||||||
n.y = 1.0;
|
n.y = 1.0;
|
||||||
};
|
};
|
||||||
vector6(double a, double b, double c, double d, double e, double f)
|
vector6(double a, double b, double c, double d, double e, double f)
|
||||||
//{x=a; y=b; z=c; n.x=d; n.y=e; n.z=f;};
|
|
||||||
{
|
{
|
||||||
x = a;
|
x = a;
|
||||||
y = b;
|
y = b;
|
||||||
@@ -45,13 +44,14 @@ class vector6 : public Math3D::vector3
|
|||||||
n.z = 0.0;
|
n.z = 0.0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
class TSegment
|
class TSegment
|
||||||
{ // aproksymacja toru (zwrotnica ma dwa takie, jeden z nich jest aktywny)
|
{ // aproksymacja toru (zwrotnica ma dwa takie, jeden z nich jest aktywny)
|
||||||
private:
|
private:
|
||||||
Math3D::vector3 Point1, CPointOut, CPointIn, Point2;
|
Math3D::vector3 Point1, CPointOut, CPointIn, Point2;
|
||||||
double fRoll1 = 0.0,
|
float
|
||||||
fRoll2 = 0.0; // przechyłka na końcach
|
fRoll1{ 0.f },
|
||||||
|
fRoll2{ 0.f }; // przechyłka na końcach
|
||||||
double fLength = 0.0; // długość policzona
|
double fLength = 0.0; // długość policzona
|
||||||
double *fTsBuffer = nullptr; // wartości parametru krzywej dla równych odcinków
|
double *fTsBuffer = nullptr; // wartości parametru krzywej dla równych odcinków
|
||||||
double fStep = 0.0;
|
double fStep = 0.0;
|
||||||
@@ -118,18 +118,18 @@ public:
|
|||||||
FastGetPoint_1() const {
|
FastGetPoint_1() const {
|
||||||
return Point2; };
|
return Point2; };
|
||||||
inline
|
inline
|
||||||
double
|
float
|
||||||
GetRoll(double const Distance) const {
|
GetRoll(double const Distance) const {
|
||||||
return interpolate( fRoll1, fRoll2, Distance / fLength ); }
|
return interpolate( fRoll1, fRoll2, static_cast<float>(Distance / fLength) ); }
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
GetRolls(double &r1, double &r2) const {
|
GetRolls(float &r1, float &r2) const {
|
||||||
// pobranie przechyłek (do generowania trójkątów)
|
// pobranie przechyłek (do generowania trójkątów)
|
||||||
r1 = fRoll1;
|
r1 = fRoll1;
|
||||||
r2 = fRoll2; }
|
r2 = fRoll2; }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
RenderLoft( vertex_array &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, Math3D::vector3 **p = nullptr, bool bRender = true);
|
RenderLoft( vertex_array &Output, Math3D::vector3 const &Origin, basic_vertex const *ShapePoints, int iNumShapePoints, double fTextureLength, double Texturescale = 1.0, int iSkip = 0, int iEnd = 0, float fOffsetX = 0.f, glm::vec3 **p = nullptr, bool bRender = true);
|
||||||
void
|
void
|
||||||
Render();
|
Render();
|
||||||
inline
|
inline
|
||||||
|
|||||||
49
Track.h
49
Track.h
@@ -10,23 +10,23 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "GL/glew.h"
|
#include <vector>
|
||||||
#include "ResourceManager.h"
|
#include <deque>
|
||||||
|
|
||||||
#include "Segment.h"
|
#include "Segment.h"
|
||||||
#include "material.h"
|
#include "material.h"
|
||||||
|
|
||||||
typedef enum
|
enum TTrackType {
|
||||||
{
|
|
||||||
tt_Unknown,
|
tt_Unknown,
|
||||||
tt_Normal,
|
tt_Normal,
|
||||||
tt_Switch,
|
tt_Switch,
|
||||||
tt_Table,
|
tt_Table,
|
||||||
tt_Cross,
|
tt_Cross,
|
||||||
tt_Tributary
|
tt_Tributary
|
||||||
} TTrackType;
|
};
|
||||||
// McZapkie-100502
|
// McZapkie-100502
|
||||||
typedef enum
|
|
||||||
{
|
enum TEnvironmentType {
|
||||||
e_unknown = -1,
|
e_unknown = -1,
|
||||||
e_flat = 0,
|
e_flat = 0,
|
||||||
e_mountains,
|
e_mountains,
|
||||||
@@ -34,7 +34,7 @@ typedef enum
|
|||||||
e_tunnel,
|
e_tunnel,
|
||||||
e_bridge,
|
e_bridge,
|
||||||
e_bank
|
e_bank
|
||||||
} TEnvironmentType;
|
};
|
||||||
// Ra: opracować alternatywny system cieni/świateł z definiowaniem koloru oświetlenia w halach
|
// Ra: opracować alternatywny system cieni/świateł z definiowaniem koloru oświetlenia w halach
|
||||||
|
|
||||||
class TEvent;
|
class TEvent;
|
||||||
@@ -49,23 +49,22 @@ class TSwitchExtension
|
|||||||
TSwitchExtension(TTrack *owner, int const what);
|
TSwitchExtension(TTrack *owner, int const what);
|
||||||
~TSwitchExtension();
|
~TSwitchExtension();
|
||||||
std::shared_ptr<TSegment> Segments[6]; // dwa tory od punktu 1, pozosta³e dwa od 2? Ra 140101: 6 po³¹czeñ dla skrzy¿owañ
|
std::shared_ptr<TSegment> Segments[6]; // dwa tory od punktu 1, pozosta³e dwa od 2? Ra 140101: 6 po³¹czeñ dla skrzy¿owañ
|
||||||
// TTrack *trNear[4]; //tory do³¹czone do punktów 1, 2, 3 i 4
|
|
||||||
// dotychczasowe [2]+[2] wskaŸniki zamieniæ na nowe [4]
|
|
||||||
TTrack *pNexts[2]; // tory do³¹czone do punktów 2 i 4
|
TTrack *pNexts[2]; // tory do³¹czone do punktów 2 i 4
|
||||||
TTrack *pPrevs[2]; // tory do³¹czone do punktów 1 i 3
|
TTrack *pPrevs[2]; // tory do³¹czone do punktów 1 i 3
|
||||||
int iNextDirection[2]; // to te¿ z [2]+[2] przerobiæ na [4]
|
int iNextDirection[2]; // to te¿ z [2]+[2] przerobiæ na [4]
|
||||||
int iPrevDirection[2];
|
int iPrevDirection[2];
|
||||||
int CurrentIndex = 0; // dla zwrotnicy
|
int CurrentIndex = 0; // dla zwrotnicy
|
||||||
double fOffset = 0.0,
|
float
|
||||||
fDesiredOffset = 0.0; // aktualne i docelowe położenie napędu iglic
|
fOffset{ 0.f },
|
||||||
double fOffsetSpeed = 0.1; // prędkość liniowa ruchu iglic
|
fDesiredOffset{ 0.f }; // aktualne i docelowe położenie napędu iglic
|
||||||
double fOffsetDelay = 0.05; // opóźnienie ruchu drugiej iglicy względem pierwszej // dodatkowy ruch drugiej iglicy po zablokowaniu pierwszej na opornicy
|
float fOffsetSpeed = 0.1f; // prędkość liniowa ruchu iglic
|
||||||
|
float fOffsetDelay = 0.05f; // opóźnienie ruchu drugiej iglicy względem pierwszej // dodatkowy ruch drugiej iglicy po zablokowaniu pierwszej na opornicy
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{ // zmienne potrzebne tylko dla zwrotnicy
|
{ // zmienne potrzebne tylko dla zwrotnicy
|
||||||
double fOffset1,
|
float fOffset1,
|
||||||
fOffset2; // przesunięcia iglic - 0=na wprost
|
fOffset2; // przesunięcia iglic - 0=na wprost
|
||||||
bool RightSwitch; // czy zwrotnica w prawo
|
bool RightSwitch; // czy zwrotnica w prawo
|
||||||
};
|
};
|
||||||
struct
|
struct
|
||||||
@@ -77,21 +76,17 @@ class TSwitchExtension
|
|||||||
struct
|
struct
|
||||||
{ // zmienne dla skrzyżowania
|
{ // zmienne dla skrzyżowania
|
||||||
int iRoads; // ile dróg się spotyka?
|
int iRoads; // ile dróg się spotyka?
|
||||||
Math3D::vector3 *vPoints; // tablica wierzchołków nawierzchni, generowana przez pobocze
|
glm::vec3 *vPoints; // tablica wierzchołków nawierzchni, generowana przez pobocze
|
||||||
// int iPoints; // liczba faktycznie użytych wierzchołków nawierzchni
|
|
||||||
bool bPoints; // czy utworzone?
|
bool bPoints; // czy utworzone?
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
bool bMovement = false; // czy w trakcie animacji
|
bool bMovement = false; // czy w trakcie animacji
|
||||||
int iLeftVBO = 0,
|
|
||||||
iRightVBO = 0; // indeksy iglic w VBO
|
|
||||||
TSubRect *pOwner = nullptr; // sektor, któremu trzeba zgłosić animację
|
TSubRect *pOwner = nullptr; // sektor, któremu trzeba zgłosić animację
|
||||||
TTrack *pNextAnim = nullptr; // następny tor do animowania
|
TTrack *pNextAnim = nullptr; // następny tor do animowania
|
||||||
TEvent *evPlus = nullptr,
|
TEvent *evPlus = nullptr,
|
||||||
*evMinus = nullptr; // zdarzenia sygnalizacji rozprucia
|
*evMinus = nullptr; // zdarzenia sygnalizacji rozprucia
|
||||||
float fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem)
|
float fVelocity = -1.0; // maksymalne ograniczenie prędkości (ustawianej eventem)
|
||||||
Math3D::vector3 vTrans; // docelowa translacja przesuwnicy
|
Math3D::vector3 vTrans; // docelowa translacja przesuwnicy
|
||||||
private:
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TIsolated
|
class TIsolated
|
||||||
@@ -106,7 +101,6 @@ class TIsolated
|
|||||||
TMemCell *pMemCell = nullptr; // automatyczna komórka pamięci, która współpracuje z odcinkiem izolowanym
|
TMemCell *pMemCell = nullptr; // automatyczna komórka pamięci, która współpracuje z odcinkiem izolowanym
|
||||||
TIsolated();
|
TIsolated();
|
||||||
TIsolated(const std::string &n, TIsolated *i);
|
TIsolated(const std::string &n, TIsolated *i);
|
||||||
~TIsolated();
|
|
||||||
static TIsolated * Find(const std::string &n); // znalezienie obiektu albo utworzenie nowego
|
static TIsolated * Find(const std::string &n); // znalezienie obiektu albo utworzenie nowego
|
||||||
void Modify(int i, TDynamicObject *o); // dodanie lub odjęcie osi
|
void Modify(int i, TDynamicObject *o); // dodanie lub odjęcie osi
|
||||||
bool Busy() {
|
bool Busy() {
|
||||||
@@ -118,7 +112,7 @@ class TIsolated
|
|||||||
};
|
};
|
||||||
|
|
||||||
// trajektoria ruchu - opakowanie
|
// trajektoria ruchu - opakowanie
|
||||||
class TTrack /*: public Resource*/ {
|
class TTrack {
|
||||||
|
|
||||||
friend class opengl_renderer;
|
friend class opengl_renderer;
|
||||||
|
|
||||||
@@ -207,7 +201,7 @@ public:
|
|||||||
return trPrev; };
|
return trPrev; };
|
||||||
TTrack *Connected(int s, double &d) const;
|
TTrack *Connected(int s, double &d) const;
|
||||||
bool SetConnections(int i);
|
bool SetConnections(int i);
|
||||||
bool Switch(int i, double t = -1.0, double d = -1.0);
|
bool Switch(int i, float const t = -1.f, float const d = -1.f);
|
||||||
bool SwitchForced(int i, TDynamicObject *o);
|
bool SwitchForced(int i, TDynamicObject *o);
|
||||||
int CrossSegment(int from, int into);
|
int CrossSegment(int from, int into);
|
||||||
inline int GetSwitchState() {
|
inline int GetSwitchState() {
|
||||||
@@ -241,17 +235,12 @@ public:
|
|||||||
std::string IsolatedName();
|
std::string IsolatedName();
|
||||||
bool IsolatedEventsAssign(TEvent *busy, TEvent *free);
|
bool IsolatedEventsAssign(TEvent *busy, TEvent *free);
|
||||||
double WidthTotal();
|
double WidthTotal();
|
||||||
GLuint TextureGet(int i) {
|
|
||||||
return (
|
|
||||||
i ?
|
|
||||||
m_material1 :
|
|
||||||
m_material2 ); };
|
|
||||||
bool IsGroupable();
|
bool IsGroupable();
|
||||||
int TestPoint( Math3D::vector3 *Point);
|
int TestPoint( Math3D::vector3 *Point);
|
||||||
void MovedUp1(float const dh);
|
void MovedUp1(float const dh);
|
||||||
std::string NameGet();
|
std::string NameGet();
|
||||||
void VelocitySet(float v);
|
void VelocitySet(float v);
|
||||||
float VelocityGet();
|
double VelocityGet();
|
||||||
void ConnectionsLog();
|
void ConnectionsLog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user