void Nena::Utility::MayaReader::GetXYZWAttributes(XMLNode *node, ::FLOAT &x, ::FLOAT &y, ::FLOAT &z, ::FLOAT *w, ::UINT32 &result) { ::UINT32 partialResult = 0; GetFloatAttribute(node, "X", x, partialResult); if (partialResult) result |= (1 << 0); GetFloatAttribute(node, "Y", y, partialResult); if (partialResult) result |= (1 << 1); GetFloatAttribute(node, "Z", z, partialResult); if (partialResult) result |= (1 << 2); if (w) GetFloatAttribute(node, "W", (*w), partialResult); if (partialResult) result |= (1 << 3); }
///===================================================== /// ///===================================================== TeleportBehavior::TeleportBehavior(const std::string& name, const XMLNode& behaviorNode) : BaseAIBehavior(name, BehaviorType::Attack, behaviorNode), m_healthThreshold(0.0f), m_chance(0.0f), m_phrase("casts Teleport"), m_numUses(-1){ m_healthThreshold = GetFloatAttribute(behaviorNode, "healthThreshold", m_healthThreshold); m_chance = GetFloatAttribute(behaviorNode, "chance", m_chance); m_phrase = GetStringAttribute(behaviorNode, "phrase", m_phrase); m_numUses = GetIntAttribute(behaviorNode, "numUses", m_numUses); }
void Nena::Utility::MayaReader::ImportSkinCluster(XMLNode *clusterNode) { ::UINT32 result = 0; ::std::string clusterName; GetNameAttribute(clusterNode, clusterName, result); ::UINT32 skinCount; GetCountAttribute(clusterNode, skinCount, result); Data::SkinCluster *clusterData = new Data::SkinCluster(); Root->GetHandles()->push_back(clusterData); clusterData->m_type = Data::IItem::kSkinCluster; clusterData->m_name = clusterName; XMLNode *skinNode = clusterNode->first_node("Skin"); while (skinNode) { Data::SkinCluster::Skin *skin = new Data::SkinCluster::Skin; clusterData->Geometries.push_back(skin); Root->GetHandles()->push_back(skin); ::UINT32 skinIndex; GetIndexAttribute(skinNode, skinIndex, result); ::std::string skinName; GetNameAttribute(skinNode, skinName, result); ::UINT32 componentCount; GetCountAttribute(skinNode, componentCount, result); skin->m_name = skinName; skin->m_type = Data::IItem::kSkin; skin->ComponentCount = componentCount; skin->Components = new Data::SkinCluster::Skin::Component[componentCount]; XMLNode *componentNode = skinNode->first_node("Component"); while (componentNode) { ::UINT32 componentIndex; GetIndexAttribute(componentNode, componentIndex, result); ::UINT32 influenceCount; GetCountAttribute(componentNode, influenceCount, result); skin->Components[componentIndex].InfluenceCount = influenceCount; skin->Components[componentIndex].Influences = new Data::SkinCluster::Skin::Component::Influence[influenceCount]; XMLNode *influenceNode = componentNode->first_node("Influence"); while (influenceNode) { ::UINT32 influenceIndex; GetIndexAttribute(influenceNode, influenceIndex, result); ::FLOAT influenceWeight; GetFloatAttribute(influenceNode, "Weight", influenceWeight, result); ::std::string fullPath; GetStringAttribute(influenceNode, "Full-Path", fullPath, result); ::std::string partialPath; GetStringAttribute(influenceNode, "Partial-Path", partialPath, result); skin->Components[componentIndex].Influences[influenceIndex].Weight = influenceWeight; skin->Components[componentIndex].Influences[influenceIndex].FullPath = fullPath; skin->Components[componentIndex].Influences[influenceIndex].PartialPath = partialPath; influenceNode = influenceNode->next_sibling("Influence"); } componentNode = componentNode->next_sibling("Component"); } skinNode = skinNode->next_sibling("Skin"); } }
void Nena::Utility::MayaReader::ImportCurves( XMLNode *transformNode, Data::Transform *transformData ) { ::UINT32 type = 0; ::UINT32 result = 0; ::UINT32 keyCount = 0; ::std::string curveName; XMLNode *curveNode, *keyNode; curveNode = transformNode->first_node("Curve"); if (curveNode) transformData->Curves = new ::std::vector<Data::Transform::Curve *>(); while (curveNode) { GetCountAttribute(curveNode, keyCount, result); GetUIntAttribute(curveNode, "Type", type, result); GetStringAttribute(curveNode, "Name", curveName, result); Data::Transform::Curve *curveData = new Data::Transform::Curve(); transformData->Curves->push_back(curveData); //Root->GetHandles()->push_back(curveData); curveData->m_name = curveName; curveData->m_type = Data::IItem::kAnimationCurve; curveData->Type = type; curveData->KeyCount = keyCount; curveData->Keys = new Data::Transform::Curve::Key[keyCount]; keyNode = curveNode->first_node("Key"); while (keyNode) { ::UINT32 keyIndex; GetIndexAttribute(keyNode, keyIndex, result); GetFloatAttribute(keyNode, "Time", curveData->Keys[keyIndex].Time, result); GetFloatAttribute(keyNode, "Value", curveData->Keys[keyIndex].Value, result); GetFloatAttribute(keyNode, "InX", curveData->Keys[keyIndex].In.x, result); GetFloatAttribute(keyNode, "InY", curveData->Keys[keyIndex].In.y, result); GetFloatAttribute(keyNode, "OutX", curveData->Keys[keyIndex].Out.x, result); GetFloatAttribute(keyNode, "OutY", curveData->Keys[keyIndex].Out.y, result); GetUIntAttribute(keyNode, "InType", curveData->Keys[keyIndex].InTangent, result); GetUIntAttribute(keyNode, "OutType", curveData->Keys[keyIndex].OutTangent, result); keyNode = keyNode->next_sibling("Key"); } curveNode = curveNode->next_sibling("Curve"); } }
void Nena::Utility::MayaReader::GetUVAttributes(XMLNode *node, ::FLOAT &u, ::FLOAT &v, ::UINT32 &result) { ::UINT32 partialResult = 0; GetFloatAttribute(node, "U", u, partialResult); if (partialResult) result |= (1 << 0); GetFloatAttribute(node, "V", v, partialResult); if (partialResult) result |= (1 << 1); }
///===================================================== /// ///===================================================== Item::Item(const XMLNode& itemNode, OpenGLRenderer* renderer) : Entity(itemNode, renderer), m_type(Undefined), m_equippedSlot(Unequippable), m_damageReductionPercent(0.0f), m_numUses(1), m_healing(0), m_damage(0, 0){ m_name = GetStringAttribute(itemNode, "name"); std::string itemType = GetStringAttribute(itemNode, "type"); m_damageReductionPercent = GetFloatAttribute(itemNode, "damageReductionPercent", m_damageReductionPercent); m_numUses = GetIntAttribute(itemNode, "numUses", m_numUses); m_healing = GetIntAttribute(itemNode, "healing", m_healing); m_damage = IntVec2(GetIntAttribute(itemNode, "minDamage", m_damage.x), GetIntAttribute(itemNode, "maxDamage", m_damage.y)); RGBAchars defaultColor = RGBAchars::WHITE; char defaultGlyph = ':'; if (itemType == "Weapon"){ m_type = ItemType::Weapon; } else if (itemType == "Armor"){ m_type = ItemType::Armor; } else if (itemType == "Consumable"){ m_type = ItemType::Consumable; } else{ //unknown item assert(false); } if (m_type != ItemType::Undefined){ defaultColor = ITEM_COLOR_TABLE[m_type]; defaultGlyph = ITEM_SYMBOL_TABLE[m_type]; } std::string itemEquipSlot = GetStringAttribute(itemNode, "equip"); if (itemEquipSlot == "Weapon"){ m_equippedSlot = EquipmentSlot::WeaponSlot; } else if (itemEquipSlot == "Chest"){ m_equippedSlot = EquipmentSlot::Chest; } else if (itemEquipSlot == "Head"){ m_equippedSlot = EquipmentSlot::Head; } else if (itemEquipSlot == "Ring"){ m_equippedSlot = EquipmentSlot::Ring; } else if (itemEquipSlot == "Hands"){ m_equippedSlot = EquipmentSlot::Hands; } else if (itemEquipSlot == "Feet"){ m_equippedSlot = EquipmentSlot::Feet; } else if (itemEquipSlot == "Legs"){ m_equippedSlot = EquipmentSlot::Legs; } m_glyph = GetCharAttribute(itemNode, "glyph", defaultGlyph); m_color = GetColorAttribute(itemNode, "color", defaultColor); m_textRenderer.SetInputString(std::string(1, m_glyph)); m_textRenderer.SetInputStringColor(m_color); }