mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 04:39:18 +02:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
11
Button.cpp
11
Button.cpp
@@ -18,11 +18,10 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
void TButton::Clear(int i)
|
void TButton::Clear(int i)
|
||||||
{
|
{
|
||||||
pModelOn = nullptr;
|
*this = TButton();
|
||||||
pModelOff = nullptr;
|
if( i >= 0 ) {
|
||||||
m_state = false;
|
FeedbackBitSet( i );
|
||||||
if (i >= 0)
|
}
|
||||||
FeedbackBitSet(i);
|
|
||||||
Update(); // kasowanie bitu Feedback, o ile jakiś ustawiony
|
Update(); // kasowanie bitu Feedback, o ile jakiś ustawiony
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ void TButton::Load( cParser &Parser, TDynamicObject const *Owner ) {
|
|||||||
std::array<TModel3d *, 3> sources { Owner->mdKabina, Owner->mdLowPolyInt, Owner->mdModel };
|
std::array<TModel3d *, 3> sources { Owner->mdKabina, Owner->mdLowPolyInt, Owner->mdModel };
|
||||||
for( auto const *source : sources ) {
|
for( auto const *source : sources ) {
|
||||||
if( true == Init( submodelname, source, false ) ) {
|
if( true == Init( submodelname, source, false ) ) {
|
||||||
// got what we wanted, bail out
|
// got what we wanted, don't need to search further
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4870,8 +4870,6 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
sm->WillBeAnimated();
|
sm->WillBeAnimated();
|
||||||
sm->ParentMatrix(&m); // pobranie macierzy transformacji
|
sm->ParentMatrix(&m); // pobranie macierzy transformacji
|
||||||
// m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak)
|
// m(3)[1]=m[3][1]+0.054; //w górę o wysokość ślizgu (na razie tak)
|
||||||
if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D
|
|
||||||
m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, tzn. przed wykonaniem Init()
|
|
||||||
pants[i].fParamPants->vPos.z = m[3][0]; // przesunięcie w bok (asymetria)
|
pants[i].fParamPants->vPos.z = m[3][0]; // przesunięcie w bok (asymetria)
|
||||||
pants[i].fParamPants->vPos.y = m[3][1]; // przesunięcie w górę odczytane z modelu
|
pants[i].fParamPants->vPos.y = m[3][1]; // przesunięcie w górę odczytane z modelu
|
||||||
if ((sm = pants[i].smElement[0]->ChildGet()) != NULL)
|
if ((sm = pants[i].smElement[0]->ChildGet()) != NULL)
|
||||||
@@ -4908,8 +4906,6 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
|||||||
pants[i].fParamPants->fAngleU = pants[i].fParamPants->fAngleU0; // początkowy kąt
|
pants[i].fParamPants->fAngleU = pants[i].fParamPants->fAngleU0; // początkowy kąt
|
||||||
// Ra: ze względu na to, że niektóre modele pantografów są zrąbane, ich mierzenie ma obecnie ograniczony sens
|
// Ra: ze względu na to, że niektóre modele pantografów są zrąbane, ich mierzenie ma obecnie ograniczony sens
|
||||||
sm->ParentMatrix(&m); // pobranie macierzy transformacji pivota ślizgu względem wstawienia pojazdu
|
sm->ParentMatrix(&m); // pobranie macierzy transformacji pivota ślizgu względem wstawienia pojazdu
|
||||||
if ((mdModel->Flags() & 0x8000) == 0) // jeśli wczytano z T3D
|
|
||||||
m.InitialRotate(); // może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, tzn. przed wykonaniem Init()
|
|
||||||
float det = Det(m);
|
float det = Det(m);
|
||||||
if (std::fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu na skalowaniu ślizgu
|
if (std::fabs(det - 1.0) < 0.001) // dopuszczamy 1 promil błędu na skalowaniu ślizgu
|
||||||
{ // skalowanie jest w normie, można pobrać wymiary z modelu
|
{ // skalowanie jest w normie, można pobrać wymiary z modelu
|
||||||
|
|||||||
40
Model3d.cpp
40
Model3d.cpp
@@ -1119,9 +1119,33 @@ void TSubModel::ColorsSet( glm::vec3 const &Ambient, glm::vec3 const &Diffuse, g
|
|||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
void TSubModel::ParentMatrix( float4x4 *m ) const { // pobranie transformacji względem wstawienia modelu
|
// pobranie transformacji względem wstawienia modelu
|
||||||
// jeśli nie zostało wykonane Init() (tzn. zaraz po wczytaniu T3D),
|
void TSubModel::ParentMatrix( float4x4 *m ) const {
|
||||||
// to dodatkowy obrót obrót T3D jest wymagany np. do policzenia wysokości pantografów
|
|
||||||
|
m->Identity();
|
||||||
|
|
||||||
|
float4x4 submodelmatrix;
|
||||||
|
auto *submodel = this;
|
||||||
|
do {
|
||||||
|
// for given step in hierarchy there can be custom transformation matrix, or no transformation
|
||||||
|
// retrieve it...
|
||||||
|
submodelmatrix.Identity();
|
||||||
|
if( submodel->GetMatrix() ) {
|
||||||
|
submodelmatrix = float4x4( *submodel->GetMatrix() );
|
||||||
|
}
|
||||||
|
// ...potentially adjust transformations of the root matrix if the model wasn't yet initialized...
|
||||||
|
if( ( submodel->Parent == nullptr )
|
||||||
|
&& ( false == submodel->m_rotation_init_done ) ) {
|
||||||
|
// dla ostatniego może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, a nie obrócono jeszcze
|
||||||
|
submodelmatrix.InitialRotate();
|
||||||
|
}
|
||||||
|
// ...combine the transformations...
|
||||||
|
*m = submodelmatrix * ( *m );
|
||||||
|
// ...and move up the transformation chain for the iteration...
|
||||||
|
submodel = submodel->Parent;
|
||||||
|
// ... until we hit the root
|
||||||
|
} while( submodel != nullptr );
|
||||||
|
/*
|
||||||
if( fMatrix != nullptr ) {
|
if( fMatrix != nullptr ) {
|
||||||
// skopiowanie, bo będziemy mnożyć
|
// skopiowanie, bo będziemy mnożyć
|
||||||
*m = float4x4( *fMatrix );
|
*m = float4x4( *fMatrix );
|
||||||
@@ -1136,8 +1160,7 @@ void TSubModel::ParentMatrix( float4x4 *m ) const { // pobranie transformacji wz
|
|||||||
*m = *sm->Parent->GetMatrix() * *m;
|
*m = *sm->Parent->GetMatrix() * *m;
|
||||||
sm = sm->Parent;
|
sm = sm->Parent;
|
||||||
}
|
}
|
||||||
// dla ostatniego może być potrzebny dodatkowy obrót, jeśli wczytano z T3D, a
|
*/
|
||||||
// nie obrócono jeszcze
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// obliczenie maksymalnej wysokości, na początek ślizgu w pantografie
|
// obliczenie maksymalnej wysokości, na początek ślizgu w pantografie
|
||||||
@@ -1239,7 +1262,7 @@ TSubModel::offset( float const Geometrytestoffsetthreshold ) const {
|
|||||||
|
|
||||||
float4x4 parentmatrix;
|
float4x4 parentmatrix;
|
||||||
ParentMatrix( &parentmatrix );
|
ParentMatrix( &parentmatrix );
|
||||||
|
|
||||||
auto offset { glm::vec3 { glm::make_mat4( parentmatrix.readArray() ) * glm::vec4 { 0, 0, 0, 1 } } };
|
auto offset { glm::vec3 { glm::make_mat4( parentmatrix.readArray() ) * glm::vec4 { 0, 0, 0, 1 } } };
|
||||||
|
|
||||||
if( glm::length( offset ) < Geometrytestoffsetthreshold ) {
|
if( glm::length( offset ) < Geometrytestoffsetthreshold ) {
|
||||||
@@ -1262,11 +1285,6 @@ TSubModel::offset( float const Geometrytestoffsetthreshold ) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_rotation_init_done)
|
|
||||||
// NOTE, HACK: results require flipping if the model wasn't yet initialized,
|
|
||||||
// TODO: sort out this mess, maybe try unify offset lookups to take place before (or after) initialization,
|
|
||||||
offset = { -offset.x, offset.z, offset.y };
|
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user