import javax.swing.*; import java.awt.*; /** * Simple raytrace in Java 2D - top level driver - was SimplestDraw * This version has a black background and white text. * This ray traces a triangle using barycentric coordinates. * @author Bob Futrelle * @version 0.2, 20 October 2005 (was 3 April 2003) * * */ class RTSimplestRaytrace { int height, width; P3d pa, pb, pc; Tri tri; Color[][] colorArray = new Color[700][500]; TinyRayTrace trace = new TinyRayTrace(700,500); public RTSimplestRaytrace() { height = 500; width = 600; } RTDrawer drawer; RTGUI gui; public static void main(String[] args) { RTSimplestRaytrace simplest = new RTSimplestRaytrace(); simplest.setup(); } // main() void setup(){ // Pass the triangle and get the returned Color array. // Create the model data pa = new P3d(20.0,20.0,7.0); pb = new P3d(160.0,40.0,5.0); pc = new P3d(40.0,150.0,6.3765); tri = new Tri(pa,pb,pc,Color.red); // Inits color array to black for(int i =0; i < 700; i++) for(int j=0; j < 500; j++) colorArray[i][j] = Color.black; // Fills the color array with triangle color in the right places. trace.doTrace(tri,colorArray); JFrame frame = new JFrame(); gui = new RTGUI(width, height); drawer = new RTDrawer(colorArray); gui.setup(frame, drawer); } } // class SimplestRaytrace