Example #1
0
void Batch::Write(Archive& ar)
{
	static int BATCH_VERSION=1;

	ar.WriteInt("version",BATCH_VERSION);
	ar.WriteInt("primitive",primitive);    	

	ar.Push("ambient" );ambient.Write (ar);ar.Pop("ambient");
	ar.Push("diffuse" );diffuse.Write (ar);ar.Pop("diffuse");
	ar.Push("specular");specular.Write(ar);ar.Pop("specular");
	ar.Push("emission");emission.Write(ar);ar.Pop("emission");
	ar.WriteFloat("shininess",shininess);

	ar.Push("matrix"   );matrix.Write(ar);ar.Pop("matrix");

	ar.Push("vertices" );ar.WriteSmartPointer(vertices);ar.Pop("vertices");
	ar.Push("normals"  );ar.WriteSmartPointer(normals );ar.Pop("normals");
	ar.Push("colors"   );ar.WriteSmartPointer(colors  );ar.Pop("colors");
	ar.WriteString("texture0",this->texture0?texture0->filename:"");
	ar.Push("texture0coords");ar.WriteSmartPointer(texture0coords);ar.Pop("texture0coords");
	ar.WriteString("texture1",this->texture1?texture1->filename:"");
	ar.Push("texture1coords");ar.WriteSmartPointer(texture1coords);ar.Pop("texture1coords");

	//important: I do not write the bounding box getBox();
}
Example #2
0
void Batch::Save(std::string filename,std::vector< SmartPointer<Batch> > batches)
{
	Clock t1;
	printf("Saving file %s\n",filename.c_str());
	std::set<std::string> light_textures;
	Archive ar;
	ar.Open(filename,true);
	ar.Push("batches");
	int num=(int)batches.size();
	ar.WriteInt("num",num);
	for (int i=0;i<num;i++) 
	{
		ar.Push("batch");
		ar.WriteSmartPointer(batches[i]);
		ar.Pop("batch");

		//save the light maps
		if (batches[i]->texture1 && light_textures.find(batches[i]->texture1->filename)==light_textures.end())
		{
			light_textures.insert(batches[i]->texture1->filename);
			batches[i]->texture1->save();
		}
	}
	ar.Pop("batches");
	ar.Close();
	//printf("done in %d msec\n",t1.msec());
}