Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/model')
-rw-r--r--src/model/mapfile.cc16
-rw-r--r--src/model/model.cc50
-rw-r--r--src/model/model.h20
3 files changed, 65 insertions, 21 deletions
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;