mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
Merge remote-tracking branch 'refs/remotes/TMJ/mover_in_c++'
This commit is contained in:
@@ -445,7 +445,7 @@ bool TAnimModel::Init(std::string const &asName, std::string const &asReplacable
|
|||||||
asText = asReplacableTexture.substr(1, asReplacableTexture.length() - 1); // zapamiętanie tekstu
|
asText = asReplacableTexture.substr(1, asReplacableTexture.length() - 1); // zapamiętanie tekstu
|
||||||
else if (asReplacableTexture != "none")
|
else if (asReplacableTexture != "none")
|
||||||
m_materialdata.replacable_skins[1] =
|
m_materialdata.replacable_skins[1] =
|
||||||
GfxRenderer.GetTextureId( asReplacableTexture, "" );
|
GfxRenderer.Fetch_Texture( asReplacableTexture, "" );
|
||||||
if( ( m_materialdata.replacable_skins[ 1 ] != 0 )
|
if( ( m_materialdata.replacable_skins[ 1 ] != 0 )
|
||||||
&& ( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) ) {
|
&& ( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) ) {
|
||||||
// tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
@@ -606,6 +606,7 @@ int TAnimModel::Flags()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// 2011-03-16 funkcje renderowania z możliwością pochylania obiektów
|
// 2011-03-16 funkcje renderowania z możliwością pochylania obiektów
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void TAnimModel::Render( vector3 const &Position ) {
|
void TAnimModel::Render( vector3 const &Position ) {
|
||||||
RaAnimate(); // jednorazowe przeliczenie animacji
|
RaAnimate(); // jednorazowe przeliczenie animacji
|
||||||
RaPrepare();
|
RaPrepare();
|
||||||
@@ -617,7 +618,7 @@ void TAnimModel::RenderAlpha( vector3 const &Position ) {
|
|||||||
if( pModel ) // renderowanie rekurencyjne submodeli
|
if( pModel ) // renderowanie rekurencyjne submodeli
|
||||||
GfxRenderer.Render_Alpha( pModel, Material(), Position, vAngle );
|
GfxRenderer.Render_Alpha( pModel, Material(), Position, vAngle );
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
bool TAnimModel::TerrainLoaded()
|
bool TAnimModel::TerrainLoaded()
|
||||||
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
|
{ // zliczanie kwadratów kilometrowych (główna linia po Next) do tworznia tablicy
|
||||||
|
|||||||
@@ -164,8 +164,10 @@ class TAnimModel {
|
|||||||
bool Load(cParser *parser, bool ter = false);
|
bool Load(cParser *parser, bool ter = false);
|
||||||
TAnimContainer * AddContainer(char *pName);
|
TAnimContainer * AddContainer(char *pName);
|
||||||
TAnimContainer * GetContainer(char *pName);
|
TAnimContainer * GetContainer(char *pName);
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void Render( vector3 const &Position );
|
void Render( vector3 const &Position );
|
||||||
void RenderAlpha( vector3 const &Position );
|
void RenderAlpha( vector3 const &Position );
|
||||||
|
#endif
|
||||||
int Flags();
|
int Flags();
|
||||||
void RaAnglesSet(double a, double b, double c)
|
void RaAnglesSet(double a, double b, double c)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,13 +14,6 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
#include "logs.h"
|
#include "logs.h"
|
||||||
|
|
||||||
TButton::TButton()
|
|
||||||
{
|
|
||||||
iFeedbackBit = 0;
|
|
||||||
bData = NULL;
|
|
||||||
Clear();
|
|
||||||
};
|
|
||||||
|
|
||||||
void TButton::Clear(int i)
|
void TButton::Clear(int i)
|
||||||
{
|
{
|
||||||
pModelOn = nullptr;
|
pModelOn = nullptr;
|
||||||
|
|||||||
2
Button.h
2
Button.h
@@ -36,7 +36,7 @@ class TButton
|
|||||||
play( PSound Sound );
|
play( PSound Sound );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TButton();
|
TButton() = default;
|
||||||
void Clear(int const i = -1);
|
void Clear(int const i = -1);
|
||||||
inline void FeedbackBitSet(int const i) {
|
inline void FeedbackBitSet(int const i) {
|
||||||
iFeedbackBit = 1 << i; };
|
iFeedbackBit = 1 << i; };
|
||||||
|
|||||||
20
DynObj.cpp
20
DynObj.cpp
@@ -4064,7 +4064,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
{
|
{
|
||||||
std::string nowheretexture = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie
|
std::string nowheretexture = TextureTest(Global::asCurrentTexturePath + "nowhere"); // na razie prymitywnie
|
||||||
if( false == nowheretexture.empty() ) {
|
if( false == nowheretexture.empty() ) {
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( nowheretexture, "", 9 );
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( nowheretexture, "", 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_materialdata.multi_textures > 0) {
|
if (m_materialdata.multi_textures > 0) {
|
||||||
@@ -4076,7 +4076,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
int skinindex = 0;
|
int skinindex = 0;
|
||||||
std::string texturename; nameparser >> texturename;
|
std::string texturename; nameparser >> texturename;
|
||||||
while( ( texturename != "" ) && ( skinindex < 4 ) ) {
|
while( ( texturename != "" ) && ( skinindex < 4 ) ) {
|
||||||
m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + texturename, "" );
|
m_materialdata.replacable_skins[ skinindex + 1 ] = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + texturename, "" );
|
||||||
++skinindex;
|
++skinindex;
|
||||||
texturename = ""; nameparser >> texturename;
|
texturename = ""; nameparser >> texturename;
|
||||||
}
|
}
|
||||||
@@ -4086,7 +4086,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
// otherwise try the basic approach
|
// otherwise try the basic approach
|
||||||
int skinindex = 0;
|
int skinindex = 0;
|
||||||
do {
|
do {
|
||||||
texture_handle texture = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), "", Global::iDynamicFiltering, true );
|
texture_handle texture = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + ReplacableSkin + "," + std::to_string( skinindex + 1 ), "", Global::iDynamicFiltering, true );
|
||||||
if( texture == NULL ) {
|
if( texture == NULL ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4096,12 +4096,12 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
|||||||
m_materialdata.multi_textures = skinindex;
|
m_materialdata.multi_textures = skinindex;
|
||||||
if( m_materialdata.multi_textures == 0 ) {
|
if( m_materialdata.multi_textures == 0 ) {
|
||||||
// zestaw nie zadziałał, próbujemy normanie
|
// zestaw nie zadziałał, próbujemy normanie
|
||||||
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.GetTextureId( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
m_materialdata.replacable_skins[ 1 ] = GfxRenderer.Fetch_Texture( Global::asCurrentTexturePath + ReplacableSkin, "", Global::iDynamicFiltering );
|
||||||
}
|
}
|
||||||
if( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
|
if( GfxRenderer.Texture( m_materialdata.replacable_skins[ 1 ] ).has_alpha ) {
|
||||||
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
@@ -5424,13 +5424,13 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer)
|
|||||||
std::string x = TextureTest(asBaseDir + numer + "@" + MoverParameters->TypeName);
|
std::string x = TextureTest(asBaseDir + numer + "@" + MoverParameters->TypeName);
|
||||||
if (!x.empty())
|
if (!x.empty())
|
||||||
{
|
{
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
x = TextureTest(asBaseDir + numer );
|
x = TextureTest(asBaseDir + numer );
|
||||||
if (!x.empty())
|
if (!x.empty())
|
||||||
{
|
{
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (to.empty())
|
if (to.empty())
|
||||||
@@ -5438,17 +5438,17 @@ void TDynamicObject::DestinationSet(std::string to, std::string numer)
|
|||||||
x = TextureTest(asBaseDir + to + "@" + MoverParameters->TypeName); // w pierwszej kolejności z nazwą FIZ/MMD
|
x = TextureTest(asBaseDir + to + "@" + MoverParameters->TypeName); // w pierwszej kolejności z nazwą FIZ/MMD
|
||||||
if (!x.empty())
|
if (!x.empty())
|
||||||
{
|
{
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
x = TextureTest(asBaseDir + to); // na razie prymitywnie
|
x = TextureTest(asBaseDir + to); // na razie prymitywnie
|
||||||
if (!x.empty())
|
if (!x.empty())
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( x, "", 9 ); // rozmywania 0,1,4,5 nie nadają się
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = TextureTest(asBaseDir + "nowhere"); // jak nie znalazł dedykowanej, to niech daje nowhere
|
x = TextureTest(asBaseDir + "nowhere"); // jak nie znalazł dedykowanej, to niech daje nowhere
|
||||||
if (!x.empty())
|
if (!x.empty())
|
||||||
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.GetTextureId( x, "", 9 );
|
m_materialdata.replacable_skins[ 4 ] = GfxRenderer.Fetch_Texture( x, "", 9 );
|
||||||
}
|
}
|
||||||
// Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa tekstury nr 4
|
// Ra 2015-01: żeby zalogować błąd, trzeba by mieć pewność, że model używa tekstury nr 4
|
||||||
};
|
};
|
||||||
|
|||||||
19
Gauge.cpp
19
Gauge.cpp
@@ -139,8 +139,8 @@ TGauge::Load_mapping( cParser &Input ) {
|
|||||||
}
|
}
|
||||||
else if( key.find( "sound" ) == 0 ) {
|
else if( key.find( "sound" ) == 0 ) {
|
||||||
// sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value
|
// sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value
|
||||||
auto const indexstart = key.find_first_of( "1234567890" );
|
auto const indexstart = key.find_first_of( "-1234567890" );
|
||||||
auto const indexend = key.find_first_not_of( "1234567890", indexstart );
|
auto const indexend = key.find_first_not_of( "-1234567890", indexstart );
|
||||||
if( indexstart != std::string::npos ) {
|
if( indexstart != std::string::npos ) {
|
||||||
m_soundfxvalues.emplace(
|
m_soundfxvalues.emplace(
|
||||||
std::stoi( key.substr( indexstart, indexend - indexstart ) ),
|
std::stoi( key.substr( indexstart, indexend - indexstart ) ),
|
||||||
@@ -180,17 +180,20 @@ void TGauge::DecValue(double fNewDesired)
|
|||||||
void
|
void
|
||||||
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
|
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
|
||||||
|
|
||||||
if( static_cast<int>( std::round( ( fDesiredValue - fOffset ) / fScale ) ) == static_cast<int>( fNewDesired ) ) {
|
auto const desiredtimes100 = static_cast<int>( 100.0 * fNewDesired );
|
||||||
|
if( static_cast<int>( std::round( 100.0 * ( fDesiredValue - fOffset ) / fScale ) ) == desiredtimes100 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fDesiredValue = fNewDesired * fScale + fOffset;
|
fDesiredValue = fNewDesired * fScale + fOffset;
|
||||||
// if there's any sound associated with new requested value, play it
|
// if there's any sound associated with new requested value, play it
|
||||||
// check value-specific table first...
|
// check value-specific table first...
|
||||||
auto const desiredvalue = static_cast<int>( std::round( fNewDesired ) );
|
if( desiredtimes100 % 100 == 0 ) {
|
||||||
auto const lookup = m_soundfxvalues.find( desiredvalue );
|
// filter out values other than full integers
|
||||||
if( lookup != m_soundfxvalues.end() ) {
|
auto const lookup = m_soundfxvalues.find( desiredtimes100 / 100 );
|
||||||
play( lookup->second );
|
if( lookup != m_soundfxvalues.end() ) {
|
||||||
return;
|
play( lookup->second );
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ...and if there isn't any, fall back on the basic set...
|
// ...and if there isn't any, fall back on the basic set...
|
||||||
auto const currentvalue = GetValue();
|
auto const currentvalue = GetValue();
|
||||||
|
|||||||
15
Globals.cpp
15
Globals.cpp
@@ -87,6 +87,8 @@ float Global::Overcast { 0.1f }; // NOTE: all this weather stuff should be moved
|
|||||||
opengl_light Global::DayLight;
|
opengl_light Global::DayLight;
|
||||||
int Global::DynamicLightCount { 3 };
|
int Global::DynamicLightCount { 3 };
|
||||||
bool Global::ScaleSpecularValues { true };
|
bool Global::ScaleSpecularValues { true };
|
||||||
|
bool Global::RenderShadows { false };
|
||||||
|
Global::shadowtune_t Global::shadowtune = { 2048, 200.0f, 150.0f, 100.0f };
|
||||||
bool Global::bRollFix = true; // czy wykonać przeliczanie przechyłki
|
bool Global::bRollFix = true; // czy wykonać przeliczanie przechyłki
|
||||||
bool Global::bJoinEvents = false; // czy grupować eventy o tych samych nazwach
|
bool Global::bJoinEvents = false; // czy grupować eventy o tych samych nazwach
|
||||||
int Global::iHiddenEvents = 1; // czy łączyć eventy z torami poprzez nazwę toru
|
int Global::iHiddenEvents = 1; // czy łączyć eventy z torami poprzez nazwę toru
|
||||||
@@ -544,6 +546,19 @@ void Global::ConfigParse(cParser &Parser)
|
|||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
Parser >> Global::ScaleSpecularValues;
|
Parser >> Global::ScaleSpecularValues;
|
||||||
}
|
}
|
||||||
|
else if( token == "shadows" ) {
|
||||||
|
// shadow render toggle
|
||||||
|
Parser.getTokens();
|
||||||
|
Parser >> Global::RenderShadows;
|
||||||
|
}
|
||||||
|
else if( token == "shadowtune" ) {
|
||||||
|
Parser.getTokens( 4, false );
|
||||||
|
Parser
|
||||||
|
>> Global::shadowtune.map_size
|
||||||
|
>> Global::shadowtune.width
|
||||||
|
>> Global::shadowtune.depth
|
||||||
|
>> Global::shadowtune.distance;
|
||||||
|
}
|
||||||
else if (token == "smoothtraction")
|
else if (token == "smoothtraction")
|
||||||
{
|
{
|
||||||
// podwójna jasność ambient
|
// podwójna jasność ambient
|
||||||
|
|||||||
@@ -226,6 +226,13 @@ class Global
|
|||||||
static opengl_light DayLight;
|
static opengl_light DayLight;
|
||||||
static int DynamicLightCount;
|
static int DynamicLightCount;
|
||||||
static bool ScaleSpecularValues;
|
static bool ScaleSpecularValues;
|
||||||
|
static bool RenderShadows;
|
||||||
|
static struct shadowtune_t {
|
||||||
|
unsigned int map_size;
|
||||||
|
float width;
|
||||||
|
float depth;
|
||||||
|
float distance;
|
||||||
|
} shadowtune;
|
||||||
|
|
||||||
static int iSlowMotion;
|
static int iSlowMotion;
|
||||||
static TDynamicObject *changeDynObj;
|
static TDynamicObject *changeDynObj;
|
||||||
|
|||||||
11
Ground.cpp
11
Ground.cpp
@@ -49,15 +49,6 @@ extern "C"
|
|||||||
bool bCondition; // McZapkie: do testowania warunku na event multiple
|
bool bCondition; // McZapkie: do testowania warunku na event multiple
|
||||||
std::string LogComment;
|
std::string LogComment;
|
||||||
|
|
||||||
// tests whether provided points form a degenerate triangle
|
|
||||||
bool
|
|
||||||
degenerate( glm::dvec3 const &Vertex1, glm::dvec3 const &Vertex2, glm::dvec3 const &Vertex3 ) {
|
|
||||||
|
|
||||||
return ( ( Vertex1 == Vertex2 )
|
|
||||||
|| ( Vertex2 == Vertex3 )
|
|
||||||
|| ( Vertex3 == Vertex1 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Obiekt renderujący siatkę jest sztucznie tworzonym obiektem pomocniczym,
|
// Obiekt renderujący siatkę jest sztucznie tworzonym obiektem pomocniczym,
|
||||||
// grupującym siatki obiektów dla danej tekstury. Obiektami składowymi mogą
|
// grupującym siatki obiektów dla danej tekstury. Obiektami składowymi mogą
|
||||||
@@ -1330,7 +1321,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
|
|||||||
*parser >> token;
|
*parser >> token;
|
||||||
}
|
}
|
||||||
str = token;
|
str = token;
|
||||||
tmp->TextureID = GfxRenderer.GetTextureId( str, szTexturePath );
|
tmp->TextureID = GfxRenderer.Fetch_Texture( str );
|
||||||
bool const clamps = (
|
bool const clamps = (
|
||||||
tmp->TextureID ?
|
tmp->TextureID ?
|
||||||
GfxRenderer.Texture( tmp->TextureID ).traits.find( 's' ) != std::string::npos :
|
GfxRenderer.Texture( tmp->TextureID ).traits.find( 's' ) != std::string::npos :
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ std::string to_string( glm::tvec3<Type_, Precision_> const &Value ) {
|
|||||||
return to_string( Value.x, 2 ) + ", " + to_string( Value.y, 2 ) + ", " + to_string( Value.z, 2 );
|
return to_string( Value.x, 2 ) + ", " + to_string( Value.y, 2 ) + ", " + to_string( Value.z, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Type_, glm::precision Precision_ = glm::defaultp>
|
||||||
|
std::string to_string( glm::tvec4<Type_, Precision_> const &Value, int const Width = 2 ) {
|
||||||
|
return to_string( Value.x, Width ) + ", " + to_string( Value.y, Width ) + ", " + to_string( Value.z, Width ) + ", " + to_string( Value.w, Width );
|
||||||
|
}
|
||||||
|
|
||||||
int stol_def(const std::string & str, const int & DefaultValue);
|
int stol_def(const std::string & str, const int & DefaultValue);
|
||||||
|
|
||||||
std::string ToLower(std::string const &text);
|
std::string ToLower(std::string const &text);
|
||||||
|
|||||||
10
Model3d.cpp
10
Model3d.cpp
@@ -341,7 +341,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
|
|||||||
if( texture.find_first_of( "/\\" ) == texture.npos ) {
|
if( texture.find_first_of( "/\\" ) == texture.npos ) {
|
||||||
texture.insert( 0, Global::asCurrentTexturePath );
|
texture.insert( 0, Global::asCurrentTexturePath );
|
||||||
}
|
}
|
||||||
TextureID = GfxRenderer.GetTextureId( texture, szTexturePath );
|
TextureID = GfxRenderer.Fetch_Texture( texture );
|
||||||
// renderowanie w cyklu przezroczystych tylko jeśli:
|
// renderowanie w cyklu przezroczystych tylko jeśli:
|
||||||
// 1. Opacity=0 (przejściowo <1, czy tam <100) oraz
|
// 1. Opacity=0 (przejściowo <1, czy tam <100) oraz
|
||||||
// 2. tekstura ma przezroczystość
|
// 2. tekstura ma przezroczystość
|
||||||
@@ -460,10 +460,8 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
|
|||||||
>> Vertices[i].texture.t;
|
>> Vertices[i].texture.t;
|
||||||
if (i % 3 == 2) {
|
if (i % 3 == 2) {
|
||||||
// jeżeli wczytano 3 punkty
|
// jeżeli wczytano 3 punkty
|
||||||
if (Vertices[i ].position == Vertices[i - 1].position
|
if( true == degenerate( Vertices[ i ].position, Vertices[ i - 1 ].position, Vertices[ i - 2 ].position ) ) {
|
||||||
|| Vertices[i - 1].position == Vertices[i - 2].position
|
// jeżeli punkty się nakładają na siebie
|
||||||
|| Vertices[i - 2].position == Vertices[i ].position)
|
|
||||||
{ // jeżeli punkty się nakładają na siebie
|
|
||||||
--facecount; // o jeden trójkąt mniej
|
--facecount; // o jeden trójkąt mniej
|
||||||
iNumVerts -= 3; // czyli o 3 wierzchołki
|
iNumVerts -= 3; // czyli o 3 wierzchołki
|
||||||
i -= 3; // wczytanie kolejnego w to miejsce
|
i -= 3; // wczytanie kolejnego w to miejsce
|
||||||
@@ -1670,7 +1668,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
pTexture = t->at(iTexture);
|
pTexture = t->at(iTexture);
|
||||||
if (pTexture.find_last_of("/\\") == std::string::npos)
|
if (pTexture.find_last_of("/\\") == std::string::npos)
|
||||||
pTexture.insert(0, Global::asCurrentTexturePath);
|
pTexture.insert(0, Global::asCurrentTexturePath);
|
||||||
TextureID = GfxRenderer.GetTextureId(pTexture, szTexturePath);
|
TextureID = GfxRenderer.Fetch_Texture(pTexture);
|
||||||
if( ( iFlags & 0x30 ) == 0 ) {
|
if( ( iFlags & 0x30 ) == 0 ) {
|
||||||
// texture-alpha based fallback if for some reason we don't have opacity flag set yet
|
// texture-alpha based fallback if for some reason we don't have opacity flag set yet
|
||||||
iFlags |=
|
iFlags |=
|
||||||
|
|||||||
53
Track.cpp
53
Track.cpp
@@ -483,20 +483,20 @@ void TTrack::Load(cParser *parser, vector3 pOrigin, std::string name)
|
|||||||
{
|
{
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> str; // railtex
|
*parser >> str; // railtex
|
||||||
TextureID1 = (str == "none" ? 0 : GfxRenderer.GetTextureId(
|
TextureID1 = (
|
||||||
str, szTexturePath,
|
str == "none" ?
|
||||||
(iCategoryFlag & 1) ? Global::iRailProFiltering :
|
NULL :
|
||||||
Global::iBallastFiltering));
|
GfxRenderer.Fetch_Texture( str ) );
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> fTexLength; // tex tile length
|
*parser >> fTexLength; // tex tile length
|
||||||
if (fTexLength < 0.01)
|
if (fTexLength < 0.01)
|
||||||
fTexLength = 4; // Ra: zabezpiecznie przed zawieszeniem
|
fTexLength = 4; // Ra: zabezpiecznie przed zawieszeniem
|
||||||
parser->getTokens();
|
parser->getTokens();
|
||||||
*parser >> str; // sub || railtex
|
*parser >> str; // sub || railtex
|
||||||
TextureID2 = (str == "none" ? 0 : GfxRenderer.GetTextureId(
|
TextureID2 = (
|
||||||
str, szTexturePath,
|
str == "none" ?
|
||||||
(eType == tt_Normal) ? Global::iBallastFiltering :
|
NULL :
|
||||||
Global::iRailProFiltering));
|
GfxRenderer.Fetch_Texture( str ) );
|
||||||
parser->getTokens(3);
|
parser->getTokens(3);
|
||||||
*parser >> fTexHeight1 >> fTexWidth >> fTexSlope;
|
*parser >> fTexHeight1 >> fTexWidth >> fTexSlope;
|
||||||
if (iCategoryFlag & 4)
|
if (iCategoryFlag & 4)
|
||||||
@@ -1267,31 +1267,32 @@ void TTrack::create_geometry( geometrybank_handle const &Bank ) {
|
|||||||
}
|
}
|
||||||
vertex_array vertices;
|
vertex_array vertices;
|
||||||
Segment->RenderLoft(vertices, origin, bpts1, iTrapezoid ? -4 : 4, fTexLength);
|
Segment->RenderLoft(vertices, origin, bpts1, iTrapezoid ? -4 : 4, fTexLength);
|
||||||
|
if( ( Bank != 0 ) && ( true == Geometry2.empty() ) ) {
|
||||||
|
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
|
||||||
|
}
|
||||||
if( ( Bank == 0 ) && ( false == Geometry2.empty() ) ) {
|
if( ( Bank == 0 ) && ( false == Geometry2.empty() ) ) {
|
||||||
// special variant, replace existing data for a turntable track
|
// special variant, replace existing data for a turntable track
|
||||||
GfxRenderer.Replace( vertices, Geometry2[ 0 ] );
|
GfxRenderer.Replace( vertices, Geometry2[ 0 ] );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Geometry2.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (TextureID1)
|
if (TextureID1)
|
||||||
{ // szyny - generujemy dwie, najwyżej rysować się będzie jedną
|
{ // szyny - generujemy dwie, najwyżej rysować się będzie jedną
|
||||||
vertex_array vertices;
|
vertex_array vertices;
|
||||||
|
if( ( Bank != 0 ) && ( true == Geometry1.empty() ) ) {
|
||||||
|
Segment->RenderLoft( vertices, origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
||||||
|
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
|
||||||
|
vertices.clear(); // reuse the scratchpad
|
||||||
|
Segment->RenderLoft( vertices, origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
||||||
|
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
|
||||||
|
}
|
||||||
if( ( Bank == 0 ) && ( false == Geometry1.empty() ) ) {
|
if( ( Bank == 0 ) && ( false == Geometry1.empty() ) ) {
|
||||||
|
// special variant, replace existing data for a turntable track
|
||||||
Segment->RenderLoft( vertices, origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
Segment->RenderLoft( vertices, origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
||||||
GfxRenderer.Replace( vertices, Geometry1[ 0 ] );
|
GfxRenderer.Replace( vertices, Geometry1[ 0 ] );
|
||||||
vertices.clear(); // reuse the scratchpad
|
vertices.clear(); // reuse the scratchpad
|
||||||
Segment->RenderLoft( vertices, origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
Segment->RenderLoft( vertices, origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
||||||
GfxRenderer.Replace( vertices, Geometry1[ 1 ] );
|
GfxRenderer.Replace( vertices, Geometry1[ 1 ] );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Segment->RenderLoft( vertices, origin, rpts1, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
|
||||||
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
|
|
||||||
vertices.clear(); // reuse the scratchpad
|
|
||||||
Segment->RenderLoft( vertices, origin, rpts2, iTrapezoid ? -nnumPts : nnumPts, fTexLength );
|
|
||||||
Geometry1.emplace_back( GfxRenderer.Insert( vertices, Bank, GL_TRIANGLE_STRIP ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case tt_Switch: // dla zwrotnicy dwa razy szyny
|
case tt_Switch: // dla zwrotnicy dwa razy szyny
|
||||||
@@ -1865,22 +1866,6 @@ void TTrack::EnvironmentReset()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void TTrack::RenderDyn()
|
|
||||||
{ // renderowanie nieprzezroczystych fragmentów pojazdów
|
|
||||||
for( auto dynamic : Dynamics ) {
|
|
||||||
// sam sprawdza, czy VBO; zmienia kontekst VBO!
|
|
||||||
GfxRenderer.Render( dynamic );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void TTrack::RenderDynAlpha()
|
|
||||||
{ // renderowanie przezroczystych fragmentów pojazdów
|
|
||||||
for( auto dynamic : Dynamics ) {
|
|
||||||
// sam sprawdza, czy VBO; zmienia kontekst VBO!
|
|
||||||
GfxRenderer.Render_Alpha( dynamic );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void TTrack::RenderDynSounds()
|
void TTrack::RenderDynSounds()
|
||||||
{ // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
{ // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
||||||
for( auto dynamic : Dynamics ) {
|
for( auto dynamic : Dynamics ) {
|
||||||
|
|||||||
2
Track.h
2
Track.h
@@ -236,8 +236,6 @@ public:
|
|||||||
/*
|
/*
|
||||||
void RaRenderVBO(int iPtr); // renderowanie z VBO sektora
|
void RaRenderVBO(int iPtr); // renderowanie z VBO sektora
|
||||||
*/
|
*/
|
||||||
void RenderDyn(); // renderowanie nieprzezroczystych pojazdów (oba tryby)
|
|
||||||
void RenderDynAlpha(); // renderowanie przezroczystych pojazdów (oba tryby)
|
|
||||||
void RenderDynSounds(); // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
void RenderDynSounds(); // odtwarzanie dźwięków pojazdów jest niezależne od ich wyświetlania
|
||||||
|
|
||||||
void RaOwnerSet(TSubRect *o) {
|
void RaOwnerSet(TSubRect *o) {
|
||||||
|
|||||||
13
World.cpp
13
World.cpp
@@ -32,6 +32,8 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "uilayer.h"
|
#include "uilayer.h"
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
|
|
||||||
|
//#define EU07_USE_DEBUG_SHADOWMAP
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
TDynamicObject *Controlled = NULL; // pojazd, który prowadzimy
|
TDynamicObject *Controlled = NULL; // pojazd, który prowadzimy
|
||||||
@@ -632,8 +634,13 @@ void TWorld::OnKeyDown(int cKey)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GLFW_KEY_F8: {
|
case GLFW_KEY_F8: {
|
||||||
|
#ifdef EU07_USE_DEBUG_SHADOWMAP
|
||||||
|
if( Global::iTextMode == cKey ) { ++Global::iScreenMode[ cKey - GLFW_KEY_F1 ]; }
|
||||||
|
if( Global::iScreenMode[ cKey - GLFW_KEY_F1 ] > 1 ) {
|
||||||
|
Global::iScreenMode[ cKey - GLFW_KEY_F1 ] = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Global::iTextMode = cKey;
|
Global::iTextMode = cKey;
|
||||||
// FPS
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GLFW_KEY_F9: {
|
case GLFW_KEY_F9: {
|
||||||
@@ -956,8 +963,6 @@ void TWorld::FollowView(bool wycisz) {
|
|||||||
+ Train->GetDirection() * 5.0 * Train->Dynamic()->MoverParameters->ActiveCab;
|
+ Train->GetDirection() * 5.0 * Train->Dynamic()->MoverParameters->ActiveCab;
|
||||||
}
|
}
|
||||||
Train->pMechOffset = Train->pMechSittingPosition;
|
Train->pMechOffset = Train->pMechSittingPosition;
|
||||||
|
|
||||||
Global::SetCameraPosition( Train->Dynamic() ->GetPosition()); // tu ustawić nową, bo od niej liczą się odległości
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1696,7 +1701,7 @@ TWorld::Update_UI() {
|
|||||||
std::to_string( int( tmp->MoverParameters->Im ) ) )
|
std::to_string( int( tmp->MoverParameters->Im ) ) )
|
||||||
+ "; U=" + to_string( int( tmp->MoverParameters->RunningTraction.TractionVoltage + 0.5 ) )
|
+ "; U=" + to_string( int( tmp->MoverParameters->RunningTraction.TractionVoltage + 0.5 ) )
|
||||||
+ "; R=" +
|
+ "; R=" +
|
||||||
( tmp->MoverParameters->RunningShape.R > 100000.0 ?
|
( std::abs( tmp->MoverParameters->RunningShape.R ) > 10000.0 ?
|
||||||
"~0.0" :
|
"~0.0" :
|
||||||
to_string( tmp->MoverParameters->RunningShape.R, 1 ) )
|
to_string( tmp->MoverParameters->RunningShape.R, 1 ) )
|
||||||
+ " An=" + to_string( tmp->MoverParameters->AccN, 2 ); // przyspieszenie poprzeczne
|
+ " An=" + to_string( tmp->MoverParameters->AccN, 2 ); // przyspieszenie poprzeczne
|
||||||
|
|||||||
@@ -125,9 +125,11 @@ mouse_input::button( int const Button, int const Action ) {
|
|||||||
// TODO: pass correct entity id once the missing systems are in place
|
// TODO: pass correct entity id once the missing systems are in place
|
||||||
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
m_relay.post( mousecommand, 0, 0, Action, 0 );
|
||||||
m_updateaccumulator = 0.0; // prevent potential command repeat right after issuing one
|
m_updateaccumulator = 0.0; // prevent potential command repeat right after issuing one
|
||||||
|
/*
|
||||||
if( mousecommand == user_command::mastercontrollerincrease ) {
|
if( mousecommand == user_command::mastercontrollerincrease ) {
|
||||||
m_updateaccumulator -= 0.15; // extra pause on first increase of master controller
|
m_updateaccumulator -= 0.15; // extra pause on first increase of master controller
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
switch( mousecommand ) {
|
switch( mousecommand ) {
|
||||||
case user_command::mastercontrollerincrease:
|
case user_command::mastercontrollerincrease:
|
||||||
case user_command::mastercontrollerdecrease:
|
case user_command::mastercontrollerdecrease:
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ geometry_bank::append( vertex_array &Vertices, geometry_handle const &Geometry )
|
|||||||
|
|
||||||
// draws geometry stored in specified chunk
|
// draws geometry stored in specified chunk
|
||||||
void
|
void
|
||||||
geometry_bank::draw( geometry_handle const &Geometry, unsigned int const Streams ) {
|
geometry_bank::draw( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) {
|
||||||
// template method implementation
|
// template method implementation
|
||||||
draw_( Geometry, Streams );
|
draw_( Geometry, Units, Streams );
|
||||||
}
|
}
|
||||||
|
|
||||||
// frees subclass-specific resources associated with the bank, typically called when the bank wasn't in use for a period of time
|
// frees subclass-specific resources associated with the bank, typically called when the bank wasn't in use for a period of time
|
||||||
@@ -148,7 +148,7 @@ opengl_vbogeometrybank::replace_( geometry_handle const &Geometry ) {
|
|||||||
|
|
||||||
// draw() subclass details
|
// draw() subclass details
|
||||||
void
|
void
|
||||||
opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, unsigned int const Streams ) {
|
opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) {
|
||||||
|
|
||||||
if( m_buffer == NULL ) {
|
if( m_buffer == NULL ) {
|
||||||
// if there's no buffer, we'll have to make one
|
// if there's no buffer, we'll have to make one
|
||||||
@@ -203,7 +203,7 @@ opengl_vbogeometrybank::draw_( geometry_handle const &Geometry, unsigned int con
|
|||||||
chunkrecord.is_good = true;
|
chunkrecord.is_good = true;
|
||||||
}
|
}
|
||||||
if( m_activestreams != Streams ) {
|
if( m_activestreams != Streams ) {
|
||||||
bind_streams( Streams );
|
bind_streams( Units, Streams );
|
||||||
}
|
}
|
||||||
// ...render...
|
// ...render...
|
||||||
::glDrawArrays( chunk.type, chunkrecord.offset, chunkrecord.size );
|
::glDrawArrays( chunk.type, chunkrecord.offset, chunkrecord.size );
|
||||||
@@ -239,7 +239,7 @@ opengl_vbogeometrybank::delete_buffer() {
|
|||||||
::glDeleteBuffers( 1, &m_buffer );
|
::glDeleteBuffers( 1, &m_buffer );
|
||||||
if( m_activebuffer == m_buffer ) {
|
if( m_activebuffer == m_buffer ) {
|
||||||
m_activebuffer = NULL;
|
m_activebuffer = NULL;
|
||||||
bind_streams( stream::none );
|
release_streams();
|
||||||
}
|
}
|
||||||
m_buffer = NULL;
|
m_buffer = NULL;
|
||||||
m_buffercapacity = 0;
|
m_buffercapacity = 0;
|
||||||
@@ -249,7 +249,7 @@ opengl_vbogeometrybank::delete_buffer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
opengl_vbogeometrybank::bind_streams( unsigned int const Streams ) {
|
opengl_vbogeometrybank::bind_streams( stream_units const &Units, unsigned int const Streams ) {
|
||||||
|
|
||||||
if( Streams & stream::position ) {
|
if( Streams & stream::position ) {
|
||||||
::glVertexPointer( 3, GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) );
|
::glVertexPointer( 3, GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) );
|
||||||
@@ -274,6 +274,7 @@ opengl_vbogeometrybank::bind_streams( unsigned int const Streams ) {
|
|||||||
::glDisableClientState( GL_COLOR_ARRAY );
|
::glDisableClientState( GL_COLOR_ARRAY );
|
||||||
}
|
}
|
||||||
if( Streams & stream::texture ) {
|
if( Streams & stream::texture ) {
|
||||||
|
::glClientActiveTexture( Units.texture );
|
||||||
::glTexCoordPointer( 2, GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) + 24 );
|
::glTexCoordPointer( 2, GL_FLOAT, sizeof( basic_vertex ), static_cast<char *>( nullptr ) + 24 );
|
||||||
::glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
::glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||||
}
|
}
|
||||||
@@ -284,6 +285,17 @@ opengl_vbogeometrybank::bind_streams( unsigned int const Streams ) {
|
|||||||
m_activestreams = Streams;
|
m_activestreams = Streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
opengl_vbogeometrybank::release_streams() {
|
||||||
|
|
||||||
|
::glDisableClientState( GL_VERTEX_ARRAY );
|
||||||
|
::glDisableClientState( GL_NORMAL_ARRAY );
|
||||||
|
::glDisableClientState( GL_COLOR_ARRAY );
|
||||||
|
::glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||||
|
|
||||||
|
m_activestreams = stream::none;
|
||||||
|
}
|
||||||
|
|
||||||
// opengl display list based variant of the geometry bank
|
// opengl display list based variant of the geometry bank
|
||||||
|
|
||||||
// create() subclass details
|
// create() subclass details
|
||||||
@@ -302,7 +314,7 @@ opengl_dlgeometrybank::replace_( geometry_handle const &Geometry ) {
|
|||||||
|
|
||||||
// draw() subclass details
|
// draw() subclass details
|
||||||
void
|
void
|
||||||
opengl_dlgeometrybank::draw_( geometry_handle const &Geometry, unsigned int const Streams ) {
|
opengl_dlgeometrybank::draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) {
|
||||||
|
|
||||||
auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ];
|
auto &chunkrecord = m_chunkrecords[ Geometry.chunk - 1 ];
|
||||||
if( chunkrecord.streams != Streams ) {
|
if( chunkrecord.streams != Streams ) {
|
||||||
@@ -319,7 +331,7 @@ opengl_dlgeometrybank::draw_( geometry_handle const &Geometry, unsigned int cons
|
|||||||
for( auto const &vertex : chunk.vertices ) {
|
for( auto const &vertex : chunk.vertices ) {
|
||||||
if( Streams & stream::normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); }
|
if( Streams & stream::normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); }
|
||||||
else if( Streams & stream::color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); }
|
else if( Streams & stream::color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); }
|
||||||
if( Streams & stream::texture ) { ::glTexCoord2fv( glm::value_ptr( vertex.texture ) ); }
|
if( Streams & stream::texture ) { ::glMultiTexCoord2fv( Units.texture, glm::value_ptr( vertex.texture ) ); }
|
||||||
if( Streams & stream::position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); }
|
if( Streams & stream::position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); }
|
||||||
}
|
}
|
||||||
::glEnd();
|
::glEnd();
|
||||||
@@ -404,7 +416,7 @@ geometrybank_manager::draw( geometry_handle const &Geometry, unsigned int const
|
|||||||
auto &bankrecord = bank( Geometry );
|
auto &bankrecord = bank( Geometry );
|
||||||
|
|
||||||
bankrecord.second = m_garbagecollector.timestamp();
|
bankrecord.second = m_garbagecollector.timestamp();
|
||||||
bankrecord.first->draw( Geometry, Streams );
|
bankrecord.first->draw( Geometry, m_units, Streams );
|
||||||
}
|
}
|
||||||
|
|
||||||
// provides direct access to vertex data of specfied chunk
|
// provides direct access to vertex data of specfied chunk
|
||||||
|
|||||||
@@ -42,7 +42,12 @@ enum stream {
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsigned int const basic_streams { stream::position | stream::normal | stream::texture };
|
unsigned int const basic_streams { stream::position | stream::normal | stream::texture };
|
||||||
unsigned int const color_streams{ stream::position | stream::color | stream::texture };
|
unsigned int const color_streams { stream::position | stream::color | stream::texture };
|
||||||
|
|
||||||
|
struct stream_units {
|
||||||
|
|
||||||
|
GLint texture { GL_TEXTURE0 }; // unit associated with main texture data stream. TODO: allow multiple units per stream
|
||||||
|
};
|
||||||
|
|
||||||
typedef std::vector<basic_vertex> vertex_array;
|
typedef std::vector<basic_vertex> vertex_array;
|
||||||
|
|
||||||
@@ -98,11 +103,11 @@ public:
|
|||||||
append( vertex_array &Vertices, geometry_handle const &Geometry );
|
append( vertex_array &Vertices, geometry_handle const &Geometry );
|
||||||
// draws geometry stored in specified chunk
|
// draws geometry stored in specified chunk
|
||||||
void
|
void
|
||||||
draw( geometry_handle const &Geometry, unsigned int const Streams = basic_streams );
|
draw( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams = basic_streams );
|
||||||
// draws geometry stored in supplied list of chunks
|
// draws geometry stored in supplied list of chunks
|
||||||
template <typename Iterator_>
|
template <typename Iterator_>
|
||||||
void
|
void
|
||||||
draw( Iterator_ First, Iterator_ Last, unsigned int const Streams = basic_streams ) { while( First != Last ) { draw( *First, Streams ); ++First; } }
|
draw( Iterator_ First, Iterator_ Last, stream_units const &Units, unsigned int const Streams = basic_streams ) { while( First != Last ) { draw( *First, Units, Streams ); ++First; } }
|
||||||
// frees subclass-specific resources associated with the bank, typically called when the bank wasn't in use for a period of time
|
// frees subclass-specific resources associated with the bank, typically called when the bank wasn't in use for a period of time
|
||||||
void
|
void
|
||||||
release();
|
release();
|
||||||
@@ -145,7 +150,7 @@ private:
|
|||||||
// replace() subclass details
|
// replace() subclass details
|
||||||
virtual void replace_( geometry_handle const &Geometry ) = 0;
|
virtual void replace_( geometry_handle const &Geometry ) = 0;
|
||||||
// draw() subclass details
|
// draw() subclass details
|
||||||
virtual void draw_( geometry_handle const &Geometry, unsigned int const Streams ) = 0;
|
virtual void draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams ) = 0;
|
||||||
// resource release subclass details
|
// resource release subclass details
|
||||||
virtual void release_() = 0;
|
virtual void release_() = 0;
|
||||||
};
|
};
|
||||||
@@ -186,8 +191,8 @@ private:
|
|||||||
replace_( geometry_handle const &Geometry );
|
replace_( geometry_handle const &Geometry );
|
||||||
// draw() subclass details
|
// draw() subclass details
|
||||||
void
|
void
|
||||||
draw_( geometry_handle const &Geometry, unsigned int const Streams );
|
draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams );
|
||||||
// release () subclass details
|
// release() subclass details
|
||||||
void
|
void
|
||||||
release_();
|
release_();
|
||||||
void
|
void
|
||||||
@@ -195,7 +200,9 @@ private:
|
|||||||
void
|
void
|
||||||
delete_buffer();
|
delete_buffer();
|
||||||
void
|
void
|
||||||
bind_streams( unsigned int const Streams );
|
bind_streams( stream_units const &Units, unsigned int const Streams );
|
||||||
|
void
|
||||||
|
release_streams();
|
||||||
|
|
||||||
// members:
|
// members:
|
||||||
static GLuint m_activebuffer; // buffer bound currently on the opengl end, if any
|
static GLuint m_activebuffer; // buffer bound currently on the opengl end, if any
|
||||||
@@ -236,7 +243,7 @@ private:
|
|||||||
replace_( geometry_handle const &Geometry );
|
replace_( geometry_handle const &Geometry );
|
||||||
// draw() subclass details
|
// draw() subclass details
|
||||||
void
|
void
|
||||||
draw_( geometry_handle const &Geometry, unsigned int const Streams );
|
draw_( geometry_handle const &Geometry, stream_units const &Units, unsigned int const Streams );
|
||||||
// release () subclass details
|
// release () subclass details
|
||||||
void
|
void
|
||||||
release_();
|
release_();
|
||||||
@@ -282,6 +289,9 @@ public:
|
|||||||
// provides direct access to vertex data of specfied chunk
|
// provides direct access to vertex data of specfied chunk
|
||||||
vertex_array const &
|
vertex_array const &
|
||||||
vertices( geometry_handle const &Geometry ) const;
|
vertices( geometry_handle const &Geometry ) const;
|
||||||
|
// sets target texture unit for the texture data stream
|
||||||
|
stream_units &
|
||||||
|
units() { return m_units; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// types:
|
// types:
|
||||||
@@ -294,6 +304,7 @@ private:
|
|||||||
// members:
|
// members:
|
||||||
geometrybanktimepointpair_sequence m_geometrybanks;
|
geometrybanktimepointpair_sequence m_geometrybanks;
|
||||||
garbage_collector<geometrybanktimepointpair_sequence> m_garbagecollector { m_geometrybanks, 60, 120, "geometry buffer" };
|
garbage_collector<geometrybanktimepointpair_sequence> m_garbagecollector { m_geometrybanks, 60, 120, "geometry buffer" };
|
||||||
|
stream_units m_units;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
inline
|
inline
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ public:
|
|||||||
multiply( glm::mat4 const &Matrix ) {
|
multiply( glm::mat4 const &Matrix ) {
|
||||||
m_stack.top() *= Matrix;
|
m_stack.top() *= Matrix;
|
||||||
upload(); }
|
upload(); }
|
||||||
|
void
|
||||||
|
ortho( float const Left, float const Right, float const Bottom, float const Top, float const Znear, float const Zfar ) {
|
||||||
|
m_stack.top() *= glm::ortho( Left, Right, Bottom, Top, Znear, Zfar );
|
||||||
|
upload(); }
|
||||||
void
|
void
|
||||||
perspective( float const Fovy, float const Aspect, float const Znear, float const Zfar ) {
|
perspective( float const Fovy, float const Aspect, float const Znear, float const Zfar ) {
|
||||||
m_stack.top() *= glm::perspective( Fovy, Aspect, Znear, Zfar );
|
m_stack.top() *= glm::perspective( Fovy, Aspect, Znear, Zfar );
|
||||||
@@ -132,10 +136,20 @@ public:
|
|||||||
m_stacks[ m_mode ].multiply(
|
m_stacks[ m_mode ].multiply(
|
||||||
glm::make_mat4( Matrix ) ); }
|
glm::make_mat4( Matrix ) ); }
|
||||||
template <typename Type_>
|
template <typename Type_>
|
||||||
|
void
|
||||||
|
ortho( Type_ const Left, Type_ const Right, Type_ const Bottom, Type_ const Top, Type_ const Znear, Type_ const Zfar ) {
|
||||||
|
m_stacks[ m_mode ].ortho(
|
||||||
|
static_cast<float>( Left ),
|
||||||
|
static_cast<float>( Right ),
|
||||||
|
static_cast<float>( Bottom ),
|
||||||
|
static_cast<float>( Top ),
|
||||||
|
static_cast<float>( Znear ),
|
||||||
|
static_cast<float>( Zfar ) ); }
|
||||||
|
template <typename Type_>
|
||||||
void
|
void
|
||||||
perspective( Type_ const Fovy, Type_ const Aspect, Type_ const Znear, Type_ const Zfar ) {
|
perspective( Type_ const Fovy, Type_ const Aspect, Type_ const Znear, Type_ const Zfar ) {
|
||||||
m_stacks[ m_mode ].perspective(
|
m_stacks[ m_mode ].perspective(
|
||||||
static_cast<float>(Fovy) * 0.0174532925f, // deg2rad
|
static_cast<float>( glm::radians( Fovy ) ),
|
||||||
static_cast<float>( Aspect ),
|
static_cast<float>( Aspect ),
|
||||||
static_cast<float>( Znear ),
|
static_cast<float>( Znear ),
|
||||||
static_cast<float>( Zfar ) ); }
|
static_cast<float>( Zfar ) ); }
|
||||||
@@ -177,6 +191,7 @@ extern opengl_matrices OpenGLMatrices;
|
|||||||
// NOTE: no scale override as we aren't using it anywhere
|
// NOTE: no scale override as we aren't using it anywhere
|
||||||
#define glMultMatrixd OpenGLMatrices.multiply
|
#define glMultMatrixd OpenGLMatrices.multiply
|
||||||
#define glMultMatrixf OpenGLMatrices.multiply
|
#define glMultMatrixf OpenGLMatrices.multiply
|
||||||
|
#define glOrtho OpenGLMatrices.ortho
|
||||||
#define gluPerspective OpenGLMatrices.perspective
|
#define gluPerspective OpenGLMatrices.perspective
|
||||||
#define gluLookAt OpenGLMatrices.look_at
|
#define gluLookAt OpenGLMatrices.look_at
|
||||||
|
|
||||||
|
|||||||
929
renderer.cpp
929
renderer.cpp
File diff suppressed because it is too large
Load Diff
69
renderer.h
69
renderer.h
@@ -119,21 +119,6 @@ public:
|
|||||||
// main draw call. returns false on error
|
// main draw call. returns false on error
|
||||||
bool
|
bool
|
||||||
Render();
|
Render();
|
||||||
// render sub-methods, temporarily exposed until we complete migrating render code to the renderer
|
|
||||||
bool
|
|
||||||
Render( TDynamicObject *Dynamic );
|
|
||||||
bool
|
|
||||||
Render( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
|
||||||
bool
|
|
||||||
Render( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
|
||||||
void
|
|
||||||
Render( TSubModel *Submodel );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TDynamicObject *Dynamic );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
|
||||||
bool
|
|
||||||
Render_Alpha( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
|
||||||
// geometry methods
|
// geometry methods
|
||||||
// NOTE: hands-on geometry management is exposed as a temporary measure; ultimately all visualization data should be generated/handled automatically by the renderer itself
|
// NOTE: hands-on geometry management is exposed as a temporary measure; ultimately all visualization data should be generated/handled automatically by the renderer itself
|
||||||
// creates a new geometry bank. returns: handle to the bank or NULL
|
// creates a new geometry bank. returns: handle to the bank or NULL
|
||||||
@@ -153,7 +138,7 @@ public:
|
|||||||
Vertices( geometry_handle const &Geometry ) const;
|
Vertices( geometry_handle const &Geometry ) const;
|
||||||
// texture methods
|
// texture methods
|
||||||
texture_handle
|
texture_handle
|
||||||
GetTextureId( std::string Filename, std::string const &Dir, int const Filter = -1, bool const Loadnow = true );
|
Fetch_Texture( std::string const &Filename, std::string const &Dir = szTexturePath, int const Filter = -1, bool const Loadnow = true );
|
||||||
void
|
void
|
||||||
Bind( texture_handle const Texture );
|
Bind( texture_handle const Texture );
|
||||||
opengl_texture const &
|
opengl_texture const &
|
||||||
@@ -174,7 +159,7 @@ public:
|
|||||||
TGroundNode const *
|
TGroundNode const *
|
||||||
Update_Pick_Node();
|
Update_Pick_Node();
|
||||||
// debug performance string
|
// debug performance string
|
||||||
std::string const &
|
std::string
|
||||||
Info() const;
|
Info() const;
|
||||||
|
|
||||||
// members
|
// members
|
||||||
@@ -184,6 +169,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
// types
|
// types
|
||||||
enum class rendermode {
|
enum class rendermode {
|
||||||
|
none,
|
||||||
color,
|
color,
|
||||||
shadows,
|
shadows,
|
||||||
pickcontrols,
|
pickcontrols,
|
||||||
@@ -209,12 +195,30 @@ private:
|
|||||||
Render_pass( rendermode const Mode );
|
Render_pass( rendermode const Mode );
|
||||||
// configures projection matrix for the current render pass
|
// configures projection matrix for the current render pass
|
||||||
void
|
void
|
||||||
Render_projection();
|
setup_projection();
|
||||||
|
void
|
||||||
|
setup_projection_world();
|
||||||
|
void
|
||||||
|
setup_projection_light_ortho();
|
||||||
|
void
|
||||||
|
setup_projection_light_perspective();
|
||||||
// configures camera for the current render pass
|
// configures camera for the current render pass
|
||||||
void
|
void
|
||||||
Render_camera();
|
setup_camera();
|
||||||
void
|
void
|
||||||
Render_setup( bool const Alpha = false );
|
setup_camera_world( glm::dmat4 &Viewmatrix );
|
||||||
|
void
|
||||||
|
setup_camera_light_ortho( glm::dmat4 &Viewmatrix );
|
||||||
|
void
|
||||||
|
setup_camera_light_perspective( glm::dmat4 &Viewmatrix );
|
||||||
|
void
|
||||||
|
setup_drawing( bool const Alpha = false );
|
||||||
|
void
|
||||||
|
setup_units( bool const Diffuse, bool const Shadows, bool const Reflections );
|
||||||
|
void
|
||||||
|
setup_shadow_color( glm::vec4 const &Shadowcolor );
|
||||||
|
void
|
||||||
|
toggle_units( bool const Diffuse, bool const Shadows, bool const Reflections );
|
||||||
bool
|
bool
|
||||||
Render( world_environment *Environment );
|
Render( world_environment *Environment );
|
||||||
bool
|
bool
|
||||||
@@ -225,6 +229,14 @@ private:
|
|||||||
Render( TSubRect *Groundsubcell );
|
Render( TSubRect *Groundsubcell );
|
||||||
bool
|
bool
|
||||||
Render( TGroundNode *Node );
|
Render( TGroundNode *Node );
|
||||||
|
bool
|
||||||
|
Render( TDynamicObject *Dynamic );
|
||||||
|
bool
|
||||||
|
Render( TModel3d *Model, material_data const *Material, double const Squaredistance, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
||||||
|
bool
|
||||||
|
Render( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
||||||
|
void
|
||||||
|
Render( TSubModel *Submodel );
|
||||||
void
|
void
|
||||||
Render( TTrack *Track );
|
Render( TTrack *Track );
|
||||||
bool
|
bool
|
||||||
@@ -237,6 +249,12 @@ private:
|
|||||||
Render_Alpha( TSubRect *Groundsubcell );
|
Render_Alpha( TSubRect *Groundsubcell );
|
||||||
bool
|
bool
|
||||||
Render_Alpha( TGroundNode *Node );
|
Render_Alpha( TGroundNode *Node );
|
||||||
|
bool
|
||||||
|
Render_Alpha( TDynamicObject *Dynamic );
|
||||||
|
bool
|
||||||
|
Render_Alpha( TModel3d *Model, material_data const *Material, double const Squaredistance, Math3D::vector3 const &Position, Math3D::vector3 const &Angle );
|
||||||
|
bool
|
||||||
|
Render_Alpha( TModel3d *Model, material_data const *Material, double const Squaredistance );
|
||||||
void
|
void
|
||||||
Render_Alpha( TSubModel *Submodel );
|
Render_Alpha( TSubModel *Submodel );
|
||||||
void
|
void
|
||||||
@@ -254,13 +272,23 @@ private:
|
|||||||
GLuint m_pickframebuffer { 0 }; // TODO: refactor pick framebuffer stuff into an object
|
GLuint m_pickframebuffer { 0 }; // TODO: refactor pick framebuffer stuff into an object
|
||||||
GLuint m_picktexture { 0 };
|
GLuint m_picktexture { 0 };
|
||||||
GLuint m_pickdepthbuffer { 0 };
|
GLuint m_pickdepthbuffer { 0 };
|
||||||
|
int m_pickbuffersize { 1024 }; // size of (square) textures bound with the pick framebuffer
|
||||||
#endif
|
#endif
|
||||||
|
GLuint m_shadowframebuffer { 0 };
|
||||||
|
GLuint m_shadowtexture { 0 };
|
||||||
|
int m_shadowbuffersize { 4096 };
|
||||||
|
glm::mat4 m_shadowtexturematrix;
|
||||||
|
glm::vec4 m_shadowcolor{ 0.5f, 0.5f, 0.5f, 1.f };
|
||||||
GLUquadricObj *m_quadric { nullptr }; // helper object for drawing debug mode scene elements
|
GLUquadricObj *m_quadric { nullptr }; // helper object for drawing debug mode scene elements
|
||||||
|
int m_shadowtextureunit { GL_TEXTURE1 };
|
||||||
|
int m_helpertextureunit { GL_TEXTURE0 };
|
||||||
|
int m_diffusetextureunit { GL_TEXTURE2 };
|
||||||
|
|
||||||
geometry_handle m_billboardgeometry { 0, 0 };
|
geometry_handle m_billboardgeometry { 0, 0 };
|
||||||
texture_handle m_glaretexture { -1 };
|
texture_handle m_glaretexture { -1 };
|
||||||
texture_handle m_suntexture { -1 };
|
texture_handle m_suntexture { -1 };
|
||||||
texture_handle m_moontexture { -1 };
|
texture_handle m_moontexture { -1 };
|
||||||
|
texture_handle m_reflectiontexture { -1 };
|
||||||
|
|
||||||
float m_drawtime { 1000.0f / 30.0f * 20.0f }; // start with presumed 'neutral' average of 30 fps
|
float m_drawtime { 1000.0f / 30.0f * 20.0f }; // start with presumed 'neutral' average of 30 fps
|
||||||
double m_updateaccumulator { 0.0 };
|
double m_updateaccumulator { 0.0 };
|
||||||
@@ -271,7 +299,6 @@ private:
|
|||||||
float m_speculartranslucentscalefactor { 1.0f };
|
float m_speculartranslucentscalefactor { 1.0f };
|
||||||
|
|
||||||
bool m_framebuffersupport { false };
|
bool m_framebuffersupport { false };
|
||||||
rendermode m_texenvmode { rendermode::color }; // last configured texture environment
|
|
||||||
renderpass_config m_renderpass;
|
renderpass_config m_renderpass;
|
||||||
bool m_renderspecular { false }; // controls whether to include specular component in the calculations
|
bool m_renderspecular { false }; // controls whether to include specular component in the calculations
|
||||||
std::vector<TGroundNode const *> m_picksceneryitems;
|
std::vector<TGroundNode const *> m_picksceneryitems;
|
||||||
|
|||||||
15
sky.cpp
15
sky.cpp
@@ -9,24 +9,22 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "sky.h"
|
#include "sky.h"
|
||||||
#include "Logs.h"
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "MdlMngr.h"
|
#include "MdlMngr.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
GLfloat lightPos[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
//GLfloat lightPos[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
TSky::~TSky(){};
|
void TSky::Init() {
|
||||||
|
|
||||||
TSky::TSky(){};
|
if( ( Global::asSky != "1" )
|
||||||
|
&& ( Global::asSky != "0" ) ) {
|
||||||
|
|
||||||
void TSky::Init()
|
|
||||||
{
|
|
||||||
WriteLog( "Clouds init" );
|
|
||||||
if ((Global::asSky != "1") && (Global::asSky != "0"))
|
|
||||||
mdCloud = TModelsManager::GetModel( Global::asSky );
|
mdCloud = TModelsManager::GetModel( Global::asSky );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void TSky::Render( glm::vec3 const &Tint )
|
void TSky::Render( glm::vec3 const &Tint )
|
||||||
{
|
{
|
||||||
if (mdCloud)
|
if (mdCloud)
|
||||||
@@ -45,5 +43,6 @@ void TSky::Render( glm::vec3 const &Tint )
|
|||||||
::glDisable( GL_LIGHTING );
|
::glDisable( GL_LIGHTING );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
16
sky.h
16
sky.h
@@ -12,16 +12,18 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
#include "Model3d.h"
|
#include "Model3d.h"
|
||||||
|
|
||||||
class TSky
|
class TSky {
|
||||||
{
|
|
||||||
private:
|
|
||||||
TModel3d *mdCloud;
|
|
||||||
|
|
||||||
public:
|
friend class opengl_renderer;
|
||||||
TSky();
|
|
||||||
~TSky();
|
private:
|
||||||
|
TModel3d *mdCloud { nullptr };
|
||||||
|
|
||||||
|
public:
|
||||||
void Init();
|
void Init();
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void Render( glm::vec3 const &Tint = glm::vec3(1.0f, 1.0f, 1.0f) );
|
void Render( glm::vec3 const &Tint = glm::vec3(1.0f, 1.0f, 1.0f) );
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "stars.h"
|
#include "stars.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "MdlMngr.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cStars -- simple starfield model, simulating appearance of starry sky
|
// cStars -- simple starfield model, simulating appearance of starry sky
|
||||||
@@ -9,9 +10,9 @@
|
|||||||
void
|
void
|
||||||
cStars::init() {
|
cStars::init() {
|
||||||
|
|
||||||
m_stars.LoadFromFile( "models\\skydome_stars.t3d", false );
|
m_stars = TModelsManager::GetModel( "models\\skydome_stars.t3d", false );
|
||||||
}
|
}
|
||||||
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
void
|
void
|
||||||
cStars::render() {
|
cStars::render() {
|
||||||
// setup
|
// setup
|
||||||
@@ -27,4 +28,5 @@ cStars::render() {
|
|||||||
::glPointSize( 3.0f );
|
::glPointSize( 3.0f );
|
||||||
|
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
9
stars.h
9
stars.h
@@ -8,13 +8,16 @@
|
|||||||
|
|
||||||
class cStars {
|
class cStars {
|
||||||
|
|
||||||
|
friend class opengl_renderer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// types:
|
// types:
|
||||||
|
|
||||||
// methods:
|
// methods:
|
||||||
void init();
|
void init();
|
||||||
void render();
|
#ifdef EU07_USE_OLD_RENDERCODE
|
||||||
|
void render();
|
||||||
|
#endif
|
||||||
// constructors:
|
// constructors:
|
||||||
|
|
||||||
// deconstructor:
|
// deconstructor:
|
||||||
@@ -29,5 +32,5 @@ private:
|
|||||||
// members:
|
// members:
|
||||||
float m_longitude{ 19.0f }; // geograpic coordinates hardcoded roughly to Poland location, for the time being
|
float m_longitude{ 19.0f }; // geograpic coordinates hardcoded roughly to Poland location, for the time being
|
||||||
float m_latitude{ 52.0f };
|
float m_latitude{ 52.0f };
|
||||||
TModel3d m_stars;
|
TModel3d *m_stars { nullptr };
|
||||||
};
|
};
|
||||||
|
|||||||
2
stdafx.h
2
stdafx.h
@@ -91,4 +91,4 @@
|
|||||||
#include <glm/gtx/rotate_vector.hpp>
|
#include <glm/gtx/rotate_vector.hpp>
|
||||||
#include <glm/gtx/norm.hpp>
|
#include <glm/gtx/norm.hpp>
|
||||||
|
|
||||||
#include "openglmatrixstack.h"
|
#include "openglmatrixstack.h"
|
||||||
|
|||||||
12
uilayer.cpp
12
uilayer.cpp
@@ -65,7 +65,7 @@ ui_layer::render() {
|
|||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glOrtho( 0.f, Global::ScreenWidth, Global::ScreenHeight, 0.f, -1.f, 1.f );
|
glOrtho( 0, std::max( 1, Global::ScreenWidth ), std::max( 1, Global::ScreenHeight ), 0, -1, 1 );
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
@@ -96,7 +96,7 @@ void
|
|||||||
ui_layer::set_background( std::string const &Filename ) {
|
ui_layer::set_background( std::string const &Filename ) {
|
||||||
|
|
||||||
if( false == Filename.empty() ) {
|
if( false == Filename.empty() ) {
|
||||||
m_background = GfxRenderer.GetTextureId( Filename, szTexturePath );
|
m_background = GfxRenderer.Fetch_Texture( Filename );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_background = NULL;
|
m_background = NULL;
|
||||||
@@ -272,10 +272,10 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) {
|
|||||||
|
|
||||||
glBegin( GL_TRIANGLE_STRIP );
|
glBegin( GL_TRIANGLE_STRIP );
|
||||||
|
|
||||||
glTexCoord2f( 0.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
glMultiTexCoord2f( m_textureunit, 0.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
||||||
glTexCoord2f( 0.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
glMultiTexCoord2f( m_textureunit, 0.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
||||||
glTexCoord2f( 1.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
glMultiTexCoord2f( m_textureunit, 1.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio );
|
||||||
glTexCoord2f( 1.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
glMultiTexCoord2f( m_textureunit, 1.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public:
|
|||||||
// methods:
|
// methods:
|
||||||
bool
|
bool
|
||||||
init( GLFWwindow *Window );
|
init( GLFWwindow *Window );
|
||||||
|
void
|
||||||
|
set_unit( GLint const Textureunit ) { m_textureunit = Textureunit; }
|
||||||
// draws requested UI elements
|
// draws requested UI elements
|
||||||
void
|
void
|
||||||
render();
|
render();
|
||||||
@@ -83,6 +85,7 @@ private:
|
|||||||
|
|
||||||
// members:
|
// members:
|
||||||
GLFWwindow *m_window { nullptr };
|
GLFWwindow *m_window { nullptr };
|
||||||
|
GLint m_textureunit{ GL_TEXTURE0 };
|
||||||
GLuint m_fontbase { (GLuint)-1 }; // numer DL dla znaków w napisach
|
GLuint m_fontbase { (GLuint)-1 }; // numer DL dla znaków w napisach
|
||||||
|
|
||||||
// progress bar config. TODO: put these together into an object
|
// progress bar config. TODO: put these together into an object
|
||||||
|
|||||||
@@ -71,4 +71,13 @@ interpolate( Type_ const &First, Type_ const &Second, double const Factor ) {
|
|||||||
return ( First * ( 1.0 - Factor ) ) + ( Second * Factor );
|
return ( First * ( 1.0 - Factor ) ) + ( Second * Factor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tests whether provided points form a degenerate triangle
|
||||||
|
template <typename VecType_>
|
||||||
|
bool
|
||||||
|
degenerate( VecType_ const &Vertex1, VecType_ const &Vertex2, VecType_ const &Vertex3 ) {
|
||||||
|
|
||||||
|
// degenerate( A, B, C, minarea ) = ( ( B - A ).cross( C - A ) ).lengthSquared() < ( 4.0f * minarea * minarea );
|
||||||
|
return glm::length2( glm::cross( Vertex2 - Vertex1, Vertex3 - Vertex1 ) ) < std::numeric_limits<VecType_::value_type>::epsilon();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user