void BinaryConverter::SaveMaterials(Serializer::Writer& wr, Model* model)
{
	//Look for the .model definition and parse it
	//for material definitions
	const ModelDefinition &modelDef = FindModelDefinition(model->GetName());

	wr.Int32(modelDef.matDefs.size());

	for (const auto& m : modelDef.matDefs) {
		wr.String(m.name);
		wr.String(m.tex_diff);
		wr.String(m.tex_spec);
		wr.String(m.tex_glow);
		wr.String(m.tex_ambi);
		wr.String(m.tex_norm);
		wr.Color4UB(m.diffuse);
		wr.Color4UB(m.specular);
		wr.Color4UB(m.ambient);
		wr.Color4UB(m.emissive);
		wr.Int16(m.shininess);
		wr.Int16(m.opacity);
		wr.Bool(m.alpha_test);
		wr.Bool(m.unlit);
		wr.Bool(m.use_pattern);
	}
}
示例#2
0
void GeomTree::Save(Serializer::Writer &wr) const
{
	wr.Int32(m_numVertices);
	wr.Int32(m_numEdges);
	wr.Int32(m_numTris);
	wr.Double(m_radius);

	wr.Vector3d(m_aabb.max);
	wr.Vector3d(m_aabb.min);
	wr.Double(m_aabb.radius);

	wr.Int32(m_numEdges);
	for (Sint32 iAabb = 0; iAabb < m_numEdges; ++iAabb) {
		wr.Vector3d(m_aabbs[iAabb].max);
		wr.Vector3d(m_aabbs[iAabb].min);
		wr.Double(m_aabbs[iAabb].radius);
	}

	for (Sint32 iEdge = 0; iEdge < m_numEdges; ++iEdge) {
		m_edges[iEdge].Save(wr);
	}

	for (Sint32 iVert = 0; iVert < m_numVertices; ++iVert) {
		wr.Vector3f(m_vertices[iVert]);
	}

	for (Sint32 iIndi = 0; iIndi < (m_numTris * 3); ++iIndi) {
		wr.Int16(m_indices[iIndi]);
	}

	for (Sint32 iTri = 0; iTri < m_numTris; ++iTri) {
		wr.Int32(m_triFlags[iTri]);
	}
}