diff options
author | eteq <[email protected]> | 2007-01-12 09:43:00 +0000 |
---|---|---|
committer | eteq <[email protected]> | 2007-01-12 09:43:00 +0000 |
commit | 2b2e66cab202e6b591f308f75dc1e0e6a288737d (patch) | |
tree | 5cff300a00e3d304cbc6a87d7c164ba8babdb12e | |
parent | 00c7c7122ff4c2a5625413b4d10bbac016693e4c (diff) |
Moved demos to demo package, Cleaned up some copyright headers
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/joglutils/trunk@29 83d24430-9974-4f80-8418-2cc3294053b9
-rw-r--r-- | build/joglutils.jnlp | 1 | ||||
-rw-r--r-- | src/net/java/joglutils/GLJFrame.java | 25 | ||||
-rw-r--r-- | src/net/java/joglutils/demos/BasicGLJFrameDemo.java | 75 | ||||
-rw-r--r-- | src/net/java/joglutils/demos/FontDrawerDemo.java | 264 | ||||
-rw-r--r-- | src/net/java/joglutils/jogltext/FontDrawer.java | 204 | ||||
-rw-r--r-- | src/net/java/joglutils/jogltext/JogltextException.java | 39 | ||||
-rw-r--r-- | src/net/java/joglutils/lighting/LightPanel.java | 16 | ||||
-rw-r--r-- | src/net/java/joglutils/lighting/MaterialPanel.java | 14 |
8 files changed, 419 insertions, 219 deletions
diff --git a/build/joglutils.jnlp b/build/joglutils.jnlp index 56480eb..ced6485 100644 --- a/build/joglutils.jnlp +++ b/build/joglutils.jnlp @@ -10,6 +10,7 @@ </information> <resources> <jar href="joglutilsnb.jar" /> + <extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp"/> </resources> <component-desc /> </jnlp> diff --git a/src/net/java/joglutils/GLJFrame.java b/src/net/java/joglutils/GLJFrame.java index 2dd8e12..8ce1304 100644 --- a/src/net/java/joglutils/GLJFrame.java +++ b/src/net/java/joglutils/GLJFrame.java @@ -558,29 +558,4 @@ public class GLJFrame extends JFrame { return (GLAutoDrawable)mainCanvas;
}
- public static void main(String[] args) {
- GLJFrame gljf = new GLJFrame(new GLEventListener() {
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- }
-
- public void init(GLAutoDrawable drawable) {
- }
-
- public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
- gl.glColor3f(1.0f,0.323f,0.8f);
- gl.glBegin(GL.GL_TRIANGLE_STRIP);
- gl.glVertex2d(0,0);
- gl.glVertex2d(0.5,1.0);
- gl.glVertex2d(-0.3,-0.9);
- gl.glEnd();
- }
-
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
- }
-
- });
- gljf.setDefaultCloseOperation(gljf.EXIT_ON_CLOSE);
- gljf.setVisible(true);
- }
}
diff --git a/src/net/java/joglutils/demos/BasicGLJFrameDemo.java b/src/net/java/joglutils/demos/BasicGLJFrameDemo.java new file mode 100644 index 0000000..370a4cc --- /dev/null +++ b/src/net/java/joglutils/demos/BasicGLJFrameDemo.java @@ -0,0 +1,75 @@ +/*
+ * Copyright (c) 2007 Erik Tollerud ([email protected]) All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * The names of Erik Tollerud, Sun Microsystems, Inc. or the names of
+ * contributors may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * 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. ERIK TOLLERUD,
+ * SUN MICROSYSTEMS, INC. ("SUN"), AND SUN'S LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ERIK
+ * TOLLERUD, SUN, OR SUN'S 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 THIS SOFTWARE, EVEN IF ERIK
+ * TOLLERUD OR SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ */
+
+package net.java.joglutils.demos;
+
+import net.java.joglutils.*;
+import javax.media.opengl.*;
+
+/**
+ *
+ * @author Erik J. Tollerud
+ * @created January 12, 2007
+ */
+public class BasicGLJFrameDemo {
+
+ public static void main(String[] args) {
+ GLJFrame gljf = new GLJFrame(new GLEventListener() {
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL gl = drawable.getGL();
+ gl.glColor3f(1.0f,0.323f,0.8f);
+ gl.glBegin(GL.GL_TRIANGLE_STRIP);
+ gl.glVertex2d(0,0);
+ gl.glVertex2d(0.5,1.0);
+ gl.glVertex2d(-0.3,-0.9);
+ gl.glEnd();
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ });
+ gljf.setDefaultCloseOperation(gljf.EXIT_ON_CLOSE);
+ gljf.setVisible(true);
+ }
+
+}
diff --git a/src/net/java/joglutils/demos/FontDrawerDemo.java b/src/net/java/joglutils/demos/FontDrawerDemo.java new file mode 100644 index 0000000..4b77a8a --- /dev/null +++ b/src/net/java/joglutils/demos/FontDrawerDemo.java @@ -0,0 +1,264 @@ +/*
+ * Copyright (c) 2007 Erik Tollerud ([email protected]) All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * The names of Erik Tollerud, Sun Microsystems, Inc. or the names of
+ * contributors may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * 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. ERIK TOLLERUD,
+ * SUN MICROSYSTEMS, INC. ("SUN"), AND SUN'S LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ERIK
+ * TOLLERUD, SUN, OR SUN'S 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 THIS SOFTWARE, EVEN IF ERIK
+ * TOLLERUD OR SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ */
+
+package net.java.joglutils.demos;
+
+import net.java.joglutils.jogltext.*;
+import java.awt.geom.*;
+import java.awt.font.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.media.opengl.*;
+import javax.media.opengl.glu.*;
+import com.sun.opengl.util.Animator;
+
+/**
+ * This Demo application uses the Lighting class and the FontDrawer class to render 3D text into a GLJFrame.
+ * See the console for keyboard commands and command line option instructions.
+ * @author Erik J. Tollerud
+ * @created January 12, 2007
+ */
+public class FontDrawerDemo {
+
+ /**
+ * Generates {@link GLJFrame}
+ * Generates a GLJFrame with a FontDrawer demo. Console output describes input.
+ * @param args Command Line argument order: textDepth xRotspeed yRotspeed zRotspeed filled flatnormal
+ *
+ */
+
+
+
+ public static void main(String[] args) {
+ final float[] rotSteps = {0.0f, 0.3f, 0.0f};
+
+ System.out.println("Option Command line argument order (first 4 numerical, last 2 boolean)\ntextDepth xRotspeed yRotspeed zRotspeed filled flatnormal");
+ System.out.println("Keyboard Inputs (case sensitive)\n" +
+ "r: toggle rotation\n" +
+ "R: change rotation speeds\n" +
+ "n: toggle flat normals\n" +
+ "f: toggle filled text\n" +
+ "t: edit text\n" +
+ "</>: decrease/increase text depth\n" +
+ "F: change font\n" +
+ "s: resize font");
+ final String[] argsFin = args;
+ Font font = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()[5];
+ final FontDrawer dttf = new FontDrawer(font);
+ final StringBuffer upperStr = new StringBuffer("0,0");
+ final StringBuffer lowerStr = new StringBuffer("-1,-1");
+
+ GLEventListener listener = new GLEventListener() {
+ GLU glu;
+ float xrot,yrot,zrot;
+ float dpth = 0.2f;
+ boolean filled = true, fnorm = true;
+ net.java.joglutils.lighting.Light lt;
+ net.java.joglutils.lighting.Material mt;
+
+
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
+ }
+
+ public void init(GLAutoDrawable drawable) {
+ drawable.setGL(new DebugGL(drawable.getGL()));
+ glu = new GLU();
+ switch(argsFin.length) {
+ case 6:
+ fnorm = Boolean.parseBoolean(argsFin[5]);
+ case 5:
+ filled = Boolean.parseBoolean(argsFin[4]);
+ case 4:
+ rotSteps[2] = Float.parseFloat(argsFin[3]);
+ case 3:
+ rotSteps[1] = Float.parseFloat(argsFin[2]);
+ case 2:
+ rotSteps[0] = Float.parseFloat(argsFin[1]);
+ case 1:
+ dpth = Float.parseFloat(argsFin[0]);
+ }
+ dttf.setDepth(dpth);
+ dttf.setFill(filled);
+ dttf.setFlatNormals(fnorm);
+
+ xrot = 0;yrot = 0;zrot = 0;
+ GL gl = drawable.getGL();
+ lt = new net.java.joglutils.lighting.Light(gl);
+ //mt = new net.java.joglutils.lighting.Material(gl);
+
+
+ lt.setLightPosition(0,0,1);
+ lt.enable();
+ lt.apply();
+ //mt.apply();
+ gl.glColorMaterial( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE ) ;
+
+ gl.glEnable(GL.GL_DEPTH_TEST);
+ gl.glEnable(GL.GL_LIGHTING);
+ gl.glEnable(GL.GL_NORMALIZE);
+
+ gl.glClearColor(0.3f,0.5f,0.2f,0);
+ }
+
+ public void drawAxis(GL gl) {
+ gl.glDisable(GL.GL_LIGHTING);
+ gl.glBegin(GL.GL_LINES);
+ gl.glColor3f(1,0,0);
+ gl.glVertex3i(0,0,0);
+ gl.glVertex3i(10,0,0);
+ gl.glColor3f(0,1,0);
+ gl.glVertex3i(0,0,0);
+ gl.glVertex3i(0,10,0);
+ gl.glColor3f(0,0,1);
+ gl.glVertex3i(0,0,0);
+ gl.glVertex3i(0,0,10);
+ gl.glEnd();
+ gl.glEnable(GL.GL_LIGHTING);
+ }
+
+ public void display(GLAutoDrawable drawable) {
+ GL gl = drawable.getGL();
+ gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
+
+ gl.glMatrixMode(GL.GL_PROJECTION);
+ gl.glLoadIdentity();
+ glu.gluPerspective(90,1,0.001,10);
+ //gl.glFrustum(-1.5f,1.5f,-1.5f,1.5f,1,5);
+ //gl.glOrtho(-5,5,-5,5,-5,5);
+
+ gl.glMatrixMode(GL.GL_MODELVIEW);
+ gl.glLoadIdentity();
+ glu.gluLookAt(0,0,2,0,0,0,0,1,0);
+ //drawAxis(gl);
+ gl.glRotatef(xrot,1.0f,0,0);
+ gl.glRotatef(yrot,0,1.0f,0);
+ gl.glRotatef(zrot,0,0,1.0f);
+ xrot+=rotSteps[0];
+ yrot+=rotSteps[1];
+ zrot+=rotSteps[2];
+
+
+ drawAxis(gl);
+ dttf.drawString(upperStr.toString(),glu,gl);
+ dttf.drawString(lowerStr.toString(),glu,gl,-0.8f,-0.8f,0);
+ }
+
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
+ }
+
+ };
+ final net.java.joglutils.GLJFrame gljf = new net.java.joglutils.GLJFrame("FontDrawerDemo", listener, 600, 600);
+ gljf.setDefaultCloseOperation(gljf.EXIT_ON_CLOSE);
+ gljf.addKeyListener(new java.awt.event.KeyAdapter() {
+
+ public void keyPressed(KeyEvent e) {
+ switch (e.getKeyChar()) {
+ case 'f':
+ FontDrawer fd = dttf;
+ dttf.setFill(!dttf.isFill());
+ break;
+ case 'n':
+ dttf.setFlatNormals(!dttf.isFlatNormals());
+ break;
+ case 'r':
+ Animator anim = gljf.getAnimator();
+ if(anim.isAnimating())
+ anim.stop();
+ else
+ anim.start();
+ break;
+ case 'R':
+ //TODO:change rotation speed
+ String strRes;
+ strRes = JOptionPane.showInputDialog("X Rotation Speed?",Float.toString(rotSteps[0]));
+ if (strRes != null) {
+ rotSteps[0] = Float.parseFloat(strRes);
+ strRes = JOptionPane.showInputDialog("Y Rotation Speed?",Float.toString(rotSteps[1]));
+ if (strRes != null) {
+ rotSteps[1] = Float.parseFloat(strRes);
+ strRes = JOptionPane.showInputDialog("Z Rotation Speed?",Float.toString(rotSteps[2]));
+ if (strRes != null)
+ rotSteps[2] = Float.parseFloat(strRes);
+ }
+ }
+ break;
+ case '>':
+ case '.':
+ float depthStep = dttf.getFont().getSize()/20.0f;
+ dttf.setDepth(dttf.getDepth() + depthStep);
+ break;
+ case '<':
+ case ',':
+ depthStep = dttf.getFont().getSize()/20.0f;
+ dttf.setDepth(dttf.getDepth() - depthStep);
+ break;
+ case 't':
+ case 'T':
+ String up = JOptionPane.showInputDialog("Upper Text:",upperStr.toString());
+ upperStr.delete(0,upperStr.length());
+ upperStr.append(up);
+ String dn = JOptionPane.showInputDialog("Lower Text:",lowerStr.toString());
+ lowerStr.delete(0,lowerStr.length());
+ lowerStr.append(dn);
+ break;
+ case 'F':
+ Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
+
+ JPanel pan = new JPanel();
+ JComboBox cb = new JComboBox();
+ for (Font f : fonts)
+ cb.addItem(f);
+ cb.setSelectedItem(dttf.getFont());
+ pan.add(cb);
+ net.java.joglutils.JPanelDialog jpd = new net.java.joglutils.JPanelDialog("Choose Font",pan);
+ if (jpd.showAsModal())
+ dttf.setFont((Font)cb.getSelectedItem());
+ break;
+ case 's':
+ Font currFont = dttf.getFont();
+ String resultStr = JOptionPane.showInputDialog("Font Size?",Integer.toString(currFont.getSize()));
+ float targSize = Float.parseFloat(resultStr);
+ dttf.setFont(currFont.deriveFont(currFont.getStyle(),targSize));
+ break;
+ }
+ gljf.repaint();
+ }
+ });
+ gljf.generateAnimator();
+ gljf.setVisible(true);
+ }
+}
diff --git a/src/net/java/joglutils/jogltext/FontDrawer.java b/src/net/java/joglutils/jogltext/FontDrawer.java index a8a1c6a..d50e1a8 100644 --- a/src/net/java/joglutils/jogltext/FontDrawer.java +++ b/src/net/java/joglutils/jogltext/FontDrawer.java @@ -1,14 +1,47 @@ +/*
+ * Copyright (c) 2006 Erik Tollerud ([email protected]) All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * The names of Erik Tollerud, Davide Raccagni, Sun Microsystems, Inc. or the names of
+ * contributors may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * 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. ERIK TOLLERUD,
+ * SUN MICROSYSTEMS, INC. ("SUN"), AND SUN'S LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ERIK
+ * TOLLERUD, SUN, OR SUN'S 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 THIS SOFTWARE, EVEN IF ERIK
+ * TOLLERUD OR SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ */
+
package net.java.joglutils.jogltext;
import java.awt.*;
-import java.awt.event.*;
import java.awt.geom.*;
import java.awt.font.*;
-import java.io.*;
import java.text.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
-import com.sun.opengl.util.*;
/**
* This class renders a TrueType Font into OpenGL
@@ -73,11 +106,11 @@ public class FontDrawer { new StringCharacterIterator(str));
GeneralPath gp = (GeneralPath)gv.getOutline();
PathIterator pi = gp.getPathIterator(AffineTransform.getScaleInstance(1.0, -1.0), 1.0f);
- gl.glNormal3i(0,0,1);
+ gl.glNormal3i(0,0,-1);
tesselateFace(glu, gl, pi, pi.getWindingRule(), this.edgeOnly);
if (this.depth != 0.0) {
pi = gp.getPathIterator(AffineTransform.getScaleInstance(1.0, -1.0), 1.0f);
- gl.glNormal3i(0,0,-1);
+ gl.glNormal3i(0,0,1);
tesselateFace(glu, gl, pi, pi.getWindingRule(), this.edgeOnly, this.depth);
pi = gp.getPathIterator(AffineTransform.getScaleInstance(1.0, -1.0), 1.0f);
if (this.flatNorm)
@@ -156,7 +189,7 @@ public class FontDrawer { //TODO: work out texture coords
//TODO:work out double vs. float
- if (justBoundary)
+ if (justBoundary)
gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_LINE);
else
gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL);
@@ -168,9 +201,9 @@ public class FontDrawer { case PathIterator.SEG_MOVETO:
gl.glBegin(GL.GL_QUADS);
lastCoord[0] = coords[0];
- lastCoord[1] = coords[1];
+ lastCoord[1] = coords[1];
firstCoord[0] = coords[0];
- firstCoord[1] = coords[1];
+ firstCoord[1] = coords[1];
break;
case PathIterator.SEG_LINETO:
//Normal: {deltay,-deltax,0}
@@ -211,7 +244,7 @@ public class FontDrawer { //TODO: work out texture coords
//TODO: improve performance
- if (justBoundary)
+ if (justBoundary)
gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_LINE);
else
gl.glPolygonMode(GL.GL_FRONT_AND_BACK,GL.GL_FILL);
@@ -252,8 +285,7 @@ public class FontDrawer { secondNorm[0] = avgdeltay;
secondNorm[1] = -avgdeltax;
secondNorm[2] = 0;
- }
- else if (thirdNorm == null) {
+ } else if (thirdNorm == null) {
thirdNorm = new float[3];
thirdNorm[0] = avgdeltay;
thirdNorm[1] = -avgdeltax;
@@ -264,14 +296,14 @@ public class FontDrawer { gl.glVertex3fv(oneBackCoord,0);
oneBackCoord[2] = tessZ;
gl.glVertex3fv(oneBackCoord,0);
-
+
//copy to not have to recreate
twoBackCoord[0] = oneBackCoord[0];
twoBackCoord[1] = oneBackCoord[1];
oneBackCoord[0] = coords[0];
oneBackCoord[1] = coords[1];
}
- break;
+ break;
case PathIterator.SEG_CLOSE:
float avgdeltax = oneBackCoord[0] - twoBackCoord[0] + firstCoord[0] - oneBackCoord[0];
float avgdeltay = oneBackCoord[1] - twoBackCoord[1] + firstCoord[1] - oneBackCoord[1];
@@ -318,152 +350,6 @@ public class FontDrawer { }
}
-
- /**
- * Generates {@link GLJFrame}
- * Generates a GLJFrame with a FontDrawer demo. Console output describes input.
- * @param args Command Line argument order: textDepth xRotspeed yRotspeed zRotspeed filled flatnormal
- *
- */
- public static void main(String[] args) {
- System.out.println("Option Command line argument order (first 4 numerical, last 2 boolean)\ntextDepth xRotspeed yRotspeed zRotspeed filled flatnormal");
- System.out.println("Keyboard Inputs (case sensitive)\nr: toggle rotation\nn: toggle flat normals\nf: toggle filled text\nt: change text\nF: change font");
- final String[] argsFin = args;
- Font font = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()[5];
- final FontDrawer dttf = new FontDrawer(font);
- final StringBuffer upperStr = new StringBuffer("0,0");
- final StringBuffer lowerStr = new StringBuffer("-1,-1");
-
- GLEventListener listener = new GLEventListener() {
- GLU glu;
- float xrot,yrot,zrot,xstep = 0,ystep = 0.1f,zstep = 0;
- float dpth = 0.2f;
- boolean filled = true, fnorm = true;
- net.java.joglutils.lighting.Light lt;
- net.java.joglutils.lighting.Material mt;
-
-
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
- }
-
- public void init(GLAutoDrawable drawable) {
- drawable.setGL(new DebugGL(drawable.getGL()));
- glu = new GLU();
- switch(argsFin.length) {
- case 6:
- fnorm = Boolean.parseBoolean(argsFin[5]);
- case 5:
- filled = Boolean.parseBoolean(argsFin[4]);
- case 4:
- zstep = Float.parseFloat(argsFin[3]);
- case 3:
- ystep = Float.parseFloat(argsFin[2]);
- case 2:
- xstep = Float.parseFloat(argsFin[1]);
- case 1:
- dpth = Float.parseFloat(argsFin[0]);
- }
- dttf.setDepth(dpth);
- dttf.setFill(filled);
- dttf.setFlatNormals(fnorm);
-
- xrot = 0;yrot = 0;zrot = 0;
- GL gl = drawable.getGL();
- lt = new net.java.joglutils.lighting.Light(gl);
- //mt = new net.java.joglutils.lighting.Material(gl);
-
-
- lt.setLightPosition(0,0,1);
- lt.enable();
- lt.apply();
- //mt.apply();
- gl.glColorMaterial ( GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE ) ;
-
- gl.glEnable(GL.GL_DEPTH_TEST);
- gl.glEnable(GL.GL_LIGHTING);
- gl.glEnable(GL.GL_NORMALIZE);
-
- gl.glClearColor(0.3f,0.5f,0.2f,0);
- }
-
- public void display(GLAutoDrawable drawable) {
- GL gl = drawable.getGL();
-
- gl.glMatrixMode(GL.GL_PROJECTION);
- gl.glLoadIdentity();
- //glu.gluPerspective(90,1,0.001,10);
- //gl.glFrustum(-1.5f,1.5f,-1.5f,1.5f,1,5);
-
- gl.glMatrixMode(GL.GL_MODELVIEW);
- gl.glLoadIdentity();
- //glu.gluLookAt(0,0,-2,0,0,1,0,1,0);
- gl.glRotatef(xrot,1.0f,0,0);
- gl.glRotatef(yrot,0,1.0f,0);
- gl.glRotatef(zrot,0,0,1.0f);
- xrot+=xstep;
- yrot+=ystep;
- zrot+=zstep;
-
-
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- dttf.drawString(upperStr.toString(),glu,gl);
- dttf.drawString(lowerStr.toString(),glu,gl,-0.8f,-0.8f,0);
- }
-
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
- }
-
- };
- final net.java.joglutils.GLJFrame gljf = new net.java.joglutils.GLJFrame("FontDrawerDemo", listener, 600, 600);
- gljf.setDefaultCloseOperation(gljf.EXIT_ON_CLOSE);
- gljf.addKeyListener(new java.awt.event.KeyAdapter() {
-
- public void keyPressed(KeyEvent e) {
- switch (e.getKeyChar()) {
- case 'f':
- FontDrawer fd = dttf;
- dttf.setFill(!dttf.isFill());
- break;
- case 'n':
- dttf.setFlatNormals(!dttf.isFlatNormals());
- break;
- case 'r':
- Animator anim = gljf.getAnimator();
- if(anim.isAnimating())
- anim.stop();
- else
- anim.start();
- break;
- case '>':
- case '.':
- float depthStep = dttf.getFont().getSize()/20.0f;
- dttf.setDepth(dttf.getDepth() + depthStep);
- break;
- case '<':
- case ',':
- depthStep = dttf.getFont().getSize()/20.0f;
- dttf.setDepth(dttf.getDepth() - depthStep);
- break;
- case 't':
- case 'T':
- String up = javax.swing.JOptionPane.showInputDialog("Upper Text:",upperStr.toString());
- upperStr.delete(0,upperStr.length());
- upperStr.append(up);
- String dn = javax.swing.JOptionPane.showInputDialog("Lower Text:",lowerStr.toString());
- lowerStr.delete(0,lowerStr.length());
- lowerStr.append(dn);
- break;
- case 'F':
- //TODO:implement font change
- break;
- }
- gljf.repaint();
- }
- });
- gljf.generateAnimator();
- gljf.setVisible(true);
- }
-
private class GLUtesselatorCallbackImpl extends javax.media.opengl.glu.GLUtessellatorCallbackAdapter {
private GL gl;
diff --git a/src/net/java/joglutils/jogltext/JogltextException.java b/src/net/java/joglutils/jogltext/JogltextException.java index 34a160f..2018b30 100644 --- a/src/net/java/joglutils/jogltext/JogltextException.java +++ b/src/net/java/joglutils/jogltext/JogltextException.java @@ -1,10 +1,37 @@ /*
- * jogltextException.java
- *
- * Created on December 20, 2006, 8:46 AM
- *
- * To change this template, choose Tools | Template Manager
- * and open the template in the editor.
+ * Copyright (c) 2006 Erik Tollerud ([email protected]) All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * The names of Erik Tollerud, Sun Microsystems, Inc. or the names of
+ * contributors may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * 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. ERIK TOLLERUD,
+ * SUN MICROSYSTEMS, INC. ("SUN"), AND SUN'S LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL ERIK
+ * TOLLERUD, SUN, OR SUN'S 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 THIS SOFTWARE, EVEN IF ERIK
+ * TOLLERUD OR SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
*/
package net.java.joglutils.jogltext;
diff --git a/src/net/java/joglutils/lighting/LightPanel.java b/src/net/java/joglutils/lighting/LightPanel.java index d87564d..09419c6 100644 --- a/src/net/java/joglutils/lighting/LightPanel.java +++ b/src/net/java/joglutils/lighting/LightPanel.java @@ -409,19 +409,5 @@ public class LightPanel extends javax.swing.JPanel { }
- public static void main(String args[]) {
- Light l = new Light();
- LightPanel lp = new LightPanel(l);
- net.java.joglutils.JPanelDialog jdp = new net.java.joglutils.JPanelDialog(lp);
- jdp.setTitle("the new title");
- System.err.println("bf modal show");
- boolean accept = jdp.showAsModal();
- System.err.println("after modal show");
- if (accept) {
- lp.panelToLight(l);
- System.err.println("Light Number:"+l.getLightNumber()+" const atten:"+l.getConstantAttenuation());
- } else
- System.err.println("cancelled");
-
- }
+
}
diff --git a/src/net/java/joglutils/lighting/MaterialPanel.java b/src/net/java/joglutils/lighting/MaterialPanel.java index 779f65a..d1b3361 100644 --- a/src/net/java/joglutils/lighting/MaterialPanel.java +++ b/src/net/java/joglutils/lighting/MaterialPanel.java @@ -173,19 +173,5 @@ public class MaterialPanel extends javax.swing.JPanel { m.setSpecular(this.specularButton.getForeground());
m.setEmissive(this.emissiveButton.getForeground());
}
- public static void main(String[] args) {
- Material m = new Material();
- MaterialPanel mp = new MaterialPanel(m);
- net.java.joglutils.JPanelDialog jdp = new net.java.joglutils.JPanelDialog(mp);
- jdp.setTitle("the new title");
- System.err.println("bf modal show");
- boolean accept = jdp.showAsModal();
- System.err.println("after modal show");
- if (accept) {
- mp.panelToMat(m);
- System.err.println("shininess:"+m.getShininess()+" Emissive color:"+m.getEmissive());
- } else
- System.err.println("cancelled");
- }
}
|