void Creature::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { _info = CreatureInfo(instance); // General properties if (blueprint) loadProperties(*blueprint); // Blueprint loadProperties(instance); // Instance // Appearance if (_appearance == Aurora::kFieldIDInvalid) throw Common::Exception("Creature without an appearance"); loadEquippedModel(); // Position setPosition(instance.getDouble("XPosition"), instance.getDouble("YPosition"), instance.getDouble("ZPosition")); // Orientation float bearingX = instance.getDouble("XOrientation"); float bearingY = instance.getDouble("YOrientation"); setOrientation(0.0f, 0.0f, 1.0f, -Common::rad2deg(atan2(bearingX, bearingY))); }
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { // General properties if (blueprint) loadProperties(*blueprint); // Blueprint loadProperties(instance); // Instance // Specialized object properties if (blueprint) loadObject(*blueprint); // Blueprint loadObject(instance); // Instance // Appearance if (_appearanceID == Aurora::kFieldIDInvalid) throw Common::Exception("Situated object without an appearance"); loadAppearance(); loadSounds(); // Position float posX = instance.getDouble("X"); float posY = instance.getDouble("Y"); float posZ = instance.getDouble("Z"); if (instance.hasField("Position")) { const Aurora::GFF3Struct &pos = instance.getStruct("Position"); posX = pos.getDouble("x"); posY = pos.getDouble("y"); posZ = pos.getDouble("z"); } setPosition(posX, posY, posZ); // Orientation float bearing = instance.getDouble("Bearing"); float rotX = 0.0f; float rotY = 0.0f; float rotZ = 1.0f; float rotW = Common::rad2deg(bearing); if (instance.hasField("Orientation")) { const Aurora::GFF3Struct &o = instance.getStruct("Orientation"); rotX = o.getDouble("x"); rotY = o.getDouble("y"); rotZ = o.getDouble("z"); rotW = -Common::rad2deg(acos(o.getDouble("w")) * 2.0); } setOrientation(rotX, rotY, rotZ, rotW); }
void Trigger::load(const Aurora::GFF3Struct &gff) { Common::UString temp = gff.getString("TemplateResRef"); Common::ScopedPtr<Aurora::GFF3File> utt; if (!temp.empty()) utt.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTT, MKTAG('U', 'T', 'T', ' '))); loadBlueprint(utt->getTopLevel()); if (!utt) warning("Trigger \"%s\" has no blueprint", temp.c_str()); float x, y, z; x = (float)gff.getDouble("XPosition"); y = (float)gff.getDouble("YPosition"); z = (float)gff.getDouble("ZPosition"); glm::vec3 position(x, y, z); setPosition(x, y, z); x = (float)gff.getDouble("XOrientation"); y = (float)gff.getDouble("YOrientation"); z = (float)gff.getDouble("ZOrientation"); glm::vec3 orientation(x, y, z); const Aurora::GFF3List &geometry = gff.getList("Geometry"); for (Aurora::GFF3List::const_iterator p = geometry.begin(); p != geometry.end(); ++p) { x = (float)(*p)->getDouble("PointX"); y = (float)(*p)->getDouble("PointY"); z = (float)(*p)->getDouble("PointZ"); _geometry.push_back(position + glm::vec3(x, y, z)); } }
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { // General properties if (blueprint) loadProperties(*blueprint); // Blueprint loadProperties(instance); // Instance // Specialized object properties if (blueprint) loadObject(*blueprint); // Blueprint loadObject(instance); // Instance // Appearance if (_appearanceID == Aurora::kFieldIDInvalid) warning("Situated object \"%s\" without an appearance", _tag.c_str()); loadAppearance(); loadSounds(); // Model if (!_modelName.empty()) { _model.reset(loadModelObject(_modelName)); if (!_model) throw Common::Exception("Failed to load situated object model \"%s\"", _modelName.c_str()); } else warning("Situated object \"%s\" (\"%s\") has no model", _name.c_str(), _tag.c_str()); if (_model) { // Clickable _model->setTag(_tag); _model->setClickable(isClickable()); // ID _ids.push_back(_model->getID()); } // Position setPosition(instance.getDouble("X"), instance.getDouble("Y"), instance.getDouble("Z")); // Orientation float bearing = instance.getDouble("Bearing"); setOrientation(0.0f, 0.0f, 1.0f, Common::rad2deg(bearing)); }
void Placeable::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Name and description gff.getLocString("LocName" , _name); gff.getLocString("LocPopupText", _description); // Conversation _conversation = gff.getString("Conversation", _conversation); // Static and usable _static = !gff.getBool("Active" , !_static); _usable = gff.getBool("Useable", _usable); // Appearance _appearanceID = gff.getUint("Appearance", _appearanceID); // Position if (gff.hasField("XPosition")) { const float position[3] = { (float) gff.getDouble("XPosition"), (float) gff.getDouble("YPosition"), (float) gff.getDouble("ZPosition") }; setPosition(position[0], position[1], position[2]); } // Orientation if (gff.hasField("XOrientation")) { const float orientation[4] = { (float) gff.getDouble("XOrientation"), (float) gff.getDouble("YOrientation"), (float) gff.getDouble("ZOrientation"), (float) Common::rad2deg(acos(gff.getDouble("WOrientation")) * 2.0) }; setOrientation(orientation[0], orientation[1], orientation[2], orientation[3]); } // Variables and script readVarTable(gff); readScript(gff); enableEvents(true); }
void Waypoint::load(const Aurora::GFF3Struct &waypoint) { // Tag _tag = waypoint.getString("Tag"); // Group _group = waypoint.getSint("Group", -1); // Map Note _hasMapNote = waypoint.getBool("HasMapNote"); _enabledMapNote = waypoint.getBool("MapNoteEnabled"); waypoint.getLocString("MapNote", _mapNote); // Type _type = (uint32) ((int32) waypoint.getSint("MapNoteType", -1)); // Position const float position[3] = { (float) waypoint.getDouble("XPosition"), (float) waypoint.getDouble("YPosition"), (float) waypoint.getDouble("ZPosition") }; setPosition(position[0], position[1], position[2]); // Orientation const float orientation[4] = { (float) waypoint.getDouble("XOrientation"), (float) waypoint.getDouble("YOrientation"), (float) waypoint.getDouble("ZOrientation"), (float) Common::rad2deg(acos(waypoint.getDouble("WOrientation")) * 2.0) }; setOrientation(orientation[0], orientation[1], orientation[2], orientation[3]); const Aurora::GDAFile &gda = getMGDA(kWorksheetWaypoints); // Icon _icon = gda.getString(_type, "Icon"); // Variables and script readVarTable(waypoint); readScript(waypoint); enableEvents(true); }
void Creature::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { // General properties if (blueprint) loadProperties(*blueprint); // Blueprint loadProperties(instance); // Instance // Position setPosition(instance.getDouble("XPosition"), instance.getDouble("YPosition"), instance.getDouble("ZPosition")); // Orientation float bearingX = instance.getDouble("XOrientation"); float bearingY = instance.getDouble("YOrientation"); setOrientation(0.0f, 0.0f, 1.0f, -Common::rad2deg(atan2(bearingX, bearingY))); }
void WidgetCheckBox::load(const Aurora::GFF3Struct &gff) { gff.getVector("COLOR", _r, _g, _b); _a = gff.getDouble("ALPHA", 1.0); Extend extend = createExtend(gff); _width = extend.w; _height = extend.h; Widget::setPosition(extend.x, extend.y, 0.0f); Border border = createBorder(gff); if (!border.fill.empty()) { _quad = new Graphics::Aurora::HighlightableGUIQuad(border.fill, 0.0f, 0.0f, extend.h * .62, extend.h * .62); } else { _quad = new Graphics::Aurora::GUIQuad(border.fill, 0.0f, 0.0f, extend.h * .62, extend.h * .62); } _quad->setPosition(extend.x, extend.y, 0.0f); _quad->setTag(getTag()); _quad->setClickable(true); if (border.fill.empty()) _quad->setColor(0.0f, 0.0f, 0.0f, 0.0f); Text text = createText(gff); if (!text.text.empty() && !text.font.empty()) { _text = new Graphics::Aurora::HighlightableText(FontMan.get(text.font), text.text, text.r, text.g, text.b, 1.0f); const float hspan = extend.w - _text->getWidth(); const float vspan = extend.h - _text->getHeight(); const float x = extend.x + text.halign * hspan; const float y = extend.y + text.valign * vspan; _text->setPosition(x, y, -1.0f); _text->setTag(getTag()); _text->setClickable(true); } if (getTextHighlightableComponent() != 0) { setDefaultHighlighting(getTextHighlightableComponent()); } if (getQuadHighlightableComponent() != 0) { setDefaultHighlighting(getQuadHighlightableComponent()); } }
void Waypoint::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { // General properties if (blueprint) loadProperties(*blueprint); // Blueprint loadProperties(instance); // Instance // Position setPosition(instance.getDouble("XPosition"), instance.getDouble("YPosition"), instance.getDouble("ZPosition")); // Orientation float bearingX = instance.getDouble("XOrientation"); float bearingY = instance.getDouble("YOrientation"); float o[3]; Common::vector2orientation(bearingX, bearingY, o[0], o[1], o[2]); setOrientation(o[0], o[1], o[2]); }
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { // General properties if (blueprint) loadProperties(*blueprint); // Blueprint loadProperties(instance); // Instance // Specialized object properties if (blueprint) loadObject(*blueprint); // Blueprint loadObject(instance); // Instance // Sounds loadSounds(); // Position setPosition(instance.getDouble("X"), instance.getDouble("Y"), instance.getDouble("Z")); // Orientation float bearing = instance.getDouble("Bearing"); float rotX = 0.0f; float rotY = 0.0f; float rotZ = 1.0f; float rotW = Common::rad2deg(bearing); if (instance.hasField("OrientationW")) { rotX = instance.getDouble("OrientationX"); rotY = instance.getDouble("OrientationY"); rotZ = instance.getDouble("OrientationZ"); rotW = Common::rad2deg(acos(instance.getDouble("OrientationW")) * 2.0); } setOrientation(rotX, rotY, rotZ, rotW); }
void Situated::load(const Aurora::GFF3Struct &instance, const Aurora::GFF3Struct *blueprint) { // General properties if (blueprint) loadProperties(*blueprint); // Blueprint loadProperties(instance); // Instance // Specialized object properties if (blueprint) loadObject(*blueprint); // Blueprint loadObject(instance); // Instance // Appearance if (_appearanceID == Aurora::kFieldIDInvalid) throw Common::Exception("Situated object without an appearance"); loadAppearance(); loadSounds(); // Position float posX = instance.getDouble("X"); float posY = instance.getDouble("Y"); float posZ = instance.getDouble("Z"); if (instance.hasField("Position")) { const Aurora::GFF3Struct &pos = instance.getStruct("Position"); posX = pos.getDouble("x"); posY = pos.getDouble("y"); posZ = pos.getDouble("z"); } setPosition(posX, posY, posZ); // Orientation float bearing = instance.getDouble("Bearing"); float rotX = 0.0f; float rotY = Common::rad2deg(bearing); float rotZ = 0.0f; if (instance.hasField("Orientation")) { const Aurora::GFF3Struct &o = instance.getStruct("Orientation"); float oX = o.getDouble("x"); float oY = o.getDouble("y"); float oZ = o.getDouble("z"); float oW = o.getDouble("w"); // Convert quaternions to roll/pitch/yaw rotY = 180.0f - Common::rad2deg(atan2(2 * (oX*oY + oZ*oW), 1 - 2 * (oY*oY + oZ*oZ))); rotX = 180.0f - Common::rad2deg(asin(2 * (oX*oZ - oW*oY))); rotZ = Common::rad2deg(atan2(2 * (oX*oW + oY*oZ), 1 - 2 * (oZ*oZ + oW*oW))); } setOrientation(rotX, rotY, rotZ); }
void GFF3Dumper::dumpField(const Aurora::GFF3Struct &strct, const Common::UString &field) { Aurora::GFF3Struct::FieldType type = strct.getType(field); Common::UString typeName; if (((size_t) type) < ARRAYSIZE(kGFF3FieldTypeNames)) typeName = kGFF3FieldTypeNames[(int)type]; else typeName = "filetype" + Common::composeString((uint64) type); Common::UString label = field; // Structs already open their own tag if (type != Aurora::GFF3Struct::kFieldTypeStruct) { _xml->openTag(typeName); _xml->addProperty("label", label); } switch (type) { case Aurora::GFF3Struct::kFieldTypeChar: _xml->setContents(Common::composeString(strct.getUint(field))); break; case Aurora::GFF3Struct::kFieldTypeByte: case Aurora::GFF3Struct::kFieldTypeUint16: case Aurora::GFF3Struct::kFieldTypeUint32: case Aurora::GFF3Struct::kFieldTypeUint64: _xml->setContents(Common::composeString(strct.getUint(field))); break; case Aurora::GFF3Struct::kFieldTypeSint16: case Aurora::GFF3Struct::kFieldTypeSint32: case Aurora::GFF3Struct::kFieldTypeSint64: _xml->setContents(Common::composeString(strct.getSint(field))); break; case Aurora::GFF3Struct::kFieldTypeFloat: case Aurora::GFF3Struct::kFieldTypeDouble: _xml->setContents(Common::UString::format("%.6f", strct.getDouble(field))); break; case Aurora::GFF3Struct::kFieldTypeStrRef: _xml->setContents(strct.getString(field)); break; case Aurora::GFF3Struct::kFieldTypeExoString: case Aurora::GFF3Struct::kFieldTypeResRef: try { _xml->setContents(strct.getString(field)); } catch (...) { _xml->addProperty("base64", "true"); Common::SeekableReadStream *data = strct.getData(field); _xml->setContents(*data); delete data; } break; case Aurora::GFF3Struct::kFieldTypeLocString: { Aurora::LocString locString; strct.getLocString(field, locString); _xml->addProperty("strref", Common::composeString(locString.getID())); dumpLocString(locString); } break; case Aurora::GFF3Struct::kFieldTypeVoid: _xml->setContents(*strct.getData(field)); break; case Aurora::GFF3Struct::kFieldTypeStruct: dumpStruct(strct.getStruct(field), label); break; case Aurora::GFF3Struct::kFieldTypeList: dumpList(strct.getList(field)); break; case Aurora::GFF3Struct::kFieldTypeOrientation: { double a = 0.0, b = 0.0, c = 0.0, d = 0.0; strct.getOrientation(field, a, b, c, d); _xml->breakLine(); _xml->openTag("double"); _xml->setContents(Common::UString::format("%.6f", a)); _xml->closeTag(); _xml->breakLine(); _xml->openTag("double"); _xml->setContents(Common::UString::format("%.6f", b)); _xml->closeTag(); _xml->breakLine(); _xml->openTag("double"); _xml->setContents(Common::UString::format("%.6f", c)); _xml->closeTag(); _xml->breakLine(); _xml->openTag("double"); _xml->setContents(Common::UString::format("%.6f", d)); _xml->closeTag(); _xml->breakLine(); } break; case Aurora::GFF3Struct::kFieldTypeVector: { double x = 0.0, y = 0.0, z = 0.0; strct.getVector(field, x, y, z); _xml->breakLine(); _xml->openTag("double"); _xml->setContents(Common::UString::format("%.6f", x)); _xml->closeTag(); _xml->breakLine(); _xml->openTag("double"); _xml->setContents(Common::UString::format("%.6f", y)); _xml->closeTag(); _xml->breakLine(); _xml->openTag("double"); _xml->setContents(Common::UString::format("%.6f", z)); _xml->closeTag(); _xml->breakLine(); } break; default: break; } // Structs already close their own tag if (type != Aurora::GFF3Struct::kFieldTypeStruct) { _xml->closeTag(); _xml->breakLine(); } }