From d01664f17503d52d4be1c31e099065da0d38d7f3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 23 Nov 2008 22:13:03 +0000 Subject: merged model classes into one file, classname cleanup, fx_particles --- src/model/map.cc | 88 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 34 deletions(-) (limited to 'src/model/map.cc') diff --git a/src/model/map.cc b/src/model/map.cc index 1767743..29332ee 100644 --- a/src/model/map.cc +++ b/src/model/map.cc @@ -6,9 +6,6 @@ #include "filesystem/filesystem.h" #include "math/mathlib.h" -#include "model/dock.h" -#include "model/engine.h" -#include "model/light.h" #include "model/map.h" #include "model/material.h" #include "model/model.h" @@ -30,9 +27,6 @@ inline bool spawnflag_isset(unsigned int spawnflags, unsigned int flag) // max geometry bounds const float MAX_BOUNDS = 16384; -// scaling factor when loading .map geometry -const float SCALE = 1.0f / 1024.0f; - const float MIN_DELTA = 10e-10; Map::Map() : map_center(0,0,0) @@ -795,11 +789,12 @@ Model * Map::load(std::string const &name) Model *model = new Model(name); Dock *dock = 0; - Engine *engine = 0; + Particles *particles = 0; Flare *flare = 0; Light *light = 0; unsigned int u; + float angle; while (mapfile.getline()) { @@ -858,10 +853,10 @@ Model * Map::load(std::string const &name) light->light_entity = spawnflag_isset(u, 2); } else if (mapfile.got_key_float("light", light->light_radius)) { - light->light_radius /= 100.0f; + light->light_radius *= LIGHTSCALE; } else if (mapfile.got_key_float("radius", light->light_radius)) { - light->light_radius /= 100.0f; + light->light_radius *= LIGHTSCALE; } else if (mapfile.got_key_float("frequency", light->light_frequency)) { continue; @@ -880,13 +875,13 @@ Model * Map::load(std::string const &name) } - } else if (mapfile.got_classname("trigger_dock")) { + } else if (mapfile.got_classname("location_dock")) { // new docking location dock = new Dock(); model->add_dock(dock); - } else if (mapfile.classname().compare("trigger_dock") == 0) { + } else if (mapfile.classname().compare("location_dock") == 0) { // dock attributes if (mapfile.got_key_vector3f("origin", dock->dock_location)) { @@ -894,7 +889,7 @@ Model * Map::load(std::string const &name) continue; } else if (mapfile.got_key_float("radius", dock->dock_radius)) { - dock->dock_radius /= 100.0f; + dock->dock_radius *= SCALE; continue; } else if (mapfile.got_key("angle")) { @@ -905,13 +900,28 @@ Model * Map::load(std::string const &name) } - } else if (mapfile.got_classname("target_flare")) { + } 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 flare = new Flare(); model->add_flare(flare); - - } else if (mapfile.classname().compare("target_flare") == 0) { + + } else if (mapfile.classname().compare("fx_flare") == 0) { // flare attributes if (mapfile.got_key_vector3f("origin", flare->light_location)) { @@ -927,7 +937,7 @@ Model * Map::load(std::string const &name) flare->flare_engine = spawnflag_isset(u, 4); } else if (mapfile.got_key_float("radius", flare->light_radius)) { - flare->light_radius /= 100.0f; + flare->light_radius *= LIGHTSCALE; } else if (mapfile.got_key_float("frequency", flare->light_frequency)) { continue; @@ -949,35 +959,45 @@ Model * Map::load(std::string const &name) con_warn "unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; } - } else if (mapfile.got_classname("target_engine")) { - // new engine - engine = new Engine(); - model->add_engine(engine); - - } else if (mapfile.classname().compare("target_engine") == 0) { - // engine attributes + } else if (mapfile.got_classname("fx_particles")) { + + // new particle system + particles = new Particles(); + model->add_particles(particles); - if (mapfile.got_key_vector3f("origin", engine->engine_location)) { - engine->engine_location *= SCALE; + } else if (mapfile.classname().compare("fx_particles") == 0) { + + // particle system attributes + if (mapfile.got_key_vector3f("origin", particles->particles_location)) { + particles->particles_location *= SCALE; continue; - - } else if (mapfile.got_key_float("radius", engine->engine_radius)) { - engine->engine_radius /= 100.0f; + } else if (mapfile.got_key_string("script", particles->particles_script)) { continue; + } else if (mapfile.got_key_float("angle", angle)) { + particles->particles_axis.change_direction(angle); - } else if (mapfile.got_key("angle")) { - continue; + } else if (mapfile.got_key_float("direction", angle)) { + particles->particles_axis.change_direction(angle); + + } else if (mapfile.got_key_float("pitch", angle)) { + particles->particles_axis.change_pitch(angle); + + } else if (mapfile.got_key_float("roll", angle)) { + particles->particles_axis.change_roll(angle); } else if (mapfile.got_key()) { - con_warn "unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; + con_warn << "Unknown key " << mapfile.classname() << ":" << mapfile.key() << std::endl; } + } else if (mapfile.got_classname()) { + + con_warn << "Unkown class '" << mapfile.classname() << "'" << std::endl; } } mapfile.close(); - // reposition docks, lights, flares and engines according to the model center + // reposition docks, lights, flares and particles according to the model center for (Model::Lights::iterator lit = model->lights().begin(); lit != model->lights().end(); lit++) { (*lit)->light_location -= mapfile.map_center; } @@ -986,8 +1006,8 @@ Model * Map::load(std::string const &name) (*flit)->light_location -= mapfile.map_center; } - for (Model::Engines::iterator eit = model->engines().begin(); eit != model->engines().end(); eit++) { - (*eit)->engine_location -= mapfile.map_center; + for (Model::ParticleSystems::iterator pit = model->particles().begin(); pit != model->particles().end(); pit++) { + (*pit)->particles_location -= mapfile.map_center; } for (Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) { -- cgit v1.2.3