예제 #1
0
파일: jni-engine.cpp 프로젝트: ElaraFX/tbb
int CreateScene(argoptions &opt) {
    char *filename;

    global_scene = rt_newscene();
    rt_initialize();

    //filename = "/mnt/sdcard/tachyon/data.dat";
    filename = opt.filename;
    LOG_INFO("CreateScene: data file name is %s", filename);

    LOG_INFO("Readmodel");
    if (readmodel(filename, global_scene) != 0) {
        LOG_ERROR("Parser returned a non-zero error code reading %s\n", filename);
        LOG_ERROR("Aborting Render...\n");
        rt_finalize();
        return -1;
    }
    LOG_INFO("Readmodel done");

    scenedef *scene = (scenedef *) global_scene;

    //scene->hres and scene->yres are taken from display properties in *initBitmap() function
    scene->hres = global_xwinsize = global_xsize;
    scene->vres = global_ywinsize = global_ysize;
    LOG_INFO("CreateScene: global_xsize=%d global_ysize=%d", global_xsize, global_ysize);

    return 0;
}
예제 #2
0
int CreateScene() {

    CFURLRef balls_dat_url = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("balls"), CFSTR("dat"),NULL);
    char filename[1024];
    CFURLGetFileSystemRepresentation(balls_dat_url, true, (UInt8*)filename, (CFIndex)sizeof(filename));
    CFRelease(balls_dat_url);

    global_scene = rt_newscene();
    rt_initialize();

    if ( readmodel(filename, global_scene) != 0 ) {
        rt_finalize();
        return -1;
    }

    // need these early for create_graphics_window() so grab these here...
    scenedef *scene = (scenedef *) global_scene;

    get_screen_resolution(&global_xsize, &global_ysize);

    // scene->hres and scene->vres should be equal to screen resolution
    scene->hres = global_xwinsize = global_xsize;
    scene->vres = global_ywinsize = global_ysize;
    return 0;
}
예제 #3
0
static int main_init_parts (int argc, char **argv)
{
    int rc;
    argoptions opt;
    char * filename;

    global_window_title = window_title_string (argc, argv);

    global_scene = rt_newscene();

    rt_initialize(&argc, &argv);

    if ((rc = getargs(argc, argv, &opt)) == -1) {
#if _WIN32||_WIN64
        rt_sleep(10000);
#endif
        exit(rc);
    }

#ifdef DEFAULT_MODELFILE
#if  _WIN32||_WIN64
#define _GLUE_FILENAME(x) "..\\dat\\" #x
#else
#define _GLUE_FILENAME(x) #x
#endif
#define GLUE_FILENAME(x) _GLUE_FILENAME(x)
    if(opt.foundfilename == -1)
        filename = GLUE_FILENAME(DEFAULT_MODELFILE);
    else
#endif//DEFAULT_MODELFILE
        filename = opt.filename;

    rc = readmodel(filename, global_scene);

    if (rc != 0) {
        fprintf(stderr, "Parser returned a non-zero error code reading %s\n", filename);
        fprintf(stderr, "Aborting Render...\n");
        rt_finalize();
        return -1;
    }

    /* process command line overrides */
    useoptions(&opt, global_scene);

    // need these early for create_graphics_window() so grab these here...
    scenedef *scene = (scenedef *) global_scene;
    global_xsize = scene->hres;
    global_ysize = scene->vres;
    global_xwinsize = global_xsize;
    global_ywinsize = global_ysize;  // add some here to leave extra blank space on bottom for status etc.
    global_usegraphics = (scene->displaymode == RT_DISPLAY_ENABLED);

    return 0;
}
예제 #4
0
파일: main.cpp 프로젝트: ElaraFX/tbb
int CreateScene() {

   char* filename = "Assets/balls.dat";

    global_scene = rt_newscene();
    rt_initialize();

    if ( readmodel(filename, global_scene) != 0 ) {
        rt_finalize();
        return -1;
    }

    // need these early for create_graphics_window() so grab these here...
    scenedef *scene = (scenedef *) global_scene;

    // scene->hres and scene->vres should be equal to screen resolution
    scene->hres = global_xwinsize = global_xsize;
    scene->vres = global_ywinsize = global_ysize;  

    return 0;
}
예제 #5
0
int CreateScene(argoptions &opt) {
    char *filename;

    global_scene = rt_newscene();
    rt_initialize();

    /* process command line overrides */
    useoptions(&opt, global_scene);

#ifdef DEFAULT_MODELFILE
#if  _WIN32||_WIN64
#define _GLUE_FILENAME(x) "..\\dat\\" #x
#else
#define _GLUE_FILENAME(x) #x
#endif
#define GLUE_FILENAME(x) _GLUE_FILENAME(x)
    if(opt.foundfilename == -1)
        filename = GLUE_FILENAME(DEFAULT_MODELFILE);
    else
#endif//DEFAULT_MODELFILE
        filename = opt.filename;

    if ( readmodel(filename, global_scene) != 0 ) {
        fprintf(stderr, "Parser returned a non-zero error code reading %s\n", filename);
        fprintf(stderr, "Aborting Render...\n");
        rt_finalize();
        return -1;
    }

    // need these early for create_graphics_window() so grab these here...
    scenedef *scene = (scenedef *) global_scene;
    global_xsize = scene->hres;
    global_ysize = scene->vres;
    global_xwinsize = global_xsize;
    global_ywinsize = global_ysize;  // add some here to leave extra blank space on bottom for status etc.
    global_usegraphics = (scene->displaymode == RT_DISPLAY_ENABLED);

    return 0;
}
예제 #6
0
int ray(int argc, char **argv) {
#else
int main(int argc, char **argv) {
#endif
    SceneHandle scene;
    unsigned int rc;
    argoptions opt;
    char * filename;
    int node, fileindex;
    rt_timerhandle parsetimer;
    size_t len;

    node = rt_initialize(&argc, &argv);

    rt_set_ui_message(my_ui_message);
    rt_set_ui_progress(my_ui_progress);

    if (node == 0) {
        printf("Tachyon Parallel/Multiprocessor Ray Tracer   Version %s   \n",
               TACHYON_VERSION_STRING);
        printf("Copyright 1994-2010,    John E. Stone <*****@*****.**> \n");
        printf("------------------------------------------------------------ \n");
    }

    if ((rc = getargs(argc, argv, &opt, node)) != 0) {
        rt_finalize();
        exit(rc);
    }

    if (opt.numfiles > 1) {
        printf("Rendering %d scene files.\n", opt.numfiles);
    }

    for (fileindex=0; fileindex<opt.numfiles; fileindex++) {
        scene = rt_newscene();

        /* process command line overrides */
        presceneoptions(&opt, scene);

        filename = opt.filenames[fileindex];

        if (opt.numfiles > 1) {
            printf("\nRendering scene file %d of %d, %s\n", fileindex+1, opt.numfiles, filename);
        }

        parsetimer=rt_timer_create();
        rt_timer_start(parsetimer);

        len = strlen(filename);

        if (len > 4 && (!strcmp(filename+len-4, ".nff") ||
                        !strcmp(filename+len-4, ".NFF"))) {
            rc = ParseNFF(filename, scene); /* must be an NFF file */
        }
        else if (len > 3 && (!strcmp(filename+len-3, ".ac") ||
                             !strcmp(filename+len-3, ".AC"))) {
            rc = ParseAC3D(filename, scene); /* Must be an AC3D file */
        }
#ifdef USELIBMGF
        else if (len > 4 && (!strcmp(filename+len-4, ".mgf") ||
                             !strcmp(filename+len-4, ".MGF"))) {
            rc = ParseMGF(filename, scene, 1); /* Must be an MGF file */
        }
#endif
        else {
            rc = readmodel(filename, scene); /* Assume its a Tachyon scene file */
        }

        rt_timer_stop(parsetimer);
        if (rc == PARSENOERR && node == 0)
            printf("Scene Parsing Time: %10.4f seconds\n", rt_timer_time(parsetimer));
        rt_timer_destroy(parsetimer);

        if (rc != PARSENOERR && node == 0) {
            switch(rc) {
            case PARSEBADFILE:
                printf("Parser failed due to nonexistent input file: %s\n", filename);
                break;
            case PARSEBADSUBFILE:
                printf("Parser failed due to nonexistent included file.\n");
                break;
            case PARSEBADSYNTAX:
                printf("Parser failed due to an input file syntax error.\n");
                break;
            case PARSEEOF:
                printf("Parser unexpectedly hit an end of file.\n");
                break;
            case PARSEALLOCERR:
                printf("Parser ran out of memory.\n");
                break;
            }
            if (fileindex+1 < opt.numfiles)
                printf("Aborting render, continuing with next scene file...\n");
            else
                printf("Aborting render.\n");

            rt_deletescene(scene); /* free the scene */
            continue;              /* process the next scene */
        }

        /* process command line overrides */
        postsceneoptions(&opt, scene);

        /* choose which rendering mode to use */
        if (opt.usecamfile == 1) {
            return animate_scene(opt, scene, node); /* fly using prerecorded data */
        }
        else if (strlen(opt.spaceball) > 0) {
            return fly_scene(opt, scene, node);     /* fly with spaceball etc */
        }
        else {
            if (opt.numfiles > 1 && opt.nosave != 1) {
                char multioutfilename[FILENAME_MAX];
                sprintf(multioutfilename, opt.outfilename, fileindex);
                rt_outputfile(scene, multioutfilename);
            }

            rt_renderscene(scene); /* Render a single frame */
        }

        rt_deletescene(scene);   /* free the scene, get ready for next one */
    }

    rt_finalize();             /* close down the rendering library and MPI */
    freeoptions(&opt);         /* free parsed command line option data */

    return 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;
}