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

build 170626. individual self-illumination levels for interior sections, automatic merging of suitable terrain geometry during load from text files, unused resource release by geometry bank manager, support for ui backgrounds with width:height ratio other than 4:3, comment parsing optimization, minor bug fixes

This commit is contained in:
tmj-fstate
2017-06-26 16:57:25 +02:00
parent 34a899239f
commit 5d7b3fb036
18 changed files with 608 additions and 339 deletions

View File

@@ -78,6 +78,23 @@ void TSubModel::NameSet(std::string const &Name)
pName = Name;
};
// sets light level (alpha component of illumination color) to specified value
void
TSubModel::SetLightLevel( float const Level, bool const Includechildren, bool const Includesiblings ) {
f4Emision.a = Level;
if( true == Includesiblings ) {
auto sibling { this };
while( ( sibling = sibling->Next ) != nullptr ) {
sibling->f4Emision.a = Level;
}
}
if( ( true == Includechildren )
&& ( Child != nullptr ) ) {
Child->SetLightLevel( Level, true, true ); // node's children include child's siblings and children
}
}
int TSubModel::SeekFaceNormal(std::vector<unsigned int> const &Masks, int const Startface, unsigned int const Mask, glm::vec3 const &Position, vertex_array const &Vertices)
{ // szukanie punktu stycznego do (pt), zwraca numer wierzchołka, a nie trójkąta
int facecount = iNumVerts / 3; // bo maska powierzchni jest jedna na trójkąt
@@ -315,9 +332,9 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
}
else
{ // jeśli tylko nazwa pliku, to dawać bieżącą ścieżkę do tekstur
TextureNameSet(texture.c_str());
TextureNameSet(texture);
if( texture.find_first_of( "/\\" ) == texture.npos ) {
texture.insert( 0, Global::asCurrentTexturePath.c_str() );
texture.insert( 0, Global::asCurrentTexturePath );
}
TextureID = GfxRenderer.GetTextureId( texture, szTexturePath );
// renderowanie w cyklu przezroczystych tylko jeśli:
@@ -429,7 +446,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
--facecount; // o jeden trójkąt mniej
iNumVerts -= 3; // czyli o 3 wierzchołki
i -= 3; // wczytanie kolejnego w to miejsce
WriteLog("Degenerated triangle ignored in: \"" + pName + "\", verticle " + std::to_string(i));
WriteLog("Degenerated triangle ignored in: \"" + pName + "\", vertice " + std::to_string(i));
}
if (i > 0) {
// jeśli pierwszy trójkąt będzie zdegenerowany, to zostanie usunięty i nie ma co sprawdzać
@@ -487,6 +504,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
glm::vec3() ); // przepisanie do wierzchołka trójkąta
}
}
Vertices.resize( iNumVerts ); // in case we had some degenerate triangles along the way
/*
delete[] wsp;
delete[] n;
@@ -534,6 +552,7 @@ int TSubModel::Load( cParser &parser, TModel3d *Model, /*int Pos,*/ bool dynamic
else if( eType == TP_FREESPOTLIGHT ) {
// single light points only have single data point, duh
Vertices.emplace_back();
iNumVerts = 1;
}
// Visible=true; //się potem wyłączy w razie potrzeby
// iFlags|=0x0200; //wczytano z pliku tekstowego (jest właścicielem tablic)
@@ -711,25 +730,20 @@ void TSubModel::InitialRotate(bool doit)
{ // jeśli jest jednostkowy transform, to przeliczamy
// wierzchołki, a mnożenie podajemy dalej
float swapcopy;
// if( false == Vertices.empty() ) {
/*
for( auto &vertex : Vertices ) {
*/
for( auto &vertex : Vertices ) {
vertex.position.x = -vertex.position.x; // zmiana znaku X
swapcopy = vertex.position.y; // zamiana Y i Z
vertex.position.y = vertex.position.z;
vertex.position.z = swapcopy;
// wektory normalne również trzeba przekształcić, bo się źle oświetlają
if( eType != TP_STARS ) {
// gwiazdki mają kolory zamiast normalnych, to // ich wtedy nie ruszamy
vertex.normal.x = -vertex.normal.x; // zmiana znaku X
swapcopy = vertex.normal.y; // zamiana Y i Z
vertex.normal.y = vertex.normal.z;
vertex.normal.z = swapcopy;
}
vertex.position.x = -vertex.position.x; // zmiana znaku X
swapcopy = vertex.position.y; // zamiana Y i Z
vertex.position.y = vertex.position.z;
vertex.position.z = swapcopy;
// wektory normalne również trzeba przekształcić, bo się źle oświetlają
if( eType != TP_STARS ) {
// gwiazdki mają kolory zamiast normalnych, to // ich wtedy nie ruszamy
vertex.normal.x = -vertex.normal.x; // zmiana znaku X
swapcopy = vertex.normal.y; // zamiana Y i Z
vertex.normal.y = vertex.normal.z;
vertex.normal.z = swapcopy;
}
// }
}
if (Child)
Child->InitialRotate(doit); // potomne ewentualnie obrócimy
}