diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-18 10:59:23 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-18 10:59:23 +0000 |
commit | 415cbb44d031e0a348d937c917c629913da0afce (patch) | |
tree | b310564128d80bd24217cc32f71d39844dae5441 | |
parent | d419f413daa75262cbf9ba3eb271c4028b0b6921 (diff) |
parse engine sound from .map model
-rw-r--r-- | src/client/view.cc | 12 | ||||
-rw-r--r-- | src/core/entity.cc | 2 | ||||
-rw-r--r-- | src/model/map.cc | 13 | ||||
-rw-r--r-- | src/model/model.cc | 1 | ||||
-rw-r--r-- | src/model/model.h | 5 |
5 files changed, 29 insertions, 4 deletions
diff --git a/src/client/view.cc b/src/client/view.cc index 56c692e..34fe3fa 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -315,8 +315,16 @@ void render_sound() float pitch = 0.2f + entitycontrolable->thrust() * 0.8f; if (!state->state_enginesound) { - if ((state->state_enginesound = audio::Sources::get()) > 0 ) - audio::loop(state->state_enginesound, "engines/loop01", pitch, 0); + if ((state->state_enginesound = audio::Sources::get()) > 0 ) { + + size_t enginesound = 0; + if (entity->model()) + enginesound = entity->model()->enginesound(); + + std::stringstream soundname; + soundname << "engines/loop" << std::setfill('0') << std::setw(2) << enginesound; + audio::loop(state->state_enginesound, soundname.str().c_str(), pitch, 0); + } } if (state->state_enginesound) { diff --git a/src/core/entity.cc b/src/core/entity.cc index db40f76..a0b859b 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -86,7 +86,7 @@ Entity::Entity(unsigned int flags) : entity_flags = flags; entity_moduletypeid = 0; - entity_radius = 1.0f; + entity_radius = 0.5f; entity_shape = Diamond; entity_created = true; diff --git a/src/model/map.cc b/src/model/map.cc index 39e2b9c..972ae82 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -39,14 +39,25 @@ Model * Map::load(std::string const &name) if (mapfile.got_classname("worldspawn")) { + // new wordspawn + + } else if (mapfile.classname().compare("worldspawn") == 0 ) { + + // worldspawn attributes + if (mapfile.got_key_int("enginesound", u)) { + model->model_enginesound = u; + continue; + } + } else if (mapfile.got_classname("light")) { + // new light light = new Light(); model->add_light(light); } else if (mapfile.classname().compare("light") == 0 ) { - // light attributes + // light attributes if (mapfile.got_key_vector3f("origin", light->light_location)) { light->light_location *= SCALE; continue; diff --git a/src/model/model.cc b/src/model/model.cc index 6508fdf..2e9f0ba 100644 --- a/src/model/model.cc +++ b/src/model/model.cc @@ -29,6 +29,7 @@ Model::Model(std::string const & name) : model_lvertex_countdetail = 0; model_radius = 0.5f; + model_enginesound = 0; } Model::~Model() diff --git a/src/model/model.h b/src/model/model.h index cb1352f..d2b7d65 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -70,6 +70,9 @@ public: /// number of detail evertices in this model inline size_t lvertex_detail() const { return model_lvertex_countdetail; } + /// engine sound loop for this model + inline unsigned int enginesound() const { return model_enginesound; } + /// total number of triangles in this model size_t tris() const; @@ -115,6 +118,8 @@ public: size_t model_lvertex_count; size_t model_lvertex_countdetail; + unsigned int model_enginesound; + /* ---- static functions for the Model registry -------------------- */ /// the Model registry |