// SurfOR.java // Sean Cier, 29 July 1997 // Ported from The RenderMan Companion, listing 6.3 // This trivial example would in general probably not be worth implementing // in its own class, as it is here, so treat it as just that -- an example, // nothing more import com.PostHorizon.renderMan.*; import java.util.Hashtable; public class SurfOR { public static class Point2D { public double x, y; public Point2D(double _x, double _y) { x = _x; y = _y; } } protected static final int NU = 13; protected static final double F = 0.5522847; protected static final double COEFF[][] = { { 1, 0 }, { 1, F }, { F, 1 }, { 0, 1 }, {-F, 1 }, {-1, F }, {-1, 0 }, {-1,-F }, {-F,-1 }, { 0,-1 }, { F,-1 }, { 1,-F }, { 1, 0} }; protected RenderMan renderer; protected Point mesh[]; protected int npoints; public SurfOR(RenderMan _renderer, Point2D points[], int _npoints) { renderer = _renderer; npoints = _npoints; mesh = new Point[npoints*NU]; for (int v = 0; v < npoints; v++) { for (int u = 0; u < NU; u++) { mesh[v*NU + u] = new Point( points[v].x * COEFF[u][0], points[v].x * COEFF[u][1], points[v].y); } } } public void execute() throws RMException { Hashtable params = new Hashtable(); params.put(RenderMan.P, mesh); renderer.patchMesh(RenderMan.BICUBIC, NU, RenderMan.NONPERIODIC, npoints, RenderMan.NONPERIODIC, params); params.clear(); } }