Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/mapfile.cc')
-rw-r--r--src/model/mapfile.cc235
1 files changed, 133 insertions, 102 deletions
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