From d8be908233fd7b85492d7a9e87f07bb207173990 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 25 Nov 2012 12:06:13 +0000 Subject: Moved core::EntityGlobe into a separate file, added various methods to core::Item and core::Slot, added r_slots cvar to draw entity slots and docks, added game methods for mounting and umounting of weapons, added playerlist to chat window. --- src/model/mapfile.cc | 16 +++++++++++++++- src/model/model.cc | 50 +++++++++++++++++++++++++++++++++++++------------- src/model/model.h | 20 +++++++++++++------- 3 files changed, 65 insertions(+), 21 deletions(-) (limited to 'src/model') diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index fd82036..9badc9b 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -2045,11 +2045,25 @@ Model * MapFile::load(std::string const &name) model->set_origin(map_center * -1.0f); // translate transformed vertex groups + size_t frags = 0; for (Model::Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) { FragmentGroup *fragmentgroup = (*git); fragmentgroup->set_location(fragmentgroup->location() - map_center); + frags += fragmentgroup->size(); } + // set a sane radius if the mapfile is empty + if (frags == 0) { + const float r = SCALE; + model->model_box.assign( + math::Vector3f(-r, -r, -r), + math::Vector3f(r, r, r) + + ); + model->set_radius(model->box().max().length()); + } + + // translate tags for (Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) { (*lit)->get_location() -= map_center; @@ -2074,7 +2088,7 @@ Model * MapFile::load(std::string const &name) 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; diff --git a/src/model/model.cc b/src/model/model.cc index f29350f..304e151 100644 --- a/src/model/model.cc +++ b/src/model/model.cc @@ -5,6 +5,7 @@ */ #include "sys/sys.h" +#include "auxiliary/functions.h" #include "model/model.h" #include "model/asefile.h" #include "model/mapfile.h" @@ -129,6 +130,10 @@ void Model::add_weapon(Weapon *weapon) model_weapons.push_back(weapon); } +void Model::print() const +{ +} + Model *Model::find(const std::string & name) { Registry::iterator it = model_registry.find(name); @@ -138,6 +143,27 @@ Model *Model::find(const std::string & name) return (*it).second; } +Model *Model::search(const std::string & searchname) +{ + std::string strsearchkey(aux::lowercase(searchname)); + std::stringstream str(strsearchkey); + + if (strsearchkey.size() < 3) { + return 0; + } + + for (Registry::iterator it = model_registry.begin(); it != model_registry.end(); it++) { + std::string label((*it).first); + Model *model= (*it).second; + + if (label.size() && (label.find(strsearchkey) != std::string::npos)) { + return model; + } + } + + return 0; +} + Model *Model::load(const std::string & name) { Model *model = find(name); @@ -178,22 +204,20 @@ void Model::clear() VertexArray::instance()->clear(); } -void Model::list_model(Model *model) -{ - size_t frags = 0; - for (Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) { - frags += (*git)->size(); - } - - con_print << " " << model->name() << " " << frags << " frags " << - model->model_tris_detail_count << "/" << model->model_tris_count << " detail/tris " << - model->model_quad_detail_count << "/" << model->model_quad_count << " detail/quads" << std::endl; -} - void Model::list() { for (Registry::iterator mit = model_registry.begin(); mit != model_registry.end(); mit++) { - list_model((*mit).second); + Model *model = (*mit).second; + size_t frags = 0; + + for (Groups::iterator git = model->groups().begin(); git != model->groups().end(); git++) { + frags += (*git)->size(); + } + + con_print << " " << model->name() << " " << frags << " frags " << + model->model_tris_detail_count << "/" << model->model_tris_count << " detail/tris " << + model->model_quad_detail_count << "/" << model->model_quad_count << " detail/quads " << + "radius " << model->radius() << std::endl; } diff --git a/src/model/model.h b/src/model/model.h index a33e365..3c94ad6 100644 --- a/src/model/model.h +++ b/src/model/model.h @@ -74,11 +74,15 @@ public: return model_radius; } - /// additional model fragment groups + /// print information about the model to console + void print() const; + + /// model fragment groups inline Groups & groups() { return model_groups; } + /// associated collisionmodel inline CollisionModel *collisionmodel() { return model_collisionmodel; } @@ -191,10 +195,16 @@ public: return model_registry; } - /// get name model, returns 0 if not found + /// search the model registry static Model *find(const std::string & name); + + /// search the model registry for a partial name + static Model *search(const std::string & searchname); - /// get named model from the registry and load it if necessary + /** + * @brief load a model + * If the model has already been loaded, a pointer to the existing instance will be returned + * */ static Model *load(const std::string & name); /// clear the model registry @@ -203,10 +213,6 @@ public: /// list the content of the model registry static void list(); - /// list one model - static void list_model(Model *model); - - private: std::string model_name; Docks model_docks; -- cgit v1.2.3