Exemplo n.º 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;
}
Exemplo n.º 2
0
char HPolygonalUV::save(APolygonalUV * poly)
{
	int nuv = poly->numCoords();
	if(!hasNamedAttr(".nuv"))
		addIntAttr(".nuv");
	
	writeIntAttr(".nuv", &nuv);
	
	int nind = poly->numIndices();
	if(!hasNamedAttr(".nind"))
		addIntAttr(".nind");
	
	writeIntAttr(".nind", &nind);
	
	if(!hasNamedData(".ucoord"))
	    addFloatData(".ucoord", nuv);
	
	writeFloatData(".ucoord", nuv, (float *)poly->ucoord());
	
	if(!hasNamedData(".vcoord"))
	    addFloatData(".vcoord", nuv);
	
	writeFloatData(".vcoord", nuv, (float *)poly->vcoord());
		
	if(!hasNamedData(".uvid"))
	    addIntData(".uvid", nind);
	
	writeIntData(".uvid", nind, (int *)poly->indices());

	return 1;
}
Exemplo n.º 3
0
char HTriangleMeshGroup::save(ATriangleMeshGroup * tri)
{
	if(!hasNamedAttr(".npart"))
		addIntAttr(".npart");
		
	int np = tri->numStripes();
	writeIntAttr(".npart", &np);
	
	if(!hasNamedData(".pntdrift"))
		addIntData(".pntdrift", np);
		
	writeIntData(".pntdrift", np, (int *)tri->pointDrifts());
	
	if(!hasNamedData(".inddrift"))
		addIntData(".inddrift", np);
		
	writeIntData(".inddrift", np, (int *)tri->indexDrifts());
	
	return HTriangleMesh::save(tri);
}
Exemplo n.º 4
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;
}