// Pins.java // Sean Cier, 29 July 1997 // Port of ch16/pins_a.c from the PRMan tutorial // To use: compile and run "java Pins" import com.PostHorizon.renderMan.*; import java.util.Hashtable; public class Pins extends Example { protected String getFilename() { return("pins.out"); } protected int getXRes() { return(256); } protected int getYRes() { return(192); } protected double getCamZoom() { return(1.5); } protected double getCamRoll() { return(90.0); } protected Point getCameraFrom() { return(new Point(-5.0, 0.5, 4.0)); } protected Point getCameraTo() { return(new Point( 5.0, -0.25, -1.0)); } protected static final int NPOINTS = 10; protected static final Point GROUND[] = { new Point( -0.5, -7.5, 0.0 ), new Point( -0.5, 7.5, 0.0 ), new Point( 2.0, 7.5, 0.0 ), new Point( 2.0, -7.5, 0.0 ) }; protected static final SurfOR.Point2D POINTS[] = { new SurfOR.Point2D(0.0000,1.5000), new SurfOR.Point2D(0.0703,1.5000), new SurfOR.Point2D(0.1273,1.4293), new SurfOR.Point2D(0.1273,1.3727), new SurfOR.Point2D(0.1273,1.2300), new SurfOR.Point2D(0.0899,1.1600), new SurfOR.Point2D(0.0899,1.0000), new SurfOR.Point2D(0.0899,0.7500), new SurfOR.Point2D(0.4100,0.6780), new SurfOR.Point2D(0.1250,0.0000) }; protected Point to = new Point( 2.0, 0.0, 0.0), from = new Point(-5.0, 0.5, 5.0); protected Color color = new Color(0.9, 0.9, 0.5); public void go() throws RMException { Hashtable params = new Hashtable(); params.put(RenderMan.INTENSITY, new Double(0.05)); renderer.lightSource(RenderMan.AMBIENTLIGHT, params); params.clear(); params.put(RenderMan.INTENSITY, new Double(64)); params.put(RenderMan.CONEANGLE, new Double(12*Math.PI/180.0)); params.put(RenderMan.CONEDELTAANGLE, new Double(1*Math.PI/180.0)); params.put(RenderMan.FROM, from); params.put(RenderMan.TO, to); renderer.lightSource(RenderMan.SPOTLIGHT, params); params.clear(); from.setY(-3); from.setZ(4); params.put(RenderMan.INTENSITY, new Double(8)); params.put(RenderMan.FROM, from); renderer.lightSource(RenderMan.POINTLIGHT, params); params.clear(); renderer.transformBegin(); renderer.scale(2.0, 0.33333, 1.0); renderer.surface("wood", null); params.put(RenderMan.P, GROUND); renderer.polygon(4, params); params.clear(); renderer.transformEnd(); renderer.surface("plastic", null); placePins(1.2*Math.sin(60.0*Math.PI/180.0), 1.2); } protected void placePins(double xseperation, double yseperation) throws RMException { int row, pin; ObjectHandle phandle; renderer.basis(RenderMan.bezierBasis, RenderMan.BEZIERSTEP, RenderMan.bezierBasis, RenderMan.BEZIERSTEP); phandle = renderer.objectBegin(); // No need to check return value -- if the renderer is incapable of // object instantiation, it will throw an exception bowlingPin(); renderer.objectEnd(); renderer.color(color); for (row = 0; row < 4; row++) { renderer.transformBegin(); renderer.translate(row*xseperation, row*yseperation/2, 0.0); for (pin = 0; pin <= row; pin++) { renderer.transformBegin(); renderer.translate(0.0, -pin * yseperation, 0.0); renderer.objectInstance(phandle); renderer.transformEnd(); } renderer.transformEnd(); } } protected void bowlingPin() throws RMException { (new SurfOR(renderer, POINTS, NPOINTS)).execute(); } public static void main(String argv[]) { try { new Pins().execute(); } catch (RMException e) { System.err.println(e.toString()); } } }