Esempio n. 1
0
int main(int argc, char *argv[]) {
    FILE *inf;
    wave_object_t obj;
    const size_t NUM_FRAMES = 360;
    RtInt md = 4;
    scene_info_t scene;
    double rad = 20;
    double t = 0.0;
    double dt = 2.0*PI/(NUM_FRAMES-1);
    size_t fnum;

    if (argc <3) {
        printf("No input and output file names given!\n");
        return 1;
    }
    
    inf = fopen(argv[1], "rt");
    if (inf == NULL) {
        printf("Could not open \"%s\"\n", argv[1]);
        return 1;

    }
    init_object(&obj);
    read_object(inf, &obj);
    
    
    printf("Object file has:\n  %zu vertices\n  %zu normals\n  %zu texture coordinates\n  %zu faces\n  %d objects\n",
           obj.num_verts, obj.num_norms, obj.num_texts, obj.num_faces, 1);

    RiBegin(RI_NULL);
    RiOption("trace", "maxdepth", &md, RI_NULL);
    RiSides(2);


    scene.cam.location[0] = rad;
    scene.cam.location[1] = rad;
    scene.cam.location[2] = rad;

    scene.cam.look_at[0]= 0.0;
    scene.cam.look_at[1]= 0.0;
    scene.cam.look_at[2]= 0.0;
    scene.cam.roll = 0.0;
    
    scene.fprefix = argv[2];

    for (fnum = 0; fnum < NUM_FRAMES; ++fnum) {
        scene.cam.location[0] = rad * sin(t);
        scene.cam.location[2] = rad * cos(t);
        t += dt;
        printf("Rendering frame %lu\n", fnum);
        doFrame(fnum, &scene, &obj);
    }
    RiEnd();

    free_object(&obj);

    fclose(inf);
    return 0;
}
Esempio n. 2
0
int main()
{
    std::ostringstream output;

    // Test setting of options.
    const char* outputType = "Ascii";
    RiOption((char*)"RI2RIB_Output", "Type", &outputType,
                                     "OStream", &output, RI_NULL);
    int indentSize = 2;
    const char* indentType = "Space";
    RiOption((char*)"RI2RIB_Indentation", "Size", &indentSize,
                                          "Type", &indentType, RI_NULL);

    RtPointer badHandle = RtPointer(0xDEADBEEF);

    // Create RIB
    RiBegin(0);
        RiFrameBegin(0);
            RiBasis(RiCatmullRomBasis, 2, RiHermiteBasis, 3);
        RiFrameEnd();

        RiArchiveRecord((char*)"comment",
                        (char*)" Note that we expect a bad handle error "
                               "regarding %p somewhere here!", badHandle);

        RiFrameBegin(1);
            RiDisplay((char*)"blah.tif", (char*)"framebuffer", (char*)"rgb",
                      RI_NULL);
            RiBasis(RiBezierBasis, 3, RiCatmullRomBasis, 1);
            RiPixelFilter(RiGaussianFilter, 2, 2);
            RiProjection((char*)"perspective", RI_NULL);
            RiTranslate(0,0,5);
            RiWorldBegin();
                RtLightHandle h = RiLightSource((char*)"pointlight", RI_NULL);
                RiIlluminate(h, RI_FALSE);
                RiIlluminate(badHandle, RI_TRUE); // Invalid handle!
                float Cs[] = {1,0,0,  0,1,0,  0,0,1,  2,2,2};
                RiSphere(1, -1, 1, 360, "Cs", Cs, RI_NULL);
                float blah[] = {42};
                RiSphere(2, -2, 2, 360, "float blah", blah, RI_NULL);

                int nvertices[] = {5};
                float P[] = {-1,-1,0,  1,-1,0,  1,1,0,   -1,1,0,  -1,-1,2};
                float width[] = {1, 2, 3};
                RiCurves((char*)"cubic", 1, nvertices,
                         (char*)"nonperiodic",
                         "P", P,
                         "width", width, RI_NULL);
            RiWorldEnd();
        RiFrameEnd();
    RiEnd();

    // Stream the output buffer to stdout
    std::cout << output.str();
    return 0;
}
Esempio n. 3
0
File: min.c Progetto: yingzm/rayer
int main(int argc, char *argv[])
{
RiBegin(RI_NULL);
	RiDisplay ("min.tiff","file","rgb",RI_NULL);
	RiProjection ("perspective",RI_NULL);
	RiWorldBegin();
		RiTranslate(0,0,2);
		RiSphere(1,-1,1,360,RI_NULL);
	RiWorldEnd();
RiEnd();
return 0;
}
Esempio n. 4
0
void SpotLight::prepass(Scene* scene)
{
#if 0
    // render shadow map
    bool castsShadow = attributeByName("Casts Shadows")->property("value").value<bool>();
    if (castsShadow) {
        QString shadowPath = QString(getenv("AQSIS_TEXTURE_PATH")).split(":")[0];

        //Scene* scene = SunshineUi::activeScene();
        QString picFile = shadowPath + "/" + scene->assetName(this) + ".z";
        QString texFile = shadowPath + "/" + scene->assetName(this) + ".shd";
        char picName[1000];
        char texName[1000];
        strcpy(picName, picFile.toStdString().c_str());
        strcpy(texName, texFile.toStdString().c_str());

        std::cout << "writing shadow map: " << picFile << std::endl;

        float shadowResolution = attributeByName("Shadow Resolution")->property("value").value<int>();

        RiBegin(RI_NULL);
        RiDisplay(picName, "zfile", "z", RI_NULL);
        RiFormat(shadowResolution, shadowResolution, 1);
        RiPixelSamples(1, 1);
        RtFloat jitterVal = 0;
        const char* midpoint = "midpoint";
        RiHider("hidden", "jitter", &jitterVal, "depthfilter", &midpoint, RI_NULL);
        RiSurface("null", RI_NULL);

        float coneAngle = attributeByName("Cone Angle")->property("value").value<float>();


        Camera camera;
        camera.setCenter(this->center());
        camera.setRotate(this->rotate());
        camera.setScale(this->scale());
        camera.setFOV(coneAngle*2);

        RenderUtil::renderScene(scene, &camera);

        RiMakeShadow(picName, texName, RI_NULL);

        RiEnd();



        std::cout << "converting " << picName << " to " << texName << std::endl;
        //
    }
#endif
}
Esempio n. 5
0
int main(int argc, char *argv[]) {
    if (argc<2) {
        printf("No output file name prefixgiven.\n");
        printf("Use:\n\t%s output_prefix\n\n", argv[0]);
        exit(1);
    }

    /* const size_t NUM_FRAMES = 10; */

    RiBegin(RI_NULL);

    scene_info_t scene;

    scene.cam.location[0] = 20;
    scene.cam.location[1] = 20;
    scene.cam.location[2] = 20;

    scene.cam.look_at[0]= 0.0;
    scene.cam.look_at[1]= 0.0;
    scene.cam.look_at[2]= 0.0;
    scene.cam.roll = 0.0;
    
    scene.fprefix = argv[1];

    size_t cur_frame = 0;
    
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[0] -= 2;
        cur_frame += 1;
    }
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[1] -= 2;
        cur_frame += 1;
    }
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[0] += 2;
        cur_frame += 1;
    }
    for (size_t fnum = 0; fnum <= 20; ++fnum) {
        doFrame(cur_frame, &scene);
        scene.cam.location[1] += 2;
        cur_frame += 1;
    }

    RiEnd();

    return 0;
}
Esempio n. 6
0
int main(int argc, char *argv[])
{
    if (argc<2) {
        std::cerr << "No filename given.\n";
        return 1;
    }
    int i;
    RiBegin(RI_NULL);

    for (i=1;i<=360; ++i) {
        doFrame(i, argv[1]);
    }
  
    RiEnd();
}
Esempio n. 7
0
int main(void) {
	RiBegin(RI_NULL);

	RiFormat(100, 100, 1.0);
	RiFrameAspectRatio(4.0 / 3.0);
	RiFrameBegin(0);

	RiProjection("perspective");
	RiTranslate(0, 0, 5.0);
	RiWorldBegin();
	RiSphere(1.0, 0, 0, 0);
	RiWorldEnd();
	RiFrameEnd();

	RiEnd();

	return 0;
}
Esempio n. 8
0
/**
 * glutrib, a RIB file loader. Displays a RIB scene into a window, using GLUT.
 * Synopsis: glutrib [ribfile]
 */
