コード例 #1
0
ファイル: glutrib.cpp プロジェクト: s-cherepanov/ricpp
/**
 * Simple cone geometry
 */
void testCone()
{
	const RtFloat rad = 0.6F;
	const RtFloat height = 1.6F;
	RiAttributeBegin(); {
		RiSides(2);
		RiOrientation(RI_OUTSIDE);
		RiColor(blueish);
		RiTransformBegin(); {
			RiTranslate(0, -height/4.0F, 3);
			RiScale(1.0, 1.0, 1.0);
			RiRotate(-45, 1, 0, 0);
			RiCone(height, rad, 360, RI_NULL);
		} RiTransformEnd();
	} RiAttributeEnd();
}
コード例 #2
0
ファイル: draw.c プロジェクト: iamjamestl/school
void drawPencil() {
	RtColor pink = {1.0, 0.5, 0.5};
	RtColor silver = {0.7, 0.7, 0.7};
	RtColor yellow = {1.0, 0.7, 0.0};
	RtColor tan = {0.9, 0.8, 0.5};
	RtColor black = {0.1, 0.1, 0.1};

	RtPoint pencilSide[4] = {{-4.0, 0.1, -0.1}, {-4.0, 0.1, 0.1}, {4.0, 0.1, 0.1}, {4.0, 0.1, -0.1}};

	RiColor(yellow);
	RiSurface("paintedmatte", RI_NULL);

	/* Draw all six sides of a pencil, each 8.0"x0.2" in size */
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	RiRotate(60.0, 1.0, 0.0, 0.0);
	RiPolygon(4, RI_P, pencilSide, RI_NULL);
	
	/* Draw the eraser */
	RiTransformBegin();
		RiTranslate(4.2, 0.0, 0.0);

		/* Draw the metal part around the eraser */
		RiTransformBegin();
			RiTranslate(-0.2, 0.0, 0.0);
			RiRotate(-90.0, 0.0, 1.0, 0.0);

			RiColor(silver);
			RiSurface("metal", RI_NULL);
			RiCylinder(0.15, 0.0, 0.3, 360.0, RI_NULL);
		RiTransformEnd();

		RiRotate(-90.0, 0.0, 1.0, 0.0);

		RiColor(pink);
		RiSurface("matte", RI_NULL);

		RiDisk(0.0, 0.15, 360, RI_NULL);
		RiCylinder(0.15, 0.0, 0.2, 360, RI_NULL);
	RiTransformEnd();

	RiColor(tan);
	RiSurface("matte", RI_NULL);

	/* Draw the exposed wood part at the bottom of the pencil */
	RiTranslate(-4.0, 0.0, 0.0);
	RiTransformBegin();
		RiRotate(-90.0, 0.0, 1.0, 0.0);
		RiCone(1.0, 0.15, 360, RI_NULL);
	RiTransformEnd();

	/* Draw the lead of the pencil */
	RiTranslate(-0.7, 0.0, 0.0);
	RiRotate(-90.0, 0.0, 1.0, 0.0);

	RiColor(black);
	RiCone(0.3, 0.05, 360, RI_NULL);
}
コード例 #3
0
ファイル: main.cpp プロジェクト: github11/Renderman-Tests
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();
}