diff options
author | Stijn Buys <ingar@osirion.org> | 2009-08-15 08:18:13 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-08-15 08:18:13 +0000 |
commit | 4ca453e2272beed121b957244408a61b0b0d8b9b (patch) | |
tree | 6be8e297eb49da4d957081d8faeff64d6ff35e52 /src/model | |
parent | 05928e35b08a47f5c80b7aa9a5b391a0c1d76ad5 (diff) |
don't render entites behind the camera
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/asefile.cc | 1 | ||||
-rw-r--r-- | src/model/mapfile.cc | 235 | ||||
-rw-r--r-- | src/model/parts.cc | 2 | ||||
-rw-r--r-- | src/model/parts.h | 103 |
4 files changed, 204 insertions, 137 deletions
diff --git a/src/model/asefile.cc b/src/model/asefile.cc index edbd848..a9e57d4 100644 --- a/src/model/asefile.cc +++ b/src/model/asefile.cc @@ -462,7 +462,6 @@ Model * ASEFile::load(const std::string &name) fragment->add_vertex((triangle->v2() - center) * scale , triangle->n2(), triangle->t2(), false); model->model_tris_count++; - model->model_tris_detail_count++; } model->add_group(group); diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index 36dc536..a86e06e 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -1018,85 +1018,55 @@ Model * MapFile::load(std::string const &name) // new light light = new Light(); model->add_light(light); + continue; } else if (mapfile.classname().compare("light") == 0) { // light attributes if (mapfile.got_key_vector3f("origin", location)) { - light->set_location(location * SCALE); + light->get_location().assign(location * SCALE); continue; - } else if (mapfile.got_key_color("_color", light->light_color)) { + } else if (mapfile.got_key_color("_color", color)) { + 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)); + continue; - } else if (mapfile.got_key_float("light", light->light_radius)) { - light->light_radius *= LIGHTSCALE; + } else if (mapfile.got_key_float("light", r)) { + light->set_radius( r * LIGHTSCALE); + continue; - } else if (mapfile.got_key_float("radius", light->light_radius)) { - light->light_radius *= LIGHTSCALE; + } else if (mapfile.got_key_float("radius", r)) { + light->set_radius( r * LIGHTSCALE); + continue; - } else if (mapfile.got_key_float("frequency", light->light_frequency)) { + } else if (mapfile.got_key_float("frequency", r)) { + light->set_frequency(r); continue; - } else if (mapfile.got_key_float("offset", light->light_offset)) { + } else if (mapfile.got_key_float("offset", r)) { + light->set_offset(r); continue; - } else if (mapfile.got_key_float("time", light->light_time)) { + } else if (mapfile.got_key_float("time", r)) { + light->set_time(r); continue; - } else if (mapfile.got_key_int("flare", light->light_flare)) { + } else if (mapfile.got_key_int("flare", u)) { + light->set_flare(u); continue; } else if (mapfile.got_key()) { mapfile.unknown_key(); - - } - - } else if (mapfile.got_classname("location_dock")) { - - // new docking location - dock = new Dock(); - model->add_dock(dock); - - } else if (mapfile.classname().compare("location_dock") == 0) { - - // dock attributes - if (mapfile.got_key_vector3f("origin", dock->dock_location)) { - dock->dock_location *= SCALE; - continue; - - } else if (mapfile.got_key_float("radius", dock->dock_radius)) { - dock->dock_radius *= SCALE; - continue; - - } else if (mapfile.got_key("angle")) { continue; - - } else if (mapfile.got_key()) { - mapfile.unknown_key(); - + } - } else if (mapfile.got_classname("location_cannon")) { - // new cannon - - } else if (mapfile.classname().compare("location_cannon") == 0) { - - } else if (mapfile.got_classname("location_turret")) { - // new turret - - } else if (mapfile.classname().compare("location_turret") == 0) { - - } else if (mapfile.got_classname("location_cockpit")) { - // cockpit location - - } else if (mapfile.classname().compare("location_cockpit") == 0) { - } else if (mapfile.got_classname("fx_flare")) { // new flare @@ -1107,10 +1077,11 @@ Model * MapFile::load(std::string const &name) // flare attributes if (mapfile.got_key_vector3f("origin", location)) { - flare->set_location(location * SCALE); + flare->get_location().assign(location * SCALE); continue; - } else if (mapfile.got_key_color("_color", flare->light_color)) { + } else if (mapfile.got_key_color("_color", color)) { + flare->get_color().assign(color); continue; } else if (mapfile.got_key_int("spawnflags", u)) { @@ -1118,19 +1089,24 @@ Model * MapFile::load(std::string const &name) flare->set_entity(spawnflag_isset(u, 2)); flare->set_engine(spawnflag_isset(u, 4)); - } else if (mapfile.got_key_float("radius", flare->light_radius)) { - flare->light_radius *= LIGHTSCALE; - - } else if (mapfile.got_key_float("frequency", flare->light_frequency)) { + } else if (mapfile.got_key_float("radius", r)) { + flare->set_radius( r * LIGHTSCALE); + continue; + + } else if (mapfile.got_key_float("frequency", r)) { + flare->set_frequency(r); continue; - } else if (mapfile.got_key_float("offset", flare->light_offset)) { + } else if (mapfile.got_key_float("offset", r)) { + flare->set_offset(r); continue; - } else if (mapfile.got_key_float("time", flare->light_time)) { + } else if (mapfile.got_key_float("time", r)) { + flare->set_time(r); continue; - } else if (mapfile.got_key_int("flare", flare->light_flare)) { + } else if (mapfile.got_key_int("flare", u)) { + flare->set_flare(u); continue; } else if (mapfile.got_key_float("angle", angle)) { @@ -1167,46 +1143,6 @@ Model * MapFile::load(std::string const &name) mapfile.unknown_key(); } - } else if (mapfile.got_classname("misc_model")) { - - // new submodel - submodel = new SubModel(); - submodel_list.push_back(submodel); - - } else if (mapfile.classname().compare("misc_model") == 0) { - - // submodel attributes - if (mapfile.got_key_vector3f("origin", location)) { - submodel->set_location(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); - continue; - - } else if (mapfile.got_key_float("angle", angle)) { - if (angle == ANGLEUP) { - submodel->axis().change_pitch(90.0f); - } else if (angle == ANGLEDOWN) { - submodel->axis().change_pitch(-90.0f); - } else { - submodel->axis().change_direction(angle); - } - - } else if (mapfile.got_key_float("modelscale", s)) { - if (s) { - submodel->set_scale(s); - } else { - submodel->set_scale(1.0f); - } - } - } else if (mapfile.got_classname("fx_particles")) { // new particle system @@ -1217,10 +1153,13 @@ Model * MapFile::load(std::string const &name) // particle system attributes if (mapfile.got_key_vector3f("origin", location)) { - particles->set_location(location * SCALE); + particles->get_location().assign(location * SCALE); continue; - } else if (mapfile.got_key_string("script", particles->particles_script)) { + + } else if (mapfile.got_key_string("script", str)) { + particles->set_script(str); continue; + } else if (mapfile.got_key_float("angle", angle)) { if (angle == ANGLEUP) { particles->get_axis().change_pitch(90.0f); @@ -1261,7 +1200,99 @@ Model * MapFile::load(std::string const &name) } else if (mapfile.got_key()) { mapfile.unknown_key(); } + + } else if (mapfile.got_classname("misc_model")) { + + // new submodel + submodel = new SubModel(); + submodel_list.push_back(submodel); + + } else if (mapfile.classname().compare("misc_model") == 0) { + + // submodel attributes + if (mapfile.got_key_vector3f("origin", location)) { + submodel->set_location(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); + continue; + + } else if (mapfile.got_key_float("angle", angle)) { + if (angle == ANGLEUP) { + submodel->axis().change_pitch(90.0f); + } else if (angle == ANGLEDOWN) { + submodel->axis().change_pitch(-90.0f); + } else { + submodel->axis().change_direction(angle); + } + + } else if (mapfile.got_key_float("modelscale", s)) { + if (s) { + submodel->set_scale(s); + } else { + submodel->set_scale(1.0f); + } + } + + } else if (mapfile.got_classname("location_dock")) { + + // new docking location + dock = new Dock(); + model->add_dock(dock); + + } else if (mapfile.classname().compare("location_dock") == 0) { + + // dock attributes + if (mapfile.got_key_vector3f("origin", location)) { + dock->get_location().assign(location * SCALE); + continue; + + } else if (mapfile.got_key_float("radius", r)) { + dock->set_radius (r * SCALE); + continue; + + } else if (mapfile.got_key("angle")) { + // TODO + continue; + + } else if (mapfile.got_key()) { + mapfile.unknown_key(); + + } + + } else if (mapfile.got_classname("location_cannon")) { + // TODO cannon attachment point + continue; + + } else if (mapfile.classname().compare("location_cannon") == 0) { + // TODO cannon options + continue; + + } else if (mapfile.got_classname("location_turret")) { + // TODO turret attachment point + continue; + + } else if (mapfile.classname().compare("location_turret") == 0) { + // TODO turret options + continue; + + } else if (mapfile.got_classname("location_cockpit")) { + // TODO cockpit location + continue; + + } else if (mapfile.classname().compare("location_cockpit") == 0) { + // TODO cockpit options + continue; + } else if (mapfile.got_classname()) { + mapfile.unknown_class(); } } @@ -1282,7 +1313,7 @@ Model * MapFile::load(std::string const &name) } for (Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) { - (*dit)->dock_location -= mapfile.map_center; + (*dit)->get_location() -= mapfile.map_center; } // FIXME this will go wrong if a Rotate group is imported as submodel diff --git a/src/model/parts.cc b/src/model/parts.cc index bcd8446..eabc108 100644 --- a/src/model/parts.cc +++ b/src/model/parts.cc @@ -25,7 +25,7 @@ Light::Light() : light_flare = 0; - render_texture = 0; + light_texture = 0; } Light::~Light() diff --git a/src/model/parts.h b/src/model/parts.h index 78ad5e4..c3a0401 100644 --- a/src/model/parts.h +++ b/src/model/parts.h @@ -120,7 +120,7 @@ public: } /// true if this light has engine activation - inline const bool engine() const + inline bool engine() const { return light_engine; } @@ -137,7 +137,7 @@ public: return light_offset; } - /// frequency in strobes per second + /// strobe frequency in strobes per second, default is 1.0f inline float frequency() const { return light_frequency; @@ -155,41 +155,78 @@ public: return light_flare; } - /// render texture number + /// render texture id inline size_t texture() const { - return render_texture; + return light_texture; } /* ---- mutators ------------------------------------------- */ - /// set strobe on or off - inline void set_strobe(bool strobe) { light_strobe = strobe; } + /** + * @brief set strobe color on or off + */ + inline void set_strobe(const bool strobe) { light_strobe = strobe; } /** * @brief set entity color on or off */ - inline void set_entity(bool entity) { light_entity = entity; } + inline void set_entity(const bool entity) { light_entity = entity; } /** * @brief set engine activation on or off */ - inline void set_engine(bool engine) { light_engine = engine; } + inline void set_engine(const bool engine) { light_engine = engine; } + /** + * @brief set the light radius + */ + inline void set_radius(const float radius) { light_radius = radius; } - math::Color light_color; - float light_radius; - float light_frequency; - float light_offset; - float light_time; + /** + * @brief set the light strobe frequency, in strobes per second + */ + inline void set_frequency(const float frequency) { light_frequency = frequency; } - unsigned int light_flare; + /** + * @brief set the light on time, from 0.0 (always off) to 1.0 (always on) + */ + inline void set_time(const float time) { light_radius = time; } - size_t render_texture; + /** + * @brief set the light strobe time offset, in seconds + */ + inline void set_offset(const float offset) { light_offset = offset; } + + /** + * @brief set the flare texture number + */ + inline void set_flare(unsigned int flare) { light_flare = flare; } + + /** + * @brief set the render texture id + */ + inline void set_texture(size_t texture) { light_texture = texture; } + /** + * @brief mutable reference to the color + */ + inline math::Color& get_color() { return light_color; } + private: bool light_strobe; bool light_engine; bool light_entity; + + unsigned int light_flare; + + float light_radius; + float light_frequency; + float light_offset; + float light_time; + + math::Color light_color; + + size_t light_texture; }; /* ---- class Flare ------------------------------------------------ */ @@ -223,11 +260,11 @@ public: /** * @brief mutable reference to the axis */ - inline math::Axis &get_axis() { return flare_axis; } + inline math::Axis& get_axis() { return flare_axis; } private: - math::Axis flare_axis; Cull flare_cull; + math::Axis flare_axis; }; /* ---- class Particles -------------------------------------------- */ @@ -285,7 +322,9 @@ public: inline void set_radius(const float radius) { particles_radius = radius; } inline void set_cull(const Cull cull) { particles_cull = cull; } - + + inline void set_script(const std::string &script) { particles_script.assign(script); } + /* ---- actors --------------------------------------------- */ /** @@ -293,39 +332,37 @@ public: */ inline math::Axis &get_axis() { return particles_axis; } - std::string particles_script; - private: - math::Axis particles_axis; - float particles_radius; bool particles_entity; bool particles_engine; + Cull particles_cull; + + float particles_radius; + + math::Axis particles_axis; + std::string particles_script; }; /* ---- class Dock ------------------------------------------------- */ /// a docking location -class Dock +class Dock : public Part { public: Dock(); ~Dock(); - /// location of the dock - inline const math::Vector3f & location() const - { - return dock_location; - } - - /// trigger distance default is 0.01f + /// dock radius, default is 0.01f inline float radius() const { return dock_radius; } - - - math::Vector3f dock_location; + + /// set dock radius + inline void set_radius(const float radius) { dock_radius = radius; } + +private: float dock_radius; }; |