mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
audio subsystem: completed base functionality of the renderer, external and engine sounds moved from cab to vehicle, minor fixes to various sound-related methods
This commit is contained in:
54
Button.cpp
54
Button.cpp
@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Model3d.h"
|
||||
#include "Console.h"
|
||||
#include "logs.h"
|
||||
#include "renderer.h"
|
||||
|
||||
void TButton::Clear(int i)
|
||||
{
|
||||
@@ -24,8 +25,8 @@ void TButton::Clear(int i)
|
||||
Update(); // kasowanie bitu Feedback, o ile jakiś ustawiony
|
||||
};
|
||||
|
||||
void TButton::Init(std::string const &asName, TModel3d *pModel, bool bNewOn)
|
||||
{
|
||||
void TButton::Init( std::string const &asName, TModel3d *pModel, bool bNewOn ) {
|
||||
|
||||
if( pModel == nullptr ) { return; }
|
||||
|
||||
pModelOn = pModel->GetFromName( asName + "_on" );
|
||||
@@ -34,7 +35,7 @@ void TButton::Init(std::string const &asName, TModel3d *pModel, bool bNewOn)
|
||||
Update();
|
||||
};
|
||||
|
||||
void TButton::Load(cParser &Parser, TModel3d *pModel1, TModel3d *pModel2) {
|
||||
void TButton::Load( cParser &Parser, TDynamicObject const *Owner, TModel3d *pModel1, TModel3d *pModel2 ) {
|
||||
|
||||
std::string submodelname;
|
||||
|
||||
@@ -52,25 +53,32 @@ void TButton::Load(cParser &Parser, TModel3d *pModel1, TModel3d *pModel2) {
|
||||
}
|
||||
}
|
||||
|
||||
// bind defined sounds with the button owner
|
||||
m_soundfxincrease.owner( Owner );
|
||||
m_soundfxdecrease.owner( Owner );
|
||||
|
||||
if( pModel1 ) {
|
||||
// poszukiwanie submodeli w modelu
|
||||
Init( submodelname, pModel1, false );
|
||||
if( ( pModelOn != nullptr ) || ( pModelOff != nullptr ) ) {
|
||||
// we got our models, bail out
|
||||
return;
|
||||
}
|
||||
}
|
||||
if( pModel2 ) {
|
||||
if( ( pModelOn == nullptr )
|
||||
&& ( pModelOff == nullptr )
|
||||
&& ( pModel2 != nullptr ) ) {
|
||||
// poszukiwanie submodeli w modelu
|
||||
Init( submodelname, pModel2, false );
|
||||
if( ( pModelOn != nullptr ) || ( pModelOff != nullptr ) ) {
|
||||
// we got our models, bail out
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if we failed to locate even one state submodel, cry
|
||||
ErrorLog( "Failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + pModel1->NameGet() + "\"" );
|
||||
};
|
||||
|
||||
if( ( pModelOn == nullptr )
|
||||
&& ( pModelOff == nullptr ) ) {
|
||||
// if we failed to locate even one state submodel, cry
|
||||
ErrorLog( "Bad model: failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + pModel1->NameGet() + "\"" );
|
||||
}
|
||||
|
||||
// pass submodel location to defined sounds
|
||||
auto const offset { model_offset() };
|
||||
m_soundfxincrease.offset( offset );
|
||||
m_soundfxdecrease.offset( offset );
|
||||
}
|
||||
|
||||
bool
|
||||
TButton::Load_mapping( cParser &Input ) {
|
||||
@@ -85,6 +93,22 @@ TButton::Load_mapping( cParser &Input ) {
|
||||
return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized
|
||||
}
|
||||
|
||||
// returns offset of submodel associated with the button from the model centre
|
||||
glm::vec3
|
||||
TButton::model_offset() const {
|
||||
|
||||
auto const
|
||||
submodel { (
|
||||
pModelOn ? pModelOn :
|
||||
pModelOff ? pModelOff :
|
||||
nullptr ) };
|
||||
|
||||
return (
|
||||
submodel != nullptr ?
|
||||
submodel->offset( 1.f ) :
|
||||
glm::vec3() );
|
||||
}
|
||||
|
||||
void
|
||||
TButton::Turn( bool const State ) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user