Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audio/audio.cc3
-rw-r--r--src/audio/audio.h2
-rw-r--r--src/client/client.cc12
-rw-r--r--src/client/soundext.cc52
-rw-r--r--src/client/soundext.h11
-rw-r--r--src/client/targets.cc39
-rw-r--r--src/client/targets.h6
-rw-r--r--src/game/game.cc4
-rw-r--r--src/model/mapfile.cc229
-rw-r--r--src/model/model.cc11
-rw-r--r--src/model/model.h36
11 files changed, 241 insertions, 164 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc
index e1eb0d3..2c8a7c1 100644
--- a/src/audio/audio.cc
+++ b/src/audio/audio.cc
@@ -182,7 +182,7 @@ size_t loop(size_t source_index, const char *name, float pitch, float gain)
return buffer_index;
}
-void update_listener(math::Vector3f const &location, math::Axis const &axis, math::Vector3f const & velocity)
+void update_listener(math::Vector3f const &location, math::Axis const &axis, math::Vector3f const & velocity, float gain)
{
if (!audio_context)
return;
@@ -195,6 +195,7 @@ void update_listener(math::Vector3f const &location, math::Axis const &axis, mat
orientation[i+3] = axis.up()[i];
}
alListenerfv(AL_ORIENTATION, orientation);
+ alListenerf(AL_GAIN, gain);
//alListenerfv(AL_VELOCITY, velocity.ptr());
}
diff --git a/src/audio/audio.h b/src/audio/audio.h
index 72a8fa4..ecfdf3e 100644
--- a/src/audio/audio.h
+++ b/src/audio/audio.h
@@ -57,7 +57,7 @@ size_t loop(size_t source_index, size_t buffer_index, float pitch, float gain);
void update_source(size_t source_index, math::Vector3f const & location, math::Vector3f const & velocity, float pitch = 1.0f, float gain = 1.0f);
/// update listener parameters
-void update_listener(math::Vector3f const &location, math::Axis const &axis, math::Vector3f const & velocity);
+void update_listener(math::Vector3f const &location, math::Axis const &axis, math::Vector3f const & velocity, float gain = 1.0f);
}
#endif // __INCLUDED_AUDIO_AUDIO_H__
diff --git a/src/client/client.cc b/src/client/client.cc
index 6a50743..5bf783a 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -16,6 +16,7 @@
#include "client/client.h"
#include "client/video.h"
#include "client/input.h"
+#include "client/soundext.h"
#include "core/core.h"
#include "core/loader.h"
#include "core/zone.h"
@@ -86,7 +87,16 @@ void Client::init(int count, char **arguments)
cvar = core::Cvar::get("rconpassword", "", core::Cvar::Archive | core::Cvar::Info);
cvar->set_info("[string] password for remote console access");
-
+
+ snd_volume = core::Cvar::get("snd_volume", "0.8", core::Cvar::Archive);
+ snd_volume->set_info("[float] master volume from 0 (mute) to 1 (max volume)");
+
+ snd_engines = core::Cvar::get("snd_engines", "1", core::Cvar::Archive);
+ snd_engines->set_info("[bool] enable or disable engine sounds");
+
+ snd_doppler = core::Cvar::get("snd_doppler", "0", core::Cvar::Archive);
+ snd_doppler->set_info("[bool] enable or disable doppler effect");
+
// initialize SDL, but do not initialize any subsystems
SDL_Init(0);
diff --git a/src/client/soundext.cc b/src/client/soundext.cc
index 1ea0c94..04c37f9 100644
--- a/src/client/soundext.cc
+++ b/src/client/soundext.cc
@@ -13,6 +13,7 @@
#include "core/entity.h"
#include "client/soundext.h"
#include "client/client.h"
+#include "render/camera.h"
#include <sstream>
#include <iomanip>
@@ -20,6 +21,52 @@
namespace client
{
+// cvars are initialized in client.cc
+core::Cvar *snd_doppler = 0;
+core::Cvar *snd_engines = 0;
+core::Cvar *snd_volume = 0;
+
+float master_volume = 0;
+void render_listener_sound()
+{
+ if (!(snd_engines && snd_engines->value()))
+ return;
+
+ math::Vector3f velocity(0, 0 , 0);
+ if (core::localcontrol()) {
+ velocity.assign(core::localcontrol()->axis().forward() * core::localcontrol()->speed());
+ }
+
+ if (master_volume != snd_volume->value()) {
+ master_volume = snd_volume->value();
+ math::clamp(master_volume, 0, 1);
+ (*snd_volume) = master_volume;
+ }
+
+ audio::update_listener(render::Camera::eye(), render::Camera::axis(), velocity, master_volume);
+}
+
+void render_entity_sound(core::Entity *entity)
+{
+ if (!(snd_engines && snd_engines->value())) {
+ if (ext_sound(entity))
+ delete ext_sound(entity);
+ return;
+ }
+
+ if (!ext_render(entity) || (ext_render(entity) && !ext_render(entity)->visible())) {
+ if (ext_sound(entity))
+ delete ext_sound(entity);
+ return;
+ } else {
+ if (!ext_sound(entity)) {
+ new SoundExt(entity);
+ }
+
+ ext_sound(entity)->frame(0.0f);
+ }
+}
+
SoundExt::SoundExt(core::Entity *entity) : core::Extension(core::Extension::Sound, entity)
{
state_thusterloopbuffer = 0;
@@ -103,7 +150,10 @@ void SoundExt::frame(float elapsed)
gain = 1.0f;
} else if (entity->thrust() > 0) {
pitch = 0.2f + entity->thrust() * 0.8f;
- gain = 0.8f;
+ gain = 1.0f;
+ if (entity->thrust() < 0.2f) {
+ gain *= entity->thrust() * 5.0f;
+ }
}
if (entity->state() == core::Entity::ImpulseInitiate) {
diff --git a/src/client/soundext.h b/src/client/soundext.h
index a99cee0..b0fc17a 100644
--- a/src/client/soundext.h
+++ b/src/client/soundext.h
@@ -8,10 +8,15 @@
#define __INCLUDED_CLIENT_SOUNDEXT_H__
#include "core/extension.h"
+#include "core/cvar.h"
namespace client
{
+extern core::Cvar *snd_engines;
+extern core::Cvar *snd_doppler;
+extern core::Cvar *snd_volume;
+
/// the sound extension of an entity
class SoundExt : public core::Extension
{
@@ -43,6 +48,12 @@ private:
size_t state_engineeventsource;
};
+/// render listener sound
+void render_listener_sound();
+
+/// render sound for a single entity
+void render_entity_sound(core::Entity *entity);
+
}
//namespace client
//
diff --git a/src/client/targets.cc b/src/client/targets.cc
index cd3db41..d915f20 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -39,7 +39,6 @@ unsigned int current_target_id = 0;
unsigned int current_hover = 0;
core::Entity *current_target = 0;
-core::Cvar *snd_engines = 0;
bool is_valid_hud_target(core::Entity *entity)
{
@@ -263,9 +262,6 @@ void reset()
void init()
{
- snd_engines = core::Cvar::get("snd_engines", "1", core::Cvar::Archive);
- snd_engines->set_info("[bool] enable or disable engine sounds");
-
core::Func *func = 0;
func = core::Func::add("target_next", func_target_next);
@@ -293,41 +289,6 @@ void shutdown()
core::Func::remove("target_center");
}
-void render_listener_sound()
-{
- if (!(snd_engines && snd_engines->value()))
- return;
-
- math::Vector3f velocity(0, 0 , 0);
- if (core::localcontrol()) {
- velocity.assign(core::localcontrol()->axis().forward() * core::localcontrol()->speed());
- }
-
- audio::update_listener(render::Camera::eye(), render::Camera::axis(), velocity);
-}
-
-void render_entity_sound(core::Entity *entity)
-{
- if (!(snd_engines && snd_engines->value())) {
- if (ext_sound(entity))
- delete ext_sound(entity);
- return;
- }
-
- if (!ext_render(entity) || (ext_render(entity) && !ext_render(entity)->visible())) {
- if (ext_sound(entity))
- delete ext_sound(entity);
- return;
- } else {
- if (!ext_sound(entity)) {
- new SoundExt(entity);
- }
-
- ext_sound(entity)->frame(0.0f);
- }
-}
-
-
// render targets and sounds (in world coordinates)
void frame()
{
diff --git a/src/client/targets.h b/src/client/targets.h
index 9bfa87d..5a3a655 100644
--- a/src/client/targets.h
+++ b/src/client/targets.h
@@ -33,12 +33,6 @@ bool is_valid_map_target(core::Entity *entity);
/// render targets and sounds
void frame();
-/// render sound listener properties
-void render_listener_sound();
-
-/// render the sound for one entity
-void render_entity_sound(core::Entity *Entity);
-
/// currently selected target, 0 if there is none
core::Entity *current();
diff --git a/src/game/game.cc b/src/game/game.cc
index 2a9ddad..b7c15db 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -17,11 +17,11 @@ void register_modules(bool register_noninteractive_modules)
{
con_print << "^BRegistering game modules..." << std::endl;
- // non-interactive modules
+ // interactive modules
core::Loader::add("base", game::factory);
core::Loader::add("example", example::factory);
- // interactive modules
+ // non-interactive modules
if (register_noninteractive_modules) {
core::Loader::add("intro", intro::factory);
}
diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc
index 8dff219..aa0cb37 100644
--- a/src/model/mapfile.cc
+++ b/src/model/mapfile.cc
@@ -970,11 +970,12 @@ Model * MapFile::load(std::string const &name)
Model *model = new Model(name);
mapfile.clear_bbox();
- Dock *dock = 0;
- Particles *particles = 0;
- Flare *flare = 0;
- Light *light = 0;
- SubModel *submodel = 0;
+ Dock *tag_dock = 0;
+ Particles *tag_particles = 0;
+ Flare *tag_flare = 0;
+ Light *tag_light = 0;
+ SubModel *tag_submodel = 0;
+ Sound *tag_sound = 0;
std::string modelname;
math::Vector3f location;
@@ -1074,50 +1075,50 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.got_classname("light")) {
- // new light
- light = new Light();
- model->add_light(light);
+ // new light tag
+ tag_light = new Light();
+ model->add_light(tag_light);
continue;
} else if (mapfile.classname().compare("light") == 0) {
// light attributes
if (mapfile.got_key_vector3f("origin", location)) {
- light->get_location().assign(location * SCALE);
+ tag_light->get_location().assign(location * SCALE);
continue;
} else if (mapfile.got_key_color("_color", color)) {
- light->get_color().assign(color);
+ tag_light->get_color().assign(color);
continue;
} else if (mapfile.got_key_int("spawnflags", u)) {
- light->set_strobe(spawnflag_isset(u, 1));
- light->set_entity(spawnflag_isset(u, 2));
- light->set_engine(spawnflag_isset(u, 4));
+ tag_light->set_strobe(spawnflag_isset(u, 1));
+ tag_light->set_entity(spawnflag_isset(u, 2));
+ tag_light->set_engine(spawnflag_isset(u, 4));
continue;
} else if (mapfile.got_key_float("light", r)) {
- light->set_radius(r * LIGHTSCALE);
+ tag_light->set_radius(r * LIGHTSCALE);
continue;
} else if (mapfile.got_key_float("radius", r)) {
- light->set_radius(r * LIGHTSCALE);
+ tag_light->set_radius(r * LIGHTSCALE);
continue;
} else if (mapfile.got_key_float("frequency", r)) {
- light->set_frequency(r);
+ tag_light->set_frequency(r);
continue;
} else if (mapfile.got_key_float("offset", r)) {
- light->set_offset(r);
+ tag_light->set_offset(r);
continue;
} else if (mapfile.got_key_float("time", r)) {
- light->set_time(r);
+ tag_light->set_time(r);
continue;
} else if (mapfile.got_key_int("flare", u)) {
- light->set_flare(u);
+ tag_light->set_flare(u);
continue;
} else if (mapfile.got_key()) {
@@ -1128,76 +1129,76 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.got_classname("fx_flare")) {
- // new flare
- flare = new Flare();
- model->add_flare(flare);
+ // new flare tag
+ tag_flare = new Flare();
+ model->add_flare(tag_flare);
} else if (mapfile.classname().compare("fx_flare") == 0) {
// flare attributes
if (mapfile.got_key_vector3f("origin", location)) {
- flare->get_location().assign(location * SCALE);
+ tag_flare->get_location().assign(location * SCALE);
continue;
} else if (mapfile.got_key_color("_color", color)) {
- flare->get_color().assign(color);
+ tag_flare->get_color().assign(color);
continue;
} else if (mapfile.got_key_int("spawnflags", u)) {
- flare->set_strobe(spawnflag_isset(u, 1));
- flare->set_entity(spawnflag_isset(u, 2));
- flare->set_engine(spawnflag_isset(u, 4));
+ tag_flare->set_strobe(spawnflag_isset(u, 1));
+ tag_flare->set_entity(spawnflag_isset(u, 2));
+ tag_flare->set_engine(spawnflag_isset(u, 4));
} else if (mapfile.got_key_float("light", r)) {
- flare->set_radius(r * LIGHTSCALE);
+ tag_flare->set_radius(r * LIGHTSCALE);
continue;
} else if (mapfile.got_key_float("radius", r)) {
- flare->set_radius(r * LIGHTSCALE);
+ tag_flare->set_radius(r * LIGHTSCALE);
continue;
} else if (mapfile.got_key_float("frequency", r)) {
- flare->set_frequency(r);
+ tag_flare->set_frequency(r);
continue;
} else if (mapfile.got_key_float("offset", r)) {
- flare->set_offset(r);
+ tag_flare->set_offset(r);
continue;
} else if (mapfile.got_key_float("time", r)) {
- flare->set_time(r);
+ tag_flare->set_time(r);
continue;
} else if (mapfile.got_key_int("flare", u)) {
- flare->set_flare(u);
+ tag_flare->set_flare(u);
continue;
} else if (mapfile.got_key_float("angle", angle)) {
if (angle == ANGLEUP) {
- flare->get_axis().change_pitch(90.0f);
+ tag_flare->get_axis().change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
- flare->get_axis().change_pitch(-90.0f);
+ tag_flare->get_axis().change_pitch(-90.0f);
} else {
- flare->get_axis().change_direction(angle);
+ tag_flare->get_axis().change_direction(angle);
}
} else if (mapfile.got_key_float("direction", angle)) {
- flare->get_axis().change_direction(angle);
+ tag_flare->get_axis().change_direction(angle);
} else if (mapfile.got_key_float("pitch", angle)) {
- flare->get_axis().change_pitch(angle);
+ tag_flare->get_axis().change_pitch(angle);
} else if (mapfile.got_key_float("roll", angle)) {
- flare->get_axis().change_roll(angle);
+ tag_flare->get_axis().change_roll(angle);
} else if (mapfile.got_key_string("cull", str)) {
aux::to_lowercase(str);
if (str.compare("none") == 0) {
- flare->set_cull(CullNone);
+ tag_flare->set_cull(CullNone);
} else if (str.compare("back") == 0) {
- flare->set_cull(CullBack);
+ tag_flare->set_cull(CullBack);
} else if (str.compare("front") == 0) {
- flare->set_cull(CullFront);
+ tag_flare->set_cull(CullFront);
} else {
mapfile.unknown_value();
}
@@ -1208,54 +1209,53 @@ Model * MapFile::load(std::string const &name)
} else if (mapfile.got_classname("fx_particles")) {
- // new particle system
- particles = new Particles();
- model->add_particles(particles);
+ // new particle system tag
+ tag_particles = new Particles();
+ model->add_particles(tag_particles);
} else if (mapfile.classname().compare("fx_particles") == 0) {
// particle system attributes
if (mapfile.got_key_vector3f("origin", location)) {
- particles->get_location().assign(location * SCALE);
+ tag_particles->get_location().assign(location * SCALE);
continue;
} else if (mapfile.got_key_string("script", str)) {
- particles->set_script(str);
+ tag_particles->set_script(str);
continue;
} else if (mapfile.got_key_float("angle", angle)) {
if (angle == ANGLEUP) {
- particles->get_axis().change_pitch(90.0f);
+ tag_particles->get_axis().change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
- particles->get_axis().change_pitch(-90.0f);
+ tag_particles->get_axis().change_pitch(-90.0f);
} else {
- particles->get_axis().change_direction(angle);
+ tag_particles->get_axis().change_direction(angle);
}
} else if (mapfile.got_key_float("direction", angle)) {
- particles->get_axis().change_direction(angle);
+ tag_particles->get_axis().change_direction(angle);
} else if (mapfile.got_key_float("pitch", angle)) {
- particles->get_axis().change_pitch(angle);
+ tag_particles->get_axis().change_pitch(angle);
} else if (mapfile.got_key_float("roll", angle)) {
- particles->get_axis().change_roll(angle);
+ tag_particles->get_axis().change_roll(angle);
} else if (mapfile.got_key_int("spawnflags", u)) {
- particles->set_entity(spawnflag_isset(u, 2));
- particles->set_engine(spawnflag_isset(u, 4));
+ tag_particles->set_entity(spawnflag_isset(u, 2));
+ tag_particles->set_engine(spawnflag_isset(u, 4));
} else if (mapfile.got_key_float("radius", r)) {
- particles->set_radius(r * LIGHTSCALE);
+ tag_particles->set_radius(r * LIGHTSCALE);
} else if (mapfile.got_key_string("cull", str)) {
-
aux::to_lowercase(str);
if (str.compare("none") == 0) {
- particles->set_cull(CullNone);
+ tag_particles->set_cull(CullNone);
} else if (str.compare("back") == 0) {
- particles->set_cull(CullBack);
+ tag_particles->set_cull(CullBack);
} else if (str.compare("front") == 0) {
- particles->set_cull(CullFront);
+ tag_particles->set_cull(CullFront);
} else {
mapfile.unknown_value();
}
@@ -1264,61 +1264,75 @@ Model * MapFile::load(std::string const &name)
mapfile.unknown_key();
}
+ } else if (mapfile.got_classname("fx_sound")) {
+
+ // new sound tag
+ tag_sound = new Sound();
+ model->add_sound(tag_sound);
+
+ } else if (mapfile.classname().compare("fx_sound") == 0) {
+
+ // sound attributes
+ if (mapfile.got_key_vector3f("origin", location)) {
+ tag_sound->get_location().assign(location * SCALE);
+ continue;
+ } else {
+ mapfile.unknown_key();
+ }
+
} else if (mapfile.got_classname("misc_model")) {
- // new submodel
- submodel = new SubModel();
- submodel_list.push_back(submodel);
+ // new submodel tag
+ tag_submodel = new SubModel();
+ submodel_list.push_back(tag_submodel);
} else if (mapfile.classname().compare("misc_model") == 0) {
// submodel attributes
if (mapfile.got_key_vector3f("origin", location)) {
- submodel->get_location().assign(location * SCALE);
+ tag_submodel->get_location().assign(location * SCALE);
continue;
} else if (mapfile.got_key_string("model", modelname)) {
-
// remove extension
if (modelname[modelname.size()-4] == '.') {
modelname.erase(modelname.size() - 4);
}
-
- submodel->set_name(modelname);
+ tag_submodel->set_name(modelname);
continue;
} else if (mapfile.got_key_float("angle", angle)) {
if (angle == ANGLEUP) {
- submodel->get_axis().change_pitch(90.0f);
+ tag_submodel->get_axis().change_pitch(90.0f);
} else if (angle == ANGLEDOWN) {
- submodel->get_axis().change_pitch(-90.0f);
+ tag_submodel->get_axis().change_pitch(-90.0f);
} else {
- submodel->get_axis().change_direction(angle);
+ tag_submodel->get_axis().change_direction(angle);
}
} else if (mapfile.got_key_float("modelscale", s)) {
if (s) {
- submodel->set_scale(s);
+ tag_submodel->set_scale(s);
} else {
- submodel->set_scale(1.0f);
+ tag_submodel->set_scale(1.0f);
}
}
} else if (mapfile.got_classname("location_dock")) {
// new docking location
- dock = new Dock();
- model->add_dock(dock);
+ tag_dock = new Dock();
+ model->add_dock(tag_dock);
} else if (mapfile.classname().compare("location_dock") == 0) {
// dock attributes
if (mapfile.got_key_vector3f("origin", location)) {
- dock->get_location().assign(location * SCALE);
+ tag_dock->get_location().assign(location * SCALE);
continue;
} else if (mapfile.got_key_float("radius", r)) {
- dock->set_radius(r * SCALE);
+ tag_dock->set_radius(r * SCALE);
continue;
} else if (mapfile.got_key("angle")) {
@@ -1362,7 +1376,7 @@ Model * MapFile::load(std::string const &name)
mapfile.close();
- // reposition docks, lights, flares and particles according to the model center
+ // translate model tags
for (Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) {
(*lit)->get_location() -= mapfile.map_center;
}
@@ -1375,20 +1389,24 @@ Model * MapFile::load(std::string const &name)
(*pit)->get_location() -= mapfile.map_center;
}
+ for(Model::Sounds::iterator sit = model->sounds().begin(); sit != model->sounds().end(); sit++) {
+ (*sit)->get_location() -= mapfile.map_center;
+ }
+
for (Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) {
(*dit)->get_location() -= mapfile.map_center;
}
for (SubModelList::iterator smit = submodel_list.begin(); smit != submodel_list.end(); smit++) {
- submodel = (*smit);
+ tag_submodel = (*smit);
Model *submodel_model = 0;
- if (submodel->name().size()) {
- submodel_model = Model::load(submodel->name());
+ if (tag_submodel->name().size()) {
+ submodel_model = Model::load(tag_submodel->name());
}
if (submodel_model) {
- submodel->get_location() -= mapfile.map_center;
+ tag_submodel->get_location() -= mapfile.map_center;
// copy fragmentgroups
for (Model::Groups::iterator git = submodel_model->groups().begin(); git != submodel_model->groups().end(); git++) {
@@ -1397,12 +1415,12 @@ Model * MapFile::load(std::string const &name)
groupdst->set_transform(true);
groupdst->set_type(groupsrc->type());
- groupdst->set_scale(groupsrc->scale() * submodel->scale());
+ groupdst->set_scale(groupsrc->scale() * tag_submodel->scale());
groupdst->set_speed(groupsrc->speed());
- groupdst->set_location(submodel->location() + (submodel_model->origin() + groupsrc->location()) * submodel->scale());
- groupdst->set_axis(groupsrc->axis() * submodel->axis());
+ groupdst->set_location(tag_submodel->location() + (submodel_model->origin() + groupsrc->location()) * tag_submodel->scale());
+ groupdst->set_axis(groupsrc->axis() * tag_submodel->axis());
- // copy fragments
+ // copy fragments, this only copies the original fragment's pointer into the vertex array
for (FragmentGroup::iterator fit = groupsrc->begin(); fit != groupsrc->end(); fit++) {
Fragment *fragmentdst = new Fragment(*(*fit));
groupdst->add_fragment(fragmentdst);
@@ -1418,12 +1436,12 @@ Model * MapFile::load(std::string const &name)
// recalculate bbox
for (size_t i = 0; i < 3; i ++) {
float c;
- c = submodel->location()[i] + (submodel_model->origin()[i] + submodel_model->model_maxbbox[i]) * submodel->scale();
+ c = tag_submodel->location()[i] + (submodel_model->origin()[i] + submodel_model->model_maxbbox[i]) * tag_submodel->scale();
if (c > model->model_maxbbox[i]) {
model->model_maxbbox[i] = c;
}
- c = submodel->location()[i] + (submodel_model->origin()[i] + submodel_model->model_minbbox[i]) * submodel->scale();
+ c = tag_submodel->location()[i] + (submodel_model->origin()[i] + submodel_model->model_minbbox[i]) * tag_submodel->scale();
if (c < model->model_minbbox[i]) {
model->model_minbbox[i] = c;
}
@@ -1431,33 +1449,42 @@ Model * MapFile::load(std::string const &name)
}
model->set_radius(sqrtf(math::max(model->model_maxbbox.lengthsquared(), model->model_minbbox.lengthsquared())));
- // copy lights, flares and particle systems
+ // copy light tags
for (Model::Lights::const_iterator lit = submodel_model->lights().begin(); lit != submodel_model->lights().end(); lit++) {
- light = new Light(*(*lit));
- light->get_location().assign(submodel->location() + (submodel_model->origin() + light->location()) * submodel->scale());
- light->set_radius(light->radius() * submodel->scale());
- model->add_light(light);
+ tag_light = new Light(*(*lit));
+ tag_light->get_location().assign(tag_submodel->location() + (submodel_model->origin() + tag_light->location()) * tag_submodel->scale());
+ tag_light->set_radius(tag_light->radius() * tag_submodel->scale());
+ model->add_light(tag_light);
}
+ // copy flare tags
for (Model::Flares::const_iterator flit = submodel_model->flares().begin(); flit != submodel_model->flares().end(); flit++) {
- flare = new Flare(*(*flit));
- flare->get_location().assign(submodel->location() + (submodel_model->origin() + flare->location()) * submodel->scale());
- flare->set_radius(flare->radius() * submodel->scale());
- model->add_flare(flare);
+ tag_flare = new Flare(*(*flit));
+ tag_flare->get_location().assign(tag_submodel->location() + (submodel_model->origin() + tag_flare->location()) * tag_submodel->scale());
+ tag_flare->set_radius(tag_flare->radius() * tag_submodel->scale());
+ model->add_flare(tag_flare);
}
+ // copy particle system tags
for (Model::ParticleSystems::const_iterator pit = submodel_model->particles().begin(); pit != submodel_model->particles().end(); pit++) {
- particles = new Particles(*(*pit));
- particles->get_location().assign(submodel->location() + (submodel_model->origin() + particles->location()) * submodel->scale());
- particles->set_radius(particles->radius() * submodel->scale());
- model->add_particles(particles);
+ tag_particles = new Particles(*(*pit));
+ tag_particles->get_location().assign(tag_submodel->location() + (submodel_model->origin() + tag_particles->location()) * tag_submodel->scale());
+ tag_particles->set_radius(tag_particles->radius() * tag_submodel->scale());
+ model->add_particles(tag_particles);
+ }
+
+ // copy sound tags
+ for (Model::Sounds::const_iterator sit = submodel_model->sounds().begin(); sit != submodel_model->sounds().end(); sit++) {
+ tag_sound = new Sound(*(*sit));
+ tag_sound->get_location().assign(tag_submodel->location() + (submodel_model->origin() + tag_sound->location()) * tag_submodel->scale());
}
+ // TODO copy engines and docks
//con_debug << " imported submodel '" << submodel->name() << "'" << std::endl;
}
- delete submodel;
+ delete tag_submodel;
}
diff --git a/src/model/model.cc b/src/model/model.cc
index 2ac2b50..5ba4deb 100644
--- a/src/model/model.cc
+++ b/src/model/model.cc
@@ -62,6 +62,12 @@ Model::~Model()
delete(*flit);
}
model_flares.clear();
+
+ // delete all sound tags
+ for (Sounds::iterator sit = model_sounds.begin(); sit != model_sounds.end(); sit++) {
+ delete (*sit);
+ }
+ model_sounds.clear();
}
void Model::set_radius(const float radius)
@@ -94,6 +100,11 @@ void Model::add_flare(Flare *flare)
model_flares.push_back(flare);
}
+void Model::add_sound(Sound *sound)
+{
+ model_sounds.push_back(sound);
+}
+
void Model::add_dock(Dock *dock)
{
model_docks.push_back(dock);
diff --git a/src/model/model.h b/src/model/model.h
index c8f60f1..dd9cdf2 100644
--- a/src/model/model.h
+++ b/src/model/model.h
@@ -37,18 +37,21 @@ public:
/// type definition for a list of model fragments
typedef std::list<Fragment *> Fragments;
- /// type definition for a list of model lights
+ /// type definition for a list of model light tags
typedef std::list<Light *> Lights;
- /// type definition for a list of model flares
+ /// type definition for a list of model flare tags
typedef std::list<Flare *> Flares;
- /// type definition for a lost of dockable locations
+ /// type definition for a list of model dock tags
typedef std::list<Dock *> Docks;
- /// type definition for a list of model particles
+ /// type definition for a list of model particle system tags
typedef std::list<Particles *> ParticleSystems;
+ /// type definition for a list of model sound tags
+ typedef std::list<Sound *> Sounds;
+
/// type definition for a list of FragmentGroups
typedef std::list<FragmentGroup *> Groups;
@@ -73,22 +76,27 @@ public:
return model_groups;
}
- /// list of lights
+ /// list of model light tags
inline Lights & lights() {
return model_lights;
}
- /// list of dockable locations
+ /// list of model dock tags
inline Docks & docks() {
return model_docks;
}
- /// list of flares
+ /// list of model flare tags
inline Flares & flares() {
return model_flares;
}
- /// list of engines
+ /// list of model sound tags
+ inline Sounds & sounds() {
+ return model_sounds;
+ }
+
+ /// list of model particle system tags
inline ParticleSystems & particles() {
return model_particles;
}
@@ -123,18 +131,21 @@ public:
return model_origin;
}
- /// add a light to the model
+ /// add a light tag to the model
void add_light(Light *light);
- /// add a particle system to the model
+ /// add a particle system tag to the model
void add_particles(Particles *particles);
- /// add a flare to the model
+ /// add a flare tag to the model
void add_flare(Flare *flare);
- /// add a docking location to the model
+ /// add a docking location tag to the model
void add_dock(Dock *dock);
+ /// add a sound tag to the model
+ void add_sound(Sound *sound);
+
/// add a fragment group to the model
void add_group(FragmentGroup *group);
@@ -187,6 +198,7 @@ private:
Docks model_docks;
Flares model_flares;
+ Sounds model_sounds;
Lights model_lights;
ParticleSystems model_particles;
Groups model_groups;