forked from teamnwah/openmw-tes3coop
Implemented 3D sound placement. Sound management / lookup system not
done yet.actorid
parent
973ddc54e8
commit
9875d74abf
@ -1 +1 @@
|
||||
Subproject commit 85fa6d392319e72cbe359c55c7651faafcebdd2b
|
||||
Subproject commit 3db61c8bdde65910e43a3a06b34738296960e9e8
|
@ -1,47 +0,0 @@
|
||||
module scene.gamesettings;
|
||||
|
||||
import monster.monster;
|
||||
import esm.records : gameSettings;
|
||||
import esm.defs : VarType;
|
||||
import std.stdio;
|
||||
import std.string;
|
||||
|
||||
MonsterObject *gmstObj;
|
||||
|
||||
void loadGameSettings()
|
||||
{
|
||||
// Load the GameSettings Monster class, and get the singleton
|
||||
// instance
|
||||
MonsterClass mc = vm.load("GMST");
|
||||
gmstObj = mc.getSing();
|
||||
|
||||
foreach(a, b; gameSettings.names)
|
||||
{
|
||||
assert(a == b.id);
|
||||
assert(a[0] == 'i' || a[0] == 'f' || a[0] == 's');
|
||||
|
||||
// There's three cases of variable names containing
|
||||
// spaces. Since these are so seldom, it makes more sense to
|
||||
// make special workarounds for them instead of searching every
|
||||
// string.
|
||||
char[] name = a;
|
||||
if(name.length > 13 && (name[6] == ' ' || name[5] == ' '))
|
||||
{
|
||||
name = name.replace(" ", "_");
|
||||
// Make sure we don't change the original string!
|
||||
assert(name != a);
|
||||
}
|
||||
|
||||
if(!mc.sc.lookupName(name).isVar)
|
||||
{
|
||||
writefln("WARNING: GMST %s not supported!", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(b.type == VarType.Int) gmstObj.setInt(name, b.i);
|
||||
else if(b.type == VarType.Float) gmstObj.setFloat(name, b.f);
|
||||
// TODO: At some point we will probably translate strings into
|
||||
// UTF32 at load time, so string8 will not be needed here.
|
||||
else if(b.type == VarType.String) gmstObj.setString8(name, b.str);
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
||||
Copyright (C) 2008 Nicolay Korslund
|
||||
Email: < korslund@gmail.com >
|
||||
WWW: http://openmw.snaptoad.com/
|
||||
|
||||
This file (soundlist.d) is part of the OpenMW package.
|
||||
|
||||
OpenMW is distributed as free software: you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
version 3, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
version 3 along with this program. If not, see
|
||||
http://www.gnu.org/licenses/ .
|
||||
|
||||
*/
|
||||
|
||||
module scene.soundlist;
|
||||
|
||||
import esm.loadsoun;
|
||||
import sound.audio;
|
||||
import sound.sfx;
|
||||
|
||||
SoundList soundScene;
|
||||
|
||||
// Has a list over all sounds currently playing in the
|
||||
// scene. Currently only holds static, looping sounds, mainly
|
||||
// torches. Later I will have to decide what to do with play-once
|
||||
// sounds. Do I bother to update their position, or do I assume that
|
||||
// once it starts playing, it is short enough that it doesn't matter?
|
||||
// The last option is probably not viable, since some sounds can be
|
||||
// very long.
|
||||
struct SoundList
|
||||
{
|
||||
SoundInstance[] list;
|
||||
|
||||
// Get a sound instance from a Sound struct
|
||||
static SoundInstance getInstance(Sound *s, bool loop=false)
|
||||
{
|
||||
const distFactor = 40.0; // Just guessing, really.
|
||||
|
||||
assert(!s.sound.isEmpty());
|
||||
|
||||
SoundInstance inst = s.sound.getInstance();
|
||||
inst.setParams(s.data.volume/255.0,
|
||||
s.data.minRange*distFactor,
|
||||
s.data.maxRange*distFactor,
|
||||
loop);
|
||||
return inst;
|
||||
}
|
||||
|
||||
SoundInstance *insert(Sound *snd, bool loop=false)
|
||||
{
|
||||
// For some reason, we get called with empty sound instances here
|
||||
// if some files are missing, but not for others. Check into it
|
||||
// later.
|
||||
if(snd.sound.isEmpty) return null;
|
||||
|
||||
// Reuse a dead instance if one exists
|
||||
foreach(ref s; list)
|
||||
{
|
||||
if(s.owner == null)
|
||||
{
|
||||
s = getInstance(snd, loop);
|
||||
return &s;
|
||||
}
|
||||
}
|
||||
// Otherwise append a new one
|
||||
list ~= getInstance(snd, loop);
|
||||
return &list[$-1];
|
||||
}
|
||||
|
||||
void update(float x, float y, float z,
|
||||
float frontx, float fronty, float frontz,
|
||||
float upx, float upy, float upz)
|
||||
{
|
||||
SoundInstance.setPlayerPos(x,y,z,frontx,fronty,frontz,upx,upy,upz);
|
||||
foreach(ref s; list)
|
||||
if(s.owner) s.updateSound();
|
||||
}
|
||||
|
||||
void kill()
|
||||
{
|
||||
foreach(ref s; list)
|
||||
{
|
||||
if(s.owner) s.kill();
|
||||
}
|
||||
list = null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue