Esempio n. 1
0
    ArmatureData *XMLDataParser::parseArmatureData(const dragonBones::XMLElement *armatureXML, SkeletonData *data, uint frameRate)
    {
        ArmatureData *armatureData = new ArmatureData();
        armatureData->name = armatureXML->Attribute(ConstValues::A_NAME.c_str());

        for(const dragonBones::XMLElement* boneXML = armatureXML->FirstChildElement(ConstValues::BONE.c_str()) ; boneXML ; boneXML = boneXML->NextSiblingElement(ConstValues::BONE.c_str()))
        {
            armatureData->addBoneData(parseBoneData(boneXML));
        }

        for(const dragonBones::XMLElement* skinXML = armatureXML->FirstChildElement(ConstValues::SKIN.c_str()) ; skinXML ; skinXML = skinXML->NextSiblingElement(ConstValues::SKIN.c_str()))
        {
            armatureData->addSkinData(parseSkinData(skinXML, data));
        }

        DBDataUtil::transformArmatureData(armatureData);
        armatureData->sortBoneDataList();

        for(const dragonBones::XMLElement* animationXML = armatureXML->FirstChildElement(ConstValues::ANIMATION.c_str()) ; animationXML ; animationXML = animationXML->NextSiblingElement(ConstValues::ANIMATION.c_str()))
        {
            armatureData->addAnimationData(parseAnimationData(animationXML, armatureData, frameRate));
        }

        return armatureData;
    }
ArmatureData* ObjectDataParser::parseArmatureData(Json::Value & armatureObject, SkeletonData* data,
		unsigned int frameRate) {
	ArmatureData* armatureData = new ArmatureData();
	armatureData->name = armatureObject[ConstValues::A_NAME].asCString();

	Json::Value & bones = armatureObject[ConstValues::BONE];

	for (unsigned int i = 0; i < bones.size(); i++) {
		Json::Value & boneObject = bones[i];
		armatureData->addBoneData(parseBoneData(boneObject));
	}

	Json::Value & skins = armatureObject[ConstValues::SKIN];
	for (unsigned int i = 0; i < skins.size(); i++) {
		Json::Value & skinObject = skins[i];
		armatureData->addSkinData(parseSkinData(skinObject, data));
	}

	DBDataUtil::transformArmatureData(armatureData);
	armatureData->sortBoneDataList();

	Json::Value & animitions = armatureObject[ConstValues::ANIMATION];
	for (unsigned int i = 0; i < animitions.size(); i++) {
		Json::Value & animationObject = animitions[i];
		armatureData->addAnimationData(parseAnimationData(animationObject, armatureData, frameRate));
	}

	return armatureData;
}