void GregoryQuadPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v)
{
	float3 bicubic[16];

	float U = 1 - u;
	float V = 1 - v;

	/*  8     9     10     11
	 * 12   0\1     2/3    13
	 * 14   4/5     6\7    15
	 * 16    17     18     19
	 */

	bicubic[5] = (u*hull[1] + v*hull[0])/no_zero_div(u + v);
	bicubic[6] = (U*hull[2] + v*hull[3])/no_zero_div(U + v);
	bicubic[9] = (u*hull[5] + V*hull[4])/no_zero_div(u + V);
	bicubic[10] = (U*hull[6] + V*hull[7])/no_zero_div(U + V);

	// Map gregory control points to bezier control points.
	bicubic[0] = hull[8];
	bicubic[1] = hull[9];
	bicubic[2] = hull[10];
	bicubic[3] = hull[11];
	bicubic[4] = hull[12];
	bicubic[7] = hull[13];
	bicubic[8] = hull[14];
	bicubic[11] = hull[15];
	bicubic[12] = hull[16];
	bicubic[13] = hull[17];
	bicubic[14] = hull[18];
	bicubic[15] = hull[19];

	decasteljau_bicubic(P, dPdu, dPdv, bicubic, u, v);
}
void BicubicTangentPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v)
{
	decasteljau_bicubic(P, NULL, NULL, hull, u, v);

	if(dPdu) *dPdu = decasteljau_tangent(utan, u, v);
	if(dPdv) *dPdv = decasteljau_tangent(vtan, v, u);
}
Beispiel #3
0
void BicubicPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v)
{
  if (N) {
    float3 dPdu_, dPdv_;
    decasteljau_bicubic(P, &dPdu_, &dPdv_, hull, u, v);

    if (dPdu && dPdv) {
      *dPdu = dPdu_;
      *dPdv = dPdv_;
    }

    *N = normalize(cross(dPdu_, dPdv_));
  }
  else {
    decasteljau_bicubic(P, dPdu, dPdv, hull, u, v);
  }
}
void BicubicPatch::eval(float3 *P, float3 *dPdu, float3 *dPdv, float u, float v)
{
	decasteljau_bicubic(P, dPdu, dPdv, hull, u, v);
}