コード例 #1
0
static errcode GetScenedefs(FILE * dfile, SceneHandle scene) {
  apivector Ccenter, Cview, Cup;
  apiflt zoom, aspectratio;
  int raydepth, antialiasing;

  rt_outputfile(scene, "outfile.tga");
  rt_resolution(scene, 512, 512);
  rt_verbose(scene, 0);

  zoom=1.0;
  aspectratio=1.0;
  antialiasing=0;
  raydepth=6;

  Ccenter.x = 0.0;
  Ccenter.y = 0.0;
  Ccenter.z = -5.0;

  Cview.x = 0.0;
  Cview.y = 0.0;
  Cview.z = 1.0;

  Cup.x = 0.0;
  Cup.y = 1.0;
  Cup.z = 0.0;

  rt_camera_setup(scene, zoom, aspectratio, antialiasing, raydepth,
              Ccenter, Cview, Cup);

  { /* lighting hack */
    apivector ctr;
    apitexture tex;

    memset(&tex, 0, sizeof(apitexture));

    tex.col.r = 1.0;
    tex.col.g = 1.0;
    tex.col.b = 1.0;
    ctr.x = 0.0;
    ctr.y = 0.0;
    ctr.z = -100.0;
 
    rt_light(scene, rt_texture(scene, &tex), ctr, 1.0);
  }

  return PARSENOERR;
}
コード例 #2
0
int NFFGetScenedefs(FILE * dfile, SceneHandle scene) {
  apivector Ccenter, Cview, Cup;
  apiflt zoom, aspectratio;
  int raydepth, antialiasing;
  int xres, yres, verbose;
  apivector lookat;
  float vangle, hither;
 
  NFFGetString(dfile, "from");
  NFFGetVector(dfile, &Ccenter);

  NFFGetString(dfile, "at");
  NFFGetVector(dfile, &lookat);
  Cview.x = lookat.x - Ccenter.x;
  Cview.y = lookat.y - Ccenter.y;
  Cview.z = lookat.z - Ccenter.z;

  NFFGetString(dfile, "up");
  NFFGetVector(dfile, &Cup);

  NFFGetString(dfile, "angle");
  fscanf(dfile, "%f", &vangle);
  zoom = 1.0; /* XXX fix me later */
  aspectratio = 1.0;
 
  NFFGetString(dfile, "hither");
  fscanf(dfile, "%f", &hither);
 
  NFFGetString(dfile, "resolution");
  fscanf(dfile, "%d %d", &xres, &yres);

  antialiasing = 0;
  raydepth = 6;
  verbose = 0;

  rt_outputfile(scene, "outfile.tga");
  rt_resolution(scene, xres, yres);
  rt_verbose(scene, verbose);

  rt_camera_setup(scene, zoom, aspectratio, antialiasing, raydepth,
              Ccenter, Cview, Cup);

  rt_background(scene, backgr); 

  return NFFNOERR; 
}
コード例 #3
0
ファイル: api.c プロジェクト: taohonker/Ovito
/* allocate and initialize a scene with default parameters */
SceneHandle rt_newscene(void) {
  scenedef * scene;
  SceneHandle voidscene;
  apicolor bgcolor = rt_color(0.0, 0.0, 0.0);
  apicolor ambcolor = rt_color(1.0, 1.0, 1.0);

  scene = (scenedef *) malloc(sizeof(scenedef));
  memset(scene, 0, sizeof(scenedef));             /* clear all valuas to 0  */

  voidscene = (SceneHandle) scene;

  rt_outputfile(voidscene, "/tmp/outfile.tga");   /* default output file    */
  rt_crop_disable(voidscene);                     /* disable cropping */
  rt_outputformat(voidscene, RT_FORMAT_TARGA);    /* default iamge format   */
  rt_resolution(voidscene, 512, 512);             /* 512x512 resolution     */
  rt_verbose(voidscene, 0);                       /* verbose messages off   */

  rt_image_gamma(voidscene, 2.2f);                /* set default gamma */
  rt_image_clamp(voidscene);                      /* clamp image colors */

#if 1
  rt_rawimage_rgb96f(voidscene, NULL);            /* raw image output off   */
#else
  rt_rawimage_rgb24(voidscene, NULL);             /* raw image output off   */
#endif

  rt_boundmode(voidscene, RT_BOUNDING_ENABLED);   /* spatial subdivision on */
  rt_boundthresh(voidscene, BOUNDTHRESH);         /* default threshold      */
  rt_camera_setup(voidscene, 1.0, 1.0, 0, 6,
                  rt_vector(0.0, 0.0, 0.0),
                  rt_vector(0.0, 0.0, 1.0),
                  rt_vector(0.0, 1.0, 0.0));
  rt_camera_dof(voidscene, 1.0, 0.0);
  rt_shadermode(voidscene, RT_SHADER_AUTO);
  rt_rescale_lights(voidscene, 1.0);
  rt_phong_shader(voidscene, RT_SHADER_BLINN);

  rt_background(voidscene, bgcolor);
  rt_background_sky_sphere(voidscene, rt_vector(0.0, 1.0, 0.0), 0.3, 0, 
                           rt_color(0.0, 0.0, 0.0), rt_color(0.0, 0.0, 0.5));
  rt_background_mode(voidscene, RT_BACKGROUND_TEXTURE_SOLID);

  rt_ambient_occlusion(voidscene, 0, ambcolor);    /* disable AO by default  */
  rt_fog_rendering_mode(voidscene, RT_FOG_NORMAL); /* radial fog by default  */
  rt_fog_mode(voidscene, RT_FOG_NONE);             /* disable fog by default */
  rt_fog_parms(voidscene, bgcolor, 0.0, 1.0, 1.0);

  /* use max positive integer for max transparent surface limit by default */
  rt_trans_max_surfaces(voidscene,((((int)1) << ((sizeof(int) * 8) - 2))-1)*2);

  rt_trans_mode(voidscene, RT_TRANS_ORIG);         /* set transparency mode  */
  rt_normal_fixup_mode(voidscene, 0);              /* disable normal fixup   */
  rt_shadow_filtering(voidscene, 1);               /* shadow filtering on    */

  scene->objgroup.boundedobj = NULL;
  scene->objgroup.unboundedobj = NULL;
  scene->objgroup.numobjects = 0;

  scene->texlist = NULL;
  scene->lightlist = NULL;
  scene->cliplist = NULL;
  scene->numlights = 0;
  scene->scenecheck = 1;
  scene->parbuf = NULL;
  scene->threads = NULL;
  scene->threadparms = NULL;
  scene->flags = RT_SHADE_NOFLAGS;
 
  rt_set_numthreads(voidscene, -1);         /* auto determine num threads */ 

  /* number of distributed memory nodes, fills in array of node/cpu info */
  scene->nodes = rt_getcpuinfo(&scene->cpuinfo);
  scene->mynode = rt_mynode();

  return scene;
}
コード例 #4
0
static errcode GetCamera(parsehandle * ph, SceneHandle scene) {
  apivector Ccenter, Cview, Cup;
  apiflt zoom, aspectratio;
  int raydepth, antialiasing;
  float a, b, c, d;
  errcode rc = PARSENOERR;
  char data[255];

  fscanf(ph->ifp, "%s", data);
  if (stringcmp(data, "PROJECTION") == 0) {
    fscanf(ph->ifp, "%s", data);
    if (stringcmp(data, "FISHEYE") ==0) {
      rt_camera_projection(scene, RT_PROJECTION_FISHEYE);
    } else if (stringcmp(data, "PERSPECTIVE") ==0) {
      rt_camera_projection(scene, RT_PROJECTION_PERSPECTIVE);
    } else if (stringcmp(data, "PERSPECTIVE_DOF") ==0) {
      rt_camera_projection(scene, RT_PROJECTION_PERSPECTIVE_DOF);

      rc |= GetString(ph, "FOCALLENGTH");
      fscanf(ph->ifp, "%f", &a);  

      rc |= GetString(ph, "APERTURE");
      fscanf(ph->ifp, "%f", &b);  

      rt_camera_dof(scene, a, b);
    } else if (stringcmp(data, "ORTHOGRAPHIC") ==0) {
      rt_camera_projection(scene, RT_PROJECTION_ORTHOGRAPHIC);
    }

    rc |= GetString(ph, "ZOOM");
    fscanf(ph->ifp, "%f", &a);  
    zoom=a;
  } else if (stringcmp(data, "ZOOM") == 0) {
    fscanf(ph->ifp, "%f", &a);
    zoom=a;
  } else {
    rc = PARSEBADSYNTAX;
    return rc;
  }

  rc |= GetString(ph, "ASPECTRATIO");
  fscanf(ph->ifp, "%f", &b);  
  aspectratio=b;

  rc |= GetString(ph, "ANTIALIASING");
  fscanf(ph->ifp, "%d", &antialiasing);

  rc |= GetString(ph, "RAYDEPTH");
  fscanf(ph->ifp, "%d", &raydepth);

  rc |= GetString(ph, "CENTER");
  fscanf(ph->ifp, "%f %f %f", &a, &b, &c);
  Ccenter.x = a;
  Ccenter.y = b;
  Ccenter.z = c;

  rc |= GetString(ph, "VIEWDIR");
  fscanf(ph->ifp, "%f %f %f", &a, &b, &c);
  Cview.x = a;
  Cview.y = b;
  Cview.z = c;

  rc |= GetString(ph, "UPDIR");
  fscanf(ph->ifp, "%f %f %f", &a, &b, &c);
  Cup.x = a;
  Cup.y = b;
  Cup.z = c;

  rt_camera_setup(scene, zoom, aspectratio, antialiasing, raydepth,
                  Ccenter, Cview, Cup);

  fscanf(ph->ifp, "%s", data);
  if (stringcmp(data, "FRUSTUM") == 0) {
    fscanf(ph->ifp, "%f %f %f %f", &a, &b, &c, &d);
    rt_camera_frustum(scene, a, b, c, d);
    fscanf(ph->ifp, "%s", data);
    if (stringcmp(data, "END_CAMERA") != 0) {
      rc |= PARSEBADSYNTAX;
      return rc;
    }
  } else if (stringcmp(data, "END_CAMERA") != 0) {
    rc |= PARSEBADSYNTAX;
    return rc;
  }


  return rc;
}
コード例 #5
0
int main(int argc, char **argv) {
  SceneHandle scene;
  int i, j;
  apivector Ccenter, Cview, Cup;
  apivector ctr1, ctr2;
  apitexture tex1, tex2;
  void * vtx1, * vtx2;
  char fname[100];

  rt_initialize(&argc, &argv); 

  Ccenter.x=0.0; Ccenter.y=0.0; Ccenter.z=-3.0;
  Cview.x=0.0;   Cview.y=0.0;   Cview.z=1.0;
  Cup.x=0.0;     Cup.y=1.0;     Cup.z=0.0;

  ctr1.x=20.0;  ctr1.y=20.0; ctr1.z=-40.0;
  ctr2.x=-20.0; ctr2.y=20.0; ctr2.z=-40.0;
  
  tex1.col.r=1.0;
  tex1.col.g=0.5;
  tex1.col.b=0.0;
  tex1.ambient=1.0;
  tex1.opacity=1.0;
  tex2=tex1;
  tex2.col.r=0.0;
  tex2.col.b=1.0;

  initspheres();
  
 
  for (i=0; i<MAXFRAMES; i++) {  
    scene = rt_newscene();
    vtx1=rt_texture(scene, &tex1);
    vtx2=rt_texture(scene, &tex2);

    sprintf(fname,"outfile.%4.4d.tga",i);

    if (rt_mynode()==0) printf("Rendering: %s\n", fname);

    rt_outputfile(scene, fname);
    rt_resolution(scene, XRES, YRES);
    rt_verbose(scene, 0);

    rt_camera_setup(scene, 1.0, 1.0, 0, 5, Ccenter, Cview, Cup);

    movesp(); 
    drawsp(scene);

    rt_light(scene, vtx1, ctr1, 1.0);
    rt_light(scene, vtx2, ctr2, 1.0);

    rt_renderscene(scene);

    rt_deletescene(scene);

    for (j=0; j<NUMSP; j++)
      free(sp[i].voidtex);  
  }

  rt_finalize();

  return 0;
}