Merge branch 'milek-dev' into gfx-work

This commit is contained in:
milek7
2018-10-12 23:29:53 +02:00
34 changed files with 52 additions and 1528 deletions

View File

@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "AirCoupler.h"
#include "Model3d.h"
#include "parser.h"

View File

@@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/.
#include "MdlMngr.h"
#include "simulation.h"
#include "simulationtime.h"
#include "event.h"
#include "Event.h"
#include "Globals.h"
#include "Timer.h"
#include "Logs.h"

View File

@@ -11,7 +11,6 @@ file(GLOB HEADERS "*.h" "Console/*.h" "McZapkie/*.h" "gl/*.h")
set(SOURCES
"Texture.cpp"
"TextureDDS.cpp"
"Timer.cpp"
"Track.cpp"
"Traction.cpp"
@@ -76,25 +75,12 @@ set(SOURCES
"audiorenderer.cpp"
"motiontelemetry.cpp"
"utilities.cpp"
"light.cpp"
"uitranscripts.cpp"
"station.cpp"
"application.cpp"
"simulationtime.cpp"
"sceneeditor.cpp"
"screenshot.cpp"
"map.cpp"
"gl/shader.cpp"
"gl/vao.cpp"
"gl/ubo.cpp"
"gl/framebuffer.cpp"
"gl/renderbuffer.cpp"
"gl/postfx.cpp"
"gl/cubemap.cpp"
"gl/glsl_common.cpp"
"combustionengine.cpp"
"driverkeyboardinput.cpp"
"drivermode.cpp"
"driveruilayer.cpp"
@@ -110,6 +96,16 @@ set(SOURCES
"simulationstateserializer.cpp"
"precipitation.cpp"
"openglcolor.cpp"
"map.cpp"
"gl/shader.cpp"
"gl/vao.cpp"
"gl/ubo.cpp"
"gl/framebuffer.cpp"
"gl/renderbuffer.cpp"
"gl/postfx.cpp"
"gl/cubemap.cpp"
"gl/glsl_common.cpp"
"imgui/imgui.cpp"
"imgui/imgui_demo.cpp"

View File

@@ -71,5 +71,6 @@ enum class TCommandType
};
using material_handle = int;
using texture_handle = int;
#endif

146
Curve.cpp
View File

@@ -1,146 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "system.hpp"
#include "classes.hpp"
#pragma hdrstop
#include "Curve.h"
TCurve::TCurve()
{
Values = NULL;
iNumValues = 0;
iNumCols = 0;
}
TCurve::~TCurve()
{
for (int i = 0; i < iNumValues; i++)
SafeDelete(Values[i]);
SafeDelete(Values);
}
bool TCurve::Init(int n, int c)
{
for (int i = 0; i < iNumValues; i++)
SafeDelete(Values[i]);
SafeDelete(Values);
iNumValues = n;
iNumCols = c;
Values = new float *[iNumValues];
for (int i = 0; i < iNumValues; i++)
Values[i] = new float[iNumCols];
for (int i = 0; i < iNumValues; i++)
for (int j = 0; j < iNumCols; j++)
Values[i][j] = 0;
}
float TCurve::GetValue(int c, float p)
{
int a = floor(p);
int b = ceil(p);
if (a < 0)
return Values[0][c];
if (b >= iNumValues)
return Values[iNumValues - 1][c];
p -= floor(p);
return Values[a][c] * (1.0f - p) + Values[b][c] * (p);
}
bool TCurve::SetValue(int c, float p, float v)
{
int a = floor(p);
int b = ceil(p);
if (a < 0)
return false;
if (b >= iNumValues)
return false;
p -= floor(p);
if (p < 0.5)
Values[a][c] = v;
else
Values[b][c] = v;
return true;
}
bool TCurve::Load(TQueryParserComp *Parser)
{
DecimalSeparator = '.';
AnsiString Token;
int n = Parser->GetNextSymbol().ToInt();
int c = Parser->GetNextSymbol().ToInt();
Init(n, c);
n = 0;
int i;
while (!Parser->EOF && n < iNumValues)
{
for (i = 0; i < iNumCols; i++)
Values[n][i] = Parser->GetNextSymbol().ToDouble();
n++;
}
DecimalSeparator = ',';
}
bool TCurve::LoadFromFile(AnsiString asName)
{
DecimalSeparator = '.';
TFileStream *fs;
fs = new TFileStream(asName, fmOpenRead | fmShareCompat);
AnsiString str = "xxx";
int size = fs->Size;
str.SetLength(size);
fs->Read(str.c_str(), size);
str += "";
delete fs;
TQueryParserComp *Parser;
Parser = new TQueryParserComp(NULL);
Parser->TextToParse = str;
Parser->First();
Load(Parser);
delete Parser;
DecimalSeparator = ',';
}
#include <stdio.h>
bool TCurve::SaveToFile(AnsiString asName)
{
DecimalSeparator = '.';
FILE *stream = NULL;
stream = fopen(asName.c_str(), "w");
AnsiString str;
str = AnsiString(iNumValues);
fprintf(stream, str.c_str());
fprintf(stream, "\n");
for (int i = 0; i < iNumValues; i++)
{
str = "";
if (i % 10 == 0)
str += "\n";
for (int j = 0; j < iNumCols; j++)
str += FloatToStrF(Values[i][j], ffFixed, 6, 2) + AnsiString(" ");
str += AnsiString("\n");
fprintf(stream, str.c_str());
}
fclose(stream);
DecimalSeparator = ',';
}
//---------------------------------------------------------------------------
#pragma package(smart_init)

View File

@@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
#include "MemCell.h"
#include "simulation.h"
#include "simulationtime.h"
#include "Track.h"
#include "station.h"
#include "keyboardinput.h"

View File

@@ -14,7 +14,7 @@ http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "event.h"
#include "Event.h"
#include "simulation.h"
#include "messaging.h"
@@ -29,7 +29,6 @@ http://mozilla.org/MPL/2.0/.
#include "Driver.h"
#include "Timer.h"
#include "Logs.h"
#include "lua.h"
void
basic_event::event_conditions::bind( basic_event::node_sequence *Nodes ) {

View File

@@ -1,87 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "system.hpp"
#include "classes.hpp"
#pragma hdrstop
#include "Machajka.h"
#include "Timer.h"
#include "Globals.h"
TMachajka::TMachajka() : TTrain()
{
TTrain::TTrain();
}
TMachajka::~TMachajka()
{
}
bool TMachajka::Init(TDynamicObject *NewDynamicObject)
{
TTrain::Init(NewDynamicObject);
return true;
}
void TMachajka::OnKeyPress(int cKey)
{
if (!GetAsyncKeyState(VK_SHIFT) < 0) // bez shifta
{
if (cKey == Global::Keys[k_IncMainCtrl])
(DynamicObject->MoverParameters->AddPulseForce(1));
else if (cKey == Global::Keys[k_DecMainCtrl])
(DynamicObject->MoverParameters->AddPulseForce(-1));
else if (cKey == Global::Keys[k_IncLocalBrakeLevel])
(DynamicObject->MoverParameters->IncLocalBrakeLevel(1));
else if (cKey == Global::Keys[k_DecLocalBrakeLevel])
(DynamicObject->MoverParameters->DecLocalBrakeLevel(1));
else if (cKey == Global::Keys[k_MechLeft])
vMechMovement.x += fMechCroach;
else if (cKey == Global::Keys[k_MechRight])
vMechMovement.x -= fMechCroach;
else if (cKey == Global::Keys[k_MechBackward])
vMechMovement.z -= fMechCroach;
else if (cKey == Global::Keys[k_MechForward])
vMechMovement.z += fMechCroach;
else if (cKey == Global::Keys[k_MechUp])
pMechOffset.y += 0.3; // McZapkie-120302 - wstawanie
else if (cKey == Global::Keys[k_MechDown])
pMechOffset.y -= 0.3; // McZapkie-120302 - siadanie, kucanie itp
}
else // z shiftem
{
if (cKey == Global::Keys[k_IncMainCtrlFAST])
(DynamicObject->MoverParameters->AddPulseForce(2));
else if (cKey == Global::Keys[k_DecMainCtrlFAST])
(DynamicObject->MoverParameters->AddPulseForce(-2));
else if (cKey == Global::Keys[k_IncLocalBrakeLevelFAST])
(DynamicObject->MoverParameters->IncLocalBrakeLevel(2));
else if (cKey == Global::Keys[k_DecLocalBrakeLevelFAST])
(DynamicObject->MoverParameters->DecLocalBrakeLevel(2));
}
}
bool TMachajka::Update(double dt)
{
TTrain::Update(dt);
}
bool TMachajka::UpdateMechPosition()
{
TTrain::UpdateMechPosition();
}
bool TMachajka::Render()
{
TTrain::Render();
}
//---------------------------------------------------------------------------
#pragma package(smart_init)

View File

@@ -1,36 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#ifndef MachajkaH
#define MachajkaH
#include "Train.h"
class TMachajka : public TTrain
{
public:
TSubModel *wajcha;
// double v;
// double m;
// double a;
// double f;
// bool enter;
// bool space;
// double wa,wv;
TMachajka();
virtual ~TMachajka();
virtual bool Init(TDynamicObject *NewDynamicObject);
virtual void OnKeyPress(int cKey);
virtual bool Update(double dt);
virtual bool UpdateMechPosition();
virtual bool Render();
};
//---------------------------------------------------------------------------
#endif

View File

@@ -9,11 +9,13 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "MOVER.h"
#include "Oerlikon_ESt.h"
#include "utilities.h"
#include "Globals.h"
#include "Logs.h"
#include "parser.h"
//---------------------------------------------------------------------------
// Ra: tu należy przenosić funcje z mover.pas, które nie są z niego wywoływane.
// Jeśli jakieś zmienne nie są używane w mover.pas, też można je przenosić.

View File

@@ -21,6 +21,8 @@ http://mozilla.org/MPL/2.0/.
#include "Event.h"
#include "Logs.h"
//---------------------------------------------------------------------------
TMemCell::TMemCell( scene::node_data const &Nodedata ) : basic_node( Nodedata ) {}
void TMemCell::UpdateValues( std::string const &szNewText, double const fNewValue1, double const fNewValue2, int const CheckMask )

View File

@@ -30,13 +30,8 @@ void render_task::run() {
// upload texture data
if( ( outputwidth != nullptr )
&& ( outputheight != nullptr ) ) {
const opengl_material &material = GfxRenderer.Material(m_target);
if (material.textures[0] != null_handle)
{
GLuint id = GfxRenderer.Texture(material.textures[0]).id;
glBindTexture(GL_TEXTURE_2D, id);
}
::glBindTexture( GL_TEXTURE_2D, GfxRenderer.Texture( m_target ).id );
// setup texture parameters
::glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE );
::glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
@@ -49,7 +44,7 @@ void render_task::run() {
// build texture
glTexImage2D(
GL_TEXTURE_2D, 0,
GL_SRGB8_ALPHA8,
GL_SRGB8,
PyInt_AsLong( outputwidth ), PyInt_AsLong( outputheight ), 0,
GL_RGB, GL_UNSIGNED_BYTE, reinterpret_cast<GLubyte const *>( PyString_AsString( output ) ) );
glGenerateMipmap(GL_TEXTURE_2D);
@@ -166,6 +161,18 @@ auto python_taskqueue::insert( task_request const &Task ) -> bool {
// acquire a lock on the task queue and add a new task
{
std::lock_guard<std::mutex> lock( m_tasks.mutex );
// if task for this target already exists, don't add another
for (render_task *task : m_tasks.data)
if (task->get_target() == Task.target)
{
PyEval_AcquireLock();
Py_DECREF(Task.input);
PyEval_ReleaseLock();
return false;
}
m_tasks.data.emplace_back( new render_task( renderer, Task.input, Task.target ) );
}
// potentially wake a worker to handle the new task

View File

@@ -39,17 +39,18 @@ class render_task {
public:
// constructors
render_task( PyObject *Renderer, PyObject *Input, material_handle Target ) :
render_task( PyObject *Renderer, PyObject *Input, texture_handle Target ) :
m_renderer( Renderer ), m_input( Input ), m_target( Target )
{}
// methods
void run();
const texture_handle get_target() const { return m_target; }
private:
// members
PyObject *m_renderer {nullptr};
PyObject *m_input { nullptr };
material_handle m_target { null_handle };
texture_handle m_target { null_handle };
};
class python_taskqueue {
@@ -60,7 +61,7 @@ public:
std::string const &renderer;
PyObject *input;
material_handle target;
texture_handle target;
};
// constructors
python_taskqueue() = default;

View File

@@ -1,517 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "system.hpp"
#include "classes.hpp"
#pragma hdrstop
#include "geometry.h"
#include "Spline.h"
#include "usefull.h"
#include "maptextfile.hpp"
bool Connect(TKnot *k1, TKnot *k2)
{
if (k1 && k2)
{
k1->Next = k2;
k2->Prev = k1;
k1->InitLength();
return true;
}
else
return false;
}
#define Precision 10000
float CurveLength(vector3 p1, vector3 cp1, vector3 cp2, vector3 p2)
{
float t, l = 0;
vector3 tmp, last = p1;
for (int i = 1; i <= Precision; i++)
{
t = float(i) / float(Precision);
tmp = Interpolate(t, p1, cp1, cp2, p2);
t = vector3(tmp - last).Length();
l += t;
last = tmp;
}
return (l);
}
TKnot::TKnot()
{
Next = Prev = NULL;
Length = -1;
IsCurve = false;
fLengthIn = fLengthOut = 0;
fRoll = 0;
bSwitchDirectionForward = false;
bSwitchDirectionBackward = false;
}
TKnot::TKnot(int n)
{
bSwitchDirectionForward = false;
bSwitchDirectionBackward = false;
Next = Prev = NULL;
Length = -1;
IsCurve = false;
fLengthIn = fLengthOut = 0;
if (n > 0)
{
Next = new TKnot(n - 1);
Next->Prev = this;
}
}
TKnot::~TKnot()
{
}
vector3 TKnot::GetDirection(float t)
{
if (IsCurve)
{
vector3 v1 = CPointOut - Point;
vector3 v2 = Next->Point - Next->CPointIn; // BUGBUG
return v1 * (1 - t) + v2 * (t);
}
else
return (Next->Point -
Point); // Spline->Knots[KnotIndex].Point-Spline->Knots[KnotIndex].Point);
}
float TKnot::GetTFromS(float s)
{
// initial guess for Newton's method
int it = 0;
float fTolerance = 0.001;
float fRatio = s / RombergIntegral(0, 1);
float fOmRatio = 1.0 - fRatio;
float fTime = fOmRatio * 0 + fRatio * 1;
// for (int i = 0; i < iIterations; i++)
while (true)
{
it++;
if (it > 10)
MessageBox(0, "Too many iterations", "TSpline->GetTFromS", MB_OK);
float fDifference = RombergIntegral(0, fTime) - s;
if ((fDifference > 0 ? fDifference : -fDifference) < fTolerance)
return fTime;
fTime -= fDifference / GetFirstDerivative(fTime).Length();
}
// Newton's method failed. If this happens, increase iterations or
// tolerance or integration accuracy.
return -1;
}
bool TKnot::Init(TKnot *NNext, TKnot *NPrev)
{
if (NNext != NULL)
{
Next = NNext;
Next->Prev = this;
}
if (NPrev != NULL)
{
Prev = NPrev;
Prev->Next = this;
}
}
bool TKnot::InitCPoints()
{
if (Prev != NULL)
if (Prev->IsCurve)
if (Next != NULL)
{
if (!IsCurve)
{
CPointIn = Point - fLengthIn * Normalize(Next->Point - Point);
}
else
CPointIn = Point -
fLengthIn * (Normalize(Normalize(Next->Point - Point) +
Normalize(Point - Prev->Point)));
}
else
CPointIn = Point - fLengthIn * Normalize(Point - Prev->Point);
else
CPointIn = Prev->Point;
if (Next != NULL)
if (IsCurve)
if (Prev != NULL)
{
if (!Prev->IsCurve)
{
CPointOut = Point - fLengthOut * Normalize(Prev->Point - Point);
}
else
CPointOut = Point -
fLengthOut * (Normalize(Normalize(Prev->Point - Point) +
Normalize(Point - Next->Point)));
}
else
;
// CPointOut= -fLengthOut*Normalize(Next->Point-Point);
else
CPointOut = Next->Point;
else
CPointOut = Point - fLengthOut * Normalize(Prev->Point - Point);
}
bool TKnot::InitLength()
{
if (IsCurve)
if (Next)
Length = RombergIntegral(0, 1);
else
;
else if (Next)
Length = (Point - Next->Point).Length();
return true;
}
vector3 TKnot::GetFirstDerivative(float fTime)
{
float fOmTime = 1.0 - fTime;
float fPowTime = fTime;
vector3 kResult = fOmTime * (CPointOut - Point);
int iDegreeM1 = 3 - 1;
float fCoeff = 2 * fPowTime;
kResult = (kResult + fCoeff * (Next->CPointIn - CPointOut)) * fOmTime;
fPowTime *= fTime;
kResult += fPowTime * (Next->Point - Next->CPointIn);
kResult *= 3;
return kResult;
}
float TKnot::RombergIntegral(float fA, float fB)
{
float fH = fB - fA;
const int ms_iOrder = 5;
float ms_apfRom[2][ms_iOrder];
ms_apfRom[0][0] =
0.5 * fH * ((GetFirstDerivative(fA).Length()) + (GetFirstDerivative(fB).Length()));
for (int i0 = 2, iP0 = 1; i0 <= ms_iOrder; i0++, iP0 *= 2, fH *= 0.5)
{
// approximations via the trapezoid rule
float fSum = 0.0;
int i1;
for (i1 = 1; i1 <= iP0; i1++)
fSum += (GetFirstDerivative(fA + fH * (i1 - 0.5)).Length());
// Richardson extrapolation
ms_apfRom[1][0] = 0.5 * (ms_apfRom[0][0] + fH * fSum);
for (int i2 = 1, iP2 = 4; i2 < i0; i2++, iP2 *= 4)
{
ms_apfRom[1][i2] = (iP2 * ms_apfRom[1][i2 - 1] - ms_apfRom[0][i2 - 1]) / (iP2 - 1);
}
for (i1 = 0; i1 < i0; i1++)
ms_apfRom[0][i1] = ms_apfRom[1][i1];
}
return ms_apfRom[0][ms_iOrder - 1];
}
//----------------------------------------------------------------------------//
TSpline::TSpline()
{
// Closed= true;
// asName= "foo";
// Knots= NULL;
RootKnot = NULL;
iNumKnots = 0;
KnotsAllocated = false;
// Next=Prev= this;
}
TSpline::TSpline(AnsiString asNName)
{
// Closed= true;
// asName= asNName;
// Knots= NULL;
RootKnot = NULL;
iNumKnots = 0;
KnotsAllocated = false;
// Next=Prev= this;
}
TSpline::~TSpline()
{
// if (KnotsAllocated)
// SafeDeleteArray(Knots);
// SafeDelete(RootKnot);
TKnot *ck, *tk;
ck = RootKnot;
for (int i = 0; i < iNumKnots; i++)
{
tk = ck;
ck = ck->Next;
SafeDelete(tk);
}
}
bool TSpline::Create(int n, AnsiString asNName)
{
/*
// asName= asNName;
iNumKnots= n;
Knots= new TKnot[iNumKnots];
KnotsAllocated= true;
Knots[0].Prev= NULL;
Knots[iNumKnots-1].Next= NULL;
for (int i=1; i<iNumKnots; i++)
Knots[i].Init(NULL,Knots+i-1);
*/
}
bool TSpline::AssignKnots(TKnot *FirstKnot, int n)
{
// iNumKnots= n;
// Knots= FirstKnot;
// KnotsAllocated= false;
}
int TSpline::LoadFromFile(AnsiString FileName, TKnot *FirstKnot)
{
return false;
/*
int i;
iNumKnots= -1;
AnsiString buf;
buf.SetLength(255);
TMapTextfile *tf= new TMapTextfile();
tf->Open(asSceneryPatch+FileName,mmRead);
tf->ReadLn(buf);
if (buf==AnsiString("\"SPLINE\""))
{
tf->ReadLn(buf);
if (FirstKnot==NULL)
Create(buf.ToInt());
else
AssignKnots(FirstKnot,buf.ToInt());
TKnot *CurrentKnot= Knots;
// iNumKnots= buf.ToInt();
// Knots= new TKnot[iNumKnots];// malloc(*sizeof(TKnot));
DecimalSeparator= '.';
for (i=0; i<iNumKnots; i++)
{
tf->ReadLn(buf); CurrentKnot->Point.x= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->Point.z= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->Point.y= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->CPointIn.x= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->CPointIn.z= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->CPointIn.y= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->CPointOut.x= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->CPointOut.z= buf.ToDouble();
tf->ReadLn(buf); CurrentKnot->CPointOut.y= buf.ToDouble();
tf->ReadLn(buf);
// buf.Trim();
Knots[i].IsCurve= (buf!="#line ");
CurrentKnot= CurrentKnot->Next;
}
DecimalSeparator= ',';
CurrentKnot= Knots;
for (i=0; i<iNumKnots-1; i++)
{
// Knots[i].InitLength();
if (CurrentKnot->IsCurve)
{
CurrentKnot->Length=
CurveLength(CurrentKnot->Point,CurrentKnot->CPointOut,CurrentKnot->Next->CPointIn,CurrentKnot->Next->Point);
}
else
{
CurrentKnot->CPointOut= 2*CurrentKnot->Point-CurrentKnot->CPointIn;
CurrentKnot->Next->CPointIn= CurrentKnot->Point;
CurrentKnot->Length= (CurrentKnot->Point-CurrentKnot->Next->Point).Length();
}
CurrentKnot= CurrentKnot->Next;
}
CurrentKnot->Length= -1;
}
tf->Close();
delete tf;
return (iNumKnots);
*/
}
int TSpline::Load(TQueryParserComp *Parser, AnsiString asEndString)
{
TKnot *LastKnot = NULL;
;
if (RootKnot != NULL)
for (LastKnot = RootKnot; LastKnot->Next != NULL; LastKnot = LastKnot->Next)
;
TKnot *tmp;
tmp = new TKnot(0);
tmp->Prev = LastKnot;
if (LastKnot != NULL)
LastKnot->Next = tmp;
else
RootKnot = tmp;
LastKnot = tmp;
float tf, r, pr;
vector3 dir;
// asName= Parser->GetNextSymbol();
iNumKnots = 0;
do
{
LastKnot->fLengthIn = Parser->GetNextSymbol().ToDouble();
tf = Parser->GetNextSymbol().ToDouble();
LastKnot->Point.x = tf;
tf = Parser->GetNextSymbol().ToDouble();
LastKnot->Point.y = tf;
tf = Parser->GetNextSymbol().ToDouble();
LastKnot->Point.z = tf;
tf = Parser->GetNextSymbol().ToDouble();
LastKnot->fRoll = tf / 180 * M_PI;
LastKnot->fLengthOut = Parser->GetNextSymbol().ToDouble();
LastKnot->IsCurve = (LastKnot->fLengthOut != 0);
LastKnot->Next = new TKnot(0);
LastKnot->Next->Prev = LastKnot;
LastKnot = LastKnot->Next;
iNumKnots++;
} while (Parser->GetNextSymbol().LowerCase() != asEndString && !Parser->EOF);
LastKnot->Prev->Next = NULL;
delete LastKnot;
if (RootKnot != NULL)
for (LastKnot = RootKnot; LastKnot != NULL; LastKnot = LastKnot->Next)
LastKnot->InitCPoints();
if (RootKnot != NULL)
for (LastKnot = RootKnot; LastKnot != NULL; LastKnot = LastKnot->Next)
LastKnot->InitLength();
}
float TSpline::GetLength()
{
TKnot *tmp = RootKnot;
float l = 0;
for (int i = 0; i < iNumKnots; i++)
{
l += tmp->Length;
tmp = tmp->Next;
}
return l;
}
vector3 TSpline::GetCenter()
{
TKnot *ck, *tk;
ck = RootKnot;
vector3 pt = vector3(0, 0, 0);
for (int i = 0; i < iNumKnots; i++)
{
pt += ck->Point;
ck = ck->Next;
}
if (iNumKnots > 0)
pt /= iNumKnots;
}
TKnot * TSpline::GetLastKnot()
{
TKnot *ck;
ck = RootKnot;
for (int i = 0; i < iNumKnots - 1; i++)
{
ck = ck->Next;
}
return ck;
}
bool TSpline::Render()
{
TKnot *LastKnot = NULL;
;
// if (RootKnot==NULL)
// RootKnot= Knots;
if (RootKnot != NULL)
{
glBindTexture(GL_TEXTURE_2D, 0);
glBegin(GL_LINE_STRIP);
int i = 0;
for (LastKnot = RootKnot; LastKnot != NULL && i < iNumKnots; LastKnot = LastKnot->Next, i++)
// for (LastKnot= RootKnot; LastKnot!=NULL; LastKnot= LastKnot->Next)
glVertex3f(LastKnot->Point.x, LastKnot->Point.y, LastKnot->Point.z);
glEnd();
/*
if (RootKnot->Prev!=NULL)
{
glBindTexture(GL_TEXTURE_2D, 0);
glBegin(GL_LINE_STRIP);
glVertex3f(RootKnot->Point.x,RootKnot->Point.y,RootKnot->Point.z);
glVertex3f(RootKnot->Prev->Point.x,RootKnot->Prev->Point.y,RootKnot->Prev->Point.z);
glEnd();
}*/
}
}
//---------------------------------------------------------------------------
#pragma package(smart_init)

103
Spline.h
View File

@@ -1,103 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#ifndef SplineH
#define SplineH
#include "dumb3d.h"
#include "QueryParserComp.hpp"
using namespace Math3D;
#define B1(t) (t * t * t)
#define B2(t) (3 * t * t * (1 - t))
#define B3(t) (3 * t * (1 - t) * (1 - t))
#define B4(t) ((1 - t) * (1 - t) * (1 - t))
#define Interpolate(t, p1, cp1, cp2, p2) (B4(t) * p1 + B3(t) * cp1 + B2(t) * cp2 + B1(t) * p2)
class TKnot
{
public:
// inline bool IsCurve() { return (!(Point==CPointIn)); };
// inline vector3 GetDirection() { return (CPointOut-Point); };
TKnot();
TKnot(int n);
~TKnot();
inline float GetRoll(float s)
{
if (Next)
{
s /= Length;
return ((1 - s) * fRoll + (s)*Next->fRoll);
}
else
return fRoll;
// (Length-s) (s-Length)
}
vector3 GetDirection(float t = 0);
inline vector3 InterpolateSegm(float t)
{
return (Interpolate(t, Point, CPointOut, Next->CPointIn, Next->Point));
};
float GetTFromS(float s);
bool Init(TKnot *NNext, TKnot *NPrev);
bool InitCPoints();
bool InitLength();
vector3 Point, CPointIn, CPointOut;
float fRoll;
bool IsCurve;
float Length;
TKnot *Next, *Prev;
float fLengthIn, fLengthOut;
bool bSwitchDirectionForward;
bool bSwitchDirectionBackward;
private:
vector3 GetFirstDerivative(float fTime);
float RombergIntegral(float fA, float fB);
};
class TSpline
{
public:
TSpline();
TSpline(AnsiString asNName);
~TSpline();
bool Create(int n, AnsiString asNName = "foo");
bool AssignKnots(TKnot *FirstKnot, int n);
int LoadFromFile(AnsiString FileName, TKnot *FirstKnot = NULL);
int Load(TQueryParserComp *Parser, AnsiString asEndString = "endspline");
float GetLength();
vector3 GetCenter();
TKnot * GetLastKnot();
bool Render();
// inline int NextIndex(int n) { return (n<KnotsCount-1 ? n+1 : 0); };
// inline vector3 InterpolateSegm(int i, float t) { return
// (Interpolate(t,Knots[i].Point,Knots[i].CPointOut,Knots[NextIndex(i)].CPointIn,Knots[NextIndex(i)].Point)
// ); };
// inline vector3 InterpolateSegm(TKnot *Knot, float t) { return
// (Interpolate(t,Knots[i].Point,Knots[i].CPointOut,Knots[NextIndex(i)].CPointIn,Knots[NextIndex(i)].Point)
// ); };
// bool Closed;
// AnsiString asName;
// TKnot *Knots;
TKnot *RootKnot;
bool KnotsAllocated;
int iNumKnots;
// TSpline *Next,*Prev;
// TKnot Next,Prev;
private:
};
bool Connect(TKnot *k1, TKnot *k2);
//---------------------------------------------------------------------------
#endif

View File

@@ -1,340 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "TextureDDS.h"
void DxtcReadColors(const GLubyte *Data, Color8888 *result)
{
GLubyte r0, g0, b0, r1, g1, b1;
b0 = Data[0] & 0x1F;
g0 = ((Data[0] & 0xE0) >> 5) | ((Data[1] & 0x7) << 3);
r0 = (Data[1] & 0xF8) >> 3;
b1 = Data[2] & 0x1F;
g1 = ((Data[2] & 0xE0) >> 5) | ((Data[3] & 0x7) << 3);
r1 = (Data[3] & 0xF8) >> 3;
result[0].r = r0 << 3 | r0 >> 2;
result[0].g = g0 << 2 | g0 >> 3;
result[0].b = b0 << 3 | b0 >> 2;
result[1].r = r1 << 3 | r1 >> 2;
result[1].g = g1 << 2 | g1 >> 3;
result[1].b = b1 << 3 | b1 >> 2;
};
void DxtcReadColor(GLushort Data, Color8888 *Out)
{
GLubyte r, g, b;
b = Data & 0x1f;
g = (Data & 0x7E0) >> 5;
r = (Data & 0xF800) >> 11;
Out->r = r << 3 | r >> 2;
Out->g = g << 2 | g >> 3;
Out->b = b << 3 | r >> 2;
};
void DecompressDXT1(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Data)
{
GLint x, y, i, j, k;
GLuint Select;
const GLubyte *Temp;
Color8888 colours[4], *col;
GLushort color_0, color_1;
GLuint bitmask, Offset;
Temp = lCompData;
colours[0].a = 0xFF;
colours[1].a = 0xFF;
colours[2].a = 0xFF;
for (y = 0; y < lImage.height; y += 4)
{
for (x = 0; x < lImage.width; x += 4)
{
color_0 = *((const GLushort *)Temp);
color_1 = *((const GLushort *)(Temp + 2));
DxtcReadColor(color_0, colours);
DxtcReadColor(color_1, colours + 1);
bitmask = ((const GLuint *)Temp)[1];
Temp += 8;
if (color_0 > color_1)
{
// Four-color block: derive the other two colors.
// 00 = color_0, 01 = color_1, 10 = color_2, 11 = color_3
// These 2-bit codes correspond to the 2-bit fields
// stored in the 64-bit block.
colours[2].b = (2 * colours[0].b + colours[1].b + 1) / 3;
colours[2].g = (2 * colours[0].g + colours[1].g + 1) / 3;
colours[2].r = (2 * colours[0].r + colours[1].r + 1) / 3;
colours[3].b = (colours[0].b + 2 * colours[1].b + 1) / 3;
colours[3].g = (colours[0].g + 2 * colours[1].g + 1) / 3;
colours[3].r = (colours[0].r + 2 * colours[1].r + 1) / 3;
colours[3].a = 0xFF;
}
else
{
// Three-color block: derive the other color.
// 00 = color_0, 01 = color_1, 10 = color_2,
// 11 = transparent.
// These 2-bit codes correspond to the 2-bit fields
// stored in the 64-bit block.
colours[2].b = (colours[0].b + colours[1].b) / 2;
colours[2].g = (colours[0].g + colours[1].g) / 2;
colours[2].r = (colours[0].r + colours[1].r) / 2;
colours[3].b = (colours[0].b + 2 * colours[1].b + 1) / 3;
colours[3].g = (colours[0].g + 2 * colours[1].g + 1) / 3;
colours[3].r = (colours[0].r + 2 * colours[1].r + 1) / 3;
colours[3].a = 0x00;
}
for (j = 0, k = 0; j < 4; j++)
{
for (i = 0; i < 4; i++, k++)
{
Select = (bitmask & (0x03 << k * 2)) >> k * 2;
col = &colours[Select];
if (((x + i) < lImage.width) && ((y + j) < lImage.height))
{
Offset = (y + j) * lImage.width * lImage.components +
(x + i) * lImage.components;
Data[Offset + 0] = col->r;
Data[Offset + 1] = col->g;
Data[Offset + 2] = col->b;
Data[Offset + 3] = col->a;
}
}
}
}
}
}
void DecompressDXT3(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Data)
{
const GLubyte *Temp = lCompData;
Color8888 colours[4], *col;
GLuint bitmask, Offset;
const GLubyte *alpha;
for (GLint y = 0; y < lImage.height; y += 4)
{
for (GLint x = 0; x < lImage.width; x += 4)
{
alpha = Temp;
Temp += 8;
DxtcReadColors(Temp, colours);
bitmask = ((GLuint *)Temp)[1];
Temp += 8;
// Four-color block: derive the other two colors.
// 00 = color_0, 01 = color_1, 10 = color_2, 11 = color_3
// These 2-bit codes correspond to the 2-bit fields
// stored in the 64-bit block.
colours[2].b = (2 * colours[0].b + colours[1].b + 1) / 3;
colours[2].g = (2 * colours[0].g + colours[1].g + 1) / 3;
colours[2].r = (2 * colours[0].r + colours[1].r + 1) / 3;
colours[3].b = (colours[0].b + 2 * colours[1].b + 1) / 3;
colours[3].g = (colours[0].g + 2 * colours[1].g + 1) / 3;
colours[3].r = (colours[0].r + 2 * colours[1].r + 1) / 3;
GLuint k = 0;
for (GLint j = 0; j < 4; j++)
{
for (GLint i = 0; i < 4; i++, k++)
{
GLuint Select = (bitmask & (0x03 << k * 2)) >> k * 2;
col = &colours[Select];
if (((x + i) < lImage.width) && ((y + j) < lImage.height))
{
Offset = (y + j) * lImage.width * lImage.components +
(x + i) * lImage.components;
Data[Offset + 0] = col->r;
Data[Offset + 1] = col->g;
Data[Offset + 2] = col->b;
}
}
}
for (GLint j = 0; j < 4; j++)
{
GLushort word = alpha[2 * j] + 256 * alpha[2 * j + 1];
for (GLint i = 0; i < 4; i++)
{
if (((x + i) < lImage.width) && ((y + j) < lImage.height))
{
Offset = (y + j) * lImage.width * lImage.components +
(x + i) * lImage.components + 3;
Data[Offset] = word & 0x0F;
Data[Offset] = Data[Offset] | (Data[Offset] << 4);
}
word >>= 4;
}
}
}
}
}
void DecompressDXT5(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Data)
{
GLint x, y, i, j, k;
GLuint Select;
const GLubyte *Temp; //, r0, g0, b0, r1, g1, b1;
Color8888 colours[4], *col;
GLuint bitmask, Offset;
GLubyte alphas[8];
GLuint bits;
Temp = lCompData;
for (y = 0; y < lImage.height; y += 4)
{
for (x = 0; x < lImage.width; x += 4)
{
if (y >= lImage.height || x >= lImage.width)
break;
alphas[0] = Temp[0];
alphas[1] = Temp[1];
const GLubyte *alphamask = Temp + 2;
Temp += 8;
DxtcReadColors(Temp, colours);
bitmask = ((const GLuint *)Temp)[1];
Temp += 8;
// Four-color block: derive the other two colors.
// 00 = color_0, 01 = color_1, 10 = color_2, 11 = color_3
// These 2-bit codes correspond to the 2-bit fields
// stored in the 64-bit block.
colours[2].b = (2 * colours[0].b + colours[1].b + 1) / 3;
colours[2].g = (2 * colours[0].g + colours[1].g + 1) / 3;
colours[2].r = (2 * colours[0].r + colours[1].r + 1) / 3;
colours[3].b = (colours[0].b + 2 * colours[1].b + 1) / 3;
colours[3].g = (colours[0].g + 2 * colours[1].g + 1) / 3;
colours[3].r = (colours[0].r + 2 * colours[1].r + 1) / 3;
k = 0;
for (j = 0; j < 4; j++)
{
for (i = 0; i < 4; i++, k++)
{
Select = (bitmask & (0x03 << k * 2)) >> k * 2;
col = &colours[Select];
// only put pixels out < width or height
if (((x + i) < lImage.width) && ((y + j) < lImage.height))
{
Offset = (y + j) * lImage.width * lImage.components +
(x + i) * lImage.components;
Data[Offset + 0] = col->r;
Data[Offset + 1] = col->g;
Data[Offset + 2] = col->b;
}
}
}
// 8-alpha or 6-alpha block?
if (alphas[0] > alphas[1])
{
// 8-alpha block: derive the other six alphas.
// Bit code 000 = alpha_0, 001 = alpha_1, others are interpolated.
alphas[2] = (6 * alphas[0] + 1 * alphas[1] + 3) / 7; // bit code 010
alphas[3] = (5 * alphas[0] + 2 * alphas[1] + 3) / 7; // bit code 011
alphas[4] = (4 * alphas[0] + 3 * alphas[1] + 3) / 7; // bit code 100
alphas[5] = (3 * alphas[0] + 4 * alphas[1] + 3) / 7; // bit code 101
alphas[6] = (2 * alphas[0] + 5 * alphas[1] + 3) / 7; // bit code 110
alphas[7] = (1 * alphas[0] + 6 * alphas[1] + 3) / 7; // bit code 111
}
else
{
// 6-alpha block.
// Bit code 000 = alpha_0, 001 = alpha_1, others are interpolated.
alphas[2] = (4 * alphas[0] + 1 * alphas[1] + 2) / 5; // Bit code 010
alphas[3] = (3 * alphas[0] + 2 * alphas[1] + 2) / 5; // Bit code 011
alphas[4] = (2 * alphas[0] + 3 * alphas[1] + 2) / 5; // Bit code 100
alphas[5] = (1 * alphas[0] + 4 * alphas[1] + 2) / 5; // Bit code 101
alphas[6] = 0x00; // Bit code 110
alphas[7] = 0xFF; // Bit code 111
}
// Note: Have to separate the next two loops,
// it operates on a 6-byte system.
// First three bytes
// bits = *((ILint*)alphamask);
bits = (alphamask[0]) | (alphamask[1] << 8) | (alphamask[2] << 16);
for (j = 0; j < 2; j++)
{
for (i = 0; i < 4; i++)
{
// only put pixels out < width or height
if (((x + i) < lImage.width) && ((y + j) < lImage.height))
{
Offset = (y + j) * lImage.width * lImage.components +
(x + i) * lImage.components + 3;
Data[Offset] = alphas[bits & 0x07];
}
bits >>= 3;
}
}
// Last three bytes
// bits = *((ILint*)&alphamask[3]);
bits = (alphamask[3]) | (alphamask[4] << 8) | (alphamask[5] << 16);
for (j = 2; j < 4; j++)
{
for (i = 0; i < 4; i++)
{
// only put pixels out < width or height
if (((x + i) < lImage.width) && ((y + j) < lImage.height))
{
Offset = (y + j) * lImage.width * lImage.components +
(x + i) * lImage.components + 3;
Data[Offset] = alphas[bits & 0x07];
}
bits >>= 3;
}
}
}
}
}
void DecompressDXT(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Data)
{
switch (lImage.format)
{
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
DecompressDXT1(lImage, lCompData, Data);
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
DecompressDXT3(lImage, lCompData, Data);
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
DecompressDXT5(lImage, lCompData, Data);
break;
};
}

View File

@@ -1,38 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#ifndef TEXTURE_DDS_H
#define TEXTURE_DDS_H 1
#include "GL/glew.h"
#pragma hdrstop
struct Color8888
{
GLubyte r; // change the order of names to change the
GLubyte g; // order of the output ARGB or BGRA, etc...
GLubyte b; // Last one is MSB, 1st is LSB.
GLubyte a;
};
struct DDS_IMAGE_DATA
{
GLsizei width;
GLsizei height;
GLint components;
GLenum format;
GLuint blockSize;
int numMipMaps;
GLubyte *pixels;
};
void DecompressDXT(DDS_IMAGE_DATA lImage, const GLubyte *lCompData, GLubyte *Data);
#endif

View File

@@ -15,7 +15,6 @@ http://mozilla.org/MPL/2.0/.
#include "Segment.h"
#include "material.h"
#include "Names.h"
#include "Model3d.h"
class TTractionPowerSource;

View File

@@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/.
#include "mtable.h"
#include "Console.h"
#include "application.h"
#include "renderer.h"
namespace input {
@@ -453,9 +454,9 @@ PyObject *TTrain::GetTrainState() {
auto const *mover = DynamicObject->MoverParameters;
PyEval_AcquireLock();
auto *dict = PyDict_New();
PyEval_ReleaseLock();
if( ( dict == nullptr )
|| ( mover == nullptr ) ) {
PyEval_ReleaseLock();
return nullptr;
}
@@ -585,6 +586,7 @@ PyObject *TTrain::GetTrainState() {
PyDict_SetItemString( dict, "seconds", PyGetInt( simulation::Time.second() ) );
PyDict_SetItemString( dict, "air_temperature", PyGetInt( Global.AirTemperature ) );
PyEval_ReleaseLock();
return dict;
}
@@ -6810,7 +6812,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
( substr_path(renderername).empty() ? // supply vehicle folder as path if none is provided
DynamicObject->asBaseDir + renderername :
renderername ),
material );
GfxRenderer.Material( material ).textures[0] );
}
// btLampkaUnknown.Init("unknown",mdKabina,false);
} while (token != "");

View File

@@ -671,7 +671,7 @@ private:
// McZapkie: do syczenia
float fPPress, fNPress;
int iRadioChannel { 1 }; // numer aktualnego kana?u radiowego
std::vector<std::pair<std::string, material_handle>> m_screens;
std::vector<std::pair<std::string, texture_handle>> m_screens;
public:
float fPress[20][3]; // cisnienia dla wszystkich czlonow

View File

@@ -14,11 +14,8 @@ http://mozilla.org/MPL/2.0/.
#include "editormode.h"
#include "Globals.h"
#include "keyboardinput.h"
#include "drivermouseinput.h"
#include "gamepadinput.h"
#include "Console.h"
#include "simulation.h"
#include "Train.h"
#include "sceneeditor.h"
#include "renderer.h"
#include "uilayer.h"

View File

@@ -12,8 +12,8 @@ http://mozilla.org/MPL/2.0/.
#include "sound.h"
#include "Globals.h"
#include "Logs.h"
#include "Camera.h"
#include "Logs.h"
#include "utilities.h"
namespace audio {

View File

@@ -1,13 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "combustionengine.h"
//---------------------------------------------------------------------------

View File

@@ -1,20 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
// basic approximation of a fuel pump
// TODO: fuel consumption, optional automatic engine start after activation
struct fuel_pump {
bool is_enabled { false }; // device is allowed/requested to operate
bool is_active { false }; // device is working
};
//---------------------------------------------------------------------------

View File

@@ -13,13 +13,14 @@ http://mozilla.org/MPL/2.0/.
#include "Globals.h"
#include "application.h"
#include "utilities.h"
#include "Globals.h"
#include "Timer.h"
#include "simulation.h"
#include "Train.h"
#include "AnimModel.h"
#include "renderer.h"
#include "uilayer.h"
#include "Logs.h"
#include "Timer.h"
void
mouse_slider::bind( user_command const &Command ) {

View File

@@ -15,7 +15,7 @@ http://mozilla.org/MPL/2.0/.
#include "simulation.h"
#include "simulationtime.h"
#include "Timer.h"
#include "event.h"
#include "Event.h"
#include "Camera.h"
#include "mtable.h"
#include "Train.h"

View File

@@ -1,122 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include <vcl.h>
#pragma hdrstop
#include "geometry.h"
inline double sqr(double a)
{
return (a * a);
};
TLine::TLine(){};
TLine::TLine(vector3 NPoint, vector3 NVector)
{
Vector = NVector;
Point = NPoint;
};
TLine::~TLine(){};
TPlane TLine::GetPlane()
{
return (TPlane(Point, Vector));
};
double TLine::GetDistance(vector3 Point1)
{
return ((sqr((Point1.x - Point.x) * Vector.x - (Point1.y - Point.y) * Vector.y) -
sqr((Point1.y - Point.y) * Vector.y - (Point1.z - Point.z) * Vector.z) -
sqr((Point1.z - Point.z) * Vector.z - (Point1.x - Point.x) * Vector.x)) /
(sqr(Vector.x) + sqr(Vector.y) + sqr(Vector.z)));
;
};
//---------------------------------------------------------------------------
TPlane::TPlane()
{
Vector = vector3(0, 0, 0);
d = 0;
};
TPlane::TPlane(vector3 NVector, double nd)
{
Vector = NVector;
d = nd;
}
TPlane::TPlane(vector3 Point, vector3 NVector)
{
Vector = NVector;
d = -NVector.x * Point.x - NVector.y * Point.y - NVector.z * Point.z;
};
TPlane::TPlane(vector3 Point1, vector3 Vector1, vector3 Vector2)
{
Vector = CrossProduct(Vector1, Vector2);
d = -Vector.x * Point1.x - Vector.y * Point1.y - Vector.z * Point1.z;
};
TPlane::~TPlane(){};
void TPlane::Normalize()
{
double mgn = Vector.Length();
Vector = Vector / mgn;
d /= mgn;
};
double TPlane::GetSide(vector3 Point)
{
return (Vector.x * Point.x + Vector.y * Point.y + Vector.z * Point.z + d);
};
// void TPlane::Transform(D3DMATRIX &Transformations)
//{
// vector3 src= Vector;
// D3DMath_VectorMatrixMultiply(Vector,src,Transformations);
//};
bool TPlane::Defined()
{
return !(Vector == vector3(0, 0, 0));
};
//---------------------------------------------------------------------------
inline double Sum(vector3 &Vector)
{
return (Vector.x + Vector.y + Vector.z);
};
bool CrossPoint(vector3 &RetPoint, TLine &Line, TPlane &Plane)
{
double ro = DotProduct(Plane.Vector, Line.Vector);
if (ro == 0)
return (false);
ro = (DotProduct(Plane.Vector, Line.Point) + Plane.d) / ro;
RetPoint = Line.Point - (Line.Vector * ro);
return (true);
};
inline double GetLength(vector3 &Vector)
{
return (Vector.Length());
};
inline vector3 SetLength(vector3 &Vector, double Length)
{
Vector.Normalize();
return (Vector * Length);
};
//---------------------------------------------------------------------------
//#pragma package(smart_init)

View File

@@ -1,54 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#ifndef GeometryH
#define GeometryH
#include "GL/glew.h"
#include "dumb3d.h"
using namespace Math3D;
//---------------------------------------------------------------------------
class TPlane;
class TLine
{
public:
vector3 Vector, Point;
TLine();
TLine(vector3 NPoint, vector3 NVector);
~TLine();
TPlane GetPlane();
double GetDistance(vector3 Point1);
};
//---------------------------------------------------------------------------
class TPlane
{
public:
vector3 Vector;
double d;
TPlane();
TPlane(vector3 NVector, double nd);
TPlane(vector3 NPoint, vector3 NVector);
TPlane(vector3 Point1, vector3 Vector1, vector3 Vector2);
~TPlane();
void Normalize();
double GetSide(vector3 Point);
// void Transform(D3DMATRIX &Transformations);
bool Defined();
};
//---------------------------------------------------------------------------
inline double Sum(vector3 &Vector);
bool CrossPoint(vector3 &RetPoint, TLine &Line, TPlane &Plane);
//---------------------------------------------------------------------------
#endif

View File

@@ -9,8 +9,8 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "keyboardinput.h"
#include "Logs.h"
#include "Globals.h"
#include "Logs.h"
#include "parser.h"
namespace input {

View File

@@ -1,11 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "light.h"

View File

@@ -14,7 +14,7 @@ http://mozilla.org/MPL/2.0/.
#include "application.h"
#include "simulation.h"
#include "simulationtime.h"
#include "event.h"
#include "Event.h"
#include "DynObj.h"
#include "Driver.h"
#include "mtable.h"

View File

@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include <string>
#include "Classes.h"
namespace Mtable

View File

@@ -12,6 +12,7 @@ http://mozilla.org/MPL/2.0/.
#include "GL/glew.h"
#include "openglgeometrybank.h"
#include "material.h"
#include "light.h"
#include "lightarray.h"
#include "dumb3d.h"
#include "frustum.h"

View File

@@ -1 +1 @@
#define VERSION_INFO "M7 (GL3) 12.10.2018, based on milek-2a00d525, tmj-44b652c"
#define VERSION_INFO "M7 (GL3) 13.10.2018, based on milek-04798821, tmj-68f82be4"