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

Merge branch 'tmj-dev' into lua

This commit is contained in:
milek7
2017-09-05 20:20:28 +02:00
15 changed files with 254 additions and 179 deletions

107
Segment.h
View File

@@ -7,24 +7,19 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#ifndef SegmentH
#define SegmentH
/*
#include "VBO.h"
*/
#pragma once
#include "openglgeometrybank.h"
#include "dumb3d.h"
#include "Classes.h"
#include "usefull.h"
using namespace Math3D;
// 110405 Ra: klasa punktów przekroju z normalnymi
class vector6 : public vector3
class vector6 : public Math3D::vector3
{ // punkt przekroju wraz z wektorem normalnym
public:
vector3 n;
Math3D::vector3 n;
vector6()
{
x = y = z = n.x = n.z = 0.0;
@@ -54,7 +49,7 @@ class vector6 : public vector3
class TSegment
{ // aproksymacja toru (zwrotnica ma dwa takie, jeden z nich jest aktywny)
private:
vector3 Point1, CPointOut, CPointIn, Point2;
Math3D::vector3 Point1, CPointOut, CPointIn, Point2;
double fRoll1 = 0.0,
fRoll2 = 0.0; // przechyłka na końcach
double fLength = 0.0; // długość policzona
@@ -63,19 +58,27 @@ class TSegment
int iSegCount = 0; // ilość odcinków do rysowania krzywej
double fDirection = 0.0; // Ra: kąt prostego w planie; dla łuku kąt od Point1
double fStoop = 0.0; // Ra: kąt wzniesienia; dla łuku od Point1
vector3 vA, vB, vC; // współczynniki wielomianów trzeciego stopnia vD==Point1
Math3D::vector3 vA, vB, vC; // współczynniki wielomianów trzeciego stopnia vD==Point1
TTrack *pOwner = nullptr; // wskaźnik na właściciela
double fAngle[2]; // kąty zakończenia drogi na przejazdach
double fAngle[ 2 ] = { 0.0, 0.0 }; // kąty zakończenia drogi na przejazdach
vector3 GetFirstDerivative(double fTime);
double RombergIntegral(double fA, double fB);
double GetTFromS(double s);
vector3 RaInterpolate(double t);
vector3 RaInterpolate0(double t);
public:
Math3D::vector3
GetFirstDerivative(double const fTime) const;
double
RombergIntegral(double const fA, double const fB) const;
double
GetTFromS(double const s) const;
Math3D::vector3
RaInterpolate(double const t) const;
Math3D::vector3
RaInterpolate0(double const t) const;
public:
bool bCurve = false;
TSegment(TTrack *owner);
~TSegment();
<<<<<<< HEAD
bool Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0);
bool Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointIn, vector3 &NewPoint2,
double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true);
@@ -115,15 +118,77 @@ class TSegment
CPointOut += pPosition;
}
}
void AngleSet(int i, double a) {
fAngle[i] = a; };
bool
Init( Math3D::vector3 NewPoint1, Math3D::vector3 NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0);
bool
Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, Math3D::vector3 NewCPointIn, Math3D::vector3 &NewPoint2, double fNewStep, double fNewRoll1 = 0, double fNewRoll2 = 0, bool bIsCurve = true);
double
ComputeLength() const; // McZapkie-150503
// finds point on segment closest to specified point in 3d space. returns: point on segment as value in range 0-1
double
find_nearest_point( glm::dvec3 const &Point ) const;
inline
Math3D::vector3
GetDirection1() const {
return bCurve ? CPointOut - Point1 : CPointOut; };
inline
Math3D::vector3
GetDirection2() const {
return bCurve ? CPointIn - Point2 : CPointIn; };
Math3D::vector3
GetDirection(double const fDistance) const;
inline
Math3D::vector3
GetDirection() const {
return CPointOut; };
Math3D::vector3
FastGetDirection(double const fDistance, double const fOffset);
Math3D::vector3
GetPoint(double const fDistance) const;
void
RaPositionGet(double const fDistance, Math3D::vector3 &p, Math3D::vector3 &a) const;
Math3D::vector3
FastGetPoint(double const t) const;
inline
Math3D::vector3
FastGetPoint_0() const {
return Point1; };
inline
Math3D::vector3
FastGetPoint_1() const {
return Point2; };
inline
double
GetRoll(double const Distance) const {
return interpolate( fRoll1, fRoll2, Distance / fLength ); }
inline
void
GetRolls(double &r1, double &r2) const {
// pobranie przechyłek (do generowania trójkątów)
r1 = fRoll1;
r2 = fRoll2; }
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);
void
Render();
inline
double
GetLength() const {
return fLength; };
inline
int RaSegCount()
{
if (!fTsBuffer || !bCurve)
return 1;
return iSegCount;
};
void AngleSet(int i, double a) {
fAngle[i] = a; };
inline
void
AngleSet(int const i, double const a) {
fAngle[i] = a; };
};
//---------------------------------------------------------------------------
#endif