mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 19:49:19 +02:00
partial replacement of math classes with glm
This commit is contained in:
@@ -631,11 +631,13 @@ TSubModel * TAnimModel::TerrainSquare(int n)
|
|||||||
{ // pobieranie wskaźników do pierwszego submodelu
|
{ // pobieranie wskaźników do pierwszego submodelu
|
||||||
return pModel ? pModel->TerrainSquare(n) : 0;
|
return pModel ? pModel->TerrainSquare(n) : 0;
|
||||||
};
|
};
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void TAnimModel::TerrainRenderVBO(int n)
|
void TAnimModel::TerrainRenderVBO(int n)
|
||||||
{ // renderowanie terenu z VBO
|
{ // renderowanie terenu z VBO
|
||||||
if (pModel)
|
if (pModel)
|
||||||
pModel->TerrainRenderVBO(n);
|
pModel->TerrainRenderVBO(n);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void TAnimModel::Advanced()
|
void TAnimModel::Advanced()
|
||||||
|
|||||||
@@ -128,8 +128,11 @@ class TAnimAdvanced
|
|||||||
int SortByBone();
|
int SortByBone();
|
||||||
};
|
};
|
||||||
|
|
||||||
class TAnimModel
|
// opakowanie modelu, określające stan egzemplarza
|
||||||
{ // opakowanie modelu, określające stan egzemplarza
|
class TAnimModel {
|
||||||
|
|
||||||
|
friend class opengl_renderer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TAnimContainer *pRoot; // pojemniki sterujące, tylko dla aniomowanych submodeli
|
TAnimContainer *pRoot; // pojemniki sterujące, tylko dla aniomowanych submodeli
|
||||||
TModel3d *pModel;
|
TModel3d *pModel;
|
||||||
@@ -173,7 +176,9 @@ class TAnimModel
|
|||||||
bool TerrainLoaded();
|
bool TerrainLoaded();
|
||||||
int TerrainCount();
|
int TerrainCount();
|
||||||
TSubModel * TerrainSquare(int n);
|
TSubModel * TerrainSquare(int n);
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void TerrainRenderVBO(int n);
|
void TerrainRenderVBO(int n);
|
||||||
|
#endif
|
||||||
void AnimationVND(void *pData, double a, double b, double c, double d);
|
void AnimationVND(void *pData, double a, double b, double c, double d);
|
||||||
void LightSet(int n, float v);
|
void LightSet(int n, float v);
|
||||||
static void AnimUpdate(double dt);
|
static void AnimUpdate(double dt);
|
||||||
|
|||||||
795
Ground.cpp
795
Ground.cpp
File diff suppressed because it is too large
Load Diff
93
Ground.h
93
Ground.h
@@ -23,20 +23,27 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
using namespace Math3D;
|
using namespace Math3D;
|
||||||
|
|
||||||
|
typedef int TGroundNodeType;
|
||||||
// Ra: zmniejszone liczby, aby zrobić tabelkę i zoptymalizować wyszukiwanie
|
// Ra: zmniejszone liczby, aby zrobić tabelkę i zoptymalizować wyszukiwanie
|
||||||
const int TP_MODEL = 10;
|
const int TP_MODEL = 10;
|
||||||
|
/*
|
||||||
const int TP_MESH = 11; // Ra: specjalny obiekt grupujący siatki dla tekstury
|
const int TP_MESH = 11; // Ra: specjalny obiekt grupujący siatki dla tekstury
|
||||||
const int TP_DUMMYTRACK = 12; // Ra: zdublowanie obiektu toru dla rozdzielenia tekstur
|
const int TP_DUMMYTRACK = 12; // Ra: zdublowanie obiektu toru dla rozdzielenia tekstur
|
||||||
|
*/
|
||||||
const int TP_TERRAIN = 13; // Ra: specjalny model dla terenu
|
const int TP_TERRAIN = 13; // Ra: specjalny model dla terenu
|
||||||
const int TP_DYNAMIC = 14;
|
const int TP_DYNAMIC = 14;
|
||||||
const int TP_SOUND = 15;
|
const int TP_SOUND = 15;
|
||||||
const int TP_TRACK = 16;
|
const int TP_TRACK = 16;
|
||||||
// const int TP_GEOMETRY=17;
|
/*
|
||||||
|
const int TP_GEOMETRY=17;
|
||||||
|
*/
|
||||||
const int TP_MEMCELL = 18;
|
const int TP_MEMCELL = 18;
|
||||||
const int TP_EVLAUNCH = 19; // MC
|
const int TP_EVLAUNCH = 19; // MC
|
||||||
const int TP_TRACTION = 20;
|
const int TP_TRACTION = 20;
|
||||||
const int TP_TRACTIONPOWERSOURCE = 21; // MC
|
const int TP_TRACTIONPOWERSOURCE = 21; // MC
|
||||||
// const int TP_ISOLATED=22; //Ra
|
/*
|
||||||
|
const int TP_ISOLATED=22; //Ra
|
||||||
|
*/
|
||||||
const int TP_SUBMODEL = 22; // Ra: submodele terenu
|
const int TP_SUBMODEL = 22; // Ra: submodele terenu
|
||||||
const int TP_LAST = 25; // rozmiar tablicy
|
const int TP_LAST = 25; // rozmiar tablicy
|
||||||
|
|
||||||
@@ -64,37 +71,28 @@ struct DaneRozkaz2
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int TGroundNodeType;
|
|
||||||
|
|
||||||
struct TGroundVertex
|
struct TGroundVertex
|
||||||
{
|
{
|
||||||
vector3 Point;
|
glm::dvec3 position;
|
||||||
vector3 Normal;
|
glm::vec3 normal;
|
||||||
float tu{ 0.0f }, tv{ 0.0f };
|
glm::vec2 texture;
|
||||||
|
|
||||||
void HalfSet(const TGroundVertex &v1, const TGroundVertex &v2)
|
void HalfSet(const TGroundVertex &v1, const TGroundVertex &v2)
|
||||||
{ // wyliczenie współrzędnych i mapowania punktu na środku odcinka v1<->v2
|
{ // wyliczenie współrzędnych i mapowania punktu na środku odcinka v1<->v2
|
||||||
Point = 0.5 * (v1.Point + v2.Point);
|
interpolate_( v1, v2, 0.5 );
|
||||||
Normal = 0.5 * (v1.Normal + v2.Normal);
|
|
||||||
tu = 0.5 * (v1.tu + v2.tu);
|
|
||||||
tv = 0.5 * (v1.tv + v2.tv);
|
|
||||||
}
|
}
|
||||||
void SetByX(const TGroundVertex &v1, const TGroundVertex &v2, double x)
|
void SetByX(const TGroundVertex &v1, const TGroundVertex &v2, double x)
|
||||||
{ // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2
|
{ // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2
|
||||||
double i = (x - v1.Point.x) / (v2.Point.x - v1.Point.x); // parametr równania
|
interpolate_( v1, v2, ( x - v1.position.x ) / ( v2.position.x - v1.position.x ) );
|
||||||
double j = 1.0 - i;
|
|
||||||
Point = j * v1.Point + i * v2.Point;
|
|
||||||
Normal = j * v1.Normal + i * v2.Normal;
|
|
||||||
tu = j * v1.tu + i * v2.tu;
|
|
||||||
tv = j * v1.tv + i * v2.tv;
|
|
||||||
}
|
}
|
||||||
void SetByZ(const TGroundVertex &v1, const TGroundVertex &v2, double z)
|
void SetByZ(const TGroundVertex &v1, const TGroundVertex &v2, double z)
|
||||||
{ // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2
|
{ // wyliczenie współrzędnych i mapowania punktu na odcinku v1<->v2
|
||||||
double i = (z - v1.Point.z) / (v2.Point.z - v1.Point.z); // parametr równania
|
interpolate_( v1, v2, ( z - v1.position.z ) / ( v2.position.z - v1.position.z ) );
|
||||||
double j = 1.0 - i;
|
}
|
||||||
Point = j * v1.Point + i * v2.Point;
|
void interpolate_( const TGroundVertex &v1, const TGroundVertex &v2, double factor ) {
|
||||||
Normal = j * v1.Normal + i * v2.Normal;
|
position = interpolate( v1.position, v2.position, factor );
|
||||||
tu = j * v1.tu + i * v2.tu;
|
normal = interpolate( v1.normal, v2.normal, static_cast<float>( factor ) );
|
||||||
tv = j * v1.tv + i * v2.tv;
|
texture = interpolate( v1.texture, v2.texture, static_cast<float>( factor ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,8 +101,11 @@ class TGroundNode : public Resource
|
|||||||
|
|
||||||
friend class opengl_renderer;
|
friend class opengl_renderer;
|
||||||
|
|
||||||
private:
|
|
||||||
public:
|
public:
|
||||||
|
TGroundNode *nNext; // lista wszystkich w scenerii, ostatni na początku
|
||||||
|
TGroundNode *nNext2; // lista obiektów w sektorze
|
||||||
|
TGroundNode *nNext3; // lista obiektów renderowanych we wspólnym cyklu
|
||||||
|
std::string asName; // nazwa (nie zawsze ma znaczenie)
|
||||||
TGroundNodeType iType; // typ obiektu
|
TGroundNodeType iType; // typ obiektu
|
||||||
union
|
union
|
||||||
{ // Ra: wskażniki zależne od typu - zrobić klasy dziedziczone zamiast
|
{ // Ra: wskażniki zależne od typu - zrobić klasy dziedziczone zamiast
|
||||||
@@ -112,7 +113,7 @@ public:
|
|||||||
TSubModel *smTerrain; // modele terenu (kwadratow kilometrowych)
|
TSubModel *smTerrain; // modele terenu (kwadratow kilometrowych)
|
||||||
TAnimModel *Model; // model z animacjami
|
TAnimModel *Model; // model z animacjami
|
||||||
TDynamicObject *DynamicObject; // pojazd
|
TDynamicObject *DynamicObject; // pojazd
|
||||||
vector3 *Points; // punkty dla linii
|
glm::dvec3 *Points; // punkty dla linii
|
||||||
TTrack *pTrack; // trajektoria ruchu
|
TTrack *pTrack; // trajektoria ruchu
|
||||||
TGroundVertex *Vertices; // wierzchołki dla trójkątów
|
TGroundVertex *Vertices; // wierzchołki dla trójkątów
|
||||||
TMemCell *MemCell; // komórka pamięci
|
TMemCell *MemCell; // komórka pamięci
|
||||||
@@ -122,39 +123,35 @@ public:
|
|||||||
TTextSound *tsStaticSound; // dźwięk przestrzenny
|
TTextSound *tsStaticSound; // dźwięk przestrzenny
|
||||||
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)
|
Math3D::vector3 pCenter; // współrzędne środka do przydzielenia sektora
|
||||||
|
glm::dvec3 m_rootposition; // position of the ground (sub)rectangle holding the node, in the 3d world
|
||||||
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
|
// visualization-related data
|
||||||
// TODO: wrap these in a struct, when cleaning objects up
|
// TODO: wrap these in a struct, when cleaning objects up
|
||||||
|
double fSquareMinRadius; // kwadrat widoczności od
|
||||||
|
double fSquareRadius; // kwadrat widoczności do
|
||||||
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
|
||||||
};
|
};
|
||||||
double fLineThickness; // McZapkie-120702: grubosc linii
|
|
||||||
double fSquareRadius; // kwadrat widoczności do
|
|
||||||
double fSquareMinRadius; // kwadrat widoczności od
|
|
||||||
int iVersion; // wersja siatki (do wykonania rekompilacji)
|
int iVersion; // wersja siatki (do wykonania rekompilacji)
|
||||||
// union ?
|
|
||||||
GLuint DisplayListID; // numer siatki DisplayLists
|
GLuint DisplayListID; // numer siatki DisplayLists
|
||||||
bool PROBLEND;
|
|
||||||
int iVboPtr; // indeks w buforze VBO
|
int iVboPtr; // indeks w buforze VBO
|
||||||
texture_handle TextureID; // główna (jedna) tekstura obiektu
|
|
||||||
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
|
texture_handle TextureID; // główna (jedna) tekstura obiektu
|
||||||
|
glm::vec3
|
||||||
|
Ambient{ 1.0f, 1.0f, 1.0f },
|
||||||
|
Diffuse{ 1.0f, 1.0f, 1.0f },
|
||||||
|
Specular{ 1.0f, 1.0f, 1.0f }; // oświetlenie
|
||||||
|
double fLineThickness; // McZapkie-120702: grubosc linii
|
||||||
|
bool PROBLEND;
|
||||||
bool bVisible;
|
bool bVisible;
|
||||||
|
|
||||||
TGroundNode *nNext; // lista wszystkich w scenerii, ostatni na początku
|
|
||||||
TGroundNode *nNext2; // lista obiektów w sektorze
|
|
||||||
TGroundNode *nNext3; // lista obiektów renderowanych we wspólnym cyklu
|
|
||||||
TGroundNode();
|
TGroundNode();
|
||||||
TGroundNode(TGroundNodeType t, int n = 0);
|
TGroundNode(TGroundNodeType t, int n = 0);
|
||||||
~TGroundNode();
|
~TGroundNode();
|
||||||
void Init(int n);
|
void Init(int n);
|
||||||
void InitCenter(); // obliczenie współrzędnych środka
|
|
||||||
void InitNormals();
|
void InitNormals();
|
||||||
|
|
||||||
// bool Disable();
|
// bool Disable();
|
||||||
@@ -167,19 +164,20 @@ public:
|
|||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Compile(Math3D::vector3 const &Origin, bool const Multiple = false);
|
void Compile(glm::dvec3 const &Origin, bool const Multiple = false);
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
void RenderHidden(); // obsługa dźwięków i wyzwalaczy zdarzeń
|
void RenderHidden(); // obsługa dźwięków i wyzwalaczy zdarzeń
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
// (McZapkie-131202)
|
// (McZapkie-131202)
|
||||||
void RaRenderVBO(); // renderowanie (nieprzezroczystych) ze wspólnego VBO
|
void RaRenderVBO(); // renderowanie (nieprzezroczystych) ze wspólnego VBO
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bounding_area {
|
struct bounding_area {
|
||||||
|
|
||||||
glm::vec3 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
|
||||||
};
|
};
|
||||||
|
|
||||||
class TSubRect : public Resource, public CMesh
|
class TSubRect : public Resource, public CMesh
|
||||||
@@ -190,8 +188,10 @@ class TSubRect : public Resource, public CMesh
|
|||||||
TTrack **tTracks = nullptr; // tory do renderowania pojazdów
|
TTrack **tTracks = nullptr; // tory do renderowania pojazdów
|
||||||
protected:
|
protected:
|
||||||
TTrack *tTrackAnim = nullptr; // obiekty do przeliczenia animacji
|
TTrack *tTrackAnim = nullptr; // obiekty do przeliczenia animacji
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
TGroundNode *nRootMesh = nullptr; // obiekty renderujące wg tekstury (wtórne, lista po nNext2)
|
TGroundNode *nRootMesh = nullptr; // obiekty renderujące wg tekstury (wtórne, lista po nNext2)
|
||||||
TGroundNode *nMeshed = nullptr; // lista obiektów dla których istnieją obiekty renderujące grupowo
|
TGroundNode *nMeshed = nullptr; // lista obiektów dla których istnieją obiekty renderujące grupowo
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
TGroundNode *nRootNode = nullptr; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2)
|
TGroundNode *nRootNode = nullptr; // wszystkie obiekty w sektorze, z wyjątkiem renderujących i pojazdów (nNext2)
|
||||||
TGroundNode *nRenderHidden = nullptr; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3)
|
TGroundNode *nRenderHidden = nullptr; // lista obiektów niewidocznych, "renderowanych" również z tyłu (nNext3)
|
||||||
@@ -211,10 +211,9 @@ class TSubRect : public Resource, public CMesh
|
|||||||
virtual ~TSubRect();
|
virtual ~TSubRect();
|
||||||
virtual void Release(); // zwalnianie VBO sektora
|
virtual void Release(); // zwalnianie VBO sektora
|
||||||
void NodeAdd(TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory
|
void NodeAdd(TGroundNode *Node); // dodanie obiektu do sektora na etapie rozdzielania na sektory
|
||||||
void RaNodeAdd(TGroundNode *Node); // dodanie obiektu do listy renderowania
|
|
||||||
void Sort(); // optymalizacja obiektów w sektorze (sortowanie wg tekstur)
|
void Sort(); // optymalizacja obiektów w sektorze (sortowanie wg tekstur)
|
||||||
TTrack * FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude);
|
TTrack * FindTrack(vector3 *Point, int &iConnection, TTrack *Exclude);
|
||||||
TTraction * FindTraction(vector3 *Point, int &iConnection, TTraction *Exclude);
|
TTraction * FindTraction(glm::dvec3 const &Point, int &iConnection, TTraction *Exclude);
|
||||||
bool StartVBO(); // ustwienie VBO sektora dla (nRenderRect), (nRenderRectAlpha) i (nRenderWires)
|
bool StartVBO(); // ustwienie VBO sektora dla (nRenderRect), (nRenderRectAlpha) i (nRenderWires)
|
||||||
bool RaTrackAnimAdd(TTrack *t); // zgłoszenie toru do animacji
|
bool RaTrackAnimAdd(TTrack *t); // zgłoszenie toru do animacji
|
||||||
void RaAnimate(); // przeliczenie animacji torów
|
void RaAnimate(); // przeliczenie animacji torów
|
||||||
@@ -311,8 +310,8 @@ class TGround
|
|||||||
bool InitEvents();
|
bool InitEvents();
|
||||||
bool InitLaunchers();
|
bool InitLaunchers();
|
||||||
TTrack * FindTrack(vector3 Point, int &iConnection, TGroundNode *Exclude);
|
TTrack * FindTrack(vector3 Point, int &iConnection, TGroundNode *Exclude);
|
||||||
TTraction * FindTraction(vector3 *Point, int &iConnection, TGroundNode *Exclude);
|
TTraction * FindTraction(glm::dvec3 const &Point, int &iConnection, TGroundNode *Exclude);
|
||||||
TTraction * TractionNearestFind(vector3 &p, int dir, TGroundNode *n);
|
TTraction * TractionNearestFind(glm::dvec3 &p, int dir, TGroundNode *n);
|
||||||
TGroundNode * AddGroundNode(cParser *parser);
|
TGroundNode * AddGroundNode(cParser *parser);
|
||||||
void UpdatePhys(double dt, int iter); // aktualizacja fizyki stałym krokiem
|
void UpdatePhys(double dt, int iter); // aktualizacja fizyki stałym krokiem
|
||||||
bool Update(double dt, int iter); // aktualizacja przesunięć zgodna z FPS
|
bool Update(double dt, int iter); // aktualizacja przesunięć zgodna z FPS
|
||||||
|
|||||||
97
Model3d.cpp
97
Model3d.cpp
@@ -177,12 +177,19 @@ template <typename ColorT> inline void readColor(cParser &parser, ColorT *color)
|
|||||||
color[ 2 ] /= 255.0;
|
color[ 2 ] /= 255.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void readColor(cParser &parser, int &color)
|
inline void readColor(cParser &parser, glm::vec4 &color)
|
||||||
{
|
{
|
||||||
int r, g, b, discard;
|
int discard;
|
||||||
parser.getTokens(4, false);
|
parser.getTokens(4, false);
|
||||||
parser >> discard >> r >> g >> b;
|
parser
|
||||||
|
>> discard
|
||||||
|
>> color.r
|
||||||
|
>> color.g
|
||||||
|
>> color.b;
|
||||||
|
color /= 255.0f;
|
||||||
|
/*
|
||||||
color = r + (g << 8) + (b << 16);
|
color = r + (g << 8) + (b << 16);
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
inline void readMatrix(cParser& parser,matrix4x4& matrix)
|
inline void readMatrix(cParser& parser,matrix4x4& matrix)
|
||||||
@@ -620,7 +627,7 @@ int TSubModel::TriangleAdd(TModel3d *m, texture_handle tex, int tri)
|
|||||||
return s->iNumVerts - tri; // zwraca pozycję tych trójkątów w submodelu
|
return s->iNumVerts - tri; // zwraca pozycję tych trójkątów w submodelu
|
||||||
};
|
};
|
||||||
|
|
||||||
basic_vertex *TSubModel::TrianglePtr(int tex, int pos, int *la, int *ld, int *ls)
|
basic_vertex *TSubModel::TrianglePtr(int tex, int pos, glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular )
|
||||||
{ // zwraca wskaźnik do wypełnienia tabeli wierzchołków, używane
|
{ // zwraca wskaźnik do wypełnienia tabeli wierzchołków, używane
|
||||||
// przy tworzeniu E3D terenu
|
// przy tworzeniu E3D terenu
|
||||||
TSubModel *s = this;
|
TSubModel *s = this;
|
||||||
@@ -639,7 +646,7 @@ basic_vertex *TSubModel::TrianglePtr(int tex, int pos, int *la, int *ld, int *ls
|
|||||||
s->iVboPtr = iInstance; // pozycja submodelu w tabeli wierzchołków
|
s->iVboPtr = iInstance; // pozycja submodelu w tabeli wierzchołków
|
||||||
iInstance += s->iNumVerts; // pozycja dla następnego
|
iInstance += s->iNumVerts; // pozycja dla następnego
|
||||||
}
|
}
|
||||||
s->ColorsSet(la, ld, ls); // ustawienie kolorów świateł
|
s->ColorsSet(Ambient, Diffuse, Specular); // ustawienie kolorów świateł
|
||||||
return s->Vertices + pos; // wskaźnik na wolne miejsce w tabeli wierzchołków
|
return s->Vertices + pos; // wskaźnik na wolne miejsce w tabeli wierzchołków
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1038,20 +1045,24 @@ void TSubModel::RaArrayFill(CVertNormTex *Vert)
|
|||||||
{ // wypełnianie tablic VBO
|
{ // wypełnianie tablic VBO
|
||||||
if (Child)
|
if (Child)
|
||||||
Child->RaArrayFill(Vert);
|
Child->RaArrayFill(Vert);
|
||||||
if ((eType < TP_ROTATOR) || (eType == TP_STARS))
|
if( ( eType < TP_ROTATOR ) || ( eType == TP_STARS ) )
|
||||||
for (int i = 0; i < iNumVerts; ++i)
|
for( int i = 0; i < iNumVerts; ++i ) {
|
||||||
{
|
Vert[ iVboPtr + i ].position = Vertices[ i ].position;
|
||||||
Vert[iVboPtr + i].x = Vertices[i].position.x;
|
Vert[ iVboPtr + i ].normal = Vertices[ i ].normal;
|
||||||
Vert[iVboPtr + i].y = Vertices[i].position.y;
|
Vert[ iVboPtr + i ].texture = Vertices[ i ].texture;
|
||||||
Vert[iVboPtr + i].z = Vertices[i].position.z;
|
/*
|
||||||
Vert[iVboPtr + i].nx = Vertices[i].normal.x;
|
Vert[iVboPtr + i].x = Vertices[i].position.x;
|
||||||
Vert[iVboPtr + i].ny = Vertices[i].normal.y;
|
Vert[iVboPtr + i].y = Vertices[i].position.y;
|
||||||
Vert[iVboPtr + i].nz = Vertices[i].normal.z;
|
Vert[iVboPtr + i].z = Vertices[i].position.z;
|
||||||
Vert[iVboPtr + i].u = Vertices[i].texture.s;
|
Vert[iVboPtr + i].nx = Vertices[i].normal.x;
|
||||||
Vert[iVboPtr + i].v = Vertices[i].texture.t;
|
Vert[iVboPtr + i].ny = Vertices[i].normal.y;
|
||||||
}
|
Vert[iVboPtr + i].nz = Vertices[i].normal.z;
|
||||||
else if (eType == TP_FREESPOTLIGHT)
|
Vert[iVboPtr + i].u = Vertices[i].texture.s;
|
||||||
Vert[iVboPtr].x = Vert[iVboPtr].y = Vert[iVboPtr].z = 0.0;
|
Vert[iVboPtr + i].v = Vertices[i].texture.t;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else if( eType == TP_FREESPOTLIGHT )
|
||||||
|
Vert[ iVboPtr ].position = glm::vec3();
|
||||||
if (Next)
|
if (Next)
|
||||||
Next->RaArrayFill(Vert);
|
Next->RaArrayFill(Vert);
|
||||||
};
|
};
|
||||||
@@ -1073,9 +1084,13 @@ void TSubModel::AdjustDist()
|
|||||||
Next->AdjustDist();
|
Next->AdjustDist();
|
||||||
};
|
};
|
||||||
|
|
||||||
void TSubModel::ColorsSet(int *a, int *d, int *s)
|
void TSubModel::ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular )
|
||||||
{ // ustawienie kolorów dla modelu terenu
|
{ // ustawienie kolorów dla modelu terenu
|
||||||
int i;
|
f4Ambient = glm::vec4( Ambient, 1.0f );
|
||||||
|
f4Diffuse = glm::vec4( Diffuse, 1.0f );
|
||||||
|
f4Specular = glm::vec4( Specular, 1.0f );
|
||||||
|
/*
|
||||||
|
int i;
|
||||||
if (a)
|
if (a)
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
f4Ambient[i] = a[i] / 255.0;
|
f4Ambient[i] = a[i] / 255.0;
|
||||||
@@ -1085,6 +1100,7 @@ void TSubModel::ColorsSet(int *a, int *d, int *s)
|
|||||||
if (s)
|
if (s)
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
f4Specular[i] = s[i] / 255.0;
|
f4Specular[i] = s[i] / 255.0;
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
void TSubModel::ParentMatrix(float4x4 *m)
|
void TSubModel::ParentMatrix(float4x4 *m)
|
||||||
@@ -1429,13 +1445,13 @@ void TSubModel::deserialize(std::istream &s)
|
|||||||
fVisible = sn_utils::ld_float32(s);
|
fVisible = sn_utils::ld_float32(s);
|
||||||
fLight = sn_utils::ld_float32(s);
|
fLight = sn_utils::ld_float32(s);
|
||||||
|
|
||||||
for (size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; ++i)
|
||||||
f4Ambient[i] = sn_utils::ld_float32(s);
|
f4Ambient[i] = sn_utils::ld_float32(s);
|
||||||
for (size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; ++i)
|
||||||
f4Diffuse[i] = sn_utils::ld_float32(s);
|
f4Diffuse[i] = sn_utils::ld_float32(s);
|
||||||
for (size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; ++i)
|
||||||
f4Specular[i] = sn_utils::ld_float32(s);
|
f4Specular[i] = sn_utils::ld_float32(s);
|
||||||
for (size_t i = 0; i < 4; i++)
|
for (size_t i = 0; i < 4; ++i)
|
||||||
f4Emision[i] = sn_utils::ld_float32(s);
|
f4Emision[i] = sn_utils::ld_float32(s);
|
||||||
|
|
||||||
fWireSize = sn_utils::ld_float32(s);
|
fWireSize = sn_utils::ld_float32(s);
|
||||||
@@ -1828,28 +1844,17 @@ TSubModel *TModel3d::TerrainSquare(int n)
|
|||||||
r->UnFlagNext(); // blokowanie wyświetlania po Next głównej listy
|
r->UnFlagNext(); // blokowanie wyświetlania po Next głównej listy
|
||||||
return r;
|
return r;
|
||||||
};
|
};
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void TModel3d::TerrainRenderVBO(int n)
|
void TModel3d::TerrainRenderVBO(int n)
|
||||||
{ // renderowanie terenu z VBO
|
{ // renderowanie terenu z VBO
|
||||||
glPushMatrix();
|
::glPushMatrix();
|
||||||
::glTranslated( -Global::pCameraPosition.x, -Global::pCameraPosition.y, -Global::pCameraPosition.z );
|
::glTranslated( -Global::pCameraPosition.x, -Global::pCameraPosition.y, -Global::pCameraPosition.z );
|
||||||
|
TSubModel *r = Root;
|
||||||
// glTranslated(vPosition->x,vPosition->y,vPosition->z);
|
while( r ) {
|
||||||
// if (vAngle->y!=0.0) glRotated(vAngle->y,0.0,1.0,0.0);
|
if( r->iVisible == n ) // tylko jeśli ma być widoczny w danej ramce (problem dla 0==false)
|
||||||
// if (vAngle->x!=0.0) glRotated(vAngle->x,1.0,0.0,0.0);
|
GfxRenderer.Render( r ); // sub kolejne (Next) się nie wyrenderują
|
||||||
// if (vAngle->z!=0.0) glRotated(vAngle->z,0.0,0.0,1.0);
|
r = r->NextGet();
|
||||||
// TSubModel::fSquareDist=SquareMagnitude(*vPosition-Global::GetCameraPosition());
|
}
|
||||||
// //zmienna globalna!
|
::glPopMatrix();
|
||||||
if (StartVBO())
|
|
||||||
{ // odwrócenie flag, aby wyłapać nieprzezroczyste
|
|
||||||
// Root->ReplacableSet(ReplacableSkinId,iAlpha^0x0F0F000F);
|
|
||||||
TSubModel *r = Root;
|
|
||||||
while (r)
|
|
||||||
{
|
|
||||||
if (r->iVisible == n) // tylko jeśli ma być widoczny w danej ramce (problem dla 0==false)
|
|
||||||
GfxRenderer.Render(r); // sub kolejne (Next) się nie wyrenderują
|
|
||||||
r = r->NextGet();
|
|
||||||
}
|
|
||||||
EndVBO();
|
|
||||||
}
|
|
||||||
glPopMatrix();
|
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
17
Model3d.h
17
Model3d.h
@@ -92,10 +92,11 @@ private:
|
|||||||
int iTexture; // numer nazwy tekstury, -1 wymienna, 0 brak
|
int iTexture; // numer nazwy tekstury, -1 wymienna, 0 brak
|
||||||
float fVisible; // próg jasności światła do załączenia submodelu
|
float fVisible; // próg jasności światła do załączenia submodelu
|
||||||
float fLight; // próg jasności światła do zadziałania selfillum
|
float fLight; // próg jasności światła do zadziałania selfillum
|
||||||
float f4Ambient[4];
|
glm::vec4
|
||||||
float f4Diffuse[4]; // float ze względu na glMaterialfv()
|
f4Ambient,
|
||||||
float f4Specular[4];
|
f4Diffuse,
|
||||||
float f4Emision[4];
|
f4Specular,
|
||||||
|
f4Emision;
|
||||||
float fWireSize; // nie używane, ale wczytywane
|
float fWireSize; // nie używane, ale wczytywane
|
||||||
float fSquareMaxDist;
|
float fSquareMaxDist;
|
||||||
float fSquareMinDist;
|
float fSquareMinDist;
|
||||||
@@ -156,7 +157,7 @@ public:
|
|||||||
TSubModel * NextGet() { return Next; };
|
TSubModel * NextGet() { return Next; };
|
||||||
TSubModel * ChildGet() { return Child; };
|
TSubModel * ChildGet() { return Child; };
|
||||||
int TriangleAdd(TModel3d *m, texture_handle tex, int tri);
|
int TriangleAdd(TModel3d *m, texture_handle tex, int tri);
|
||||||
basic_vertex * TrianglePtr(int tex, int pos, int *la, int *ld, int *ls);
|
basic_vertex * TrianglePtr(int tex, int pos, glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular );
|
||||||
void SetRotate(float3 vNewRotateAxis, float fNewAngle);
|
void SetRotate(float3 vNewRotateAxis, float fNewAngle);
|
||||||
void SetRotateXYZ(vector3 vNewAngles);
|
void SetRotateXYZ(vector3 vNewAngles);
|
||||||
void SetRotateXYZ(float3 vNewAngles);
|
void SetRotateXYZ(float3 vNewAngles);
|
||||||
@@ -189,7 +190,7 @@ public:
|
|||||||
// Ra: funkcje do budowania terenu z E3D
|
// Ra: funkcje do budowania terenu z E3D
|
||||||
int Flags() { return iFlags; };
|
int Flags() { return iFlags; };
|
||||||
void UnFlagNext() { iFlags &= 0x00FFFFFF; };
|
void UnFlagNext() { iFlags &= 0x00FFFFFF; };
|
||||||
void ColorsSet(int *a, int *d, int *s);
|
void ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, glm::vec3 const &Specular );
|
||||||
inline float3 Translation1Get()
|
inline float3 Translation1Get()
|
||||||
{
|
{
|
||||||
return fMatrix ? *(fMatrix->TranslationGet()) + v_TransVector : v_TransVector;
|
return fMatrix ? *(fMatrix->TranslationGet()) + v_TransVector : v_TransVector;
|
||||||
@@ -247,7 +248,9 @@ public:
|
|||||||
std::string NameGet() { return m_filename; };
|
std::string NameGet() { return m_filename; };
|
||||||
int TerrainCount();
|
int TerrainCount();
|
||||||
TSubModel * TerrainSquare(int n);
|
TSubModel * TerrainSquare(int n);
|
||||||
void TerrainRenderVBO(int n);
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
|
void TerrainRenderVBO(int n);
|
||||||
|
#endif
|
||||||
void deserialize(std::istream &s, size_t size, bool dynamic);
|
void deserialize(std::istream &s, size_t size, bool dynamic);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
64
Segment.cpp
64
Segment.cpp
@@ -398,14 +398,14 @@ int TSegment::RenderLoft( CVertNormTex* &Output, Math3D::vector3 const &Origin,
|
|||||||
::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->position.x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->position.y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->position.z = pt.z;
|
||||||
Output->nx = norm.x;
|
Output->normal.x = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->normal.y = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->normal.z = norm.z;
|
||||||
Output->u = (jmm1 * ShapePoints[ j ].z + m1 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
Output->texture.s = (jmm1 * ShapePoints[ j ].z + m1 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
||||||
Output->v = tv1;
|
Output->texture.t = tv1;
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
@@ -431,14 +431,14 @@ int TSegment::RenderLoft( CVertNormTex* &Output, Math3D::vector3 const &Origin,
|
|||||||
::glVertex3f( pt.x, pt.y, pt.z );
|
::glVertex3f( pt.x, pt.y, pt.z );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Output->x = pt.x;
|
Output->position.x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->position.y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->position.z = pt.z;
|
||||||
Output->nx = norm.x;
|
Output->normal.x = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->normal.y = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->normal.z = norm.z;
|
||||||
Output->u = (jmm2 * ShapePoints[ j ].z + m2 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
Output->texture.s = (jmm2 * ShapePoints[ j ].z + m2 * ShapePoints[ j + iNumShapePoints ].z) / Texturescale;
|
||||||
Output->v = tv2;
|
Output->texture.t = tv2;
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
@@ -468,14 +468,14 @@ int TSegment::RenderLoft( CVertNormTex* &Output, Math3D::vector3 const &Origin,
|
|||||||
::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->position.x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->position.y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->position.z = pt.z;
|
||||||
Output->nx = norm.x;
|
Output->normal.x = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->normal.y = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->normal.z = norm.z;
|
||||||
Output->u = ShapePoints[ j ].z / Texturescale;
|
Output->texture.s = ShapePoints[ j ].z / Texturescale;
|
||||||
Output->v = tv1;
|
Output->texture.t = tv1;
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
@@ -492,14 +492,14 @@ int TSegment::RenderLoft( CVertNormTex* &Output, Math3D::vector3 const &Origin,
|
|||||||
::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->position.x = pt.x;
|
||||||
Output->y = pt.y;
|
Output->position.y = pt.y;
|
||||||
Output->z = pt.z;
|
Output->position.z = pt.z;
|
||||||
Output->nx = norm.x;
|
Output->normal.x = norm.x;
|
||||||
Output->ny = norm.y;
|
Output->normal.y = norm.y;
|
||||||
Output->nz = norm.z;
|
Output->normal.z = norm.z;
|
||||||
Output->u = ShapePoints[ j ].z / Texturescale;
|
Output->texture.s = ShapePoints[ j ].z / Texturescale;
|
||||||
Output->v = tv2;
|
Output->texture.t = tv2;
|
||||||
++Output;
|
++Output;
|
||||||
}
|
}
|
||||||
++vertexcount;
|
++vertexcount;
|
||||||
|
|||||||
54
Track.cpp
54
Track.cpp
@@ -1091,7 +1091,7 @@ void TTrack::Compile(GLuint tex)
|
|||||||
normal2 = normal1;
|
normal2 = normal1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const origin = pMyNode->m_rootposition;
|
auto const origin { pMyNode->m_rootposition };
|
||||||
|
|
||||||
double roll1, roll2;
|
double roll1, roll2;
|
||||||
switch (iCategoryFlag & 15)
|
switch (iCategoryFlag & 15)
|
||||||
@@ -1866,7 +1866,7 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
normal2 = normal1;
|
normal2 = normal1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const origin = pMyNode->m_rootposition;
|
auto const origin { pMyNode->m_rootposition };
|
||||||
|
|
||||||
double roll1, roll2;
|
double roll1, roll2;
|
||||||
switch (iCategoryFlag & 15)
|
switch (iCategoryFlag & 15)
|
||||||
@@ -2302,42 +2302,42 @@ void TTrack::RaArrayFill(CVertNormTex *Vert, const CVertNormTex *Start, int cons
|
|||||||
if (TextureID1) {
|
if (TextureID1) {
|
||||||
// jeśli podana tekstura nawierzchni
|
// jeśli podana tekstura nawierzchni
|
||||||
// we start with a vertex in the middle...
|
// we start with a vertex in the middle...
|
||||||
Vert->nx = 0.0;
|
Vert->normal.x = 0.0;
|
||||||
Vert->ny = 1.0;
|
Vert->normal.y = 1.0;
|
||||||
Vert->nz = 0.0;
|
Vert->normal.z = 0.0;
|
||||||
Vert->u = 0.5;
|
Vert->texture.s = 0.5;
|
||||||
Vert->v = 0.5;
|
Vert->texture.t = 0.5;
|
||||||
Vert->x = oxz.x - origin.x;
|
Vert->position.x = oxz.x - origin.x;
|
||||||
Vert->y = oxz.y - origin.y;
|
Vert->position.y = oxz.y - origin.y;
|
||||||
Vert->z = oxz.z - origin.z;
|
Vert->position.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->normal.x = 0.0;
|
||||||
Vert->ny = 1.0;
|
Vert->normal.y = 1.0;
|
||||||
Vert->nz = 0.0;
|
Vert->normal.z = 0.0;
|
||||||
// mapowanie we współrzędnych scenerii
|
// mapowanie we współrzędnych scenerii
|
||||||
u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x + origin.x ) / fTexLength;
|
u = ( SwitchExtension->vPoints[ 0 ].x - oxz.x + origin.x ) / fTexLength;
|
||||||
v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z + origin.z ) / ( fTexRatio1 * fTexLength );
|
v = ( SwitchExtension->vPoints[ 0 ].z - oxz.z + origin.z ) / ( fTexRatio1 * fTexLength );
|
||||||
Vert->u = cosa0 * u + sina0 * v + 0.5;
|
Vert->texture.s = cosa0 * u + sina0 * v + 0.5;
|
||||||
Vert->v = -sina0 * u + cosa0 * v + 0.5;
|
Vert->texture.t = -sina0 * u + cosa0 * v + 0.5;
|
||||||
Vert->x = SwitchExtension->vPoints[ 0 ].x;
|
Vert->position.x = SwitchExtension->vPoints[ 0 ].x;
|
||||||
Vert->y = SwitchExtension->vPoints[ 0 ].y;
|
Vert->position.y = SwitchExtension->vPoints[ 0 ].y;
|
||||||
Vert->z = SwitchExtension->vPoints[ 0 ].z;
|
Vert->position.z = SwitchExtension->vPoints[ 0 ].z;
|
||||||
++Vert;
|
++Vert;
|
||||||
// ...then draw the precalculated rest
|
// ...then draw the precalculated rest
|
||||||
for (i = SwitchExtension->iPoints + SwitchExtension->iRoads - 1; i >= 0; --i)
|
for (i = SwitchExtension->iPoints + SwitchExtension->iRoads - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
Vert->nx = 0.0;
|
Vert->normal.x = 0.0;
|
||||||
Vert->ny = 1.0;
|
Vert->normal.y = 1.0;
|
||||||
Vert->nz = 0.0;
|
Vert->normal.z = 0.0;
|
||||||
// mapowanie we współrzędnych scenerii
|
// mapowanie we współrzędnych scenerii
|
||||||
u = (SwitchExtension->vPoints[i].x - oxz.x + origin.x ) / fTexLength;
|
u = (SwitchExtension->vPoints[i].x - oxz.x + origin.x ) / fTexLength;
|
||||||
v = (SwitchExtension->vPoints[i].z - oxz.z + origin.z ) / (fTexRatio1 * fTexLength);
|
v = (SwitchExtension->vPoints[i].z - oxz.z + origin.z ) / (fTexRatio1 * fTexLength);
|
||||||
Vert->u = cosa0 * u + sina0 * v + 0.5;
|
Vert->texture.s = cosa0 * u + sina0 * v + 0.5;
|
||||||
Vert->v = -sina0 * u + cosa0 * v + 0.5;
|
Vert->texture.t = -sina0 * u + cosa0 * v + 0.5;
|
||||||
Vert->x = SwitchExtension->vPoints[ i ].x;
|
Vert->position.x = SwitchExtension->vPoints[ i ].x;
|
||||||
Vert->y = SwitchExtension->vPoints[ i ].y;
|
Vert->position.y = SwitchExtension->vPoints[ i ].y;
|
||||||
Vert->z = SwitchExtension->vPoints[ i ].z;
|
Vert->position.z = SwitchExtension->vPoints[ i ].z;
|
||||||
++Vert;
|
++Vert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2894,7 +2894,7 @@ TTrack * TTrack::RaAnimate(GLuint const Vertexbuffer)
|
|||||||
bladesbuffer.data() );
|
bladesbuffer.data() );
|
||||||
*/
|
*/
|
||||||
auto bladevertices = bladesbuffer.data();
|
auto bladevertices = bladesbuffer.data();
|
||||||
auto const origin = pMyNode->m_rootposition;
|
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, origin, 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, origin, 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*/ );
|
||||||
|
|||||||
16
Traction.cpp
16
Traction.cpp
@@ -91,7 +91,7 @@ sekcji z sąsiedniego przęsła).
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
std::size_t
|
std::size_t
|
||||||
TTraction::create_geometry( geometrybank_handle const &Bank, Math3D::vector3 const &Origin ) {
|
TTraction::create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin ) {
|
||||||
|
|
||||||
if( m_geometry != NULL ) {
|
if( m_geometry != NULL ) {
|
||||||
return GfxRenderer.Vertices( m_geometry ).size() / 2;
|
return GfxRenderer.Vertices( m_geometry ).size() / 2;
|
||||||
@@ -117,13 +117,13 @@ TTraction::create_geometry( geometrybank_handle const &Bank, Math3D::vector3 con
|
|||||||
vertices.emplace_back( startvertex );
|
vertices.emplace_back( startvertex );
|
||||||
vertices.emplace_back( endvertex );
|
vertices.emplace_back( endvertex );
|
||||||
// Nie wiem co 'Marcin
|
// Nie wiem co 'Marcin
|
||||||
Math3D::vector3 pt1, pt2, pt3, pt4, v1, v2;
|
glm::dvec3 pt1, pt2, pt3, pt4, v1, v2;
|
||||||
v1 = pPoint4 - pPoint3;
|
v1 = pPoint4 - pPoint3;
|
||||||
v2 = pPoint2 - pPoint1;
|
v2 = pPoint2 - pPoint1;
|
||||||
float step = 0;
|
float step = 0;
|
||||||
if( iNumSections > 0 )
|
if( iNumSections > 0 )
|
||||||
step = 1.0f / (float)iNumSections;
|
step = 1.0f / (float)iNumSections;
|
||||||
float f = step;
|
double f = step;
|
||||||
float mid = 0.5;
|
float mid = 0.5;
|
||||||
float t;
|
float t;
|
||||||
// Przewod nosny 'Marcin
|
// Przewod nosny 'Marcin
|
||||||
@@ -274,13 +274,13 @@ TTraction::create_geometry( geometrybank_handle const &Bank, Math3D::vector3 con
|
|||||||
return elementcount;
|
return elementcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TTraction::TestPoint(Math3D::vector3 *Point)
|
int TTraction::TestPoint(glm::dvec3 const &Point)
|
||||||
{ // sprawdzanie, czy przęsła można połączyć
|
{ // sprawdzanie, czy przęsła można połączyć
|
||||||
if (!hvNext[0])
|
if (!hvNext[0])
|
||||||
if (pPoint1.Equal(Point))
|
if( glm::all( glm::epsilonEqual( Point, pPoint1, 0.025 ) ) )
|
||||||
return 0;
|
return 0;
|
||||||
if (!hvNext[1])
|
if (!hvNext[1])
|
||||||
if (pPoint2.Equal(Point))
|
if( glm::all( glm::epsilonEqual( Point, pPoint2, 0.025 ) ) )
|
||||||
return 1;
|
return 1;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
@@ -358,7 +358,7 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
|
|||||||
}
|
}
|
||||||
t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony
|
t->psPower[d] = ps; // skopiowanie wskaźnika zasilacza od danej strony
|
||||||
t->fResistance[d] = r; // wpisanie rezystancji w kierunku tego zasilacza
|
t->fResistance[d] = r; // wpisanie rezystancji w kierunku tego zasilacza
|
||||||
r += t->fResistivity * Length3(t->vParametric); // doliczenie oporu kolejnego odcinka
|
r += t->fResistivity * glm::dot(t->vParametric, t->vParametric ); // doliczenie oporu kolejnego odcinka
|
||||||
p = t; // zapamiętanie dotychczasowego
|
p = t; // zapamiętanie dotychczasowego
|
||||||
t = p->hvNext[d ^ 1]; // podążanie w tę samą stronę
|
t = p->hvNext[d ^ 1]; // podążanie w tę samą stronę
|
||||||
d = p->iNext[d ^ 1];
|
d = p->iNext[d ^ 1];
|
||||||
@@ -368,7 +368,7 @@ void TTraction::ResistanceCalc(int d, double r, TTractionPowerSource *ps)
|
|||||||
else
|
else
|
||||||
{ // podążanie w obu kierunkach, można by rekurencją, ale szkoda zasobów
|
{ // podążanie w obu kierunkach, można by rekurencją, ale szkoda zasobów
|
||||||
r = 0.5 * fResistivity *
|
r = 0.5 * fResistivity *
|
||||||
Length3(vParametric); // powiedzmy, że w zasilanym przęśle jest połowa
|
glm::dot(vParametric, vParametric ); // powiedzmy, że w zasilanym przęśle jest połowa
|
||||||
if (fResistance[0] == 0.0)
|
if (fResistance[0] == 0.0)
|
||||||
ResistanceCalc(0, r); // do tyłu (w stronę Point1)
|
ResistanceCalc(0, r); // do tyłu (w stronę Point1)
|
||||||
if (fResistance[1] == 0.0)
|
if (fResistance[1] == 0.0)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class TTraction
|
|||||||
int iNext[ 2 ] { 0, 0 }; // do którego końca się łączy
|
int iNext[ 2 ] { 0, 0 }; // do którego końca się łączy
|
||||||
int iLast { 1 }; //że niby ostatni drut // ustawiony bit 0, jeśli jest ostatnim drutem w sekcji; bit1 - przedostatni
|
int iLast { 1 }; //że niby ostatni drut // ustawiony bit 0, jeśli jest ostatnim drutem w sekcji; bit1 - przedostatni
|
||||||
public:
|
public:
|
||||||
Math3D::vector3 pPoint1, pPoint2, pPoint3, pPoint4;
|
glm::dvec3 pPoint1, pPoint2, pPoint3, pPoint4;
|
||||||
Math3D::vector3 vParametric; // współczynniki równania parametrycznego odcinka
|
glm::dvec3 vParametric; // współczynniki równania parametrycznego odcinka
|
||||||
double fHeightDifference { 0.0 }; //,fMiddleHeight;
|
double fHeightDifference { 0.0 }; //,fMiddleHeight;
|
||||||
int iNumSections { 0 };
|
int iNumSections { 0 };
|
||||||
float NominalVoltage { 0.0f };
|
float NominalVoltage { 0.0f };
|
||||||
@@ -51,8 +51,8 @@ class TTraction
|
|||||||
|
|
||||||
// creates geometry data in specified geometry bank. returns: number of created elements, or NULL
|
// creates geometry data in specified geometry bank. returns: number of created elements, or NULL
|
||||||
// NOTE: deleting nodes doesn't currently release geometry data owned by the node. TODO: implement erasing individual geometry chunks and banks
|
// NOTE: deleting nodes doesn't currently release geometry data owned by the node. TODO: implement erasing individual geometry chunks and banks
|
||||||
std::size_t create_geometry( geometrybank_handle const &Bank, Math3D::vector3 const &Origin );
|
std::size_t create_geometry( geometrybank_handle const &Bank, glm::dvec3 const &Origin );
|
||||||
int TestPoint(Math3D::vector3 *Point);
|
int TestPoint(glm::dvec3 const &Point);
|
||||||
void Connect(int my, TTraction *with, int to);
|
void Connect(int my, TTraction *with, int to);
|
||||||
void Init();
|
void Init();
|
||||||
bool WhereIs();
|
bool WhereIs();
|
||||||
|
|||||||
6
VBO.cpp
6
VBO.cpp
@@ -14,7 +14,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "sn_utils.h"
|
#include "sn_utils.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
void CVertNormTex::deserialize(std::istream &s)
|
void CVertNormTex::deserialize(std::istream &s)
|
||||||
{
|
{
|
||||||
x = sn_utils::ld_float32(s);
|
x = sn_utils::ld_float32(s);
|
||||||
@@ -42,7 +42,7 @@ void CVertNormTex::serialize(std::ostream &s)
|
|||||||
sn_utils::ls_float32(s, u);
|
sn_utils::ls_float32(s, u);
|
||||||
sn_utils::ls_float32(s, v);
|
sn_utils::ls_float32(s, v);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
CMesh::CMesh()
|
CMesh::CMesh()
|
||||||
{ // utworzenie pustego obiektu
|
{ // utworzenie pustego obiektu
|
||||||
#ifdef EU07_USE_OLD_VERTEXBUFFER
|
#ifdef EU07_USE_OLD_VERTEXBUFFER
|
||||||
@@ -117,7 +117,7 @@ bool CMesh::StartVBO()
|
|||||||
if (m_nVBOVertices)
|
if (m_nVBOVertices)
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_ARRAY_BUFFER_ARB, m_nVBOVertices);
|
glBindBuffer(GL_ARRAY_BUFFER_ARB, m_nVBOVertices);
|
||||||
glVertexPointer( 3, GL_FLOAT, sizeof(CVertNormTex), static_cast<char *>(nullptr) ); // pozycje
|
glVertexPointer( 3, GL_FLOAT, sizeof( CVertNormTex ), static_cast<char *>( nullptr ) ); // pozycje
|
||||||
glNormalPointer( GL_FLOAT, sizeof( CVertNormTex ), static_cast<char *>( nullptr ) + 12 ); // normalne
|
glNormalPointer( GL_FLOAT, sizeof( CVertNormTex ), static_cast<char *>( nullptr ) + 12 ); // normalne
|
||||||
glTexCoordPointer( 2, GL_FLOAT, sizeof( CVertNormTex ), static_cast<char *>( nullptr ) + 24 ); // wierzchołki
|
glTexCoordPointer( 2, GL_FLOAT, sizeof( CVertNormTex ), static_cast<char *>( nullptr ) + 24 ); // wierzchołki
|
||||||
return true; // można rysować z VBO
|
return true; // można rysować z VBO
|
||||||
|
|||||||
3
VBO.h
3
VBO.h
@@ -14,6 +14,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#define EU07_USE_OLD_VERTEXBUFFER
|
#define EU07_USE_OLD_VERTEXBUFFER
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
class CVertNormTex
|
class CVertNormTex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -29,6 +30,8 @@ class CVertNormTex
|
|||||||
void deserialize(std::istream&);
|
void deserialize(std::istream&);
|
||||||
void serialize(std::ostream&);
|
void serialize(std::ostream&);
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
typedef basic_vertex CVertNormTex;
|
||||||
|
|
||||||
class CMesh
|
class CMesh
|
||||||
{ // wsparcie dla VBO
|
{ // wsparcie dla VBO
|
||||||
|
|||||||
3
dumb3d.h
3
dumb3d.h
@@ -72,6 +72,9 @@ class vector3
|
|||||||
y = b;
|
y = b;
|
||||||
z = c;
|
z = c;
|
||||||
}
|
}
|
||||||
|
vector3( glm::dvec3 const &Vector ) :
|
||||||
|
x( Vector.x ), y( Vector.y ), z( Vector.z )
|
||||||
|
{}
|
||||||
|
|
||||||
// The int parameter is the number of elements to copy from initArray (3 or 4)
|
// The int parameter is the number of elements to copy from initArray (3 or 4)
|
||||||
// explicit vector3(scalar_t* initArray, int arraySize = 3)
|
// explicit vector3(scalar_t* initArray, int arraySize = 3)
|
||||||
|
|||||||
138
renderer.cpp
138
renderer.cpp
@@ -367,9 +367,9 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
for( int column = originx; column <= originx + segmentcount; ++column ) {
|
for( int column = originx; column <= originx + segmentcount; ++column ) {
|
||||||
for( int row = originz; row <= originz + segmentcount; ++row ) {
|
for( int row = originz; row <= originz + segmentcount; ++row ) {
|
||||||
|
|
||||||
auto *rectangle = &Ground->Rects[ column ][ row ];
|
auto *cell = &Ground->Rects[ column ][ row ];
|
||||||
if( m_camera.visible( rectangle->m_area ) ) {
|
if( m_camera.visible( cell->m_area ) ) {
|
||||||
Render( rectangle );
|
Render( cell );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,8 +387,8 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
int r = Ground->GetRowFromZ( Global::pCameraPosition.z );
|
int r = Ground->GetRowFromZ( Global::pCameraPosition.z );
|
||||||
TSubRect *tmp;
|
TSubRect *tmp;
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
for( j = r - n; j <= r + n; j++ ) {
|
for( j = r - n; j <= r + n; ++j ) {
|
||||||
for( i = c - n; i <= c + n; i++ ) {
|
for( i = c - n; i <= c + n; ++i ) {
|
||||||
if( ( tmp = Ground->FastGetSubRect( i, j ) ) != nullptr ) {
|
if( ( tmp = Ground->FastGetSubRect( i, j ) ) != nullptr ) {
|
||||||
// oznaczanie aktywnych sektorów
|
// oznaczanie aktywnych sektorów
|
||||||
tmp->LoadNodes();
|
tmp->LoadNodes();
|
||||||
@@ -441,12 +441,29 @@ 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 != nullptr )
|
||||||
|
&& ( Global::pTerrainCompact->pModel != nullptr ) ) {
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
Global::pTerrainCompact->TerrainRenderVBO( TGroundRect::iFrameNumber );
|
Global::pTerrainCompact->TerrainRenderVBO( TGroundRect::iFrameNumber );
|
||||||
|
#endif
|
||||||
|
// TODO: remap geometry of terrain cells to allow camera-centric rendering
|
||||||
|
::glPushMatrix();
|
||||||
|
::glTranslated( -Global::pCameraPosition.x, -Global::pCameraPosition.y, -Global::pCameraPosition.z );
|
||||||
|
TSubModel *submodel = Global::pTerrainCompact->pModel->Root;
|
||||||
|
while( submodel != nullptr ) {
|
||||||
|
if( submodel->iVisible == TGroundRect::iFrameNumber ) {
|
||||||
|
// tylko jeśli ma być widoczny w danej ramce (problem dla 0==false)
|
||||||
|
Render( submodel ); // sub kolejne (Next) się nie wyrenderują
|
||||||
|
}
|
||||||
|
submodel = submodel->NextGet();
|
||||||
|
}
|
||||||
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// renderowanie nieprzezroczystych
|
// renderowanie nieprzezroczystych
|
||||||
for( i = 0; i < Ground->iRendered; ++i ) {
|
for( i = 0; i < Ground->iRendered; ++i ) {
|
||||||
Render( Ground->pRendered[ i ] );
|
Render( Ground->pRendered[ i ] );
|
||||||
@@ -456,43 +473,42 @@ opengl_renderer::Render( TGround *Ground ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: unify ground render code, until then old version is in place
|
// TODO: unify ground render code, until then old version is in place
|
||||||
#define EU07_USE_OLD_RENDERCODE
|
|
||||||
bool
|
bool
|
||||||
opengl_renderer::Render( TGroundRect *Groundcell ) {
|
opengl_renderer::Render( TGroundRect *Groundcell ) {
|
||||||
|
|
||||||
::glPushMatrix();
|
bool result { false }; // will be true if we do any rendering
|
||||||
auto const &cellorigin = Groundcell->m_area.center;
|
|
||||||
// TODO: unify all math objects
|
|
||||||
auto const originoffset = Math3D::vector3( cellorigin.x, cellorigin.y, cellorigin.z ) - Global::pCameraPosition;
|
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
|
||||||
|
|
||||||
bool result{ false }; // will be true if we do any rendering
|
|
||||||
|
|
||||||
// TODO: unify render paths
|
// TODO: unify render paths
|
||||||
if( Global::bUseVBO ) {
|
if( Global::bUseVBO ) {
|
||||||
|
|
||||||
if ( Groundcell->iLastDisplay != Groundcell->iFrameNumber)
|
if ( Groundcell->iLastDisplay != Groundcell->iFrameNumber) {
|
||||||
{ // tylko jezeli dany kwadrat nie był jeszcze renderowany
|
// tylko jezeli dany kwadrat nie był jeszcze renderowany
|
||||||
Groundcell->LoadNodes(); // ewentualne tworzenie siatek
|
Groundcell->LoadNodes(); // ewentualne tworzenie siatek
|
||||||
if ( Groundcell->nRenderRect && Groundcell->StartVBO())
|
|
||||||
{
|
if( ( Groundcell->nRenderRect != nullptr )
|
||||||
for (TGroundNode *node = Groundcell->nRenderRect; node; node = node->nNext3) // następny tej grupy
|
&& ( true == Groundcell->StartVBO() ) ) {
|
||||||
#ifdef EU07_USE_OLD_RENDERCODE
|
// nieprzezroczyste trójkąty kwadratu kilometrowego
|
||||||
node->RaRenderVBO(); // nieprzezroczyste trójkąty kwadratu kilometrowego
|
for( TGroundNode *node = Groundcell->nRenderRect; node; node = node->nNext3 ) {
|
||||||
#else
|
Render( node );
|
||||||
Render( node ); // nieprzezroczyste trójkąty kwadratu kilometrowego
|
}
|
||||||
#endif
|
|
||||||
Groundcell->EndVBO();
|
Groundcell->EndVBO();
|
||||||
Groundcell->iLastDisplay = Groundcell->iFrameNumber;
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
if ( Groundcell->nTerrain)
|
if( Groundcell->nTerrain ) {
|
||||||
Groundcell->nTerrain->smTerrain->iVisible = Groundcell->iFrameNumber; // ma się wyświetlić w tej ramce
|
|
||||||
|
Render( Groundcell->nTerrain );
|
||||||
|
}
|
||||||
|
Groundcell->iLastDisplay = Groundcell->iFrameNumber; // drugi raz nie potrzeba
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
::glPopMatrix();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef EU07_USE_OLD_RENDERCODE
|
// display list render path
|
||||||
|
::glPushMatrix();
|
||||||
|
auto const &cellorigin = Groundcell->m_area.center;
|
||||||
|
// TODO: unify all math objects
|
||||||
|
auto const originoffset = Math3D::vector3( cellorigin.x, cellorigin.y, cellorigin.z ) - Global::pCameraPosition;
|
||||||
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
|
||||||
if (Groundcell->iLastDisplay != Groundcell->iFrameNumber)
|
if (Groundcell->iLastDisplay != Groundcell->iFrameNumber)
|
||||||
{ // tylko jezeli dany kwadrat nie był jeszcze renderowany
|
{ // tylko jezeli dany kwadrat nie był jeszcze renderowany
|
||||||
// for (TGroundNode* node=pRender;node;node=node->pNext3)
|
// for (TGroundNode* node=pRender;node;node=node->pNext3)
|
||||||
@@ -505,7 +521,7 @@ opengl_renderer::Render( TGroundRect *Groundcell ) {
|
|||||||
Groundcell->nRender->DisplayListID = glGenLists(1);
|
Groundcell->nRender->DisplayListID = glGenLists(1);
|
||||||
glNewList( Groundcell->nRender->DisplayListID, GL_COMPILE);
|
glNewList( Groundcell->nRender->DisplayListID, GL_COMPILE);
|
||||||
Groundcell->nRender->iVersion = Global::iReCompile; // aktualna wersja siatek
|
Groundcell->nRender->iVersion = Global::iReCompile; // aktualna wersja siatek
|
||||||
auto const origin = Math3D::vector3( Groundcell->m_area.center.x, Groundcell->m_area.center.y, Groundcell->m_area.center.z );
|
auto const origin = glm::dvec3( Groundcell->m_area.center );
|
||||||
for (TGroundNode *node = Groundcell->nRender; node; node = node->nNext3) // następny tej grupy
|
for (TGroundNode *node = Groundcell->nRender; node; node = node->nNext3) // następny tej grupy
|
||||||
node->Compile(origin, true);
|
node->Compile(origin, true);
|
||||||
glEndList();
|
glEndList();
|
||||||
@@ -515,32 +531,18 @@ opengl_renderer::Render( TGroundRect *Groundcell ) {
|
|||||||
// submodels geometry is world-centric, so at least for the time being we need to pop the stack early
|
// submodels geometry is world-centric, so at least for the time being we need to pop the stack early
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
|
|
||||||
if( Groundcell->nRootMesh ) {
|
if( Groundcell->nTerrain ) { Render( Groundcell->nTerrain ); }
|
||||||
Render( Groundcell->nRootMesh );
|
|
||||||
}
|
|
||||||
Groundcell->iLastDisplay = Groundcell->iFrameNumber; // drugi raz nie potrzeba
|
Groundcell->iLastDisplay = Groundcell->iFrameNumber; // drugi raz nie potrzeba
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if( iLastDisplay != iFrameNumber ) { // tylko jezeli dany kwadrat nie był jeszcze renderowany
|
|
||||||
LoadNodes(); // ewentualne tworzenie siatek
|
|
||||||
if( nRenderRect ) {
|
|
||||||
for( TGroundNode *node = nRenderRect; node; node = node->nNext3 ) // następny tej grupy
|
|
||||||
Render( node ); // nieprzezroczyste trójkąty kwadratu kilometrowego
|
|
||||||
}
|
|
||||||
if( nRootMesh )
|
|
||||||
Render( nRootMesh );
|
|
||||||
iLastDisplay = iFrameNumber;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#undef EU07_USE_OLD_RENDERCODE
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
opengl_renderer::Render( TSubRect *Groundsubcell ) {
|
opengl_renderer::Render( TSubRect *Groundsubcell ) {
|
||||||
@@ -665,11 +667,13 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
if( Node->iNumPts ) {
|
if( Node->iNumPts ) {
|
||||||
// setup
|
// setup
|
||||||
// w zaleznosci od koloru swiatla
|
// w zaleznosci od koloru swiatla
|
||||||
::glColor4ub(
|
::glColor4fv(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 0 ] * Global::DayLight.ambient[ 0 ] ) ),
|
glm::value_ptr(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 1 ] * Global::DayLight.ambient[ 1 ] ) ),
|
glm::vec4(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 2 ] * Global::DayLight.ambient[ 2 ] ) ),
|
Node->Diffuse * glm::make_vec3( Global::DayLight.ambient ),
|
||||||
static_cast<GLubyte>( std::min( 255.0, 255000 * Node->fLineThickness / ( distancesquared + 1.0 ) ) ) );
|
std::min(
|
||||||
|
1.0,
|
||||||
|
1000.0 * Node->fLineThickness / ( distancesquared + 1.0 ) ) ) ) );
|
||||||
|
|
||||||
GfxRenderer.Bind( 0 );
|
GfxRenderer.Bind( 0 );
|
||||||
|
|
||||||
@@ -700,10 +704,7 @@ opengl_renderer::Render( TGroundNode *Node ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// setup
|
// setup
|
||||||
::glColor3ub(
|
::glColor3fv( glm::value_ptr( Node->Diffuse ) );
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 0 ] ),
|
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 1 ] ),
|
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 2 ] ) );
|
|
||||||
|
|
||||||
Bind( Node->TextureID );
|
Bind( Node->TextureID );
|
||||||
|
|
||||||
@@ -874,11 +875,11 @@ opengl_renderer::Render( TSubModel *Submodel ) {
|
|||||||
// również 0
|
// również 0
|
||||||
Bind( Submodel->TextureID );
|
Bind( Submodel->TextureID );
|
||||||
}
|
}
|
||||||
::glColor3fv( Submodel->f4Diffuse ); // McZapkie-240702: zamiast ub
|
::glColor3fv( glm::value_ptr(Submodel->f4Diffuse) ); // McZapkie-240702: zamiast ub
|
||||||
// ...luminance
|
// ...luminance
|
||||||
if( Global::fLuminance < Submodel->fLight ) {
|
if( Global::fLuminance < Submodel->fLight ) {
|
||||||
// zeby swiecilo na kolorowo
|
// zeby swiecilo na kolorowo
|
||||||
::glMaterialfv( GL_FRONT, GL_EMISSION, Submodel->f4Diffuse );
|
::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr(Submodel->f4Diffuse) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// main draw call
|
// main draw call
|
||||||
@@ -1184,11 +1185,13 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
// w zaleznosci od koloru swiatla
|
// w zaleznosci od koloru swiatla
|
||||||
::glColor4ub(
|
::glColor4fv(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 0 ] * Global::DayLight.ambient[ 0 ] ) ),
|
glm::value_ptr(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 1 ] * Global::DayLight.ambient[ 1 ] ) ),
|
glm::vec4(
|
||||||
static_cast<GLubyte>( std::floor( Node->Diffuse[ 2 ] * Global::DayLight.ambient[ 2 ] ) ),
|
Node->Diffuse * glm::make_vec3( Global::DayLight.ambient ),
|
||||||
static_cast<GLubyte>( std::min( 255.0, 255000 * Node->fLineThickness / ( distancesquared + 1.0 ) ) ) );
|
std::min(
|
||||||
|
1.0,
|
||||||
|
1000.0 * Node->fLineThickness / ( distancesquared + 1.0 ) ) ) ) );
|
||||||
|
|
||||||
GfxRenderer.Bind( 0 );
|
GfxRenderer.Bind( 0 );
|
||||||
|
|
||||||
@@ -1212,10 +1215,7 @@ opengl_renderer::Render_Alpha( TGroundNode *Node ) {
|
|||||||
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
auto const originoffset = Node->m_rootposition - Global::pCameraPosition;
|
||||||
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
::glTranslated( originoffset.x, originoffset.y, originoffset.z );
|
||||||
|
|
||||||
::glColor3ub(
|
::glColor3fv( glm::value_ptr( Node->Diffuse ) );
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 0 ] ),
|
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 1 ] ),
|
|
||||||
static_cast<GLubyte>( Node->Diffuse[ 2 ] ) );
|
|
||||||
|
|
||||||
Bind( Node->TextureID );
|
Bind( Node->TextureID );
|
||||||
|
|
||||||
@@ -1392,11 +1392,11 @@ opengl_renderer::Render_Alpha( TSubModel *Submodel ) {
|
|||||||
// również 0
|
// również 0
|
||||||
Bind( Submodel->TextureID );
|
Bind( Submodel->TextureID );
|
||||||
}
|
}
|
||||||
::glColor3fv( Submodel->f4Diffuse ); // McZapkie-240702: zamiast ub
|
::glColor3fv( glm::value_ptr(Submodel->f4Diffuse) ); // McZapkie-240702: zamiast ub
|
||||||
// ...luminance
|
// ...luminance
|
||||||
if( Global::fLuminance < Submodel->fLight ) {
|
if( Global::fLuminance < Submodel->fLight ) {
|
||||||
// zeby swiecilo na kolorowo
|
// zeby swiecilo na kolorowo
|
||||||
::glMaterialfv( GL_FRONT, GL_EMISSION, Submodel->f4Diffuse );
|
::glMaterialfv( GL_FRONT, GL_EMISSION, glm::value_ptr(Submodel->f4Diffuse) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// main draw call
|
// main draw call
|
||||||
|
|||||||
3
stdafx.h
3
stdafx.h
@@ -85,5 +85,8 @@
|
|||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
#include <glm/gtc/epsilon.hpp>
|
||||||
|
#include <glm/gtx/rotate_vector.hpp>
|
||||||
|
#include <glm/gtx/norm.hpp>
|
||||||
|
|
||||||
#include "openglmatrixstack.h"
|
#include "openglmatrixstack.h"
|
||||||
@@ -59,9 +59,16 @@ clamp_circular( Type_ Value, Type_ const Range = static_cast<Type_>(360) ) {
|
|||||||
|
|
||||||
template <typename Type_>
|
template <typename Type_>
|
||||||
Type_
|
Type_
|
||||||
interpolate( Type_ const First, Type_ const Second, float const Factor ) {
|
interpolate( Type_ const &First, Type_ const &Second, float const Factor ) {
|
||||||
|
|
||||||
return ( First * ( 1.0f - Factor ) ) + ( Second * Factor );
|
return ( First * ( 1.0f - Factor ) ) + ( Second * Factor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Type_>
|
||||||
|
Type_
|
||||||
|
interpolate( Type_ const &First, Type_ const &Second, double const Factor ) {
|
||||||
|
|
||||||
|
return ( First * ( 1.0 - Factor ) ) + ( Second * Factor );
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user