Esempio n. 1
0
 csColor GetPixel (float coord_x, float coord_y)
 {
   // Scale the texture coordinates.
   coord_x *= textureScale.x;
   coord_y *= textureScale.y;
 
   // Calculate the material coordinates.
   float matcoord_x_f = (coord_x * img_w);
   float matcoord_y_f = (coord_y * img_h);
   int matcoord_x = int (matcoord_x_f);
   int matcoord_y = int (matcoord_y_f);
 
   // Bilinearly filter from material.
   csColor p00 (GetPixelWrap (img, img_w, img_h,
     matcoord_x, matcoord_y));
   csColor p01 (GetPixelWrap (img, img_w, img_h,
     matcoord_x, matcoord_y+1));
   csColor p11 (GetPixelWrap (img, img_w, img_h,
     matcoord_x+1, matcoord_y+1));
   csColor p10 (GetPixelWrap (img, img_w, img_h,
     matcoord_x+1, matcoord_y));
 
   float f1 = matcoord_x_f - matcoord_x;
   float f2 = matcoord_y_f - matcoord_y;
 
   return csLerp (csLerp (p00, p10, f1), 
     csLerp (p01, p11, f1), f2);
 }
Esempio n. 2
0
 static csVector3 LerpPC (const csVector3& v1, const csVector3& v2, float t)
 {
   float iz1 = 1.0f / v1.z;
   float iz2 = 1.0f / v2.z;
   csVector3 vLerped = csLerp (v1 * iz1, v2 * iz2, t);
   float z = 1.0f / csLerp (iz1, iz2, t);
   return vLerped * z;
 }