Esempio n. 1
0
ON_Plane::ON_Plane(
    const ON_3dPoint& P,  // point on the plane
    const ON_3dPoint& Q,  // point on the plane
    const ON_3dPoint& R   // point on the plane
    )
{
  CreateFromPoints(P,Q,R);
}
Esempio n. 2
0
BOOL CFrustum::CreateFromClipPoly(Fvector* p, int count, Fvector& vBase, CFrustum& clip)
{
	VERIFY(count<FRUSTUM_MAXPLANES);
	VERIFY(count>=3);

	sPoly	poly1	(p,count);
	sPoly	poly2;
	sPoly*	dest	= clip.ClipPoly(poly1,poly2);

	// here we end up with complete frustum-polygon in 'dest'
	if (0==dest)	return false;

	CreateFromPoints(dest->begin(),dest->size(),vBase);
	return	true;
}
Esempio n. 3
0
void CFrustum::CreateFromPortal(sPoly* poly, Fvector& vPN, Fvector& vBase, Fmatrix& mFullXFORM)
{
    Fplane P;
    P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);

    if (poly->size()>6)
    {
        SimplifyPoly_AABB(poly, P);
        P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);
    }

    // Check plane orientation relative to viewer
    // and reverse if needed
    if (P.classify(vBase) < 0)
    {
        std::reverse(poly->begin(), poly->end());
        P.build_precise((*poly)[0], (*poly)[1], (*poly)[2]);
    }

    // Base creation
    CreateFromPoints(poly->begin(), poly->size(), vBase);

    // Near clipping plane
    _add(P);

    // Far clipping plane
    Fmatrix& M = mFullXFORM;
    P.n.x = -(M._14 - M._13);
    P.n.y = -(M._24 - M._23);
    P.n.z = -(M._34 - M._33);
    P.d = -(M._44 - M._43);
    float denom = 1.0f / P.n.magnitude();
    P.n.x *= denom;
    P.n.y *= denom;
    P.n.z *= denom;
    P.d *= denom;
    _add(P);
}
GMBoundingSphere GMBoundingSphere::CreateFromFrustum(const GMBoundingFrustum& frustum)
{
    GMVector3D corners[8];
    frustum.getCorners(corners);
    return CreateFromPoints(corners, 8);
}