From 138dbc83d5720c8baa7270ece183ce356f619fce Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 18 Nov 2010 15:36:02 +0000 Subject: Have core::Parser handle axis rotations in the same manner as model::MapFile. --- src/core/parser.cc | 34 ++++++++++++++++++++++++++-------- src/model/mapfile.cc | 9 +-------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/core/parser.cc b/src/core/parser.cc index 22b2fc3..efcc58b 100644 --- a/src/core/parser.cc +++ b/src/core/parser.cc @@ -19,10 +19,7 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) std::string shapename; std::string strval; - float direction; - float pitch; - float roll; - + float yaw, pitch, roll; float f; bool blnval; @@ -75,16 +72,37 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) entity->unset_flag(Entity::ShowOnMap); return true; - } else if (inifile.got_key_angle("direction", direction)) { - entity->get_axis().change_direction(direction); + } else if (inifile.got_key_float("angle", yaw)) { + + if (yaw == model::ANGLEUP) { + entity->get_axis().change_pitch(-90.0f); + } else if (yaw == model::ANGLEDOWN) { + entity->get_axis().change_pitch(90.0f); + } else { + entity->get_axis().change_direction(yaw); + } + return true; + + } else if (inifile.got_key("angles")) { + + std::istringstream str(inifile.value()); + if (str >> pitch >> yaw >> roll) { + entity->get_axis().assign(yaw, pitch, roll); + } else { + inifile.unknown_value(); + } + return true; + + } else if (inifile.got_key_angle("yaw", yaw)) { + entity->get_axis().change_direction(yaw); return true; } else if (inifile.got_key_angle("pitch", pitch)) { - entity->get_axis().change_pitch(pitch); + entity->get_axis().change_pitch(-pitch); return true; } else if (inifile.got_key_angle("roll", roll)) { - entity->get_axis().change_roll(roll); + entity->get_axis().change_roll(-roll); return true; } else if (inifile.got_key_angle("radius", f)) { diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index b74cdbe..f8e541c 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -816,22 +816,15 @@ bool MapFile::got_key_axis(math::Axis &axis) return true; } else if (got_key_float("pitch", pitch)) { - // TODO this warning should eventually disappear - unknown_error("'" + classname() + ":" + key() + "' has switched sign"); - axis.change_pitch(-pitch); - + axis.change_pitch(-pitch); return true; } else if (got_key_float("yaw", yaw)) { axis.change_direction(yaw); - return true; } else if (got_key_float("roll", roll)) { - // TODO this warning should eventually disappear - unknown_error("'" + classname() + ":" + key() + "' has switched sign"); axis.change_roll(-roll); - return true; } -- cgit v1.2.3