Beispiel #1
0
char HTriangleMesh::save(ATriangleMesh * tri)
{
	int nv = tri->numPoints();
	if(!hasNamedAttr(".nv"))
		addIntAttr(".nv");
	
	writeIntAttr(".nv", &nv);
	
	int nt = tri->numTriangles();
	if(!hasNamedAttr(".ntri"))
		addIntAttr(".ntri");
	
	writeIntAttr(".ntri", &nt);
	
	if(!hasNamedData(".p"))
	    addVector3Data(".p", nv);
	
	writeVector3Data(".p", nv, (Vector3F *)tri->points());
	
	if(!hasNamedData(".a"))
	    addIntData(".a", nv);
	
	writeIntData(".a", nv, (int *)tri->anchors());
		
	if(!hasNamedData(".v"))
	    addIntData(".v", nt * 3);
	
	writeIntData(".v", nt * 3, (int *)tri->indices());

	return 1;
}
Beispiel #2
0
char HMesh::save(BaseMesh * mesh)
{
	mesh->verbose();
	
	int nv = mesh->getNumVertices();
	if(!hasNamedAttr(".nv"))
		addIntAttr(".nv");
	
	writeIntAttr(".nv", &nv);
	
	int nf = mesh->getNumPolygons();
	if(!hasNamedAttr(".nf"))
		addIntAttr(".nf");
	
	writeIntAttr(".nf", &nf);
		
	int nfv = mesh->getNumPolygonFaceVertices();
	if(!hasNamedAttr(".nfv"))
		addIntAttr(".nfv");
	
	writeIntAttr(".nfv", &nfv);
	
	int nuv = mesh->getNumUVs();
	if(!hasNamedAttr(".nuv"))
		addIntAttr(".nuv");
	
	writeIntAttr(".nuv", &nuv);
	
	int nuvid = mesh->getNumUVIds();
	if(!hasNamedAttr(".nuvid"))
		addIntAttr(".nuvid");
	
	writeIntAttr(".nuvid", &nuvid);
	
	if(!hasNamedData(".p"))
	    addVector3Data(".p", nv);
	
	writeVector3Data(".p", nv, mesh->getVertices());
		
	if(!hasNamedData(".polyc"))
	    addIntData(".polyc", nf);
	
	writeIntData(".polyc", nf, (int *)mesh->getPolygonCounts());
	
	if(!hasNamedData(".polyv"))
	    addIntData(".polyv", nfv);
	
	std::cout<<" polyv[0]"<<mesh->getPolygonIndices()[0]<<"\n";
	std::cout<<" polyv["<<nfv<<"-1]"<<mesh->getPolygonIndices()[nfv - 1]<<"\n";
	writeIntData(".polyv", nfv, (int *)mesh->getPolygonIndices());
	
	if(!hasNamedData(".us"))
		addFloatData(".us", nuv);
		
	writeFloatData(".us", nuv, mesh->getUs());
	
	if(!hasNamedData(".vs"))
		addFloatData(".vs", nuv);
		
	writeFloatData(".vs", nuv, mesh->getVs());
	
	if(!hasNamedData(".uvids"))
		addIntData(".uvids", nuvid);
		
	writeIntData(".uvids", nuvid, (int *)mesh->getUvIds());

	return 1;
}