/* Copyrighted Pixar 1989 */ /* From the RenderMan Companion p. 168 */ /* Listing 8.5 An improved boilerplate viewing program */ #include #include #include #include /* viewbasics.c: file compiling view options into a rendering shell. */ #define DATATYPE RI_RGBA /* Pixels have RGB and coverage */ #define SHADINGRATE 20.0 #define PICXRES 800.0 /* Horizontal output resolution */ #define PICYRES 600.0 /* Vertical output resolution */ #define CROPMINX 0.0 /* RiCropWindow() parameters */ #define CROPMAXX 1.0 #define CROPMINY 0.0 #define CROPMAXY 1.0 #define CAMXFROM 0.0 /* Camera position */ #define CAMYFROM 0.0 #define CAMZFROM -2.0 #define CAMXTO 0.5 /* Camera direction */ #define CAMYTO 0.0 #define CAMZTO 1.0 #define CAMROLL 0.0 /* Camera roll */ #define CAMZOOM 0.5 /* Camera zoom rate */ //-------------------------------------------------------------------- RtPoint CameraFrom = { CAMXFROM, CAMYFROM, CAMZFROM }, CameraTo = { CAMXTO, CAMYTO, CAMZTO }; RtPoint Square[4] = { {.5,.5,0}, {.5,-.5,0}, {-.5,-.5,0}, {-.5,.5,0} }; static RtColor Color = { .6, .8, .2 }; #define L -.5 /* For x: left side */ #define R .5 /* For x: right side */ #define D -.5 /* For y: down side */ #define U .5 /* For y: upper side */ #define F .5 /* For z: far side */ #define N -.5 /* For z: near side */ /* UnitCube(): define a cube in the graphics environment */ void UnitCube() { static RtPoint Cube[6][4] = { { {L,D,F}, {L,D,N}, {R,D,N}, {R,D,F} }, /* Bottom face */ { {L,D,F}, {L,U,F}, {L,U,N}, {L,D,N} }, /* Left face */ { {R,U,N}, {L,U,N}, {L,U,F}, {R,U,F} }, /* Top face */ { {R,U,N}, {R,U,F}, {R,D,F}, {R,D,N} }, /* Right face */ { {R,D,F}, {R,U,F}, {L,U,F}, {L,D,F} }, /* Far face */ { {L,U,N}, {R,U,N}, {R,D,N}, {L,D,N} } /* Near face */ }; int i; for( i = 0; i < 6; i++) /* Declare the cube */ RiPolygon( (RtInt) 4, RI_P, (RtPointer) Cube[i], RI_NULL); } //-------------------------------------------------------------------- #define NPOINTS 16 Point2D points[NPOINTS] = { {1.5000,.0000}, {1.4600,.0900}, {1.3500,.1273}, {1.2625,.1203}, {1.1750,.1047}, {1.0875,.0935}, {1.0000,.0899}, {0.9375,.0982}, {0.8625,.1236}, {0.7250,.1851}, {0.5875,.2281}, {0.4500,.2383}, {0.3375,.2255}, {0.2250,.1953}, {0.0750,.1414}, {0.0000,.1125} }; RtColor colors[NPOINTS] = { {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5}, {.9,.9,.5} }; RtColor color = {.9,.9,.5}; void Go(void) { RiColor(color); /*RiTranslate(0.0,-0.5,0.0);*/ RiRotate(-90.0, 1.0, 0.0, 0.0); PolySurfOR(points, colors, NPOINTS); } int main() { RiBegin(RI_NULL); /* As always */ /* Output image characteristics */ RiDisplay(RI_NULL, RI_FRAMEBUFFER, DATATYPE, RI_NULL); RiShadingRate(SHADINGRATE); RiFormat((RtInt)PICXRES, (RtInt)PICYRES, -1.0); /* Image resolution */ RiTransformBegin(); RiRotate(30, 1.0, 0.0, 0.0); RiLightSource( "distantlight", RI_NULL); RiTransformEnd(); /* Region of image rendered */ RiCropWindow(CROPMINX, CROPMAXX, CROPMINY, CROPMAXY); FrameCamera2(PICXRES*CAMZOOM, PICXRES, PICYRES); // RiFrameAspectRatio(1.83); /* Camera position and orientation */ CameraTo[0] -= CameraFrom[0]; CameraTo[1] -= CameraFrom[1]; CameraTo[2] -= CameraFrom[2]; PlaceCamera(CameraFrom, CameraTo, CAMROLL); RiClipping(1E-3, RI_INFINITY); /* Clipping planes*/ // RiRotate(-40, 3.0, 2.0, 1.0); /* Now describe the world */ RiWorldBegin(); /* ...Your scene here... */ RiSurface("matte", RI_NULL); RiColor(Color); /* Declare the color */ // RiRotate(10, 0.0, 1.0, 0.0); RiTranslate(0, -1.0, 0.0); // RiScale(2.0, 1.0, 1.0); // RiPatch(RI_BICUBIC, RI_P, (RtPointer)Square, RI_NULL); // RiPatch(RI_BILINEAR, RI_P, (RtPointer)Square, RI_NULL); UnitCube(); // RiPointsPolygons(1, (RtInt*)&nverts, verts, RI_P, (RtPointer)Square, RI_NULL); RiTranslate(0, 0.5, 0.0); Go(); RiWorldEnd(); RiEnd(); return 0; }