#include <stdio.h>
#include "_pvr.h"
void
pv_bg(int *c)
{ float f[3];
  f[0]=(float)c[0]; f[0]/=255.0;
  f[1]=(float)c[1]; f[1]/=255.0;
  f[2]=(float)c[2]; f[2]/=255.0;
  fprintf(stdout, "background{ color rgb <%.2g,%.2g,%.2g> }\n", f[0],f[1],f[2]);}

void
pv_cm(int *l, int *t)
{ fprintf(stdout, "camera{ location <%d,%d,%d> look_at <%d,%d,%d> }\n", l[0],l[1],l[2],
  t[0],t[1],t[2]);}

void
pv_ci()
{ fprintf(stdout, "#include \"colors.inc\"\n");}

void
pv_ls(int *l, int *c)
{ float f[3];
  f[0]=(float)c[0]; f[0]/=255.0;
  f[1]=(float)c[1]; f[1]/=255.0;
  f[2]=(float)c[2]; f[2]/=255.0;
  fprintf(stdout, "light_source{ <%d,%d,%d> color rgb <%.2g,%.2g,%.2g> }\n", l[0],l[1],l[2],
  f[0],f[1],f[2]);}

void
pv_gs(int *l)
{ float f[3];
  f[0]=(float)l[0]; f[0]/=255.0;
  f[1]=(float)l[1]; f[1]/=255.0;
  f[2]=(float)l[2]; f[2]/=255.0;
  fprintf(stdout, "global_settings{ ambient_light rgb <%.2g,%.2g,%.2g> }\n", f[0],f[1],f[2]);}

void
pv_sh(int *c, float r, int *t, float *p)
{ float f[3];
  f[0]=(float)t[0]; f[0]/=255.0;
  f[1]=(float)t[1]; f[1]/=255.0;
  f[2]=(float)t[2]; f[2]/=255.0;
  fprintf(stdout, "sphere{\n <%d,%d,%d>, %.2g\n", c[0],c[1],c[2], r );
  fprintf(stdout, " texture{ pigment{ color rgb <%.2g,%.2g,%.2g> }}\n", f[0],f[1],f[2] );
  fprintf(stdout, " translate <%.2g,%.2g,%.2g>\n}\n", p[0],p[1],p[2] );
}

void
pv_cb(float sh, int *c, float *p)
{ float _sh; _sh=-sh;
  float t[3];
  t[0]=(float)c[0]; t[0]/=255.0;
  t[1]=(float)c[1]; t[1]/=255.0;
  t[2]=(float)c[2]; t[2]/=255.0;
  fprintf(stdout, "box{\n <%.2g,%.2g,%.2g>, <%.2g,%.2g,%.2g>\n", _sh,_sh,_sh,  sh,sh,sh );
  fprintf(stdout, " texture{ pigment{ color rgb <%.2g,%.2g,%.2g> }}\n", t[0],t[1],t[2] );
  fprintf(stdout, " translate <%.2g,%.2g,%.2g>\n}\n", p[0],p[1],p[2] );
}

void
pv_gd(int *c1, int *c2)
{ float t1[3];
  float t2[3];
  t1[0]=(float)c1[0]; t1[0]/=255.0;
  t1[1]=(float)c1[1]; t1[1]/=255.0;
  t1[2]=(float)c1[2]; t1[2]/=255.0;

  t2[0]=(float)c2[0]; t2[0]/=255.0;
  t2[1]=(float)c2[1]; t2[1]/=255.0;
  t2[2]=(float)c2[2]; t2[2]/=255.0;
  fprintf(stdout, "plane{\n <0,1,0>, 0\n");
  fprintf(stdout, " texture{ pigment{ checker color rgb <%.2g,%.2g,%.2g>, color rgb <%.2g,%.2g,%.2g> }}\n}\n",
   t1[0],t1[1],t1[2], t2[0],t2[1],t2[2] );
}

