Пример #1
0
void FEdgeXDetector::ProcessSilhouetteEdge(WXEdge *iEdge, bool meshSilhouettes)
{
    if(iEdge->nature() & Nature::BORDER)
        return;
    // SILHOUETTE ?
    //-------------
    WXFace * fA = (WXFace *)iEdge->GetaOEdge()->GetaFace();
    WXFace * fB = (WXFace *)iEdge->GetaOEdge()->GetbFace();

    if((fA->front(_useConsistency))^(fB->front(_useConsistency))){ // fA->visible XOR fB->visible (true if one is 0 and the other is 1)
        // Freestyle is using a hack here to determine if these faces are "smooth" or "sharp."  Specifically,
        // if the normals disagree at a vertex, then it must be "sharp."  This hack broke with the bunny triangle mesh that had planar
        // faces in one version.  New hack includes more tests...

        if(!meshSilhouettes &&
                fA->GetVertexNormal(iEdge->GetaVertex()) == fB->GetVertexNormal(iEdge->GetaVertex()) &&
                fA->GetVertexNormal(iEdge->GetbVertex()) == fB->GetVertexNormal(iEdge->GetbVertex()) &&
                fA->GetVertexNormal(iEdge->GetaVertex()) != fA->GetVertexNormal(iEdge->GetbVertex()))
            // Aaron: added second and third conditions
        {
            //	Vec3r Aa = fA->GetVertexNormal(iEdge->GetaVertex());
            //	Vec3r Ba = fB->GetVertexNormal(iEdge->GetaVertex());
            //	Vec3r Ab = fA->GetVertexNormal(iEdge->GetbVertex());
            //	Vec3r Bb = fB->GetVertexNormal(iEdge->GetbVertex());

            //	printf("Non-silhouette detected\n");
            //	printf("%f %f %f,   %f %f %f\n", Aa[0], Aa[1], Aa[2], Ba[0], Ba[1], Ba[2]);
            //	printf("%f %f %f,   %f %f %f\n", Ab[0], Ab[1], Ab[2], Bb[0], Bb[1], Bb[2]);
            return;
        }

        iEdge->AddNature(Nature::SILHOUETTE);
        if(fB->front(_useConsistency))
            iEdge->SetOrder(1);
        else
            iEdge->SetOrder(-1);
    }
}
Пример #2
0
void FEdgeXDetector::ProcessSilhouetteEdge(WXEdge *iEdge)
{
	if (iEdge->nature() & Nature::BORDER)
		return;
	// SILHOUETTE ?
	//-------------
	WXFace *fA = (WXFace *)iEdge->GetaOEdge()->GetaFace();
	WXFace *fB = (WXFace *)iEdge->GetaOEdge()->GetbFace();

	if ((fA->front()) ^ (fB->front())) { // fA->visible XOR fB->visible (true if one is 0 and the other is 1)
		// The only edges we want to set as silhouette edges in this way are the ones with 2 different normals
		// for 1 vertex for these two faces
		//--------------------
		// In reality we only test the normals for 1 of the 2 vertices.
		if (fA->GetVertexNormal(iEdge->GetaVertex()) == fB->GetVertexNormal(iEdge->GetaVertex()))
			return;
		iEdge->AddNature(Nature::SILHOUETTE);
		if (fB->front())
			iEdge->setOrder(1);
		else
			iEdge->setOrder(-1);
	}
}