Esempio n. 1
0
/**
 * Simple polygon geometry
 */
void testPolygon()
{
	RiAttributeBegin(); {
		RtFloat p[12] = {
			-.5F,  .5F, 0,
			 .5F,  .5F, 0,
			 .5F, -.5F, 0,
			-.5F, -.5F, 0
		};
		RtFloat st[8] = {
			0, 0,
			1, 0,
			1, 1,
			0, 1
		};
		RtFloat color[12] = {
			0, 0, 0,
			1, 0, 0,
			0, 1, 0,
			0, 0, 1
		};
		RiTranslate(0, 0, 3);
		RiPolygon(4, RI_P, p, RI_ST, st, RI_CS, color, RI_NULL);
	} RiAttributeEnd();
}
Esempio n. 2
0
/* Draw a rectangular prism which spans two given opposite corners */
void drawCube(RtPoint from, RtPoint to) {
	RtPoint front[4] = {{from[0], from[1], from[2]}, {from[0], to[1], from[2]}, {to[0], to[1], from[2]}, {to[0], from[1], from[2]}};
	RtPoint back[4] = {{from[0], from[1], to[2]}, {from[0], to[1], to[2]}, {to[0], to[1], from[2]}, {to[0], from[1], to[2]}};
	RtPoint left[4] = {{from[0], from[1], from[2]}, {from[0], to[1], from[2]}, {from[0], to[1], to[2]}, {from[0], from[1], to[2]}};
	RtPoint right[4] = {{to[0], from[1], from[2]}, {to[0], to[1], from[2]}, {to[0], to[1], to[2]}, {to[0], from[1], to[2]}};
	RtPoint top[4] = {{from[0], to[1], from[2]}, {from[0], to[1], to[2]}, {to[0], to[1], to[2]}, {to[0], to[1], from[2]}};
	RtPoint bottom[4] = {{from[0], from[1], from[2]}, {from[0], from[1], to[2]}, {to[0], from[1], to[2]}, {to[0], from[1], from[2]}};

	RiPolygon(4, RI_P, (RtPointer) front, RI_NULL);
	RiPolygon(4, RI_P, (RtPointer) back, RI_NULL);
	RiPolygon(4, RI_P, (RtPointer) left, RI_NULL);
	RiPolygon(4, RI_P, (RtPointer) right, RI_NULL);
	RiPolygon(4, RI_P, (RtPointer) top, RI_NULL);
	RiPolygon(4, RI_P, (RtPointer) bottom, RI_NULL);
}
Esempio n. 3
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. 4
0
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);
}
Esempio n. 5
0
/**
 * Various polygon geometry interface calls
 */
void testPoly10()
{
	RtFloat p[] = {
		// outer
		-.5, -.5, 1, //  1
		-.5,  .5, 1, //  2
		.5,  .5, 1, //  3
		.5, -.5, 1, //  4
		0
	};
	RtInt nloops[] = {
		1
	};
	RtInt nverts[] = {
		4
	};
	RtInt verts[] = {
		0, 1, 2, 3
	};

	// Disable warnings (variable not used)
	opacity_25[0] = opacity_25[0]+0;
	opacity_50[0] = opacity_50[0]+0;
	opacity_75[0] = opacity_75[0]+0;

	RiAttributeBegin(); {
		RiTranslate(0, 0, 1.5);
		RiAttributeBegin(); {
			RiRotate(15.0, 0, 0, 1);
			RiOpacity(opacity_50);
			RiColor(greenish);

			// RiGeneralPolygon(nloops[0], nverts, RI_P, &p, RI_NULL);
			RiPolygon(4, RI_P, &p, RI_NULL);
			// RiPointsPolygons(1, nverts, verts, RI_P, &p, RI_NULL);
			// RiPointsGeneralPolygons(1, nloops, nverts, verts, RI_P, &p, RI_NULL);
	
#			if defined ( _TRACE )
			{
				RtInt i;
				RiTransformPoints(RI_CURRENT, RI_RASTER, sizeof(p)/sizeof(RtPoint), (RtPoint *)p);
				for ( i = 0; i < 4; ++i ) {
					printf("x %f, y %f, z %f\n", p[i*3+0], p[i*3+1], p[i*3+2]);
				}
				printf("Inverse\n");
				RiTransformPoints(RI_RASTER, RI_CURRENT, sizeof(p)/sizeof(RtPoint), (RtPoint *)p);
				for ( i = 0; i < 4; ++i ) {
					printf("x %f, y %f, z %f\n", p[i*3+0], p[i*3+1], p[i*3+2]);
				}
			}
#			endif
		} RiAttributeEnd();
	
		RiAttributeBegin(); {
			RiTranslate(0, 0, 0.2F);
			// RiOpacity(opacity_50);
			RiColor(redish);

			// RiGeneralPolygon(nloops[0], nverts, RI_P, &p, RI_NULL);
			// RiPolygon(4, RI_P, &p, RI_NULL);
			RiPointsPolygons(1, nverts, verts, RI_P, &p, RI_NULL);
			// RiPointsGeneralPolygons(1, nloops, nverts, verts, RI_P, &p, RI_NULL);
			
		} RiAttributeEnd();

		RiAttributeBegin(); {
			RiRotate(-15.0F, 0, 0, 1);
			RiTranslate(0, 0, 0.3F);
			RiOpacity(opacity_75);
			RiColor(blueish);

			// RiGeneralPolygon(nloops[0], nverts, RI_P, &p, RI_NULL);
			// RiPolygon(4, RI_P, &p, RI_NULL);
			// RiPointsPolygons(1, nverts, verts, RI_P, &p, RI_NULL);
			RiPointsGeneralPolygons(1, nloops, nverts, verts, RI_P, &p, RI_NULL);
			
		} RiAttributeEnd();

	} RiAttributeEnd();
}