/* * @(#)ThreeD.java 1.8 98/06/29 * * Copyright (c) 1995-1998 Sun Microsystems, Inc. All Rights Reserved. * * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, * modify and redistribute this software in source and binary code form, * provided that i) this copyright notice and license appear on all copies of * the software; and ii) Licensee does not utilize the software in a manner * which is disparaging to Sun. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * This software is not designed or intended for use in on-line control of * aircraft, air traffic, aircraft navigation or aircraft communications; or in * the design, construction, operation or maintenance of any nuclear * facility. Licensee represents and warrants that it will not use or * redistribute the Software for such purposes. */ /* Modified by Håkan Johansson 2000-02-10 */ /* A set of classes to parse, represent and display 3D wireframe models represented in Wavefront .obj format. */ import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.URL; /** An applet to put a 3D model into a page */ public class ThreeD extends Applet { ThreeDCanvas canvas; public void init() { // System.out.println ("init"); canvas = new ThreeDCanvas(); if (canvas != null) { try { setLayout(new BorderLayout()); Panel btnPanel = new Panel(new GridLayout (1,4)); add(btnPanel, BorderLayout.SOUTH); add(canvas, BorderLayout.CENTER); btnPanel.add(canvas.btn[0] = new BtnOrText("Points")); btnPanel.add(canvas.btn[1] = new BtnOrText("Plates")); btnPanel.add(canvas.btn[2] = new BtnOrText("Lines")); btnPanel.add(canvas.btn[3] = new BtnOrText("Triangles")); }catch(Exception e){canvas.message = e.toString();}; canvas.mdname = getParameter("model"); canvas.docbase = getDocumentBase (); try { canvas.scalefudge = Float.valueOf(getParameter("scale")).floatValue(); }catch(Exception e){}; resize(getSize().width <= 20 ? 400 : getSize().width, getSize().height <= 20 ? 400 : getSize().height); canvas.init(); } } public void destroy() { // System.out.println ("destroy"); if (canvas != null) canvas.destroy(); } public void start() { // System.out.println ("start"); if (canvas != null) canvas.start (); // if (md == null && message == null) // new Thread(this).start(); } public void stop() { if (canvas != null) canvas.stop (); // System.out.println ("stop"); } // private synchronized void waitPainted() { // while (!painted) // wait(); // painted = false; // } public void paint(Graphics g){ // System.out.println ("paint"); if (canvas == null) { g.drawString("Canvas not created", 3, 20); } } public String getAppletInfo() { return "Title: ThreeD \nAuthor: Håkan Johansson\n\nBased on:\n\nTitle: ThreeD \nAuthor: James Gosling? \nAn applet to put a 3D model into a page."; } public String[][] getParameterInfo() { String[][] info = { {"model", "path string", "The path to the model to be displayed."}, {"scale", "float", "The scale of the model. Default is 1."} }; return info; } }