コード例 #1
0
ファイル: APolygonalMesh.cpp プロジェクト: ahmidou/aphid
const BoundingBox APolygonalMesh::calculateBBox(unsigned icomponent) const
{
    Vector3F * p = points();
	unsigned * v = polygonIndices(icomponent);
    const unsigned n = faceCount(icomponent);
	BoundingBox box;
    unsigned i = 0;
    for(;i<n; i++) {
        box.updateMin(p[v[i]]);
        box.updateMax(p[v[i]]);
	}
	return box;
}
コード例 #2
0
ファイル: PatchMesh.cpp プロジェクト: amattwithers/aphid
unsigned PatchMesh::processQuadFromPolygon()
{
	unsigned i, j;
	m_numQuads = 0;
    for(i = 0; i < getNumPolygons(); i++) {
		if(polygonCounts()[i] < 5)
			m_numQuads++;
	}
		
	if(m_numQuads < 1) return 0;
	
	m_quadIndices.reset(new unsigned[m_numQuads * 4]);
	m_quadUVIds.reset(new unsigned[m_numQuads * 4]);
	
	unsigned * polygonIndir = polygonIndices();
	unsigned * uvIndir = uvIds();
	unsigned fc, ie = 0;
	for(i = 0; i < getNumPolygons(); i++) {
		fc = polygonCounts()[i];
		if(fc == 4) {
			for(j = 0; j < 4; j++) {
				m_quadIndices[ie] = polygonIndir[j];
				m_quadUVIds[ie] = uvIndir[j];
				ie++;
			}
		}
		else if(fc == 3) {
			for(j = 0; j < 3; j++) {
				m_quadIndices[ie] = polygonIndir[j];
				m_quadUVIds[ie] = uvIndir[j];
				ie++;
			}
			m_quadIndices[ie] = m_quadIndices[ie - 3];
			m_quadUVIds[ie] = m_quadUVIds[ie - 3];
			ie++;
		}
		
		polygonIndir += fc;
		uvIndir += fc;
	}
	
	return m_numQuads;
}