예제 #1
0
color cyl_checker_texture(vector * hit, texture * tex, ray * ry) {
    long x,y;
    vector rh;
    flt u,v;
    color col;

    rh.x=hit->x - tex->ctr.x;
    rh.y=hit->y - tex->ctr.y;
    rh.z=hit->z - tex->ctr.z;

    xyztocyl(rh, 1.0, &u, &v);

    x=(long) (fabs(u) * 18.0);
    x=x % 2;
    y=(long) (fabs(v) * 10.0);
    y=y % 2;

    if (((x + y) % 2)==1) {
        col.r=1.0;
        col.g=0.2;
        col.b=0.0;
    }
    else {
        col.r=0.0;
        col.g=0.2;
        col.b=1.0;
    }

    return col;
}
/* cylindrical image map */
color image_cyl_texture(const vector * hit, const texture * tx, const ray * ry) {
  vector rh;
  flt u, v, miprad, maxscale, cyrad;
  standard_texture * tex = (standard_texture *) tx;
 
  rh.x=hit->x - tex->ctr.x;
  rh.z=hit->y - tex->ctr.y;
  rh.y=hit->z - tex->ctr.z;
 
  xyztocyl(rh, 1.0, &u, &v);

  u = u * tex->scale.x;  
  u = u + tex->rot.x;
  u = u - ((int) u);
  if (u < 0.0) u+=1.0; 

  v = v * tex->scale.y; 
  v = v + tex->rot.y;
  v = v - ((int) v);
  if (v < 0.0) v+=1.0; 

  cyrad = EPSILON + 8.0 * sqrt(rh.x*rh.x + rh.y*rh.y + rh.z*rh.z);

  maxscale = (fabs(tex->scale.x) > fabs(tex->scale.y)) ? 
             tex->scale.x : tex->scale.y;

  miprad = (0.05 * ry->opticdist * fabs(maxscale)) / cyrad;

  return MIPMap(tex->img, u, v, miprad);
}  
예제 #3
0
/* cylindrical image map */
color image_cyl_texture(vector * hit, texture * tex, ray * ry) {
    vector rh;
    flt u,v;

    rh.x=hit->x - tex->ctr.x;
    rh.z=hit->y - tex->ctr.y;
    rh.y=hit->z - tex->ctr.z;

    xyztocyl(rh, 1.0, &u, &v);

    u = u * tex->scale.x;
    u = u + tex->rot.x;
    u=fmod(u, 1.0);
    if (u < 0.0) u+=1.0;

    v = v * tex->scale.y;
    v = v + tex->rot.y;
    v=fmod(v, 1.0);
    if (v < 0.0) v+=1.0;

    return ImageMap((rawimage *)tex->img, u, v);
}