Ejemplo n.º 1
0
std::string SkeletonData::writeJoint(Joint * j, unsigned int indent) {

	std::stringstream json;
	indent++;
	json << std::string(indent * 3, ' ') << "{" << std::endl;
	indent++;

	json << std::string(indent * 3, ' ') << "\"id\": " << j->id << "," << std::endl;

	Joint * parentJoint = dynamic_cast<Joint *>(j->parent);
	if (parentJoint != nullptr) {
		json << std::string(indent * 3, ' ') << "\"parent\": " << dynamic_cast<Joint *>(j->parent)->id << "," << std::endl;
	}

	// Transform: Object
	json << std::string(indent * 3, ' ') << "\"transform\":{" << std::endl;
	indent++;
	json << std::string(indent * 3, ' ') << "\"pos\": " << "{" << "\"x\": " << j->getPos().x << ", " << "\"y\": " << j->getPos().y << ", " << "\"z\": " << j->getPos().z << "}," << std::endl;
	json << std::string(indent * 3, ' ') << "\"orientation\": " << "{" << "\"x\": " << j->transform->orientation.x << ", " << "\"y\": " << j->transform->orientation.y << ", " << "\"z\": " << j->transform->orientation.z << ", " << "\"w\": " << j->transform->orientation.w << "}," << std::endl;
	json << std::string(indent * 3, ' ') << "\"scaleVector\": " << "{" << "\"x\": " << j->transform->scaleVector.x << ", " << "\"y\": " << j->transform->scaleVector.y << ", " << "\"z\": " << j->transform->scaleVector.z << "}" << std::endl;
	indent--;
	json << std::string(indent * 3, ' ') << "}," << std::endl;

	// Voxels: Array
	json << std::string(indent * 3, ' ') << "\"voxels\": " << "[" << std::endl;
	for (unsigned long int i = 0; i < j->voxels.size(); ++i) {
		Voxel * v = j->voxels.at(i);
		json << writeVoxel(v, indent);
		if (i != j->voxels.size() - 1) {
			json << ",";
		}
		json << std::endl;
	}
	json << std::string(indent * 3, ' ') << "]," << std::endl;

	// Animations: Objects
	json << std::string(indent * 3, ' ') << "\"animations\":{" << std::endl;
	json << writeAnimations(j, indent);
	json << std::string(indent * 3, ' ') << "}," << std::endl;

	// Children: Array
	json << std::string(indent * 3, ' ') << "\"children\": " << "[" << std::endl;
	for(unsigned long int i = 0; i < j->children.size(); ++i) {
		Joint * child = dynamic_cast<Joint *>(j->children.at(i));
		json << writeJoint(child, indent);
		if (j->children.size() != 0 && child->id != dynamic_cast<Joint *>(j->children.back())->id) {
			json << ",";
		}
		json << std::endl;
	}
	json << std::string(indent * 3, ' ') << "]" << std::endl;
	indent--;
	json << std::string(indent * 3, ' ') << "}";
	std::string blah = json.str();
	return json.str();
}
Ejemplo n.º 2
0
void GameDatas::write(QString path){
    RPM::writeJSON(Common::pathCombine(path, RPM::pathCommonEvents),
                     *m_commonEventsDatas);
    RPM::writeJSON(Common::pathCombine(path, RPM::pathVariables),
                     *m_variablesDatas);
    writeSystem(path);
    writeBattleSystem(path);
    writeItems(path);
    writeSkills(path);
    writeWeapons(path);
    writeArmors(path);
    writeHeroes(path);
    writeMonsters(path);
    writeTroops(path);
    writeClasses(path);
    writeTilesets(path);
    writeAnimations(path);
    writeStatus(path);
    writeTitleScreenGameOver(path);
}