From d1931b1ebbe79cbd0f41290acbf9cb6d4c462878 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 22 Apr 2012 19:48:03 +0000 Subject: Load model weapon tags. --- src/model/mapfile.cc | 53 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) (limited to 'src/model/mapfile.cc') diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index d24a684..fd82036 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -1439,6 +1439,7 @@ Model * MapFile::load(std::string const &name) Light *tag_light = 0; SubModel *tag_submodel = 0; Sound *tag_sound = 0; + Weapon *tag_weapon = 0; std::string modelname; math::Vector3f location; @@ -1828,19 +1829,57 @@ Model * MapFile::load(std::string const &name) } } else if (mapfile.got_classname("location_cannon")) { - // TODO cannon attachment point + + // new cannon slot + tag_weapon = new Weapon(); + model->add_weapon(tag_weapon); continue; } else if (mapfile.classname().compare("location_cannon") == 0) { - // TODO cannon options + + // cannon options + if (mapfile.got_key_axis(tag_weapon->get_axis())) { + continue; + + } else if (mapfile.got_key_vector3f("origin", location)) { + tag_weapon->get_location().assign(location * SCALE); + continue; + + } else if (mapfile.got_key_float("radius", r)) { + tag_weapon->set_radius(r * SCALE); + continue; + + } else if (mapfile.got_key()) { + mapfile.unknown_key(); + + } continue; - } else if (mapfile.got_classname("location_turret")) { - // TODO turret attachment point + } else if (mapfile.got_classname("location_turret")) { + + // new turret slot + tag_weapon = new Weapon(); + model->add_weapon(tag_weapon); continue; } else if (mapfile.classname().compare("location_turret") == 0) { - // TODO turret options + + // turret options + if (mapfile.got_key_axis(tag_weapon->get_axis())) { + continue; + + } else if (mapfile.got_key_vector3f("origin", location)) { + tag_weapon->get_location().assign(location * SCALE); + continue; + + } else if (mapfile.got_key_float("radius", r)) { + tag_weapon->set_radius(r * SCALE); + continue; + + } else if (mapfile.got_key()) { + mapfile.unknown_key(); + + } continue; } else if (mapfile.got_classname("location_cockpit")) { @@ -2031,6 +2070,10 @@ Model * MapFile::load(std::string const &name) for (Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) { (*dit)->get_location() -= map_center; } + + for (Model::Weapons::iterator wit = model->weapons().begin(); wit != model->weapons().end(); wit++) { + (*wit)->get_location() -= map_center; + } if (mapfile.warning_q2brush) con_warn << mapfile.name() << " quake2 style brushes detected" << std::endl; -- cgit v1.2.3