mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 13:29:18 +02:00
sound fixed
This commit is contained in:
@@ -4711,7 +4711,7 @@ void TDynamicObject::LoadMMediaFile(std::string BaseDir, std::string TypeName,
|
||||
for( int i = 0; i < iAxles; i++ ) {
|
||||
parser.getTokens( 1, false );
|
||||
parser >> dWheelsPosition[ i ];
|
||||
parser.getTokens();
|
||||
parser.getTokens(1, false);
|
||||
parser >> token;
|
||||
if( token != "end" ) {
|
||||
rsStukot[i] = sound_man->create_sound(token);
|
||||
|
||||
105
Train.cpp
105
Train.cpp
@@ -6528,101 +6528,134 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
||||
// hamowanie zwykle:
|
||||
rsBrake = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(4, false);
|
||||
parser >> rsBrake->gain_mul >> rsBrake->gain_off >> rsBrake->pitch_mul >> rsBrake->pitch_off;
|
||||
rsBrake->gain_mul /= (1 + mvOccupied->MaxBrakeForce * 1000);
|
||||
rsBrake->pitch_mul /= (1 + mvOccupied->Vmax);
|
||||
if (rsBrake)
|
||||
{
|
||||
parser >> rsBrake->gain_mul >> rsBrake->gain_off >> rsBrake->pitch_mul >> rsBrake->pitch_off;
|
||||
rsBrake->gain_mul /= (1 + mvOccupied->MaxBrakeForce * 1000);
|
||||
rsBrake->pitch_mul /= (1 + mvOccupied->Vmax);
|
||||
}
|
||||
}
|
||||
else if (token == "slipperysound:")
|
||||
{
|
||||
// sanie:
|
||||
rsSlippery = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(2, false);
|
||||
parser >> rsSlippery->gain_mul >> rsSlippery->gain_off;
|
||||
rsSlippery->pitch_mul = 0.0;
|
||||
rsSlippery->pitch_off = 1.0;
|
||||
rsSlippery->gain_mul /= (1 + mvOccupied->Vmax);
|
||||
if (rsSlippery)
|
||||
{
|
||||
parser >> rsSlippery->gain_mul >> rsSlippery->gain_off;
|
||||
rsSlippery->pitch_mul = 0.0;
|
||||
rsSlippery->pitch_off = 1.0;
|
||||
rsSlippery->gain_mul /= (1 + mvOccupied->Vmax);
|
||||
}
|
||||
}
|
||||
else if (token == "airsound:")
|
||||
{
|
||||
// syk:
|
||||
rsHiss = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(2, false);
|
||||
parser >> rsHiss->gain_mul >> rsHiss->gain_off;
|
||||
rsHiss->pitch_mul = 0.0;
|
||||
rsHiss->pitch_off = 1.0;
|
||||
if (rsHiss)
|
||||
{
|
||||
parser >> rsHiss->gain_mul >> rsHiss->gain_off;
|
||||
rsHiss->pitch_mul = 0.0;
|
||||
rsHiss->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
else if (token == "airsound2:")
|
||||
{
|
||||
// syk:
|
||||
rsHissU = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(2, false);
|
||||
parser >> rsHissU->gain_mul >> rsHissU->gain_off;
|
||||
rsHissU->pitch_mul = 0.0;
|
||||
rsHissU->pitch_off = 1.0;
|
||||
if (rsHissU)
|
||||
{
|
||||
parser >> rsHissU->gain_mul >> rsHissU->gain_off;
|
||||
rsHissU->pitch_mul = 0.0;
|
||||
rsHissU->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
else if (token == "airsound3:")
|
||||
{
|
||||
// syk:
|
||||
rsHissE = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(2, false);
|
||||
parser >> rsHissE->gain_mul >> rsHissE->gain_off;
|
||||
rsHissE->pitch_mul = 0.0;
|
||||
rsHissE->pitch_off = 1.0;
|
||||
if (rsHissE)
|
||||
{
|
||||
parser >> rsHissE->gain_mul >> rsHissE->gain_off;
|
||||
rsHissE->pitch_mul = 0.0;
|
||||
rsHissE->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
else if (token == "airsound4:")
|
||||
{
|
||||
// syk:
|
||||
rsHissX = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(2, false);
|
||||
parser >> rsHissX->gain_mul >> rsHissX->gain_off;
|
||||
rsHissX->pitch_mul = 0.0;
|
||||
rsHissX->pitch_off = 1.0;
|
||||
if (rsHissX)
|
||||
{
|
||||
parser >> rsHissX->gain_mul >> rsHissX->gain_off;
|
||||
rsHissX->pitch_mul = 0.0;
|
||||
rsHissX->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
else if (token == "airsound5:")
|
||||
{
|
||||
// syk:
|
||||
rsHissT = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(2, false);
|
||||
parser >> rsHissT->gain_mul >> rsHissT->gain_off;
|
||||
rsHissT->pitch_mul = 0.0;
|
||||
rsHissT->pitch_off = 1.0;
|
||||
if (rsHissT)
|
||||
{
|
||||
parser >> rsHissT->gain_mul >> rsHissT->gain_off;
|
||||
rsHissT->pitch_mul = 0.0;
|
||||
rsHissT->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
else if (token == "fadesound:")
|
||||
{
|
||||
// syk:
|
||||
rsFadeSound = sound_man->create_sound(parser.getToken<std::string>());
|
||||
rsFadeSound->gain_mul = 1.0;
|
||||
rsFadeSound->gain_off = 1.0;
|
||||
rsFadeSound->pitch_mul = 1.0;
|
||||
rsFadeSound->pitch_off = 1.0;
|
||||
if (rsFadeSound)
|
||||
{
|
||||
rsFadeSound->gain_mul = 1.0;
|
||||
rsFadeSound->gain_off = 1.0;
|
||||
rsFadeSound->pitch_mul = 1.0;
|
||||
rsFadeSound->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
else if (token == "localbrakesound:")
|
||||
{
|
||||
// syk:
|
||||
rsSBHiss = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(2, false);
|
||||
parser >> rsSBHiss->gain_mul >> rsSBHiss->gain_off;
|
||||
rsSBHiss->pitch_mul = 0.0;
|
||||
rsSBHiss->pitch_off = 1.0;
|
||||
if (rsSBHiss)
|
||||
{
|
||||
parser >> rsSBHiss->gain_mul >> rsSBHiss->gain_off;
|
||||
rsSBHiss->pitch_mul = 0.0;
|
||||
rsSBHiss->pitch_off = 1.0;
|
||||
}
|
||||
}
|
||||
else if (token == "runningnoise:")
|
||||
{
|
||||
// szum podczas jazdy:
|
||||
rsRunningNoise = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(4, false);
|
||||
parser >> rsRunningNoise->gain_mul >> rsRunningNoise->gain_off >> rsRunningNoise->pitch_mul >>
|
||||
rsRunningNoise->pitch_off;
|
||||
rsRunningNoise->gain_mul /= (1 + mvOccupied->Vmax);
|
||||
rsRunningNoise->pitch_mul /= (1 + mvOccupied->Vmax);
|
||||
if (rsRunningNoise)
|
||||
{
|
||||
parser >> rsRunningNoise->gain_mul >> rsRunningNoise->gain_off >> rsRunningNoise->pitch_mul >>
|
||||
rsRunningNoise->pitch_off;
|
||||
rsRunningNoise->gain_mul /= (1 + mvOccupied->Vmax);
|
||||
rsRunningNoise->pitch_mul /= (1 + mvOccupied->Vmax);
|
||||
}
|
||||
}
|
||||
else if (token == "engageslippery:")
|
||||
{
|
||||
// tarcie tarcz sprzegla:
|
||||
rsEngageSlippery = sound_man->create_sound(parser.getToken<std::string>());
|
||||
parser.getTokens(4, false);
|
||||
parser >> rsEngageSlippery->gain_mul >> rsEngageSlippery->gain_off >> rsEngageSlippery->pitch_mul >>
|
||||
rsEngageSlippery->pitch_off;
|
||||
rsEngageSlippery->pitch_mul /= (1 + mvOccupied->nmax);
|
||||
if (rsEngageSlippery)
|
||||
{
|
||||
parser >> rsEngageSlippery->gain_mul >> rsEngageSlippery->gain_off >> rsEngageSlippery->pitch_mul >>
|
||||
rsEngageSlippery->pitch_off;
|
||||
rsEngageSlippery->pitch_mul /= (1 + mvOccupied->nmax);
|
||||
}
|
||||
}
|
||||
else if (token == "mechspring:")
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ std::string sound_manager::find_file(std::string name)
|
||||
return name;
|
||||
|
||||
name.erase(name.rfind('.'));
|
||||
std::vector<std::string> exts { ".wav", ".flac", ".ogg" };
|
||||
std::vector<std::string> exts { ".wav", ".WAV", ".flac", ".ogg" };
|
||||
for (auto const &ext : exts)
|
||||
if (FileExists(name + ext))
|
||||
return name + ext;
|
||||
@@ -243,6 +243,7 @@ sound::sound()
|
||||
gain_mul = 1.0f;
|
||||
pitch_off = 0.0f;
|
||||
pitch_mul = 1.0f;
|
||||
dt_sum = 0.0f;
|
||||
}
|
||||
|
||||
simple_sound::simple_sound(sound_buffer *buf) : sound::sound()
|
||||
@@ -317,12 +318,15 @@ void simple_sound::stop()
|
||||
|
||||
void sound::update(float dt)
|
||||
{
|
||||
if (spatial)
|
||||
dt_sum += dt;
|
||||
if (spatial && pos_dirty)
|
||||
{
|
||||
glm::vec3 velocity = (pos - last_pos) / dt; // m/s
|
||||
glm::vec3 velocity = (pos - last_pos) / dt_sum; // m/s
|
||||
alSourcefv(id, AL_VELOCITY, glm::value_ptr(velocity));
|
||||
last_pos = pos;
|
||||
pos_dirty = false;
|
||||
dt_sum = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
sound.h
1
sound.h
@@ -41,6 +41,7 @@ class sound
|
||||
{
|
||||
bool pos_dirty;
|
||||
glm::vec3 last_pos;
|
||||
float dt_sum;
|
||||
|
||||
protected:
|
||||
float max_dist;
|
||||
|
||||
3
stdafx.h
3
stdafx.h
@@ -77,7 +77,7 @@
|
||||
#include "GL/wglew.h"
|
||||
#endif
|
||||
#define GLFW_INCLUDE_GLU
|
||||
//m7todo: jest tu bo nie chcia³o mi siê wpychaæ do wszystkich plików
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
@@ -86,6 +86,7 @@
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/gtx/rotate_vector.hpp>
|
||||
#include <glm/gtx/norm.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
#include "openglmatrixstack.h"
|
||||
#define STRINGIZE_DETAIL(x) #x
|
||||
|
||||
Reference in New Issue
Block a user