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; }
void doFrame(int fNum, size_t cur, int fft_size, fftw_complex *fft_data[], char *fName) { RiFrameBegin(fNum); char buffer[256]; sprintf(buffer, "images/%s%05d.tif", fName, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); RiTranslate(0.0,0.0,0.8*fft_size); RiRotate( -120.0, 1.0, 0.0, 0.0); RiRotate(90.0, 0.0,0.0, 1.0); RiWorldBegin(); RiSurface((char*)"matte", RI_NULL); RiTranslate(-fft_size/2.0, -fft_size/2.0+fft_size/4.0, 0); size_t real_i = cur; RtPoint *pts = malloc(sizeof(RtPoint)*(fft_size*fft_size/2)); RtColor *colors = malloc(sizeof(RtColor)*(fft_size*fft_size/2)); RtInt *numCurves = malloc(sizeof(RtInt)*fft_size); size_t cp = 0; for (int i=fft_size-1; i>=0; --i) { real_i += 1; if (real_i == fft_size) { real_i = 0; } numCurves[i] = fft_size/2; for (size_t j=0; j<fft_size/2; ++j) { colors[cp][0] = real_i/(double)(fft_size-1); colors[cp][1] = cabs(fft_data[real_i][j]); if (colors[cp][1]>1.0) { colors[cp][1] = 1.0; } colors[cp][2] = j/(double)(fft_size/2); pts[cp][0] = fft_size-i; pts[cp][2] = cabs(fft_data[real_i][j]); pts[cp][1] = j; cp += 1; } } RiCurves( "linear", fft_size, numCurves, "nonperiodic", "P", (RtPointer)pts, "Cs", (RtPointer)colors, RI_NULL ); free(numCurves); free(colors); free(pts); RiWorldEnd(); RiFrameEnd(); }
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; }
void doFrame(size_t fNum, scene_info_t *scene, wave_object_t *obj) { RtInt on = 1; char buffer[256]; RtString on_string = "on"; RtInt samples = 2; RtPoint lightPos = {40,80,40}; RiFrameBegin(fNum); RtColor bgcolor = {0.2,0.8,0.2}; RiImager("background", "color background", bgcolor, RI_NULL); sprintf(buffer, "images/%s%05lu.tif", scene->fprefix, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiProjection((char*)"perspective",RI_NULL); PlaceCamera(&scene->cam); /* 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", RI_NULL); RiLightSource("distantlight", (RtToken)"from", (RtPointer)lightPos, RI_NULL); RiWorldBegin(); RiSurface((char*)"matte", RI_NULL); show_object(obj); RiWorldEnd(); RiFrameEnd(); }
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; }
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; }
void doFrame(int fNum, scene_info_t *scene) { RiFrameBegin(fNum); char buffer[256]; sprintf(buffer, "images/%s%05d.tif", scene->fprefix, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); /* RiTranslate(scene->x_trans, scene->y_trans, scene->z_trans); */ /* RiRotate( scene->x_rotation, 1.0, 0.0, 0.0); */ /* RiRotate( scene->y_rotation, 0.0, 1.0, 0.0); */ /* RiRotate( scene->z_rotation, 0.0, 0.0, 1.0); */ PlaceCamera(&scene->cam); RiWorldBegin(); RiSurface((char*)"matte", RI_NULL); const size_t NUM_I = 256; const size_t NUM_J = 256; RtPoint *pts = malloc(sizeof(RtPoint)*NUM_I*NUM_J); RtColor *colors = malloc(sizeof(RtPoint)*NUM_I*NUM_J); double umin = -4*PI; double umax = 4*PI; double vmin = -4*PI; double vmax = 4*PI; double du = (umax - umin)/(NUM_J-1); double dv = (vmax - vmin)/(NUM_I-1); double u = umin; for (size_t i=0; i< NUM_I; ++i) { double v = vmin; for (size_t j=0; j < NUM_J; ++j) { pts[i*NUM_J + j][0] = x(u,v); pts[i*NUM_J + j][1] = z(u,v); pts[i*NUM_J + j][2] = y(u,v); colors[i*NUM_J + j][0] = r(u,v); colors[i*NUM_J + j][1] = g(u,v); colors[i*NUM_J + j][2] = b(u,v); /* RiTransformBegin(); */ /* RiTranslate(x(u,v), y(u,v), z(u,v)); */ /* RiSphere(du, -du, du, 360.0, RI_NULL); */ /* RiTransformEnd(); */ v += dv; } u += du; } RtInt npolys = 2*(NUM_J+1)*(NUM_I+1); RtInt *nvertices = malloc(sizeof(RtInt) * npolys); for (size_t i=0; i<npolys; ++i) { nvertices[i] = 3; } RtInt *vertices = malloc(sizeof(RtInt)*3*npolys); size_t curIdx = 0; for (size_t i = 0; i<(NUM_I-1); ++i) { for (size_t j=0; j<(NUM_J-1); ++j) { vertices[curIdx] = j*NUM_I + i; vertices[curIdx+1] = (j+1)*NUM_I + i; vertices[curIdx+2] = j*NUM_I + i+1; vertices[curIdx+3] = (j+1)*NUM_I + i; vertices[curIdx+4] = (j+1)*NUM_I + (i+1); vertices[curIdx+5] = j*NUM_I + (i+1); curIdx += 6; } } RiPointsPolygons(curIdx/3, nvertices, vertices, "P", pts, "Cs", colors, RI_NULL); /* RiSphere(10.0, -10.0, 10.0, 360.0); */ free(vertices); free(nvertices); free(colors); free(pts); RiWorldEnd(); RiFrameEnd(); }
void doFrame(int fNum, char *fName) { RiFrameBegin(fNum); static RtColor Color = {.2, .4, .6} ; char buffer[256]; sprintf(buffer, "images/%s%03d.tif", fName, fNum); RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.25); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); RiTranslate(0.0,0.0,50); // RiRotate(-40.0, 1.0,0.0,0.0); // RiRotate(-20.0, 0.0,1.0,0.0); RiWorldBegin(); RiColor(Color); RiRotate(fNum, 0.0,1.0,0.0); RtFloat roughness = 0.03; int trace = 1; //RtFloat km = .3; //RtFloat maxKm = 1.0; RtFloat opac[] = {0.5, 0.9, 0.3}; // RiBasis(RiBezierBasis, 3, RiBezierBasis, 3); //km = abs(sin(2.0*PI*((double)fNum/100.0))); // RiSurface((char*)"funkyglass", "roughness", (RtPointer)&roughness, RI_NULL); // RiOpacity(opac); // RiAttribute((char*)"visibility", "int trace", &trace, RI_NULL); RiSurface((char*)"matte", RI_NULL); RiSolidBegin("difference"); // RiTranslate(15,0,0); // RiSolidBegin("primitive"); // RiSphere(10, -10, 10, 360, RI_NULL); // RiSolidEnd(); double t=-PI; int steps = 8; double dt = (2*PI)/steps; RiSolidBegin("primitive"); double rad=5.0; for (int ti=0; ti<steps; ++ti) { RiTransformBegin(); RiTranslate(xv(t),yv(t),0); // RiSolidBegin("primitive"); RiSphere(rad, -rad, rad, 360, RI_NULL); // RiSolidEnd(); RiTransformEnd(); t += dt; } for (int ti=0; ti<steps; ++ti) { RiTransformBegin(); RiTranslate(0,xv(t),yv(t)); // RiSolidBegin("primitive"); RiSphere(rad, -rad, rad, 360, RI_NULL); // RiSolidEnd(); RiTransformEnd(); t += dt; } RiSolidEnd(); RiSolidBegin("primitive"); RiSphere(15, -15, 15, 360, RI_NULL); RiSolidEnd(); // RiTranslate(-30.0,-30.0,0); // RiSolidBegin("primitive"); // RiSphere(10, -10, 10, 360, RI_NULL); // RiSolidEnd(); // RiTranslate(15.0,-15.0,0); // RiSolidBegin("primitive"); // RiSphere(15, -15, 15, 360, RI_NULL); // RiSolidEnd(); RiSolidEnd(); RiWorldEnd(); RiFrameEnd(); }
void doFrame(int fNum, char *fName) { RtPoint points[4] = {-0.5,0,-0.5, -0.5,0,0.5, 0.5,0,0.5, 0.5,0,-0.5}; RiFrameBegin(fNum); { static RtColor Color = {.2, .4, .6} ; RtFloat radius=1.0, zmin = -1.0, zmax = 1.0, thetamax=360; char buffer[256]; std::sprintf(buffer, "images/%s%03d.tif", fName, fNum); // std::cout << buffer << "\n"; RiDisplay(buffer,(char*)"file",(char*)"rgba",RI_NULL); RiFormat(800, 600, 1.3); RiLightSource((char*)"distantlight",RI_NULL); RiProjection((char*)"perspective",RI_NULL); RiTranslate(0.0,0.0,8.5); RiRotate(-40.0, 1.0,0.0,0.0); RiRotate(-40.0, 0.0,1.0,0.0); RtColor bgcolor = {0.9,0.9,0.9}; RiImager((char*)"background", (char*)"color bgcolor", &bgcolor, RI_NULL); RiWorldBegin(); { RiColor(Color); RtFloat roughness = 0.03; int trace = 1; //RtFloat km = .3; //RtFloat maxKm = 1.0; // RtFloat opac[] = {0.4,0.4,0.4}; RtFloat color[] = {0.9,0.9,0.9}; const char *texName = "texture2.tx"; RiColor(color); RiSurface((char*)"paintedplastic", (char*)"texturename", &texName, RI_NULL); RiRotate(fNum, 0,1,0); RiAttributeBegin(); { RiTranslate(-5.0,2.5,0.0); RiSphere(2.0,-2.0,2.0,360.0,RI_NULL); } RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(0.0,2.5,0.0); RiCylinder(2.0,-2.0,2.0,360.0,RI_NULL); }RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(5.0,2.5,0.0); RiCone(4.0,2.0,360.0,RI_NULL); } RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(-5.0,-2.5,0.0); RiParaboloid(4.0,0.0,4.0,360.0,RI_NULL); } RiAttributeEnd(); RtPoint p1 = {-1,-1,-4}; RtPoint p2 = {4,2,4}; RiAttributeBegin(); { RiTranslate(0.0,-2.5,0.0); RiHyperboloid(p1, p2, 360.0,RI_NULL); } RiAttributeEnd(); RiAttributeBegin(); { RiTranslate(5.0,-2.5,0.0); RiTorus(2.0,0.5,0,360,360,RI_NULL); } RiAttributeEnd(); } RiWorldEnd(); } RiFrameEnd(); }