16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 04:39:18 +02:00

merge (with bugs)

This commit is contained in:
VB
2017-04-24 19:08:08 +02:00
53 changed files with 2340 additions and 2233 deletions

View File

@@ -105,139 +105,12 @@ TTraction::TTraction()
TTraction::~TTraction()
{
if (!Global::bUseVBO)
glDeleteLists(uiDisplayList, 1);
}
void TTraction::Optimize()
{
if (Global::bUseVBO)
return;
uiDisplayList = glGenLists(1);
glNewList(uiDisplayList, GL_COMPILE);
GfxRenderer.Bind(0);
// glColor3ub(0,0,0); McZapkie: to do render
// glPushMatrix();
// glTranslatef(pPosition.x,pPosition.y,pPosition.z);
if (Wires != 0)
{
// Dlugosc odcinka trakcji 'Winger
double ddp = hypot(pPoint2.x - pPoint1.x, pPoint2.z - pPoint1.z);
if (Wires == 2)
WireOffset = 0;
// Przewoz jezdny 1 'Marcin
glBegin(GL_LINE_STRIP);
glVertex3f(pPoint1.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint1.y,
pPoint1.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
glVertex3f(pPoint2.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint2.y,
pPoint2.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
glEnd();
// Nie wiem co 'Marcin
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
v1 = pPoint4 - pPoint3;
v2 = pPoint2 - pPoint1;
float step = 0;
if (iNumSections > 0)
step = 1.0f / (float)iNumSections;
float f = step;
float mid = 0.5;
float t;
// Przewod nosny 'Marcin
if (Wires != 1)
{
glBegin(GL_LINE_STRIP);
glVertex3f(pPoint3.x, pPoint3.y, pPoint3.z);
for (int i = 0; i < iNumSections - 1; i++)
{
pt3 = pPoint3 + v1 * f;
t = (1 - fabs(f - mid) * 2);
if ((Wires < 4) || ((i != 0) && (i != iNumSections - 2)))
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference, pt3.z);
f += step;
}
glVertex3f(pPoint4.x, pPoint4.y, pPoint4.z);
glEnd();
}
// Drugi przewod jezdny 'Winger
if (Wires > 2)
{
glBegin(GL_LINE_STRIP);
glVertex3f(pPoint1.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint1.y,
pPoint1.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
glVertex3f(pPoint2.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pPoint2.y,
pPoint2.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
glEnd();
}
f = step;
if (Wires == 4)
{
glBegin(GL_LINE_STRIP);
glVertex3f(pPoint3.x, pPoint3.y - 0.65f * fHeightDifference, pPoint3.z);
for (int i = 0; i < iNumSections - 1; i++)
{
pt3 = pPoint3 + v1 * f;
t = (1 - fabs(f - mid) * 2);
glVertex3f(
pt3.x,
pt3.y - sqrt(t) * fHeightDifference -
((i == 0) || (i == iNumSections - 2) ? 0.25f * fHeightDifference : +0.05),
pt3.z);
f += step;
}
glVertex3f(pPoint4.x, pPoint4.y - 0.65f * fHeightDifference, pPoint4.z);
glEnd();
}
f = step;
// Przewody pionowe (wieszaki) 'Marcin, poprawki na 2 przewody jezdne 'Winger
if (Wires != 1)
{
glBegin(GL_LINES);
for (int i = 0; i < iNumSections - 1; i++)
{
float flo, flo1;
flo = (Wires == 4 ? 0.25f * fHeightDifference : 0);
flo1 = (Wires == 4 ? +0.05 : 0);
pt3 = pPoint3 + v1 * f;
pt4 = pPoint1 + v2 * f;
t = (1 - fabs(f - mid) * 2);
if ((i % 2) == 0)
{
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference -
((i == 0) || (i == iNumSections - 2) ? flo : flo1),
pt3.z);
glVertex3f(pt4.x - (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y,
pt4.z - (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
}
else
{
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference -
((i == 0) || (i == iNumSections - 2) ? flo : flo1),
pt3.z);
glVertex3f(pt4.x + (pPoint2.z / ddp - pPoint1.z / ddp) * WireOffset, pt4.y,
pt4.z + (-pPoint2.x / ddp + pPoint1.x / ddp) * WireOffset);
}
if ((Wires == 4) && ((i == 1) || (i == iNumSections - 3)))
{
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference - 0.05, pt3.z);
glVertex3f(pt3.x, pt3.y - sqrt(t) * fHeightDifference, pt3.z);
}
// endif;
f += step;
}
glEnd();
}
glEndList();
}
}
/*
void TTraction::InitCenter(vector3 Angles, vector3 pOrigin)