TColladaBase* TColladaAnimation::Parse(TiXmlElement* animationElement) { TColladaBase::Parse(animationElement); TiXmlElement* childAnimationElement = animationElement->FirstChildElement("animation"); for(;childAnimationElement;childAnimationElement=childAnimationElement->NextSiblingElement("animation")) { TColladaAnimation* child = new TColladaAnimation(); child->Parse(childAnimationElement); childAnimations.push_back(child); } TiXmlElement* sourceElement = animationElement->FirstChildElement("source"); // sources for(;sourceElement;sourceElement=sourceElement->NextSiblingElement("source")) { TColladaSource* source = new TColladaSource(); source->Parse(sourceElement); sources.push_back(source); } // samplers TiXmlElement* samplerElement = animationElement->FirstChildElement("sampler"); for(;samplerElement;samplerElement=samplerElement->NextSiblingElement("sampler") ) { TColladaSampler* s = ParseSampler(samplerElement); const char* id = samplerElement->Attribute("id"); if( s ) { s->id = std::string(id); samplers.push_back(s); } } // channels TiXmlElement* channelElement = animationElement->FirstChildElement("channel"); for(;channelElement;channelElement=channelElement->NextSiblingElement("channel") ) { const char* source = channelElement->Attribute("source"); const char* target = channelElement->Attribute("target"); assert( source && target ); TColladaChannel* channel = new TColladaChannel(); channel->source = std::string(source); channel->target = std::string(target); channels.push_back(channel); this->target = std::string(target); } assert(IsValid()); return this; }
Auto<Resource> SamplerLoader::LoadResource(ResourceManager& resourceManager, std::istream& inputStream, const std::string& internalName) { if (!JsonDocumentLoader::IsJsonDocument(inputStream)) { throw FormatException("Sampler must be a json document"); } Value documentRoot = JsonDocumentLoader::LoadJson(inputStream); if (documentRoot["documentType"].ToString("") != "sampler") { throw FormatException("documentType not marked as a sampler"); } return ParseSampler(resourceManager, documentRoot); }