Esempio n. 1
0
void FileHandler::SaveScene(int maxNameSize, char* sceneName,
	vector<Material*> &materials,
	vector<Transform*> &allTransforms,
	vector<Transform*> &allMeshTransforms,
	vector<Transform*> &allLightTransforms)
{
	//max_Name_Size = maxNameSize;
	int sceneNameSize = CorrectName(sceneName);
	int nrMats = materials.size();
	int nrTransforms = allTransforms.size();
	int nrMeshes = allMeshTransforms.size();
	int nrLights = allLightTransforms.size();

	std::string fileName(sceneName, sceneNameSize-1); //-1 så att inte \0 kommer med
	fileName.append(".drm");
	lastLoadedFileName = fileName;

	ofs.open(fileName, ofstream::out | ofstream::binary);
	if (ofs.is_open() == true) {
		ofs.clear();

		SaveMainHeader(sceneNameSize, sceneName, nrMats, nrTransforms, nrMeshes, nrLights);

		SaveMaterials(nrMats, materials); //måste vara först!
		SaveTransforms(nrTransforms, allTransforms);
		SaveMeshes(nrMeshes, allMeshTransforms);
		SaveLights(nrLights, allLightTransforms);
		
		ofs.close();

		//LoadScene(); //test bara
	}
}
Esempio n. 2
0
	void Model_IO::SaveMesh(Mesh& mesh, BinaryWriter& writer, const achar* path)
	{
		writer.Push((int32_t)mesh.DividedMeshes.size());

		for (auto i = 0; i < mesh.DividedMeshes.size(); i++)
		{
			SaveDividedMesh(mesh.DividedMeshes[i], writer, path);
		}

		SaveMaterials(mesh.Materials, writer, path);
	}