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 Creature::loadBlueprint(const Aurora::GFF3Struct &gff) { if (gff.hasField("Looks")) { const Aurora::GFF3Struct &looks = gff.getStruct("Looks"); // Appearance _appearance = looks.getSint("Appearance", _appearance); // Head if (looks.hasField("HeadType")) { _headType = looks.getSint("HeadType"); } } if (gff.hasField("Stats")) { const Aurora::GFF3Struct &stats = gff.getStruct("Stats"); // Conversation _conversation = stats.getString("Conversation", _conversation); // AutoBalance _autoBalance = stats.getBool("AutoBalance"); } // Scripts readScripts(gff); }
void Area::loadGIT(const Aurora::GFF3Struct &git) { if (git.hasField("AreaProperties")) loadProperties(git.getStruct("AreaProperties")); if (git.hasField("Placeable List")) loadPlaceables(git.getList("Placeable List")); if (git.hasField("Door List")) loadDoors(git.getList("Door List")); if (git.hasField("Creature List")) loadCreatures(git.getList("Creature List")); }
void Area::loadGIT(const Aurora::GFF3Struct &git) { // Waypoints if (git.hasField("WaypointList")) loadWaypoints(git.getList("WaypointList")); // Placeables if (git.hasField("Placeable List")) loadPlaceables(git.getList("Placeable List")); // Doors if (git.hasField("Door List")) loadDoors(git.getList("Door List")); }
bool readTint(const Aurora::GFF3Struct &gff, float t[3][4]) { if (!gff.hasField("Tintable")) return false; const Aurora::GFF3Struct &tintable = gff.getStruct("Tintable"); if (!tintable.hasField("Tint")) return false; const Aurora::GFF3Struct &tint = tintable.getStruct("Tint"); for (int i = 0; i < 3; i++) { Common::UString index = Common::UString::format("%d", i + 1); if (!tint.hasField(index)) continue; const Aurora::GFF3Struct &tintN = tint.getStruct(index); t[i][0] = tintN.getUint("r", t[i][0] * 255) / 255.0f; t[i][1] = tintN.getUint("g", t[i][1] * 255) / 255.0f; t[i][2] = tintN.getUint("b", t[i][2] * 255) / 255.0f; t[i][3] = tintN.getUint("a", t[i][3] * 255) / 255.0f; } return true; }
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 Creature::loadEquippedItems(const Aurora::GFF3Struct &gff) { if (!gff.hasField("Equip_ItemList")) return; const Aurora::GFF3List &cEquipped = gff.getList("Equip_ItemList"); for (Aurora::GFF3List::const_iterator e = cEquipped.begin(); e != cEquipped.end(); ++e) _equippedItems.push_back(new Item(**e)); }
void Item::loadArmorParts(const Aurora::GFF3Struct &gff) { for (uint i = 0; i < kArmorPartMAX; i++) if (gff.hasField(kArmorPartFields[i])) { _armorParts[i].id = gff.getUint(kArmorPartFields[i], _armorParts[i].id); } else _armorParts[i].id = 0; }
void Creature::loadEquipment(const Aurora::GFF3Struct &gff) { if (!gff.hasField("Equip_ItemList")) return; for (const auto &i : gff.getList("Equip_ItemList")) { InventorySlot slot = InventorySlot(static_cast<int>(std::log2f(i->getID()))); Common::UString tag = i->getString("EquippedRes"); equipItem(tag, slot, false); } }
void WidgetListBox::load(const Aurora::GFF3Struct &gff) { KotORWidget::load(gff); if (gff.hasField("PROTOITEM")) { _protoItem = &gff.getStruct("PROTOITEM"); } if (gff.hasField("LEFTSCROLLBAR")) { _leftScrollBar = gff.getBool("LEFTSCROLLBAR"); } if (gff.hasField("SCROLLBAR")) { _scrollBar = &gff.getStruct("SCROLLBAR"); } if (gff.hasField("PADDING")) { _padding = gff.getSint("PADDING"); } }
void Situated::loadProperties(const Aurora::GFF3Struct &gff) { // Unique ID and tag _uniqueID = gff.getString("UniqueID", _uniqueID); _tag = gff.getString("Tag", _tag); // Name if (gff.hasField("LocName")) { try { gff.getLocString("LocName", _name); } catch (...) { } } // Description if (gff.hasField("Description")) { try { gff.getLocString("Description", _description); } catch (...) { } } refreshLocalized(); // Appearance _modelName = gff.getString("ModelName", _modelName); // Sounds _soundAppType = gff.getUint("SoundAppType", _soundAppType); // Conversation _conversation = gff.getString("Conversation", _conversation); // Static _static = gff.getBool("Static", _static); // Usable _usable = gff.getBool("Useable", _usable); // Locked _locked = gff.getBool("Locked", _locked); }
void Area::loadGIT(const Aurora::GFF3Struct &git) { // Generic properties if (git.hasField("AreaProperties")) loadProperties(git.getStruct("AreaProperties")); // Waypoints if (git.hasField("WaypointList")) loadWaypoints(git.getList("WaypointList")); // Placeables if (git.hasField("Placeable List")) loadPlaceables(git.getList("Placeable List")); // Doors if (git.hasField("Door List")) loadDoors(git.getList("Door List")); // Creatures if (git.hasField("Creature List")) loadCreatures(git.getList("Creature List")); }
void Item::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Name if (gff.hasField("LocalizedName")) { Aurora::LocString name; gff.getLocString("LocalizedName", name); _name = name.getString(); } // Description if (gff.hasField("Description")) { Aurora::LocString description; gff.getLocString("Description", description); _description = description.getString(); } // This is an index into basitem.2da which contains inventory slot info _baseitem = gff.getUint("BaseItem", _baseitem); // TODO: Are these armor only? _colorMetal1 = gff.getUint("Metal1Color", _colorMetal1); _colorMetal2 = gff.getUint("Metal2Color", _colorMetal2); _colorLeather1 = gff.getUint("Leather1Color", _colorLeather1); _colorLeather2 = gff.getUint("Leather2Color", _colorLeather2); _colorCloth1 = gff.getUint("Cloth1Color", _colorCloth1); _colorCloth2 = gff.getUint("Cloth2Color", _colorCloth2); // Armor parts loadArmorParts(gff); // Portrait loadPortrait(gff); // Scripts readScripts(gff); }
void ScriptContainer::readScripts(const Aurora::GFF3Struct &gff) { clearScripts(); if (gff.hasField("Scripts")) { const Aurora::GFF3Struct &scripts = gff.getStruct("Scripts"); for (size_t i = 0; i < ARRAYSIZE(kScriptNames); i++) { const Script script = kScriptNames[i].script; const char *name = kScriptNames[i].name; _scripts[script] = scripts.getString(name, _scripts[script]); } } }
void Area::loadSAV(const Aurora::GFF3Struct &sav) { if (sav.hasField("CreatureList")) { const Aurora::GFF3Struct &creatures = sav.getStruct("CreatureList"); loadCreatures(creatures.getList("StaticList")); loadCreatures(creatures.getList("DynamicList")); } // TODO load crowd list if (sav.hasField("PlaceableList")) { const Aurora::GFF3Struct &placeables = sav.getStruct("PlaceableList"); loadPlaceables(placeables.getList("StaticList")); loadPlaceables(placeables.getList("DynamicList")); } // TODO load sound list if (sav.hasField("TriggerList")) { const Aurora::GFF3Struct &trigger = sav.getStruct("TriggerList"); loadTriggers(trigger.getList("StaticList")); loadTriggers(trigger.getList("DynamicList")); } if (sav.hasField("WaypointList")) { const Aurora::GFF3Struct &waypoints = sav.getStruct("WaypointList"); loadWaypoints(waypoints.getList("StaticList")); loadWaypoints(waypoints.getList("DynamicList")); } // TODO load projectile list // TODO load area of effect list // TODO load store list // TODO load apple list // TODO load camera list }
void Situated::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Name if (gff.hasField("LocName")) { Aurora::LocString name; gff.getLocString("LocName", name); _name = name.getString(); } // Description if (gff.hasField("Description")) { Aurora::LocString description; gff.getLocString("Description", description); _description = description.getString(); } // Appearance _appearanceID = gff.getUint("Appearance", _appearanceID); // Conversation _conversation = gff.getString("Conversation", _conversation); // Static _static = gff.getBool("Static", _static); // Usable _usable = gff.getBool("Useable", _usable); // Locked _locked = gff.getBool("Locked", _locked); // Tint readTint(gff, _tint); }
void Waypoint::loadProperties(const Aurora::GFF3Struct &gff) { // Unique ID and tag _uniqueID = gff.getString("UniqueID", _uniqueID); _tag = gff.getString("Tag", _tag); // Map note _hasMapNote = gff.getBool("HasMapNote", _hasMapNote); if (gff.hasField("MapNote")) gff.getLocString("MapNote", _mapNote); refreshLocalized(); }
void Waypoint::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Map note _hasMapNote = gff.getBool("MapNoteEnabled", _hasMapNote); if (gff.hasField("MapNote")) { Aurora::LocString mapNote; gff.getLocString("MapNote", mapNote); _mapNote = mapNote.getString(); } }
void Waypoint::load(const Aurora::GFF3Struct &waypoint) { // Tag _tag = waypoint.getString("Tag", _tag); loadPositional(waypoint); // Map note _hasMapNote = waypoint.getBool("MapNoteEnabled", _hasMapNote); _displayMapNote = waypoint.getBool("MapNoteDisplay", _displayMapNote); _mapNoteType = waypoint.getSint("MapNoteType"); if (waypoint.hasField("MapNote")) { _mapNote = waypoint.getString("MapNote"); } }
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 WidgetProgressbar::load(const Aurora::GFF3Struct &gff) { KotORJadeWidget::load(gff); _maxValue = gff.getSint("MAXVALUE"); _curValue = gff.getSint("CURVALUE"); _horizontal = gff.getBool("STARTFROMLEFT", true); if (gff.hasField("PROGRESS")) { const Aurora::GFF3Struct &progress = gff.getStruct("PROGRESS"); const Common::UString fill = progress.getString("FILL"); _progress.reset(new Graphics::Aurora::GUIQuad(fill, 0.0f, 0.0f, getWidth(), getHeight())); float x, y, z; getPosition(x, y, z); _progress->setPosition(x, y, -FLT_MAX); update(); } }
void Creature::loadClasses(const Aurora::GFF3Struct &gff, std::vector<Class> &classes, uint8 &hitDice) { if (!gff.hasField("ClassList")) return; classes.clear(); hitDice = 0; const Aurora::GFF3List &cClasses = gff.getList("ClassList"); for (Aurora::GFF3List::const_iterator c = cClasses.begin(); c != cClasses.end(); ++c) { classes.push_back(Class()); const Aurora::GFF3Struct &cClass = **c; classes.back().classID = cClass.getUint("Class"); classes.back().level = cClass.getUint("ClassLevel"); hitDice += classes.back().level; } }
void Area::loadARE(const Aurora::GFF3Struct &are) { // Tag _tag = are.getString("Tag"); // Name are.getLocString("Name", _name); refreshLocalized(); // Generic properties if (are.hasField("AreaProperties")) loadProperties(are.getStruct("AreaProperties")); // Area geometry model _modelName = are.getString("Tileset"); // Scripts readScripts(are); }
void Roster::loadMember(const Aurora::GFF3Struct &gff) { Member member; // Add a roster member to the list if (gff.hasField("RosName")) { member.rosterName = gff.getString("RosName", member.rosterName); member.isAvailable = gff.getBool("RosAvailable", member.isAvailable); member.isCampaignNPC = gff.getBool("RosCampaignNPC", member.isCampaignNPC); member.isSelectable = gff.getBool("RosSelectable", member.isSelectable); member.isLoadBefore = gff.getBool("RosLoadBefore", member.isLoadBefore); auto match = std::find_if(_members.begin(), _members.end(), [&](const Member &m) { return m.rosterName == member.rosterName; }); if (match == _members.end()) { _members.push_back(member); } else { throw Common::Exception("Attempt to load duplicate roster member name: \"%s\"", member.rosterName.c_str()); } } else { throw Common::Exception("Missing RosName field."); } }
void Placeable::loadObject(const Aurora::GFF3Struct &gff) { // State _state = (State) gff.getUint("AnimationState", (uint) _state); // Inventory _hasInventory = gff.getBool("HasInventory", _hasInventory); if (_hasInventory && gff.hasField("ItemList")) { Aurora::GFF3List classList = gff.getList("ItemList"); for (Aurora::GFF3List::const_iterator iter = classList.begin(); iter != classList.end(); ++iter) { const Aurora::GFF3Struct &item = **iter; _inventory.addItem(item.getString("InventoryRes")); } } // Hit Points _currentHitPoints = gff.getSint("CurrentHP"); _maxHitPoints = gff.getSint("HP"); _minOneHitPoint = gff.getBool("Min1HP"); }
bool readTint(const Aurora::GFF3Struct &gff, const Common::UString &strct, float t[3][4]) { if (!gff.hasField(strct)) return false; return readTint(gff.getStruct(strct), t); }
void Creature::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Name _firstName = gff.getString("FirstName", _firstName); _lastName = gff.getString("LastName" , _lastName); _name = _firstName + " " + _lastName; _name.trim(); // Description _description = gff.getString("Description", _description); // Conversation _conversation = gff.getString("Conversation", _conversation); // Sound Set _soundSet = gff.getUint("SoundSetFile", Aurora::kFieldIDInvalid); // Portrait loadPortrait(gff, _portrait); // Gender _gender = (Gender) gff.getUint("Gender", (uint64) _gender); // Race _race = gff.getUint("Race", _race); // Subrace _subRace = gff.getString("Subrace", _subRace); // PC and DM _isPC = gff.getBool("IsPC", _isPC); _isDM = gff.getBool("IsDM", _isDM); // Age _age = gff.getUint("Age", _age); // Experience _xp = gff.getUint("Experience", _xp); // Abilities _abilities[kAbilityStrength] = gff.getUint("Str", _abilities[kAbilityStrength]); _abilities[kAbilityDexterity] = gff.getUint("Dex", _abilities[kAbilityDexterity]); _abilities[kAbilityConstitution] = gff.getUint("Con", _abilities[kAbilityConstitution]); _abilities[kAbilityIntelligence] = gff.getUint("Int", _abilities[kAbilityIntelligence]); _abilities[kAbilityWisdom] = gff.getUint("Wis", _abilities[kAbilityWisdom]); _abilities[kAbilityCharisma] = gff.getUint("Cha", _abilities[kAbilityCharisma]); // Classes loadClasses(gff, _classes, _hitDice); // Skills if (gff.hasField("SkillList")) { _skills.clear(); const Aurora::GFF3List &skills = gff.getList("SkillList"); for (Aurora::GFF3List::const_iterator s = skills.begin(); s != skills.end(); ++s) { const Aurora::GFF3Struct &skill = **s; _skills.push_back(skill.getSint("Rank")); } } // Feats if (gff.hasField("FeatList")) { _feats.clear(); const Aurora::GFF3List &feats = gff.getList("FeatList"); for (Aurora::GFF3List::const_iterator f = feats.begin(); f != feats.end(); ++f) { const Aurora::GFF3Struct &feat = **f; _feats.push_back(feat.getUint("Feat")); } } // Deity _deity = gff.getString("Deity", _deity); // Health if (gff.hasField("HitPoints")) { _baseHP = gff.getSint("HitPoints"); _bonusHP = gff.getSint("MaxHitPoints", _baseHP) - _baseHP; _currentHP = gff.getSint("CurrentHitPoints", _baseHP); } // Alignment _goodEvil = gff.getUint("GoodEvil", _goodEvil); _lawChaos = gff.getUint("LawfulChaotic", _lawChaos); // Appearance _appearanceID = gff.getUint("Appearance_Type", _appearanceID); _phenotype = gff.getUint("Phenotype" , _phenotype); // Body parts for (size_t i = 0; i < kBodyPartMAX; i++) { _bodyParts[i].id = gff.getUint(kBodyPartFields[i], _bodyParts[i].id); _bodyParts[i].idArmor = 0; } // Colors _colorSkin = gff.getUint("Color_Skin", _colorSkin); _colorHair = gff.getUint("Color_Hair", _colorHair); _colorTattoo1 = gff.getUint("Color_Tattoo1", _colorTattoo1); _colorTattoo2 = gff.getUint("Color_Tattoo2", _colorTattoo2); // Equipped Items loadEquippedItems(gff); // Scripts readScripts(gff); }
void Creature::loadProperties(const Aurora::GFF3Struct &gff) { // Tag _tag = gff.getString("Tag", _tag); // Name _firstName = gff.getString("FirstName", _firstName); _lastName = gff.getString("LastName" , _lastName); _name = _firstName + " " + _lastName; _name.trim(); // Description _description = gff.getString("Description", _description); // Conversation _conversation = gff.getString("Conversation", _conversation); // Sound Set _soundSet = gff.getUint("SoundSetFile", Aurora::kFieldIDInvalid); // Gender _gender = gff.getUint("Gender", _gender); // Race _race = gff.getUint("Race", _race); // Subrace _subRace = gff.getUint("Subrace", _subRace); // PC and DM _isPC = gff.getBool("IsPC", _isPC); _isDM = gff.getBool("IsDM", _isDM); // Age _age = gff.getUint("Age", _age); // Experience _xp = gff.getUint("Experience", _xp); // Abilities _abilities[kAbilityStrength] = gff.getUint("Str", _abilities[kAbilityStrength]); _abilities[kAbilityDexterity] = gff.getUint("Dex", _abilities[kAbilityDexterity]); _abilities[kAbilityConstitution] = gff.getUint("Con", _abilities[kAbilityConstitution]); _abilities[kAbilityIntelligence] = gff.getUint("Int", _abilities[kAbilityIntelligence]); _abilities[kAbilityWisdom] = gff.getUint("Wis", _abilities[kAbilityWisdom]); _abilities[kAbilityCharisma] = gff.getUint("Cha", _abilities[kAbilityCharisma]); // Classes loadClasses(gff, _classes, _hitDice); // Skills if (gff.hasField("SkillList")) { _skills.clear(); const Aurora::GFF3List &skills = gff.getList("SkillList"); for (Aurora::GFF3List::const_iterator s = skills.begin(); s != skills.end(); ++s) { const Aurora::GFF3Struct &skill = **s; _skills.push_back(skill.getSint("Rank")); } } // Feats if (gff.hasField("FeatList")) { _feats.clear(); const Aurora::GFF3List &feats = gff.getList("FeatList"); for (Aurora::GFF3List::const_iterator f = feats.begin(); f != feats.end(); ++f) { const Aurora::GFF3Struct &feat = **f; _feats.push_back(feat.getUint("Feat")); } } // Deity _deity = gff.getString("Deity", _deity); // Health if (gff.hasField("HitPoints")) { _baseHP = gff.getSint("HitPoints"); _bonusHP = gff.getSint("MaxHitPoints", _baseHP) - _baseHP; _currentHP = gff.getSint("CurrentHitPoints", _baseHP); } // Alignment _goodEvil = gff.getUint("GoodEvil", _goodEvil); _lawChaos = gff.getUint("LawfulChaotic", _lawChaos); // Appearance _appearanceID = gff.getUint("Appearance_Type", _appearanceID); _appearanceHead = gff.getUint("Appearance_Head" , _appearanceHead); _appearanceMHair = gff.getUint("Appearance_Hair" , _appearanceMHair); _appearanceFHair = gff.getUint("Appearance_FHair", _appearanceFHair); _armorVisualType = gff.getUint("ArmorVisualType", _armorVisualType); _armorVariation = gff.getUint("Variation" , _armorVariation); if (gff.hasField("Boots")) { const Aurora::GFF3Struct &boots = gff.getStruct("Boots"); _bootsVisualType = boots.getUint("ArmorVisualType", _bootsVisualType); _bootsVariation = boots.getUint("Variation" , _bootsVariation); } // Scripts and variables readScripts(gff); readVarTable(gff); }
void Object::readVarTable(const Aurora::GFF3Struct &gff) { if (gff.hasField("VarTable")) readVarTable(gff.getList("VarTable")); }
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); }