int main(int argc, char **argv)
{
	// const char *searchPath = ".:&";
  	// RiCPPControl("searchpath", "renderer", &searchPath, RI_NULL);

#if defined (_DEBUG)
	drawNormals = 1;
#endif

	storedArgc = argc;
	storedArgv = argv;
	
	glutInit(&argc, argv);
	glutInitDisplayMode ((unsigned int)(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH));
	glutInitWindowSize (width, height); 
	glutInitWindowPosition (100, 100);
	glutCreateWindow(argc <= 1 ? "GLUT RIB" : argv[1]);
	
   	glutDisplayFunc(display); 
	glutReshapeFunc(reshape);
	glutMouseFunc(mouse);
	glutMotionFunc(motion);
	glutKeyboardFunc(keyboard);

	// std::cerr << "BEGIN" << std::endl;
	
	// Print errors
	RiErrorHandler(RiErrorPrint);

	RiBegin("glrenderer"); {
		if ( argc <= 1 ) {
			testScene();
		} else {
			loadScene(argv[1]);
		}
		// std::cerr << "MainLoop" << std::endl;
		glutReshapeWindow(width, height); // Hack, display did not work on my laptop until window was resized...
		glutMainLoop();
	} RiEnd();
	
	// std::cerr << "END" << std::endl;

	return 0;
}
Esempio n. 9
0
MStatus liqWriteArchive::redoIt()
{
  try {
    MString objName = objectNames[0]; // TEMP - just handling one object at the moment

    // get a handle on the named object
    MSelectionList selList;
    selList.add(objName);
    MDagPath objDagPath;
    MStatus status = selList.getDagPath(0, objDagPath);
    if (!status) {
      MGlobal::displayError("Error retrieving object " + objName);
      return MS::kFailure;
    }

    // test that the output file is writable
    FILE *f = fopen(outputFilename.asChar(), "w");
    if (!f) {
      MGlobal::displayError("Error writing to output file " + outputFilename + ". Check file permissions there");
      return MS::kFailure;
    }
    fclose(f);

#if defined( PRMAN ) || defined( DELIGHT )
    // binary or ascii
    RtString format[1] = {"ascii"};
    if ( binaryRib ) format[0] = "binary";
    RiOption( "rib", "format", ( RtPointer )&format, RI_NULL);
#endif

    // write the RIB file
    RiBegin(const_cast<char*>(outputFilename.asChar()));

    writeObjectToRib(objDagPath, outputRootTransform);

    RiEnd();

  } catch (...) {
    MGlobal::displayError("Caught exception in liqWriteArchive::redoIt()");
    return MS::kFailure;
  }

  return MS::kSuccess;
}
Esempio n. 10
0
//--------------------------------------------------------
RtVoid RiBegin_liq(RtToken name)
{
	CM_TRACE_FUNC("RiBegin_liq("<<name<<"(strlen="<<strlen(name)<<")");
	std::string newname(name);

	if( strlen(name)>=_POSIX_PATH_MAX )//file name is too long
	{
		liquidMessage2( messageError, "file name is too long(>=%d(_POSIX_PATH_MAX)):%s", _POSIX_PATH_MAX, name );
		assert(0&&"FATAL ERROE: file name is too long!");
#ifdef _WIN32
		newname = "\\\\?\\";//see MAX_PATH: http://msdn.microsoft.com/en-us/library/aa365247.aspx#maxpath
		newname+= name;
#else
#error "If the file path name is too long, how to handle this case on linux?"
		exit(0);
#endif
	}
	
	RiBegin( const_cast<RtToken>(newname.c_str()) );
}
Esempio n. 11
0
void
lsh_exec(lsh_t *lsh)
{
#ifdef WITH_READLINE
	int ret;
	char *line, *s;
#endif

	RiBegin(RI_NULL);

#ifdef WITH_READLINE
	while (1) {
		printf("Example usage:\n");
		printf("lsh: file RIBFILE  -> specify RIB file to render\n");
		printf("lsh: render        -> start rendering\n");
		printf("\n");

		line = readline("lsh: ");

		if (!line) break;

		s = stripwhite(line);

		if (*s) {
			add_history(s);
			ret = exec_line(s);
			if (ret < 0) break;
		}

		free(line);
	}
#endif

	RiEnd();

	(void)lsh;		/* for gcc */
}
Esempio n. 12
0
int main(int argc, char *argv[]) {
    if (argc<2) {
        printf("No file names given.\n");
        printf("Use:\n\t%s audio_file output_prefix\n\n", argv[0]);
        exit(1);
    }
    av_register_all();

    audio_data_t snd_data;
    read_audio(argv[1], &snd_data);

    int per_frame = snd_data.sample_rate/30;

    int32_t maxVal = 0;
    switch (snd_data.sample_size) {
    case 1:
        maxVal = 1<<6;
        break;
    case 2:
        maxVal = 1<<12;
        break;
    default:
        maxVal = 1<<28;
    }
    const int N = 120;

    fftw_complex *fft_in  __attribute__ ((aligned (16)));
    fftw_complex **fft_out  __attribute__ ((aligned (16)));

    fftw_plan fft_plan  __attribute__ ((aligned (16)));

    fft_in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
    fft_out = (fftw_complex**) fftw_malloc(sizeof(fftw_complex*) * N);

    for (int i=0; i<N; ++i) {
        fft_out[i] = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
    }

    fft_plan = fftw_plan_dft_1d(N, fft_in, fft_out[0], FFTW_FORWARD, FFTW_ESTIMATE);

    size_t fnum, cur_out;

    for (size_t i=0; i<N; ++i) {
        fft_in[i] = 0.0;
        for (size_t j=0; j<N; ++j) {
            fft_out[i][j] = 0.0;
        }
    }
    show_audio_info(&snd_data);
    
    RiBegin(RI_NULL);
    
    size_t num_frames = (snd_data.num_samples-per_frame)/per_frame;
    for (size_t i = 0, cur_out = 0, fnum = 1; i<(snd_data.num_samples-per_frame); i+= per_frame, ++fnum) {

        size_t j_size = N/2;
        size_t stp = per_frame/(j_size);
        size_t ci = per_frame*15+i;
        for (size_t j=0; j< j_size;++j) {
            
            fft_in[j] = (double)get_sample(&snd_data, ci, 0)/(double)maxVal;
            ci += stp;
        }

        fftw_execute_dft(fft_plan, fft_in, fft_out[cur_out]);

        printf("Calling doFrame %lu of %lu\n", fnum, num_frames);

        doFrame(fnum,
                cur_out, N, fft_out,
                argv[2]);

        cur_out += 1;
        if (cur_out == N) {
            cur_out = 0;
        }
    }

    RiEnd();
    for (size_t i=0; i<N; ++i) {
        fftw_free(fft_out[i]);
    }
    fftw_destroy_plan(fft_plan);
    fftw_free(fft_out);
    fftw_free(fft_in);
    fftw_cleanup();
    free(snd_data.samples);

    return 0;
}
Esempio n. 13
0
int main( int argc, const char** argv )
{
	ArgParse ap;
	RtFilterFunc filterfunc;
	float bake;

	ap.usageHeader( ArgParse::apstring( "Usage: " ) + argv[ 0 ] + " [options] infile outfile" );
	ap.argFlag( "help", "\aPrint this help and exit", &g_help );
	ap.alias( "help" , "h" );
	ap.argFlag( "version", "\aPrint version information and exit", &g_version );
	ap.argInt( "verbose", "=integer\aSet log output level\n"
		"\a0 = errors\n"
		"\a1 = warnings (default)\n"
		"\a2 = information\n"
		"\a3 = debug", &g_cl_verbose );
	ap.alias( "verbose" , "v" );
	ap.argString( "compression", "=string\a[none|lzw|packbits|deflate] (default: %default)", &g_compress );
	ap.argFlag( "envcube", " px nx py ny pz nz\aproduce a cubeface environment map from 6 images.", &g_envcube );
	ap.argFlag( "envlatl", "\aproduce a latlong environment map from an image file.", &g_envlatl );
	ap.argFlag( "shadow", "\aproduce a shadow map from a z file.", &g_shadow );
	ap.argString( "swrap", "=string\as wrap [black|periodic|clamp] (default: %default)", &g_swrap );
	ap.argString( "smode", "=string\a(equivalent to swrap for BMRT compatibility)", &g_swrap );
	ap.argString( "twrap", "=string\at wrap [black|periodic|clamp] (default: %default)", &g_twrap );
	ap.argString( "tmode", "=string\a(equivalent to twrap for BMRT compatibility)", &g_swrap );
	ap.argString( "wrap", "=string\awrap s&t [black|periodic|clamp]", &g_wrap );
	ap.argString( "mode", "=string\as (equivalent to wrap for BMRT compatibility)", &g_wrap );
	ap.argString( "filter", "=string\a[box|bessel|catmull-rom|disk|gaussian|sinc|triangle|mitchell] (default: %default)", &g_filter );
	ap.argFloat( "fov(envcube)", "=float\a[>=0.0f] (default: %default)", &g_fov );
	ap.argFloat( "swidth", "=float\as width [>0.0f] (default: %default)", &g_swidth );
	ap.alias( "swidth", "sfilterwidth" );
	ap.argFloat( "twidth", "=float\at width [>0.0f] (default: %default)", &g_twidth );
	ap.alias( "twidth", "tfilterwidth" );
	ap.argFloat( "width", "=float\awidth [>0.0f] set both swidth and twidth (default: %default)", &g_width );
	ap.alias( "width", "filterwidth" );
	ap.argFloat( "quality", "=float\a[>=1.0f && <= 100.0f] (default: %default)", &g_quality );
	ap.argFloat( "bake", "=float\a[>=2.0f && <= 2048.0f] (default: %default)", &g_bake );
	ap.argString( "resize", "=string\a[up|down|round|up-|down-|round-] (default: %default)\n\aNot used, for BMRT compatibility only!", &g_resize );


	if ( argc > 1 && !ap.parse( argc - 1, argv + 1 ) )
	{
		Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg();
		exit( 1 );
	}

	if ( g_version )
	{
		version( std::cout );
		exit( 0 );
	}

	if ( g_help || ap.leftovers().size() <= 1 )
	{
		std::cout << ap.usagemsg();
		exit( 0 );
	}

	if ( g_envcube && g_shadow )
	{
		std::cout << "Specify only one of envcube or shadow" << std::endl;
		exit( 1 );
	}


	/* find the pixel's filter function */
	filterfunc = RiBoxFilter;
	if ( g_filter == "box" )
		filterfunc = RiBoxFilter;
	else if ( g_filter == "mitchell" )
		filterfunc = RiMitchellFilter;
	else if ( g_filter == "sinc" )
		filterfunc = RiSincFilter;
	else if ( g_filter == "catmull-rom" )
		filterfunc = RiCatmullRomFilter;
	else if ( g_filter == "disk" )
		filterfunc = RiDiskFilter;
	else if ( g_filter == "bessel" )
		filterfunc = RiBesselFilter;
	else if ( g_filter == "triangle" )
		filterfunc = RiTriangleFilter;
	else if ( g_filter == "gaussian" )
		filterfunc = RiGaussianFilter;



	/* protect the s,t width */
	if ( g_swidth < 1.0 )
	{
		Aqsis::log() << "g_swidth is smaller than 1.0." << " 1.0 will be used instead." << std::endl;
		g_swidth = 1.0;
	}
	if ( g_twidth < 1.0 )
	{
		Aqsis::log() << "g_twidth is smaller than 1.0." << " 1.0 will be used instead." << std::endl;
		g_twidth = 1.0;
	}

	/* protect the s,t wrap mode */
	if ( !( ( g_swrap == "black" ) || ( g_swrap == "periodic" ) || ( g_swrap == "clamp" ) ) )
	{
		Aqsis::log() << "Unknown s wrap mode: " << g_swrap << ". black will be used instead." << std::endl;
		g_swrap = "black";
	}
	if ( !( ( g_twrap == "black" ) || ( g_twrap == "periodic" ) || ( g_twrap == "clamp" ) ) )
	{
		Aqsis::log() << "Unknown t wrap mode: " << g_twrap << ". black will be used instead." << std::endl;
		g_twrap = "black";
	}
	if ( !( ( g_wrap == "" ) || ( g_wrap == "black" ) || ( g_wrap == "periodic" ) || ( g_wrap == "clamp" ) ) )
	{
		Aqsis::log() << "Unknown wrap mode: " << g_wrap << ". black will be used instead." << std::endl;
		g_wrap = "black";
	}

	/* If wrap is specified, it overrides both s and t */
	if( g_wrap != "" )
	{
		g_twrap = g_wrap;
		g_swrap = g_wrap;
	}

	/* Need to set both st width ? */
	if ( g_width > 0.0 )
	{
		g_twidth = g_swidth = g_width;
	}

	/* protect the compression mode */
	if ( !( ( g_compress == "deflate" ) ||
	        ( g_compress == "lzw" ) ||
	        ( g_compress == "none" ) ||
	        ( g_compress == "packbits" )
	      )
	   )
	{
		Aqsis::log() << "Unknown compression mode: " << g_compress << ". none." << std::endl;
		g_compress = "none";
	}

	/* protect the quality mode */
	if ( g_quality < 1.0f )
		g_quality = 1.0;
	if ( g_quality > 100.0f )
		g_quality = 100.0;

	/* protect the bake mode */
	if ( g_bake < 2.0f )
		g_bake = 2.0;
	if ( g_bake > 2048.0f )
		g_bake = 2048.0;

	char *compression = ( char * ) g_compress.c_str();
	float quality = ( float ) g_quality;


	std::auto_ptr<std::streambuf> show_level( new Aqsis::show_level_buf(Aqsis::log()) );
	Aqsis::log_level_t level = Aqsis::ERROR;
	if( g_cl_verbose > 0 )
		level = Aqsis::WARNING;
	if( g_cl_verbose > 1 )
		level = Aqsis::INFO;
	if( g_cl_verbose > 2 )
		level = Aqsis::DEBUG;
	std::auto_ptr<std::streambuf> filter_level( new Aqsis::filter_by_level_buf(level, Aqsis::log()) );

	RiBegin(RI_NULL);

	if ( g_envcube )
	{
		if ( ap.leftovers().size() != 7 )
		{
			Aqsis::log() << "Need 6 images for cubic environment map" << std::endl;
			return ( -1 );
		}

		printf( "CubeFace Environment %s %s %s %s %s %s ----> %s \n\t\"fov\"= %4.1f\n\t\"filter\"= %s \n\t\"swidth\"= %4.1f\n\t\"twidth\"= %4.1f\n\t\"compression\" = %s\n",
		        const_cast<char*>(ap.leftovers() [ 0 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 1 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 2 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 3 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 4 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 5 ].c_str()),
		        const_cast<char*>(ap.leftovers() [ 6 ].c_str()),
		        g_fov,
		        g_filter.c_str(),
		        g_swidth,
		        g_twidth,
		        ( char* ) g_compress.c_str()
		      );

		RiMakeCubeFaceEnvironment(
		    const_cast<char*>(ap.leftovers() [ 0 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 1 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 2 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 3 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 4 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 5 ].c_str()),
		    const_cast<char*>(ap.leftovers() [ 6 ].c_str()),
		    g_fov,
		    filterfunc,
		    ( float ) g_swidth,
		    ( float ) g_twidth,
		    "compression",
		    &compression,
		    "quality",
		    &quality,
		    RI_NULL );
	}
	else if ( g_shadow )
	{
		printf( "Shadow %s ----> %s \n\t\"compression\" = %s\n",
		        ( char* ) ap.leftovers() [ 0 ].c_str(),
		        ( char* ) ap.leftovers() [ 1 ].c_str(),
		        ( char* ) g_compress.c_str() );



		RiMakeShadow( ( char* ) ap.leftovers() [ 0 ].c_str(), ( char* ) ap.leftovers() [ 1 ].c_str(), ( float ) g_twidth, "compression", &compression, "quality", &quality, RI_NULL );
	}
	else if ( g_envlatl )
	{
		printf( "LatLong Environment %s ----> %s \n\t\"compression\" = %s \n",
		        ( char* ) ap.leftovers() [ 0 ].c_str(),
		        ( char* ) ap.leftovers() [ 1 ].c_str(),
		        ( char* ) g_compress.c_str() );

		RiMakeLatLongEnvironment( ( char* ) ap.leftovers() [ 0 ].c_str(), ( char* ) ap.leftovers() [ 1 ].c_str(), filterfunc,
		                          ( float ) g_swidth, ( float ) g_twidth, "compression", &compression, "quality", &quality, RI_NULL );
	}
	else
	{
		printf( "Texture %s ----> %s \n\t\"swrap\"= %s \n\t\"twrap\"= %s \n\t\"filter\"= %s \n\t\"swidth\"= %4.1f\n\t\"twidth\"= %4.1f\n\t\"compression\" = %s\n",
		        ( char* ) ap.leftovers() [ 0 ].c_str(),
		        ( char* ) ap.leftovers() [ 1 ].c_str(),
		        ( char* ) g_swrap.c_str(),
		        ( char* ) g_twrap.c_str(),
		        ( char* ) g_filter.c_str(),
		        g_swidth,
		        g_twidth,
		        compression
		      );

 		bake = g_bake;

		RiMakeTexture( ( char* ) ap.leftovers() [ 0 ].c_str(), ( char* ) ap.leftovers() [ 1 ].c_str(),
		               ( char* ) g_swrap.c_str(), ( char* ) g_twrap.c_str(), filterfunc,
		               ( float ) g_swidth, ( float ) g_twidth, "compression", &compression, "quality", &quality, "float bake", &bake, RI_NULL );
	}

	RiEnd();

	return ( 0 );
}
Esempio n. 14
0
int main( int argc, const char** argv )
{
	std::signal(SIGINT, aqsisSignalHandler);
	std::signal(SIGABRT, aqsisSignalHandler);
	RtInt returnCode = 0;

	StartMemoryDebugging();
	{
		ArgParse ap;
		ap.usageHeader( ArgParse::apstring( "Aqsis command line renderer\nUsage: " ) + argv[ 0 ] + " [options] [RIB file...]" );
		ap.argFlag( "help", "\aPrint this help and exit", &g_cl_help );
		ap.alias( "help" , "h" );
		ap.argFlag( "version", "\aPrint version information and exit", &g_cl_version );
		ap.argFlag( "pause", "\aWait for a keypress on completion", &g_cl_pause );
		ap.argFlag( "progress", "\aPrint progress information", &g_cl_progress );
		ap.argFlag( "Progress", "\aPrint PRMan-compatible progress information (ignores -progressformat)", &g_cl_Progress );
		ap.argString( "progressformat", "=string\aprintf-style format string for -progress", &g_cl_strprogress );
		ap.argInt( "endofframe", "=integer\aEquivalent to \"endofframe\" RIB option", &g_cl_endofframe );
		ap.argInt( "verbose", "=integer\aSet log output level\n"
		           "\a0 = errors\n"
		           "\a1 = warnings (default)\n"
		           "\a2 = information\n"
		           "\a3 = debug", &g_cl_verbose );
		ap.alias( "verbose", "v" );
		ap.argFlag( "echoapi", "\aEcho all RI API calls to the log output (experimental)", &g_cl_echoapi);

		ap.argInt( "priority", "=integer\aControl the priority class of aqsis.\n"
			"\a0 = idle\n"
			"\a1 = normal\n"
			"\a2 = high\n"
			"\a3 = RT", &g_cl_priority);
		ap.alias( "priority", "z");
		
		ap.argString( "type", "=string\aSpecify a display device type to use", &g_cl_type );
		ap.argString( "addtype", "=string\aSpecify a display device type to add", &g_cl_addtype );
		ap.argString( "mode", "=string\aSpecify a display device mode to use", &g_cl_mode );
		ap.argFlag( "fb", "\aSame as --type=\"framebuffer\" --mode=\"rgb\"", &g_cl_fb );
		ap.alias( "fb", "d" );
		ap.argFloats( "crop", " x1 x2 y1 y2\aSpecify a crop window, values are in screen space.", &g_cl_cropWindow, ArgParse::SEP_ARGV, 4);
		ap.argFlag( "nocolor", "\aDisable colored output", &g_cl_no_color );
		ap.argFlag( "beep", "\aBeep on completion of all ribs", &g_cl_beep );
		ap.alias( "nocolor", "nc" );
		ap.argInts( "res", " x y\aSpecify the resolution of the render.", &g_cl_res, ArgParse::SEP_ARGV, 2);
		ap.argStrings( "option", "=string\aA valid RIB Option string, can be specified multiple times.", &g_cl_options);
#		ifdef AQSIS_SYSTEM_POSIX
		ap.argFlag( "syslog", "\aLog messages to syslog", &g_cl_syslog );
#		endif // AQSIS_SYSTEM_POSIX
#		if ENABLE_MPDUMP
		ap.argFlag( "mpdump", "\aOutput MP list to a custom 'dump' file", &g_cl_mpdump );
#		endif // ENABLE_MPDUMP

		ap.argString( "shaders", "=string\aOverride the default shader searchpath(s)", &g_cl_shader_path );
		ap.argString( "archives", "=string\aOverride the default archive searchpath(s)", &g_cl_archive_path );
		ap.argString( "textures", "=string\aOverride the default texture searchpath(s)", &g_cl_texture_path );
		ap.argString( "displays", "=string\aOverride the default display searchpath(s)", &g_cl_display_path );
		ap.argString( "procedurals", "=string\aOverride the default procedural searchpath(s)", &g_cl_procedural_path );
		ap.allowUnrecognizedOptions();

		if ( argc > 1 && !ap.parse( argc - 1, argv + 1 ) )
		{
			Aqsis::log() << ap.errmsg() << std::endl << ap.usagemsg();
			return( 1 );
		}

		// Check that the number of arguments to crop are valid if specified.
		if ( g_cl_cropWindow.size() > 0 && g_cl_cropWindow.size() != 4 )
		{
			Aqsis::log() << Aqsis::error << "Invalid number of arguments to -crop, expected 4, got " << g_cl_cropWindow.size() << std::endl;
			g_cl_help = true;
		}

		if ( g_cl_help )
		{
			std::cout << ap.usagemsg();
			return( 0 );
		}

		if ( g_cl_version )
		{
			std::cout << "aqsis version " << AQSIS_VERSION_STR_FULL
#			ifdef _DEBUG
			<< " (debug build)"
#			endif
			<< "\n"
			<< "compiled " << __DATE__ << " " << __TIME__ << "\n";
			return( 0 );
		}

#		ifdef	AQSIS_SYSTEM_WIN32
		std::auto_ptr<std::streambuf> ansi( new Aqsis::ansi_buf(Aqsis::log()) );
#		endif

		std::auto_ptr<std::streambuf> reset_level( new Aqsis::reset_level_buf(Aqsis::log()) );
		std::auto_ptr<std::streambuf> show_timestamps( new Aqsis::timestamp_buf(Aqsis::log()) );
		std::auto_ptr<std::streambuf> fold_duplicates( new Aqsis::fold_duplicates_buf(Aqsis::log()) );
		std::auto_ptr<std::streambuf> color_level;
		if(!g_cl_no_color)
		{
			std::auto_ptr<std::streambuf> temp_color_level( new Aqsis::color_level_buf(Aqsis::log()) );
			color_level = temp_color_level;
		}
		std::auto_ptr<std::streambuf> show_level( new Aqsis::show_level_buf(Aqsis::log()) );
		Aqsis::log_level_t level = Aqsis::ERROR;
		if( g_cl_verbose > 0 )
			level = Aqsis::WARNING;
		if( g_cl_verbose > 1 )
			level = Aqsis::INFO;
		if( g_cl_verbose > 2 )
			level = Aqsis::DEBUG;
		std::auto_ptr<std::streambuf> filter_level( new Aqsis::filter_by_level_buf(level, Aqsis::log()) );
#		ifdef AQSIS_SYSTEM_POSIX
		if( g_cl_syslog )
			std::auto_ptr<std::streambuf> use_syslog( new Aqsis::syslog_buf(Aqsis::log()) );
#		endif // AQSIS_SYSTEM_POSIX

		if (g_cl_priority != 1)
		{
			// Set the priority on the main thread
			setPriority(g_cl_priority);
		}

		RiBegin(RI_NULL);
		setupOptions();
		try
		{
			if ( ap.leftovers().size() == 0 )
			{
				// If no files specified, take input from stdin.
				//
				// TODO: We'd like to turn off stdio synchronisation to allow fast
				// buffering... unfortunately this causes very odd problems with
				// the aqsis logging facility as of svn r2804
				//
				//std::ios_base::sync_with_stdio(false);
				Aqsis::QGetRenderContextI()->parseRibStream(std::cin, "stdin");
			}
			else
			{
				for(ArgParse::apstringvec::const_iterator fileName = ap.leftovers().begin();
						fileName != ap.leftovers().end(); fileName++)
				{
					std::ifstream inFile(fileName->c_str());
					if(inFile)
					{
						Aqsis::QGetRenderContextI()->parseRibStream(inFile, *fileName);
						returnCode = RiLastError;
					}
					else
					{
						Aqsis::log() << Aqsis::error
							<< "Cannot open file \"" << *fileName << "\"\n";
						returnCode = RIE_NOFILE;
					}
				}
			}
		}
		catch(const std::exception& e)
		{
			Aqsis::log() << Aqsis::error << e.what() << std::endl;
			returnCode = RIE_BUG;
		}
		catch(...)
		{
			Aqsis::log() << Aqsis::error
				<< "unknown exception has been encountered\n";
			returnCode = RIE_BUG;
		}
		RiEnd();
	}

	StopMemoryDebugging();

	if(g_cl_beep)
		std::cout << "\a" << std::ends;

	if(g_cl_pause)
	{
		std::cout << "Press any key..." << std::ends;
		std::cin.ignore(std::cin.rdbuf()->in_avail() + 1);
	}

	return returnCode;
}
Esempio n. 15
0
int main(int argc, char *argv[]) {
    if (argc < 2) {
        printf("Not enough arguments given!\n");
        return 1;
    } else if (argc > 2) {
        printf("Too many arguments given!\n");
        return 1;
    }
    char *fprefix = argv[1];
    srand(time(NULL));
    const size_t NUM_FRAMES = 120;
    RtInt md = 4;
    scene_info_t scene;
    double rad = 55.0;
    double t = 0.0;
    const double tmin = 0.0;
    const double tmax = 2.0*PI;
    double dt = (tmax-tmin)/NUM_FRAMES;
    size_t fnum;

    RiBegin(RI_NULL);
    RiOption("trace", "maxdepth", &md, RI_NULL);
    RiSides(1);

    scene.cam.location[0] = rad;
    scene.cam.location[1] = rad;
    scene.cam.location[2] = rad;

    scene.cam.look_at[0]= 0.0;
    scene.cam.look_at[1]= 0.0;
    scene.cam.look_at[2]= 0.0;
    scene.cam.roll = 0.0;

    scene.fprefix = fprefix;

    
    const size_t NUM_POINTS = 100000000;

    RtPoint *pts = malloc(sizeof(RtPoint)* NUM_POINTS);
    randomPoint2D(pts[0]);
    /* pts[0][2] = 0.0; */

    /* RtFloat mats[][3][3] = {{{0.0,0.0,0.0}, */
    /*                          {0.0,0.16,0.0}, */
    /*                          {0.0,0.0,1.0}}, */
    /*                         {{0.85, 0.04, 0.0}, */
    /*                          {-0.04, 0.85, 0.0}, */
    /*                          {0.0,0.0,1.0}}, */
    /*                         {{0.20,-0.26, 0.0}, */
    /*                          {0.23, 0.22, 0.0}, */
    /*                          {0.0,0.0,1.0}}, */
    /*                         {{-0.15, 0.28,0.0}, */
    /*                          {0.26, 0.24, 0.0}, */
    /*                          {0.0,0.0,1.0}}, */
    /* }; */
    RtFloat mats[][3][3] = {{{0.34,0.0,0.0},
                             {0.0,0.34,0.0},
                             {0.0,0.0,0.34}},
                            {{0.34,0.0,0.0},
                             {0.0,0.34,0.0},
                             {0.0,0.0,0.34}},
                            {{0.34,0.0,0.0},
                             {0.0,0.34,0.0},
                             {0.0,0.0,0.34}},
                            {{0.34,0.0,0.0},
                             {0.0,0.34,0.0},
                             {0.0,0.0,0.34}},
                            {{0.34,0.0,0.0},
                             {0.0,0.34,0.0},
                             {0.0,0.0,0.34}},
                            {{0.34,0.0,0.0},
                             {0.0,0.34,0.0},
                             {0.0,0.0,0.34}},
                            {{0.34,0.0,0.0},
                             {0.0,0.34,0.0},
                             {0.0,0.0,0.34}},
    };

    RtPoint offsets[] = {{0.0,0.0,0.66},
                         {0.0,0.0,-0.66},
                         {0.0,0.0,0.0},
                         {0.66,0.0,0.0},
                         {-0.66,0.0,0.0},
                         {0.0,0.66, 0.0},
                         {0.0,-0.66, 0.0},
    };
    RtFloat probs[] = {0.14285714285714285,
                       0.14285714285714285,
                       0.14285714285714285,
                       0.14285714285714285,
                       0.14285714285714285,
                       0.14285714285714285,
                       0.14285714285714285,
    };
    for (size_t i=0; i<NUM_POINTS-1; ++i) {
        ifs(7, mats, offsets, probs, pts[i], pts[i+1]);
    }

    for (fnum = 0; fnum < NUM_FRAMES; ++fnum) {
        scene.cam.location[0] = rad*sin(t);
        scene.cam.location[1] = rad;
        scene.cam.location[2] = rad*cos(t);
        /* scene.cam.look_at[1] = rad; */
        t += dt;
        printf("Rendering frame %lu\n", (unsigned long)fnum);
        RtInt on = 1;
        char buffer[256];
        RtString on_string = "on";
        RtInt samples = 2;
        RtPoint light1Pos = {80,80,80};
        RtPoint light2Pos = {0,120,0};
        RtPoint light3Pos = {0,40,0};

        /* RiImager("background", RI_NULL); */

        RiFrameBegin(fnum);

        
        sprintf(buffer, "images/%s%05lu.jpg", scene.fprefix, (unsigned long)fnum);
        RiDisplay(buffer,(char*)"jpeg",(char*)"rgb",RI_NULL);
  
        RiFormat(1280, 720, 1.0);

        RiProjection((char*)"perspective",RI_NULL);

        PlaceCamera(&scene.cam);
        RiShadingRate(1.0);
        RiShadingInterpolation("smooth");
        /* RtFloat bound = 0.125; */
        /* char *space = "object"; */
        /* RiAttribute ("displacementbound", "sphere", (RtPointer)&bound, "space", (RtPointer)&space, RI_NULL); */
        /* RiAttribute("visibility", "int trace", &on, RI_NULL); */
        /* RiAttribute( "visibility", */
        /*              "int camera", (RtPointer)&on, */
        /*              "int transmission", (RtPointer)&on, */
        /*              "int diffuse", (RtPointer)&on, */
        /*              "int specular", (RtPointer)&on, */
        /*              "int photon", (RtPointer)&on, */
        /*              RI_NULL ); */
        /* RiAttribute( "light", (RtToken)"shadows", (RtPointer)&on_string, (RtToken)"samples", (RtPointer)&samples, RI_NULL ); */

        RiAttribute((RtToken)"light", "string shadow", (RtPointer)&on_string, RI_NULL);
        RiLightSource("distantlight", "point from", (RtPointer)light1Pos, RI_NULL);
        RiLightSource("distantlight", "point from", (RtPointer)light2Pos, RI_NULL);
        /* RiLightSource("pointlight", "point from", (RtPointer)light3Pos, RI_NULL); */
        RiWorldBegin();

        
        RiAttributeBegin();
        /* RtColor col = {((double)fnum)/NUM_FRAMES,1.0-((double)fnum)/NUM_FRAMES,0.0}; */
        RtColor col = {0.0,1.0,0.0};
        RiSurface((char*)"matte", RI_NULL);
        /* RtColor opa = {0.8,0.8,0.8}; */
        /* RiOpacity(opa); */
        /* RtFloat km = 0.125; */
        /* RiDisplacement((char*)"stucco", (RtToken)"Km", (RtPointer)&km, RI_NULL); */
        RiColor(col);
        /* RtColor opa = {0.75,0.75,0.75}; */
        /* RiOpacity(opa); */

        RiScale(50.0,50.0,50.0);
        RtFloat cw = 0.0005;
        RiPoints(NUM_POINTS, "type", "particles", "constantwidth", &cw, RI_P, pts, RI_NULL);
        /* RiSphere(0.2,-0.2,0.2,360.0, RI_NULL); */
        RiAttributeEnd();

        RiWorldEnd();
        RiFrameEnd();

    }
    RiEnd();

    return 0;
}
Esempio n. 16
0
MStatus ribGenCmd::doIt( const MArgList& args)
{
	/*=========================================*
	  *		the parameters of command															
	  *	=========================================*/
	MString ribPath, shaderPath;					
	unsigned index;
	index = args.flagIndex("p", "ribPath");

	if(MArgList::kInvalidArgIndex != index)
		args.get(index+1, ribPath);
	
	index = args.flagIndex("sp", "shaderPath");
	if(MArgList::kInvalidArgIndex != index)
		args.get(index+1, shaderPath);

	/*=========================================*
	  *		shaderPath & ribPath																		
	  *=========================================*/
	RtToken shader= new char[50] , path=new char[50];
	strcpy(shader, shaderPath.asChar());
	strcpy(path, ribPath.asChar());

	char *curve[] = {"curves"};	

	RtMatrix identityMatrix =
	{	{ 1, 0, 0, 0 },
		{ 0, 1, 0, 0 },
		{ 0, 0, 1, 0 },
		{ 0, 0, 0, 1 }}; 
	
	RtInt ustep, vstep;
	ustep = vstep =1;

  /*=====================================*
	*		Begenning of writting out the .rib file.														
	*=====================================*/	
	RiBegin(path);
		RiAttributeBegin();
			RiTransformBegin();
				//RiSurface(shader);
			RiTransformEnd();


			//RiAttribute("identifier", "name", curve);
			RiConcatTransform(identityMatrix);
			RiShadingInterpolation(RI_SMOOTH);
			RiBasis(RiBezierBasis, ustep, RiBezierBasis, vstep);			



	int nodeId	= 0, knotNum = 0;
	float baseWidth = 0.0f, tipWidth	= 0.0f;
	MObject surface, node;
	/*=========================================*
	  *		get the informations of selected Objects in scene.																		
	  *=========================================*/	
	MSelectionList selection;
	MGlobal::getActiveSelectionList(selection);
	MItSelectionList iter(selection, MFn::kNurbsSurface );

	for(; !iter.isDone(); iter.next())
	{
		RtInt numCurves = 0;
		RtInt numVertexs = 0;

		/*======================================*
		  *		get the drawHairNode from selected NurbsSurface. 
		  *======================================*/
		iter.getDependNode(surface);
		MFnDependencyNode surfaceFn(surface);
		MStatus state;
		MPlug plug = surfaceFn.findPlug("worldSpace",false, &state);

		plug = plug.elementByLogicalIndex(0);
		MPlugArray desPlugs;
		plug.connectedTo(desPlugs,false,true);
		plug = desPlugs[0];
		node = plug.node();				//drawHairNode has found here!!

		/*=====================================*
		  *		get the attributes of drawHairNode. 
		  *=====================================*/
		MFnDependencyNode hairNodeFn(node);
		plug = hairNodeFn.findPlug("nodeId");
		plug.getValue(nodeId);
		MGlobal::displayInfo(MString(" nodeId: ")+nodeId);

		plug = hairNodeFn.findPlug("number");
		plug.getValue(numCurves);

		plug= hairNodeFn.findPlug("smooth");
		plug.getValue(knotNum);

		plug = hairNodeFn.findPlug("baseWidth");
		plug.getValue(baseWidth);

		plug = hairNodeFn.findPlug("tipWidth");
		plug.getValue(tipWidth);

		/*=====================================*
		  *		caculate the linear interpolate of the width of the curve.
		  *=====================================*/
		numVertexs = numCurves * knotNum;
		int widthNum = numCurves * (knotNum -2 );
		float *curveWidth = new float[widthNum];
		
		float widthStep = 0.0f;
		for(int c=0; c<widthNum; ++c){
			widthStep = ((c%(knotNum-2)) / (float)(knotNum-3)) *(tipWidth - baseWidth);
			if(widthStep < epslion)
				widthStep = 0.0f;
			curveWidth[c] = baseWidth + widthStep;
		}
		

		RtInt *nvertices = new RtInt[numCurves];						//the numbers of vertices on each curve.
		RtPoint *vertexs = new RtPoint[numVertexs];				//the total vertexs.

		/*=====================================*
		  *		nvertices[] assignment.														
		  *=====================================*/
		for(int j=0; j<numCurves ; ++j){
			nvertices[j] = knotNum;
		}



		/*=====================================*
		  *		get the hair's datas from the static member 
		  *		named "nodeManager" of the drawHairNode class. 
		  *=====================================*/
		nodeMap::iterator  iter =  drawHairNode::nodeManager.find(nodeId);
		vector<MPointArray> helixVec = iter->second;
		

		/*=====================================*
		  *		vertexs[] assignment.														
		  *=====================================*/	
		float x=0, y=0, z=0;
		int countVT=0;
		for(vector<MPointArray>::iterator it=helixVec.begin();  it != helixVec.end();  ++it){
			MPointArray helixCurve = (MPointArray)(*it);

			for(int k=0; k <  helixCurve.length() ; ++k){
				x = helixCurve[k].x;
				if(fabs(x) < epslion)
					vertexs[countVT][0] = 0;
				else
					vertexs[countVT][0] = helixCurve[k].x;
			
				y = helixCurve[k].y;
				if(fabs(y) < epslion)
					vertexs[countVT][1] = 0;
				else
					vertexs[countVT][1] = helixCurve[k].y;
			
				z = helixCurve[k].z;			
				if(fabs(z) < epslion)
					vertexs[countVT++][2] = 0;
				else
					vertexs[countVT++][2] = helixCurve[k].z;
			}
		}
		RiCurves( RI_CUBIC, numCurves, nvertices, RI_NONPERIODIC, RI_P, vertexs, RI_WIDTH, curveWidth, RI_NULL);
	}
	


		RiAttributeEnd();
	RiEnd();

	return redoIt();
}
Esempio n. 17
0
int main(int argc, const char *argv[])
{
	RtPoint points[] = { { 0, 0, 0}, {-.5, .5, 0}, {.5, .5, 0} };
	RtPoint points2[] = { { 0, 0, 0}, { 0, 1.0F, 0}, {1.33333F, -1.0F, 0}, {-1.33333F, -1.0F, 0} };
	RtFloat color[]  = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
	RtFloat Cs1[] = {1, 1, 1};
	RtFloat Cs2[] = {1, 1, 0};
	RtFloat Cs3[] = {1, 0, 0};
	RtBound bound = { -.5F, 0, 0, .5F, .5F, 0 };
	RtInt renderer = 0;
	RtString myVal[2] = {"MyVal0", "MyVal1"};
	
	RiOption("MyOption", "string MyVar", &myVal[0], RI_NULL);
	RiCPPControl("MyControl", "string MyVar2", &myVal[1], RI_NULL);

	switch(renderer) {
		case 1:
			RiBegin("|aqsis -progress");
			break;
		case 2:
			RiBegin("|rndr -p");
			break;
		default:
			RiBegin(RI_NULL);
	}
		/* RiMakeTexture("mytexture.tiff", "mytexture.tx", RI_PERIODIC, RI_PERIODIC, RiSincFilter, (RtFloat)3.0, (RtFloat)3.0, RI_NULL); */

		/* Using gcc-4.0.1 I got a warning for Ri-functions that float is used instead of double due to prototype,
		 * even if I pass explictely float. Due to a message in fr.comp.lang.c "Complexe avex fonction réelle" Jan 23, 2008
		 * this warning (gcc-4.2.3) is not issued in gcc-4.3.0 anymore, so I disabled the "Prototype conversion" option temporarily.
		 */
		RiPixelFilter(RiGaussianFilter, 3.0f, 3.0f),
		RiShutter(0.0F, 1.0F);
		RiClipping(0.5F, 20.0F);
		RiProjection(RI_PERSPECTIVE, RI_NULL);
		RiFrameBegin(1);
			RiDisplay("Polygon", RI_FRAMEBUFFER, RI_RGB, RI_NULL);
			RiTranslate(0.0F, 0.0F, 4.5F);
			RiLightSource("pointlight", RI_NULL);
			RiTranslate(0.0F, 0.0F, .5F);
			RiWorldBegin();
				RiOrientation(RI_LH);
				RiSides(1);
				RiSurface("matte", RI_NULL);
				RiMotionBegin(3, 0.0F, 0.5F, 1.0F);
					RiColor(Cs1);
					RiColor(Cs2);
					RiColor(Cs3);
				RiMotionEnd();
				RiMotionBegin(3, 0.0F, 0.5F, 1.0F);
					RiRotate(10.0F, 0.0F, 0.0F, 1.0F);
					RiRotate(20.0F, 0.0F, 0.0F, 1.0F);
					RiRotate(30.0F, 0.0F, 0.0F, 1.0F);
				RiMotionEnd();
				RiDetail(bound);
				RiDetailRange(0.0F, 0.0F, 100.0F, 150.0F);
				RiPolygon(3, RI_P, points, RI_NULL);
				RiDetailRange(100.0F, 150.0F, RI_INFINITY, RI_INFINITY);
				RiPolygon(3, RI_P, points, RI_CS, color, RI_NULL);
				RiTransformPoints(RI_SCREEN, RI_RASTER, sizeof(points2)/sizeof(RtPoint), points2);
			RiWorldEnd();
		RiFrameEnd();
	RiEnd();
	exit(0);
	
	return 0;
}
Esempio n. 18
0
int main(int argc, char* argv[]) {
	int				tileSize		=	32;
	const char		*resizeMode		=	"up";
	const char		*smode			=	"periodic";
	const char		*tmode			=	"periodic";
	float			filterWidth		=	3;
	float			filterHeight	=	3;
	const char		*inPath			=	".";
	const char		*outPath		=	".";
	float			fov				=	90;
	RtFilterFunc	filter			=	RiCatmullRomFilter;
	float			maxerror		=	0.002f;
	float			radiusScale		=	1.0f;
	int				maxDepth		=	10;
	int				i;
	const char		*textureMode	=	"texture";
	int				processed;

	RtToken			tokens[50];
	RtPointer		vals[50];
	const char		*files[50];
	int				currentFile			=	0;
	int				currentParameter	=	0;

	if (argc == 1) {
		printUsage();
		return 0;
	}

	for (i=1;i<argc;i++) {
		if (strcmp(argv[i],"--help") == 0) {
			printUsage();
		} else if (strcmp(argv[i],shadowArgument) == 0) {
			textureMode	=	"shadow";
		} else if (strcmp(argv[i],envlatArgument) == 0) {
			textureMode	=	"envlat";
		} else if (strcmp(argv[i],envcubeArgument) == 0) {
			textureMode	=	"envcube";
		} else if (strcmp(argv[i],texture3dArgument) == 0) {
			textureMode	=	"texture3d";
		} else if (strcmp(argv[i],tileSizeArgument) == 0) {
			i++;
			tileSize	=	atoi(argv[i]);
		} else if (strcmp(argv[i],resizeModeArgument) == 0) {
			i++;
			resizeMode	=	argv[i];
		} else if (strcmp(argv[i],smodeArgument) == 0) {
			i++;
			smode		=	argv[i];
		} else if (strcmp(argv[i],tmodeArgument) == 0) {
			i++;
			tmode		=	argv[i];
		} else if (strcmp(argv[i],filterArgument) == 0) {
			i++;
			if (strcmp(argv[i],"box") == 0) {
				filter	=	RiBoxFilter;
			} else if (strcmp(argv[i],"triangle") == 0) {
				filter	=	RiTriangleFilter;
			} else if (strcmp(argv[i],"gaussian") == 0) {
				filter	=	RiGaussianFilter;
			} else if (strcmp(argv[i],"catmull-rom") == 0) {
				filter	=	RiCatmullRomFilter;
			} else if (strcmp(argv[i],"sinc") == 0) {
				filter	=	RiSincFilter;
			} else {
				fprintf(stderr,"Unknown filter: %s\n",argv[i]);
			}
		} else if (strcmp(argv[i],filterWidthArgument) == 0) {
			i++;
			filterWidth		=	(float) atof(argv[i]);
			filterHeight	=	(float) atof(argv[i]);
		} else if (strcmp(argv[i],sfilterWidthArgument) == 0) {
			i++;
			filterWidth	=	(float) atof(argv[i]);
		} else if (strcmp(argv[i],tfilterWidthArgument) == 0) {
			i++;
			filterHeight	=	(float) atof(argv[i]);
		} else if (strcmp(argv[i],fovArgument) == 0) {
			i++;
			fov	=	(float) atof(argv[i]);
		} else if (strcmp(argv[i],maxerrorArgument) == 0) {
			i++;
			maxerror		=	(float) atof(argv[i]);
		} else if (strcmp(argv[i],radiusscaleArgument) == 0) {
			i++;
			radiusScale		=	(float) atof(argv[i]);
		} else if (strcmp(argv[i],maxdepthArgument) == 0) {
			i++;
			maxDepth		=	(int) atoi(argv[i]);
		} else if (strcmp(argv[i],inputPathArgument) == 0) {
			i++;
			inPath		=	argv[i];
		} else if (strcmp(argv[i],outputPathArgument) == 0) {
			i++;
			outPath		=	argv[i];
		} else {
			files[currentFile++]	=	argv[i];
		}
	}

	processed	=	FALSE;

	if (strcmp(textureMode,"texture") == 0) {
		if (currentFile == 2) {
			RiBegin(RI_NULL);
			tokens[currentParameter]	=	"resize";
			vals[currentParameter++]	=	(RtPointer) &resizeMode;
			RiMakeTextureV(files[0],files[1],smode,tmode,filter,filterWidth,filterHeight,currentParameter,tokens,vals);
			RiEnd();

			processed	=	TRUE;
		}
	} else if (strcmp(textureMode,"shadow") == 0) {
		if (currentFile == 2) {
			RiBegin(RI_NULL);
			tokens[currentParameter]	=	"resize";
			vals[currentParameter++]	=	(RtPointer) &resizeMode;
			RiMakeShadowV(files[0],files[1],currentParameter,tokens,vals);
			RiEnd();

			processed	=	TRUE;
		}
	} else if (strcmp(textureMode,"envlat") == 0) {
		if (currentFile == 2) {
			RiBegin(RI_NULL);
			tokens[currentParameter]	=	"resize";
			vals[currentParameter++]	=	(RtPointer) &resizeMode;
			RiMakeLatLongEnvironmentV(files[0],files[1],filter,filterWidth,filterHeight,currentParameter,tokens,vals);
			RiEnd();

			processed	=	TRUE;
		}
	} else if (strcmp(textureMode,"envcube") == 0) {
		if (currentFile == 7) {
			RiBegin(RI_NULL);
			tokens[currentParameter]	=	"resize";
			vals[currentParameter++]	=	&resizeMode;
			RiMakeCubeFaceEnvironmentV(files[0],files[1],files[2],files[3],files[4],files[5],files[6],fov,filter,filterWidth,filterHeight,currentParameter,tokens,vals);
			RiEnd();

			processed	=	TRUE;
		}
	} else if (strcmp(textureMode,"texture3d") == 0) {
		if (currentFile == 2) {
			RiBegin(RI_NULL);
			tokens[currentParameter]			=	RI_MAXERROR;
			vals[currentParameter++]			= 	(RtPointer) &maxerror;
			tokens[currentParameter]			=	"radiusscale";
			vals[currentParameter++]			= 	(RtPointer) &radiusScale;
			tokens[currentParameter]			=	"maxdepth";
			vals[currentParameter++]			= 	(RtPointer) &maxDepth;
			RiMakeBrickMapV(1,&files[0],files[1],currentParameter,tokens,vals);
			RiEnd();

			processed	=	TRUE;
		}
	}

	if (processed == FALSE) {
		fprintf(stderr,"Unknown texture mode (\"%s\") or invalid number of arguments (%d)\n",textureMode,currentFile);
	}

	return 0;
}