//-------------------------------------------------- //-------------------------------------------------- template <> Vector2 GetAttributeValue<Vector2>(const XML::Node* in_node, const std::string& in_attributeName, const Vector2& in_defaultValue) { for(rapidxml::xml_attribute<>* attribute = in_node->first_attribute(); attribute != nullptr; attribute = attribute->next_attribute()) { if (GetName(attribute) == in_attributeName) { return ParseVector2(GetValue(attribute)); } } return in_defaultValue; }
bool ParseVT (std::wifstream& in, ObjectData& o) { int total = (int)o.vertex->size(); int i = 0; while (i < total) { if(!ParseVector2(in, (*o.vertex)[i++].texcoord)) return false; } return true; }
//-------------------------------------------------------------- //-------------------------------------------------------------- void TaggedFilePathResolver::SetFromJson(const Json::Value& in_json) { std::vector<std::string> supportedLanguages; const Json::Value& languages = in_json["Languages"]; if(languages.isNull() == false) { for(u32 i=0; i<languages.size(); ++i) { supportedLanguages.push_back(languages[i].asString()); } } std::vector<RangeRule> supportedResolutions; const Json::Value& resolutions = in_json["Resolutions"]; if(resolutions.isNull() == false) { for(auto it = resolutions.begin(); it != resolutions.end(); ++it) { Vector2 res = ParseVector2((*it).asString()); RangeRule rule(it.memberName(), res.x * res.y); supportedResolutions.push_back(rule); } } std::vector<RangeRule> supportedAspectRatios; const Json::Value& aspects = in_json["AspectRatios"]; if(aspects.isNull() == false) { for(auto it = aspects.begin(); it != aspects.end(); ++it) { RangeRule rule(it.memberName(), (f32)(*it).asDouble()); supportedAspectRatios.push_back(rule); } } SetTags(supportedLanguages, supportedResolutions, supportedAspectRatios); TagGroup priorityIndices[(u32)TagGroup::k_total]; const Json::Value& priorities = in_json["Priorities"]; if(priorities.isNull() == false) { CS_ASSERT(priorities.size() == (u32)TagGroup::k_total, "TaggedFilePathResolver: Need to specify all groups when setting priorities"); for(u32 i=0; i<priorities.size(); ++i) { priorityIndices[i] = ParseGroup(priorities[i].asString()); } } SetPriority(priorityIndices[0], priorityIndices[1], priorityIndices[2], priorityIndices[3]); }
void ParseVertexAttrib(const std::string& line, std::vector<Vector3>& positions, std::vector<Vector3>& normals, std::vector<Vector2>& texcoords) { if (line.size() > 1) { const char next = line[1]; if (isSpaceOrTab(next)) // "v ": parse vertex position { const Vector3 position = ParseVector3(line); positions.push_back(position); } else if (next == 'n') // "v ": parse vertex normal { const Vector3 normal = ParseVector3(line); normals.push_back(normal); } else if (next == 't') // "v ": parse vertex texcoord { const Vector2 texcoord = ParseVector2(line); texcoords.push_back(texcoord); } } }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ template <> Vector2 ParseValue(const std::string& in_value) { return ParseVector2(in_value); }