You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(116) |
May
(220) |
Jun
(52) |
Jul
(30) |
Aug
(35) |
Sep
(24) |
Oct
(49) |
Nov
(44) |
Dec
(70) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(21) |
Feb
(30) |
Mar
(9) |
Apr
(44) |
May
(2) |
Jun
|
Jul
(10) |
Aug
(20) |
Sep
(25) |
Oct
(12) |
Nov
(16) |
Dec
(4) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(4) |
Jul
(25) |
Aug
|
Sep
|
Oct
|
Nov
(26) |
Dec
(10) |
2006 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(33) |
2007 |
Jan
(4) |
Feb
(57) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ma...@us...> - 2004-02-13 06:51:51
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23606/sampleData Modified Files: testBicubic.rib teapot.rib Log Message: First PatchMesh implementation. Index: testBicubic.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/testBicubic.rib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** testBicubic.rib 9 Feb 2004 21:34:52 -0000 1.1 --- testBicubic.rib 13 Feb 2004 06:46:24 -0000 1.2 *************** *** 1,26 **** ! Display "bicubic" "framebuffer" "rgba" ! PixelFilter "gaussian" 2 2 ! Format 800 600 1 ! PixelSamples 4 4 ! Exposure 1 2.2 ! Projection "perspective" "fov" [20] ! WorldBegin ! Translate 0 0 20 ! Rotate -120 1 0 0 ! LightSource "ambientlight" 1 "intensity" [0.2] ! LightSource "distantlight" 2 "intensity" [0.8] "from" [-10 -10 10] "to" [0 0 0] ! ! Surface "paintedplastic" "texturename" "checkerboard.txr" ! Basis "bezier" 2 "bezier" 2 ! Patch "bicubic" ! "P" [ ! -3 -3 0 -1 -3 0 1 -3 0 3 -3 0 ! -3 -1 0 -1 -1 -5 1 -1 1 3 -1 0 ! -3 1 0 -1 1 1 1 1 1 3 1 0 ! -3 3 0 -1 3 0 1 3 -1 3 3 0 ! ] ! "s" [0 4 0 4] ! "t" [0 0 4 4] ! ! WorldEnd ! --- 1,32 ---- ! Display "bicubic" "framebuffer" "rgba" ! PixelFilter "gaussian" 2 2 ! Format 800 600 1 ! PixelSamples 4 4 ! Exposure 1 2.2 ! Projection "perspective" "fov" [20] ! WorldBegin ! Translate 0 0 20 ! Rotate -120 1 0 0 ! LightSource "ambientlight" 1 "intensity" [0.2] ! LightSource "distantlight" 2 "intensity" [0.8] "from" [-10 -10 10] "to" [0 0 0] ! AttributeBegin ! Color .3 .5 1 ! ShadingRate 200 ! ShadingInterpolation "smooth" ! Sphere 1000 -1000 1000 360 ! AttributeEnd ! ShadingRate .25 ! Surface "paintedplastic" "texturename" "checkerboard.txr" ! Basis "bezier" 2 "bezier" 2 ! Patch "bicubic" ! "P" [ ! -3 -3 0 -1 -3 0 1 -3 0 3 -3 0 ! -3 -1 0 -1 -1 -5 1 -1 1 3 -1 0 ! -3 1 0 -1 1 1 1 1 1 3 1 0 ! -3 3 0 -1 3 0 1 3 -1 3 3 0 ! ] ! "s" [0 4 0 4] ! "t" [0 0 4 4] ! ! WorldEnd ! Index: teapot.rib =================================================================== RCS file: /cvsroot/jrman/drafts/sampleData/teapot.rib,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** teapot.rib 8 Apr 2003 20:02:30 -0000 1.1 --- teapot.rib 13 Feb 2004 06:46:24 -0000 1.2 *************** *** 1,3 **** --- 1,29 ---- + Display "teapot" "framebuffer" "rgba" + Format 800 600 1.0 + PixelSamples 4 4 + Exposure 1.0 2.2 + Option "quality" "highlights" 1 + Projection "perspective" "fov" 3.2 + + Translate 0 -1 100 + Rotate -100 1 0 0 + WorldBegin + LightSource "ambientlight" 1 "intensity" .1 + LightSource "distantlight" 2 "intensity" .7 + "from" [-50 300 200] "to" [0 0 0] + LightSource "distantlight" 2 "intensity" 0.1 + "from" [-50 -300 200] "to" [0 0 0] + LightSource "distantlight" 2 "intensity" 0.1 + "from" [50 -200 10] "to" [0 0 0] + + Color [1 1 1] + Surface "paintedplastic" "roughness" .01 + "texturename" "brick.txr" + Displacement "noisetest" "uniform float noisescale" 2 + "uniform integer noiseoctaves" 4 + "uniform float Km" 0.15 + Attribute "displacementbound" "sphere" 0.15 AttributeBegin + ShadingRate .25 Basis "bezier" 3 "bezier" 3 PatchMesh "bicubic" 13 "nonperiodic" 10 "nonperiodic" "P" [1.5 0 0 1.5 0.828427 0 0.828427 1.5 0 0 1.5 0 -0.828427 1.5 0 -1.5 0.828427 0 -1.5 0 0 -1.5 -0.828427 0 -0.828427 -1.5 0 0 -1.5 0 0.828427 -1.5 0 1.5 -0.828427 0 1.5 0 0 1.5 0 0.075 1.5 0.828427 0.075 0.828427 1.5 0.075 0 1.5 0.075 -0.828427 1.5 0.075 -1.5 0.828427 0.075 -1.5 0 0.075 -1.5 -0.828427 0.075 -0.828427 -1.5 0.075 0 -1.5 0.075 0.828427 -1.5 0.075 1.5 -0.828427 0.075 1.5 0 0.075 2 0 0.3 2 1.10457 0.3 1.10457 2 0.3 0 2 0.3 -1.10457 2 0.3 -2 1.10457 0.3 -2 0 0.3 -2 -1.10457 0.3 -1.10457 -2 0.3 0 -2 0.3 1.10457 -2 0.3 2 -1.10457 0.3 2 0 0.3 2 0 0.75 2 1.10457 0.75 1.10457 2 0.75 0 2 0.75 -1.10457 2 0.75 -2 1.10457 0.75 -2 0 0.75 -2 -1.10457 0.75 -1.10457 -2 0.75 0 -2 0.75 1.10457 -2 0.75 2 -1.10457 0.75 2 0 0.75 2 0 1.2 2 1.10457 1.2 1.10457 2 1.2 0 2 1.2 -1.10457 2 1.2 -2 1.10457 1.2 -2 0 1.2 -2 -1.10457 1.2 -1.10457 -2 1.2 0 -2 1.2 1.10457 -2 1.2 2 -1.10457 1.2 2 0 1.2 1.75 0 1.725 1.75 0.966498 1.725 0.966498 1.75 1.725 0 1.75 1.725 -0.966498 1.75 1.725 -1.75 0.966498 1.725 -1.75 0 1.725 -1.75 -0.966498 1.725 -0.966498 -1.75 1.725 0 -1.75 1.725 0.966498 -1.75 1.725 1.75 -0.966498 1.725 1.75 0 1.725 1.5 0 2.25 1.5 0.828427 2.25 0.828427 1.5 2.25 0 1.5 2.25 -0.828427 1.5 2.25 -1.5 0.828427 2.25 -1.5 0 2.25 -1.5 -0.828427 2.25 -0.828427 -1.5 2.25 0 -1.5 2.25 0.828427 -1.5 2.25 1.5 -0.828427 2.25 1.5 0 2.25 1.4375 0 2.38125 1.4375 0.793909 2.38125 0.793909 1.4375 2.38125 0 1.4375 2.38125 -0.793909 1.4375 2.38125 -1.4375 0.793909 2.38125 -1.4375 0 2.38125 -1.4375 -0.793909 2.38125 -0.793909 -1.4375 2.38125 0 -1.4375 2.38125 0.793909 -1.4375 2.38125 1.4375 -0.793909 2.38125 1.4375 0 2.38125 1.3375 0 2.38125 1.3375 0.738681 2.38125 0.738681 1.3375 2.38125 0 1.3375 2.38125 -0.738681 1.3375 2.38125 -1.3375 0.738681 2.38125 -1.3375 0 2.38125 -1.3375 -0.738681 2.38125 -0.738681 -1.3375 2.38125 0 -1.3375 2.38125 0.738681 -1.3375 2.38125 1.3375 -0.738681 2.38125 1.3375 0 2.38125 1.4 0 2.25 1.4 0.773198 2.25 0.773198 1.4 2.25 0 1.4 2.25 -0.773198 1.4 2.25 -1.4 0.773198 2.25 -1.4 0 2.25 -1.4 -0.773198 2.25 -0.773198 -1.4 2.25 0 -1.4 2.25 0.773198 -1.4 2.25 1.4 -0.773198 2.25 1.4 0 2.25 ] *************** *** 10,11 **** --- 36,38 ---- PatchMesh "bicubic" 4 "nonperiodic" 7 "nonperiodic" "P" [3.2 0 2.25 3.2 -0.15 2.25 2.8 -0.15 2.25 2.8 0 2.25 3.45 0 2.3625 3.45 -0.15 2.3625 2.9 -0.25 2.325 2.9 0 2.325 3.525 0 2.34375 3.525 -0.25 2.34375 2.8 -0.25 2.325 2.8 0 2.325 3.3 0 2.25 3.3 -0.25 2.25 2.7 -0.25 2.25 2.7 0 2.25 2.4 0 1.875 2.4 -0.25 1.875 2.3 -0.25 1.95 2.3 0 1.95 3.1 0 0.675 3.1 -0.66 0.675 2.6 -0.66 1.275 2.6 0 1.275 1.7 0 0.45 1.7 -0.66 0.45 1.7 -0.66 1.275 1.7 0 1.275 ] AttributeEnd + WorldEnd \ No newline at end of file |
From: <ma...@us...> - 2004-02-13 06:51:51
|
Update of /cvsroot/jrman/drafts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23606 Modified Files: .classpath Log Message: First PatchMesh implementation. Index: .classpath =================================================================== RCS file: /cvsroot/jrman/drafts/.classpath,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** .classpath 11 Dec 2003 15:08:05 -0000 1.7 --- .classpath 13 Feb 2004 06:46:23 -0000 1.8 *************** *** 1,8 **** ! <?xml version="1.0" encoding="UTF-8"?> ! <classpath> ! <classpathentry kind="src" path="src"/> ! <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> ! <classpathentry kind="lib" path="lib/vecmath.jar"/> ! <classpathentry kind="lib" path="lib/commons-cli-1.0.jar"/> ! <classpathentry kind="output" path="build"/> ! </classpath> --- 1,10 ---- ! <?xml version="1.0" encoding="UTF-8"?> ! <classpath> ! <classpathentry kind="src" path="src"/> ! <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> ! <classpathentry kind="lib" path="lib/vecmath.jar"/> ! <classpathentry kind="lib" path="lib/commons-cli-1.0.jar"/> ! <classpathentry kind="lib" path="lib/forms-1.0.3.jar"/> ! <classpathentry kind="lib" path="lib/looks-1.2.0.jar"/> ! <classpathentry kind="output" path="build"/> ! </classpath> |
From: <afa...@us...> - 2004-02-11 16:24:44
|
Update of /cvsroot/jrman/drafts/jrMan/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19917/jrMan/bin Added Files: jrmangui.bat jrmangui Log Message: Launch scripts for new GUI --- NEW FILE: jrmangui.bat --- @echo off set CLASSPATH=%JRMAN_HOME%\jar\jrman.jar;%JRMAN_HOME%\jar\vecmath.jar;%JRMAN_HOME%\jar\commons-cli-1.0.jar;%JRMAN_HOME%\jar\forms-1.0.3.jar;%JRMAN_HOME%\jar\looks-1.2.0.jar set MEMORY=160m java -Xms%MEMORY% -Xmx%MEMORY% org.jrman.main.JRManGUI --- NEW FILE: jrmangui --- export CLASSPATH=$JRMAN_HOME/jar/jrman.jar:$JRMAN_HOME/jar/vecmath.jar:$JRMAN_HOME/jar/commons-cli-1.0.jar:$JRMAN_HOME/jar/form-1.0.3.jar:$JRMAN_HOME/jar/looks-1.2.0.jar export MEMORY=160m java -Xms$MEMORY -Xmx$MEMORY org.jrman.main.JRManGUI |
From: <afa...@us...> - 2004-02-11 16:23:52
|
Update of /cvsroot/jrman/drafts/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19572/lib Added Files: forms-1.0.3.jar looks-1.2.0.jar Log Message: Libraries for new GUI --- NEW FILE: forms-1.0.3.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: looks-1.2.0.jar --- (This appears to be a binary file; contents omitted.) |
From: <afa...@us...> - 2004-02-11 16:22:17
|
Update of /cvsroot/jrman/drafts/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19293/src Modified Files: SurfacePnoisetest.java Log Message: Shader for periodic noise Index: SurfacePnoisetest.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/SurfacePnoisetest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SurfacePnoisetest.java 13 Jan 2004 09:49:16 -0000 1.1 --- SurfacePnoisetest.java 11 Feb 2004 16:18:04 -0000 1.2 *************** *** 60,68 **** cg2.mul(cg2, cg3); cg1.add(cg1, cg2); ! // fg1.mul(sv.u, noisescale); ! // fg2.mul(sv.v, noisescale); ! // fg1.pnoise(fg1, fg2, period, period); ! vg1.mul(sv.P, noisescale); ! fg1.pnoise(vg1, period, period, period); cg3.set(fg1); cg1.mul(cg1, cg3); --- 60,68 ---- cg2.mul(cg2, cg3); cg1.add(cg1, cg2); ! fg1.mul(sv.u, noisescale); ! fg2.mul(sv.v, noisescale); ! fg1.pnoise(fg1, fg2, period, period); ! // vg1.mul(sv.P, noisescale); ! // fg1.pnoise(vg1, period, period, period); cg3.set(fg1); cg1.mul(cg1, cg3); |
From: <afa...@us...> - 2004-02-11 16:21:05
|
Update of /cvsroot/jrman/drafts/src/org/jrman/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19019/src/org/jrman/ui Modified Files: MainFrame.java Added Files: QueuePanel.java OptionsPanel.java ProgressObserver.java BasePanel.java AboutDialog.java RenderPanel.java ProgressObservable.java TextAreaPrintStream.java RenderRunnable.java Log Message: New totally revamped GUI: - needs JDK 1.4.2 (exact) - custom look and feel - Ability to specify rendering options - Better management of the rendering queue - Output messages captured in text area --- NEW FILE: QueuePanel.java --- /* * QueuePanel.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.io.File; import javax.swing.*; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import net.falappa.swing.ExtensionFileFilter; import com.jgoodies.forms.builder.PanelBuilder; import com.jgoodies.forms.factories.Borders; import com.jgoodies.forms.factories.ButtonBarFactory; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; /** * Is the panel managing a render queue of rib files. * <P> * Consists of a list and two buttons. * Allows to add & remove multiple selections of rib files * to the queue. * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public class QueuePanel extends BasePanel { private DefaultListModel dlmQueue= new DefaultListModel(); private JList lQueue= new JList(dlmQueue); private AddToQueueAction addAction= new AddToQueueAction(); private RemoveFromQueueAction removeAction= new RemoveFromQueueAction(); private JButton bAdd= new JButton(addAction); private JButton bRemove= new JButton(removeAction); private static final class FileListCellRenderer extends DefaultListCellRenderer { /* (non-Javadoc) * @see javax.swing.DefaultListCellRenderer#getListCellRendererComponent(javax.swing.JList, java.lang.Object, int, boolean, boolean) */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { // this method is almost that of the superclass except the setting of the icon setComponentOrientation(list.getComponentOrientation()); if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } setIcon(UIManager.getIcon("FileView.fileIcon")); setText((value == null) ? "" : value.toString()); setEnabled(list.isEnabled()); setFont(list.getFont()); setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); return this; } } /** * Constructs and initializes a QueuePanel object. */ public QueuePanel() { setTitle("1 - Queue"); // prepare components dlmQueue.addListDataListener(new ListDataListener() { public void intervalAdded(ListDataEvent e) { updateActions(); } public void intervalRemoved(ListDataEvent e) { updateActions(); } public void contentsChanged(ListDataEvent e) { updateActions(); } }); lQueue.setCellRenderer(new FileListCellRenderer()); lQueue.setBorder(Borders.createEmptyBorder("1dlu,1dlu,1dlu,1dlu")); lQueue.setVisibleRowCount(6); lQueue.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); lQueue.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateActions(); } } }); removeAction.setEnabled(false); JPanel bPanel= ButtonBarFactory.buildAddRemoveLeftBar(bAdd, bRemove); // set layout and fill the panel FormLayout layout= new FormLayout("fill:default:grow", "pref, 6dlu, fill:default:grow, 3dlu, pref"); CellConstraints cc= new CellConstraints(); PanelBuilder builder= new PanelBuilder(this, layout); builder.setBorder(Borders.TABBED_DIALOG_BORDER); builder.add(createInfoLabel("Select files to render"), cc.xy(1, 1)); builder.add(new JScrollPane(lQueue), cc.xy(1, 3)); builder.add(bPanel, cc.xy(1, 5)); } private void updateActions() { removeAction.setEnabled(dlmQueue.getSize() > 0 && lQueue.getSelectedIndex() >= 0); } private class AddToQueueAction extends AbstractAction { private JFileChooser chooser; public AddToQueueAction() { putValue(Action.NAME, "Add..."); putValue(Action.SHORT_DESCRIPTION, "Add rib file(s) to the render queue"); putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A)); putValue(Action.SMALL_ICON, new ImageIcon(getClass().getResource("images/plus.gif"))); } /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { //prepare and cache a file chooser (this allow also to remember last choosen directory) if (chooser == null) { chooser= new JFileChooser(); chooser.setDialogTitle("Select file(s) to enqueue"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setMultiSelectionEnabled(true); chooser.addChoosableFileFilter(new ExtensionFileFilter("rib")); } // prompt the dialog and add the files to the list model if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(QueuePanel.this)) { File[] files= chooser.getSelectedFiles(); if (files != null && files.length > 0) { for (int i= 0; i < files.length; i++) { dlmQueue.addElement(files[i]); } lQueue.setSelectedIndex(dlmQueue.getSize() - 1); } } } } private class RemoveFromQueueAction extends AbstractAction { public RemoveFromQueueAction() { putValue(Action.NAME, "Remove"); putValue(Action.SHORT_DESCRIPTION, "Removes the selected rib file(s) from the render queue"); putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R)); putValue(Action.SMALL_ICON, new ImageIcon(getClass().getResource("images/minus.gif"))); } /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { int[] idxs= lQueue.getSelectedIndices(); if (idxs != null && idxs.length > 0) { // ask for confirmation if more than one file is selected if (idxs.length > 1) { int choice= JOptionPane.showConfirmDialog(QueuePanel.this, "Removing " + idxs.length + " files.\nAre you sure?", "Confirmation", JOptionPane.YES_NO_OPTION); if (choice != JOptionPane.YES_OPTION) return; } // remove selected files starting from the bottom for (int i= idxs.length - 1; i >= 0; i--) { dlmQueue.remove(idxs[i]); } // select the first item or the item before the removed one if (idxs.length == 1) lQueue.setSelectedIndex(idxs[0] > 0 ? idxs[0]-- : 0); else lQueue.setSelectedIndex(0); } } } /** * @return */ public DefaultListModel getQueue() { return dlmQueue; } } --- NEW FILE: OptionsPanel.java --- /* * OptionsPanel.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.*; import org.jrman.main.JRMan; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.factories.Borders; import com.jgoodies.forms.layout.FormLayout; /** * Manages a set of jrMan options. * <P> * Allowed options are those available on the command line. * @see org.jrman.main.JRMan * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public class OptionsPanel extends BasePanel { private JTextField tfCustomOpts= new JTextField(); private JCheckBox cbQuality= new JCheckBox(); private JCheckBox cbStatistics= new JCheckBox(); private JCheckBox cbShowFramebuffer= new JCheckBox(); private JCheckBox cbFrameSubset= new JCheckBox(); private JSpinner spStartFrame= new JSpinner(); private JSpinner spEndFrame= new JSpinner(); private JLabel lFrom= new JLabel(); private JLabel lTo= new JLabel(); /** * Constructs and initializes a OptionsPanel object. * */ public OptionsPanel() { setTitle("2 - Options"); // prepare components cbShowFramebuffer.setText("Always show a framebuffer display (-d)"); cbQuality.setText("Hi quality rendering (-q)"); cbStatistics.setText("End of frame statistics (-s)"); cbFrameSubset.setText("Render frame subset (-f,-e)"); cbFrameSubset.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean enabled= (e.getStateChange() == ItemEvent.SELECTED); spStartFrame.setEnabled(enabled); spEndFrame.setEnabled(enabled); lFrom.setEnabled(enabled); lTo.setEnabled(enabled); } }); spStartFrame.setModel(new SpinnerNumberModel(1, 1, 9999, 1)); ((JSpinner.DefaultEditor)spStartFrame.getEditor()).getTextField().setColumns(4); spStartFrame.setEnabled(false); spEndFrame.setModel(new SpinnerNumberModel(1, 1, 9999, 1)); ((JSpinner.DefaultEditor)spEndFrame.getEditor()).getTextField().setColumns(4); spEndFrame.setEnabled(false); lFrom.setText("from"); lFrom.setEnabled(false); lTo.setText("to"); lTo.setEnabled(false); // set layout and fill the panel FormLayout layout= new FormLayout("12dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, pref:grow"); DefaultFormBuilder builder= new DefaultFormBuilder(this, layout); builder.setBorder(Borders.TABBED_DIALOG_BORDER); builder.append(createInfoLabel("Set rendering options"), 9); builder.append(cbShowFramebuffer, 9); builder.append(cbQuality, 9); builder.append(cbStatistics, 9); builder.nextLine(); builder.appendUnrelatedComponentsGapRow(); builder.nextLine(); builder.append(cbFrameSubset, 9); builder.setLeadingColumnOffset(1); builder.append(lFrom); builder.append(spStartFrame); builder.append(lTo); builder.append(spEndFrame); builder.nextLine(); builder.setLeadingColumnOffset(0); builder.appendUnrelatedComponentsGapRow(); builder.nextLine(); builder.append(new JLabel("Other commandline options:"), 8); builder.nextLine(); builder.append(tfCustomOpts, 9); builder.nextLine(); } /** * Builds an options string with the options set by the user in this panel. * @return the options string ready to be passed to the command line renderer */ public String getOptionsString() { StringBuffer sb= new StringBuffer(); if (cbQuality.isSelected()) sb.append('-').append(JRMan.OPTION_QUALITY).append(' '); if (cbShowFramebuffer.isSelected()) sb.append('-').append(JRMan.OPTION_FRAMEBUFFER).append(' '); if (cbStatistics.isSelected()) sb.append('-').append(JRMan.OPTION_STATISTICS).append(' '); if (cbFrameSubset.isSelected()) { sb.append('-').append(JRMan.OPTION_FIRSTFRAME).append(' ').append(spStartFrame.getValue()); sb.append(" -").append(JRMan.OPTION_LASTFRAME).append(' ').append(spEndFrame.getValue()); } if (tfCustomOpts.getText().length() > 0) sb.append(' ').append(tfCustomOpts.getText()); return sb.toString().trim(); } } --- NEW FILE: ProgressObserver.java --- /* * ProgressObserver.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; /** * Identifies an object interested in observing the progress of the * computation made by another object. * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public interface ProgressObserver { /** * Called when computation begins * @param startProgressValue the initial progress value * @param endProgressValue the last progress value */ void start(int startProgressValue, int endProgressValue); /** * Called periodically during the computation to indicate * the computation progress. * @param value the amount of progress, should go from * <code>startProgressValue</code> inclusive to <code>endProgressValue</code> * inclusive * @param message a descriptive message about the current step of the * computation, can be <code>null</code> * @see #start(int, int) */ void setProgress(int value,String message); /** * Called when computation ends */ void end(); } --- NEW FILE: BasePanel.java --- /* * BasePanel.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.awt.Color; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.CompoundBorder; import com.jgoodies.forms.factories.Borders; /** * A base class for panels intended to have a title string property * with a facility to create a nice label to contain instruction or * informational messages. * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ class BasePanel extends JPanel { private static ImageIcon infoIcon= new ImageIcon(BasePanel.class.getResource("images/help.gif")); private String title= "untitled"; /** * @return */ public String getTitle() { return title; } /** * @param string */ public void setTitle(String string) { title= string; } static JLabel createInfoLabel(String text) { JLabel lInfo= new JLabel(text, infoIcon, JLabel.LEADING); lInfo.setBorder(new CompoundBorder(BorderFactory.createEtchedBorder(), Borders.createEmptyBorder("1dlu,1dlu,1dlu,1dlu"))); lInfo.setOpaque(true); lInfo.setBackground(Color.white); return lInfo; } } --- NEW FILE: AboutDialog.java --- /* * AboutDialog.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.io.IOException; import java.io.InputStreamReader; import javax.swing.*; import org.jrman.main.JRMan; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.factories.Borders; import com.jgoodies.forms.factories.ButtonBarFactory; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; /** * The about dialog. * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public class AboutDialog extends JDialog { private final class CloseAction extends AbstractAction { public CloseAction(){ putValue(Action.MNEMONIC_KEY,new Integer(KeyEvent.VK_C)); putValue(Action.NAME,"Close"); putValue(Action.SHORT_DESCRIPTION,"Closes the dialog"); } public void actionPerformed(ActionEvent e) { dispose(); } }; private CloseAction closeAction=new CloseAction(); /** * Constructs and initializes a AboutDialog object. * @throws java.awt.HeadlessException */ public AboutDialog() throws HeadlessException { super(); commonInit(null); } /** * Constructs and initializes a AboutDialog object. * @param owner * @throws java.awt.HeadlessException */ public AboutDialog(Dialog owner) throws HeadlessException { super(owner); commonInit(owner); } /** * Constructs and initializes a AboutDialog object. * @param owner * @throws java.awt.HeadlessException */ public AboutDialog(Frame owner) throws HeadlessException { super(owner); commonInit(owner); } private void commonInit(Component parent) { setTitle("About"); // foremost about panel JLabel appName= new JLabel("JrManGUI v" + JRMan.majorNumber + "." + JRMan.minorNumber); appName.setFont(new Font("Sans Serif", Font.BOLD, 16)); JLabel logo= new JLabel(new ImageIcon(getClass().getResource("images/jrman_logo.png"))); logo.setBorder(BorderFactory.createEtchedBorder()); FormLayout layout= new FormLayout("pref:grow", "default:grow,pref, 6dlu,pref,default:grow"); DefaultFormBuilder builder= new DefaultFormBuilder(layout); CellConstraints cc= new CellConstraints(); builder.setBorder(Borders.TABBED_DIALOG_BORDER); builder.add(appName, cc.xy(1, 2)); builder.add(new JLabel("Graphical user interface frontend to JrMan"), cc.xy(1, 4)); JPanel pAbout= new JPanel(new BorderLayout()); pAbout.add(logo, BorderLayout.WEST); pAbout.add(builder.getPanel(), BorderLayout.CENTER); // authors panel JTextArea taAuthors= new JTextArea(8, 40); taAuthors.setEditable(false); try { taAuthors.read(new InputStreamReader(getClass().getResourceAsStream("texts/authors.txt")), null); } catch (IOException e1) { //ignored } JPanel pAuthors= new JPanel(new BorderLayout()); pAuthors.setBorder(Borders.TABBED_DIALOG_BORDER); pAuthors.add(new JScrollPane(taAuthors), BorderLayout.CENTER); // license panel JTextArea taLicense= new JTextArea(8, 40); taLicense.setEditable(false); try { taLicense.read(new InputStreamReader(getClass().getResourceAsStream("texts/disclaimer.txt")), null); } catch (IOException e2) { // ignored } JPanel pLicense= new JPanel(new BorderLayout()); pLicense.setBorder(Borders.TABBED_DIALOG_BORDER); pLicense.add(new JScrollPane(taLicense), BorderLayout.CENTER); // assemble JButton bClose= new JButton(closeAction); JTabbedPane tabbedPane= new JTabbedPane(); tabbedPane.setBorder(Borders.TABBED_DIALOG_BORDER); tabbedPane.add(pAbout, "About"); tabbedPane.add(pAuthors, "Authors"); tabbedPane.add(pLicense, "License"); setModal(true); setResizable(false); ((JComponent)getContentPane()).registerKeyboardAction(closeAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); getContentPane().add(tabbedPane, BorderLayout.CENTER); getContentPane().add(ButtonBarFactory.buildCloseBar(bClose), BorderLayout.SOUTH); pack(); if (parent != null) setLocationRelativeTo(parent); } } --- NEW FILE: RenderPanel.java --- /* * RenderPanel.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.io.PrintStream; import javax.swing.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.factories.Borders; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; /** * Manages start and cancel rendering of queued files and display of * rendering messages. * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public class RenderPanel extends BasePanel implements ProgressObserver { private RenderRunnable runnable; private CancelRenderAction cancelRenderAction= new CancelRenderAction(); private RenderAction renderAction= new RenderAction(); private JButton bRender= new JButton(renderAction); private JTextArea taMessages= new JTextArea(10, 40); private JProgressBar pbProgress= new JProgressBar(0, 100); private PrintStream oldOutStream=System.out; private PrintStream oldErrStream=System.err; private TextAreaPrintStream outRedirector=new TextAreaPrintStream(taMessages); private TextAreaPrintStream errRedirector=new TextAreaPrintStream(taMessages); /** * Constructs and initializes a RenderPanel object. */ public RenderPanel(RenderRunnable runnable) { if (runnable == null) throw new NullPointerException("Null RenderRunnable"); setTitle("3 - Render"); this.runnable= runnable; this.runnable.addProgressObserver(this); // prepare components taMessages.setEditable(false); taMessages.setMargin(new Insets(1, 3, 1, 3)); // set layout and fill the panel FormLayout layout= new FormLayout("fill:60dlu, 3dlu, 240dlu:grow", "pref,3dlu,pref,3dlu,fill:pref:grow"); DefaultFormBuilder builder= new DefaultFormBuilder(this, layout); builder.setBorder(Borders.TABBED_DIALOG_BORDER); CellConstraints cc= new CellConstraints(); builder.add(createInfoLabel("Start rendering and monitor progress"), cc.xywh(1, 1, 3, 1)); builder.add(bRender, cc.xy(1, 3)); builder.add(pbProgress, cc.xy(3, 3)); builder.add(new JScrollPane(taMessages), cc.xywh(1, 5, 3, 1)); } private class RenderAction extends AbstractAction { public RenderAction() { putValue(Action.NAME, "Render"); putValue(Action.SHORT_DESCRIPTION, "Starts rendering of the queued rib files"); putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R)); } /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { MainFrame.startRendering(); } } private class CancelRenderAction extends AbstractAction { public CancelRenderAction() { putValue(Action.NAME, "Cancel"); putValue(Action.SHORT_DESCRIPTION, "Cancel current rendering"); putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_C)); } /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { runnable.setCanceled(true); taMessages.append("Canceling queue rendering..."); } } /* (non-Javadoc) * @see org.jrman.ui.ProgressObserver#start(int, int) */ public void start(int startProgressValue, int endProgressValue) { pbProgress.setMinimum(startProgressValue); pbProgress.setMaximum(endProgressValue); pbProgress.setValue(startProgressValue); pbProgress.setStringPainted(true); taMessages.setText("Rendering of queued file(s) started.\n\n"); bRender.setAction(cancelRenderAction); // divert standard streams System.setOut(outRedirector); System.setErr(errRedirector); } /* (non-Javadoc) * @see org.jrman.ui.ProgressObserver#setProgress(int) */ public void setProgress(int value,String message) { pbProgress.setValue(value); pbProgress.setString(value + " file(s)"); taMessages.append("\n\n"); } /* (non-Javadoc) * @see org.jrman.ui.ProgressObserver#end() */ public void end() { bRender.setAction(renderAction); pbProgress.setValue(0); pbProgress.setStringPainted(false); taMessages.append("\nRendering of queued files finished."); // restore standard streams System.setOut(oldOutStream); System.setErr(oldErrStream); } } --- NEW FILE: ProgressObservable.java --- /* * ProgressObservable.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.util.ArrayList; import java.util.Iterator; /** * Represents an object making some lenghty computation and notifying * some <code>ProgressObserver</code> objects of its progress. * This class manages a list of <code>ProgressObserver</code> objects * allowing to add and remove observers and provides utility methods to * notify those objects of progress events. * @see org.jrman.ui.ProgressObserver * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public class ProgressObservable { protected ArrayList observers= new ArrayList(4); public void addProgressObserver(ProgressObserver observer) { if (observer == null) throw new NullPointerException("Can't add a null ProgressObserver"); observers.add(observer); } public void removeProgressObserver(ProgressObserver observer) { if (observer == null) throw new NullPointerException("Can't remove a null ProgressObserver"); observers.remove(observer); } protected void fireProgressStart(int startProgressValue, int endProgressValue) { Iterator i= observers.iterator(); while (i.hasNext()) ((ProgressObserver)i.next()).start(startProgressValue, endProgressValue); } protected void fireProgress(int progressValue,String message) { Iterator i= observers.iterator(); while (i.hasNext()) ((ProgressObserver)i.next()).setProgress(progressValue,message); } protected void fireProgressEnd() { Iterator i= observers.iterator(); while (i.hasNext()) ((ProgressObserver)i.next()).end(); } } --- NEW FILE: TextAreaPrintStream.java --- /* * TextAreaPrintStream.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import javax.swing.JTextArea; /** * A <code>PrintStream</code> that prints appending text into a <code>JTextArea</code>. * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public class TextAreaPrintStream extends PrintStream{ private JTextArea area; private static class NullOutputStream extends OutputStream{ /* (non-Javadoc) * @see java.io.OutputStream#write(int) */ public void write(int b) throws IOException { // do nothing } } /** * Constructs and initializes a TextAreaPrintStream object. * @param textArea the <code>JTextArea</code> object this stream will append text to */ public TextAreaPrintStream(JTextArea textArea) { super(new NullOutputStream()); if(textArea==null) throw new NullPointerException("textArea can't be null!"); this.area=textArea; } /* (non-Javadoc) * @see java.io.PrintStream#close() */ public void close(){ } /* (non-Javadoc) * @see java.io.PrintStream#flush() */ public void flush(){ } /* (non-Javadoc) * @see java.io.PrintStream#print(boolean) */ public void print(boolean b) { area.append(String.valueOf(b)); } /* (non-Javadoc) * @see java.io.PrintStream#print(char) */ public void print(char c) { area.append(String.valueOf(c)); } /* (non-Javadoc) * @see java.io.PrintStream#print(char[]) */ public void print(char[] s) { area.append(String.valueOf(s)); } /* (non-Javadoc) * @see java.io.PrintStream#print(double) */ public void print(double d) { area.append(String.valueOf(d)); } /* (non-Javadoc) * @see java.io.PrintStream#print(float) */ public void print(float f) { area.append(String.valueOf(f)); } /* (non-Javadoc) * @see java.io.PrintStream#print(int) */ public void print(int i) { area.append(String.valueOf(i)); } /* (non-Javadoc) * @see java.io.PrintStream#print(java.lang.Object) */ public void print(Object obj) { area.append(String.valueOf(obj)); } /* (non-Javadoc) * @see java.io.PrintStream#print(java.lang.String) */ public void print(String s) { area.append(s); } /* (non-Javadoc) * @see java.io.PrintStream#print(long) */ public void print(long l) { area.append(String.valueOf(l)); } /* (non-Javadoc) * @see java.io.PrintStream#println() */ public void println() { area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(boolean) */ public void println(boolean x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(char) */ public void println(char x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(char[]) */ public void println(char[] x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(double) */ public void println(double x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(float) */ public void println(float x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(int) */ public void println(int x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(java.lang.Object) */ public void println(Object x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(java.lang.String) */ public void println(String x) { area.append(String.valueOf(x)); area.append("\n"); } /* (non-Javadoc) * @see java.io.PrintStream#println(long) */ public void println(long x) { area.append(String.valueOf(x)); area.append("\n"); } } --- NEW FILE: RenderRunnable.java --- /* * RenderRunnable.java Copyright (C) 2004 Alessandro Falappa * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; import java.io.File; import javax.swing.DefaultListModel; import org.jrman.main.JRMan; class RenderRunnable extends ProgressObservable implements Runnable { private DefaultListModel queue; private String optionsString; private boolean canceled; // (non-Javadoc) // @see java.lang.Runnable#run() // public void run() { canceled= false; if (queue != null && optionsString != null) { // begin rendering of queue fireProgressStart(0, queue.size()); StringBuffer sb= new StringBuffer(optionsString.length() + 20); for (int i= 0; i < queue.size(); i++) { // prepare command line arguments String fileName= ((File)queue.elementAt(i)).getAbsolutePath(); sb.setLength(0); sb.append(optionsString).append(' ').append(fileName); // launch renderer passing the arguments /*TODO see if there's a way to change at this point the current directory * of the JVM to the parent directory of the current filename */ String[] tmp=sb.toString().split("\\s+"); JRMan.main(tmp); // signal file rendering completion and check for cancellation fireProgress(i + 1, fileName); if (canceled) break; } fireProgressEnd(); } } /** * @param b */ public void setCanceled(boolean b) { canceled= b; } /** * @param model */ public void setQueue(DefaultListModel model) { queue= model; } /** * @param string */ public void setOptionsString(String string) { optionsString= string; } } Index: MainFrame.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/ui/MainFrame.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MainFrame.java 8 Feb 2004 08:54:55 -0000 1.4 --- MainFrame.java 11 Feb 2004 16:16:51 -0000 1.5 *************** *** 1,268 **** /* ! * Created on 26-ott-2003 */ package org.jrman.ui; ! import java.awt.GridBagConstraints; ! import java.awt.GridBagLayout; import java.awt.HeadlessException; - import java.awt.Insets; import java.awt.event.ActionEvent; - import java.awt.event.ActionListener; import java.awt.event.KeyEvent; - import java.io.File; - import java.io.IOException; - - import javax.swing.AbstractAction; - import javax.swing.Action; - import javax.swing.BorderFactory; - import javax.swing.Box; - import javax.swing.DefaultListModel; - import javax.swing.ImageIcon; - import javax.swing.JButton; - import javax.swing.JFileChooser; - import javax.swing.JFrame; - import javax.swing.JLabel; - import javax.swing.JList; - import javax.swing.JPanel; - import javax.swing.JScrollPane; - import javax.swing.ListSelectionModel; - import javax.swing.ProgressMonitor; - import javax.swing.event.ListDataEvent; - import javax.swing.event.ListDataListener; - import javax.swing.event.ListSelectionEvent; - import javax.swing.event.ListSelectionListener; ! import net.falappa.swing.ExtensionFileFilter; ! import org.apache.commons.cli.CommandLine; ! import org.apache.commons.cli.ParseException; ! import org.jrman.parser.Parser; /** ! * A basic graphical user interface to select a group of file to render, start ! * the rendering process and monitoring its progress. * * @author Alessandro Falappa */ ! public class MainFrame extends JFrame { ! private CommandLine commandLine; ! private JButton bExit = new JButton("Exit"); ! private DefaultListModel dlm = new DefaultListModel(); ! private JList fileList = new JList(dlm); ! private class RenderRunnable implements Runnable { ! DefaultListModel queue; ! CommandLine commandLine; ! /* (non-Javadoc) ! * @see java.lang.Runnable#run() ! */ ! public void run() { ! if (queue != null && MainFrame.this.commandLine != null) { ! ProgressMonitor monitor = ! new ProgressMonitor( ! MainFrame.this, ! "Rendering:", ! "filename", ! 0, ! queue.size() + 1); ! monitor.setMillisToDecideToPopup(0); ! monitor.setMillisToPopup(0); ! monitor.setProgress(0); ! for (int i = 0; i < queue.size(); i++) { ! File f = (File) queue.elementAt(i); ! monitor.setNote(f.getName()); ! monitor.setProgress(i + 1); ! try { ! Parser parser = new Parser(commandLine); ! parser.begin(f.getAbsolutePath()); ! parser.parse(f.getAbsolutePath()); ! parser.end(); ! } catch (ParseException pe) { ! System.err.println(pe.getLocalizedMessage()); ! } catch (IOException ioe) { ! System.err.println( ! "Error on file " + ioe.getLocalizedMessage()); ! } catch (Exception e) { ! System.err.println(e.getLocalizedMessage()); ! } ! if (monitor.isCanceled()) ! break; ! } ! monitor.close(); ! renderAction.setEnabled(true); ! addAction.setEnabled(true); ! removeAction.setEnabled(true); ! } ! } } ! private class AddAction extends AbstractAction { ! private JFileChooser chooser; ! public AddAction() { ! putValue(Action.NAME, "Add..."); ! putValue( ! Action.SHORT_DESCRIPTION, ! "Add a rib file to the render queue"); ! putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_A)); } ! /* ! * (non-Javadoc) ! * * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { ! if (chooser == null) { ! chooser = new JFileChooser(); ! chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); ! chooser.addChoosableFileFilter(new ExtensionFileFilter("rib")); ! } ! if (JFileChooser.APPROVE_OPTION ! == chooser.showOpenDialog(MainFrame.this)) { ! File f = chooser.getSelectedFile(); ! if (f != null) { ! dlm.addElement(f); ! fileList.setSelectedIndex(dlm.getSize() - 1); ! } ! } } ! }; ! private class RemoveAction extends AbstractAction { ! public RemoveAction() { ! putValue(Action.NAME, "Delete"); ! putValue( ! Action.SHORT_DESCRIPTION, ! "Removes the selected rib file from the render queue"); ! putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); } ! /* ! * (non-Javadoc) ! * * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { ! int idx = fileList.getSelectedIndex(); ! if (idx >= 0) { ! dlm.remove(idx--); ! fileList.setSelectedIndex(idx < 0 ? 0 : idx); ! } } } ! private class RenderAction extends AbstractAction { ! public RenderAction() { ! putValue(Action.NAME, "Render"); ! putValue( ! Action.SHORT_DESCRIPTION, ! "Starts rendering of the queued rib files"); ! putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_R)); } ! /* ! * (non-Javadoc) ! * * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { ! this.setEnabled(false); ! addAction.setEnabled(false); ! removeAction.setEnabled(false); ! RenderRunnable runnable = new RenderRunnable(); ! runnable.queue = dlm; ! runnable.commandLine = commandLine; ! Thread t = new Thread(runnable, "renderthread"); ! t.start(); } - } - private AddAction addAction = new AddAction(); - private RemoveAction removeAction = new RemoveAction(); - private RenderAction renderAction = new RenderAction(); - private JButton bAdd = new JButton(addAction); - private JButton bRemove = new JButton(removeAction); - private JButton bRender = new JButton(renderAction); ! public MainFrame(CommandLine commandLine) throws HeadlessException { ! super("jrMan"); ! this.commandLine = commandLine; ! removeAction.setEnabled(false); ! renderAction.setEnabled(false); ! bExit.addActionListener(new ActionListener() { ! public void actionPerformed(ActionEvent e) { ! System.exit(0); ! } ! }); ! fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ! fileList.addListSelectionListener(new ListSelectionListener() { ! public void valueChanged(ListSelectionEvent e) { ! if (!e.getValueIsAdjusting()) { ! updateActions(); ! } ! } ! }); ! fileList.getModel().addListDataListener(new ListDataListener() { ! public void intervalAdded(ListDataEvent e) { ! updateActions(); ! } ! ! public void intervalRemoved(ListDataEvent e) { ! updateActions(); ! } ! ! public void contentsChanged(ListDataEvent e) { ! updateActions(); ! } ! }); ! layComponents(); ! Framebuffer.dontExit(); } ! private void layComponents() { ! JPanel contentPane = new JPanel(new GridBagLayout()); ! contentPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); ! GridBagConstraints gbc = new GridBagConstraints(); ! gbc.gridwidth = 2; ! gbc.weightx = 1.0; ! gbc.gridx = GridBagConstraints.REMAINDER; ! gbc.anchor = GridBagConstraints.WEST; ! contentPane.add(new JLabel("Select files to render"), gbc); ! gbc.gridheight = 5; ! gbc.gridwidth = 1; ! gbc.weighty = 1.0; ! gbc.fill = GridBagConstraints.BOTH; ! contentPane.add(new JScrollPane(fileList), gbc); ! gbc.gridheight = 1; ! gbc.weighty = 0.0; ! gbc.weightx = 0.0; ! gbc.fill = GridBagConstraints.HORIZONTAL; ! gbc.gridx = 1; ! gbc.gridy = 1; ! gbc.insets = new Insets(0, 2, 0, 0); ! contentPane.add(bAdd, gbc); ! gbc.gridy = 2; ! gbc.insets = new Insets(2, 2, 0, 0); ! contentPane.add(bRemove, gbc); ! gbc.gridy = 3; ! gbc.weighty = 1.0; ! gbc.fill = GridBagConstraints.BOTH; ! contentPane.add(Box.createVerticalGlue(), gbc); ! gbc.gridy = 4; ! gbc.weighty = 0.0; ! gbc.fill = GridBagConstraints.HORIZONTAL; ! contentPane.add(bRender, gbc); ! gbc.gridy = 5; ! contentPane.add(bExit, gbc); ! setContentPane(contentPane); ! setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ! setIconImage( ! new ImageIcon( ! getClass().getResource("images/framebuffer_icon.png")) ! .getImage()); ! pack(); } ! private void updateActions() { ! renderAction.setEnabled(fileList.getModel().getSize() > 0); ! removeAction.setEnabled( ! fileList.getModel().getSize() > 0 ! && fileList.getSelectedIndex() >= 0); } } --- 1,164 ---- /* ! * MainFrame.java Copyright (C) 2004 Alessandro Falappa ! * ! * This program is free software; you can redistribute it and/or modify it ! * under the terms of the GNU General Public License as published by the Free ! * Software Foundation; either version 2 of the License, or (at your option) ! * any later version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for ! * more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.ui; ! import java.awt.BorderLayout; import java.awt.HeadlessException; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; ! import javax.swing.*; ! import com.jgoodies.forms.builder.ButtonBarBuilder; ! import com.jgoodies.forms.factories.Borders; /** ! * A basic GUI for the JrMan renderer allowing to prepare a render queue, ! * set rendering options and render the files in the queue, monitoring the ! * process and eventually looking at rendering messages. ! * <P> ! * Makes use of the JGoodies Forms framework and JGoodies Looks additional ! * Java Look And Feels. ! * @link http://www.jgoodies.com/freeware ! * <P> ! * Manages application wide functionalities like showing the about dialog, ! * the settings dialog and exiting * * @author Alessandro Falappa + * @version $Revision$ */ ! public class MainFrame extends JFrame implements ProgressObserver { ! // non visual members ! private static RenderRunnable renderRunnable= new RenderRunnable(); ! // visual members ! private JButton bAbout= new JButton(new AboutAction()); ! private JButton bSettings= new JButton(new PrefsAction()); ! private JButton bExit= new JButton(new ExitAction()); ! private JTabbedPane tabbedPane= new JTabbedPane(); ! private static QueuePanel pQueue= new QueuePanel(); ! private static OptionsPanel pOptions= new OptionsPanel(); ! private RenderPanel pRender= new RenderPanel(renderRunnable); ! ! /** ! * Constructs and initializes a MainFrame object. ! * @throws HeadlessException ! */ ! public MainFrame() throws HeadlessException { ! super("JrManGUI"); ! setIconImage(new ImageIcon(getClass().getResource("images/framebuffer_icon.png")).getImage()); ! setDefaultCloseOperation(EXIT_ON_CLOSE); ! renderRunnable.addProgressObserver(this); ! // assemble panels ! tabbedPane.add(pQueue, pQueue.getTitle()); ! tabbedPane.add(pOptions, pOptions.getTitle()); ! tabbedPane.add(pRender, pRender.getTitle()); ! tabbedPane.setBorder(Borders.TABBED_DIALOG_BORDER); ! getContentPane().add(tabbedPane, BorderLayout.CENTER); ! getContentPane().add(createButtonsBar(), BorderLayout.SOUTH); ! pack(); } ! ! private JPanel createButtonsBar() { ! // fill the panel ! ButtonBarBuilder builder= new ButtonBarBuilder(); ! builder.setBorder(Borders.TABBED_DIALOG_BORDER); ! builder.addGridded(bAbout); ! //builder.addGriddedButtons(new JButton[] { bAbout, bSettings }); ! builder.addGlue(); ! builder.addGridded(bExit); ! return builder.getPanel(); ! } ! ! private class ExitAction extends AbstractAction { ! public ExitAction() { ! putValue(Action.NAME, "Exit"); ! putValue(Action.SHORT_DESCRIPTION, "Quits from the application"); ! putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E)); ! putValue(Action.SMALL_ICON, new ImageIcon(getClass().getResource("images/exit.png"))); } ! /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { ! System.exit(0); } ! } ! private class AboutAction extends AbstractAction { ! public AboutAction() { ! putValue(Action.NAME, "About..."); ! putValue(Action.SHORT_DESCRIPTION, "Shows some information about this application"); ! putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_B)); ! putValue(Action.SMALL_ICON, new ImageIcon(getClass().getResource("images/info.png"))); } ! /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { ! new AboutDialog(MainFrame.this).setVisible(true); } } ! ! private class PrefsAction extends AbstractAction { ! public PrefsAction() { ! putValue(Action.NAME, "Settings..."); ! putValue(Action.SHORT_DESCRIPTION, "Edit application settings"); ! putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_S)); ! putValue(Action.SMALL_ICON, new ImageIcon(getClass().getResource("images/prefs.png"))); } ! /* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { ! new AboutDialog(MainFrame.this).setVisible(true); } } ! /* (non-Javadoc) ! * @see org.jrman.ui.ProgressObserver#start(int, int) ! */ ! public void start(int startProgressValue, int endProgressValue) { ! tabbedPane.setEnabledAt(0, false); ! tabbedPane.setEnabledAt(1, false); ! } ! /* (non-Javadoc) ! * @see org.jrman.ui.ProgressObserver#setProgress(int) ! */ ! public void setProgress(int value,String message) { ! //do nothing } ! /* (non-Javadoc) ! * @see org.jrman.ui.ProgressObserver#end() ! */ ! public void end() { ! tabbedPane.setEnabledAt(0, true); ! tabbedPane.setEnabledAt(1, true); } ! /** ! * Starts the rendering process ! */ ! public static void startRendering() { ! renderRunnable.setQueue(pQueue.getQueue()); ! renderRunnable.setOptionsString(pOptions.getOptionsString()); ! Thread t= new Thread(renderRunnable, "renderthread"); ! t.start(); } } |
From: <afa...@us...> - 2004-02-11 16:21:04
|
Update of /cvsroot/jrman/drafts/src/org/jrman/main In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19019/src/org/jrman/main Modified Files: JRMan.java Added Files: JrManGUI.java Log Message: New totally revamped GUI: - needs JDK 1.4.2 (exact) - custom look and feel - Ability to specify rendering options - Better management of the rendering queue - Output messages captured in text area --- NEW FILE: JrManGUI.java --- /* * Created on 25-gen-2004 */ package org.jrman.main; import java.awt.Dimension; import java.awt.Frame; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import org.jrman.ui.MainFrame; import com.jgoodies.plaf.plastic.Plastic3DLookAndFeel; /** * The entry point for the basic GUI for jrMan * * @author Alessandro Falappa * @version $Revision: 1.1 $ */ public class JrManGUI { private static void centerOnScreen(Frame frame) { Dimension paneSize= frame.getSize(); Dimension screenSize= frame.getToolkit().getScreenSize(); frame.setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2); } /** * Main method of the GUI. * @param args command line arguments */ public static void main(String[] args) { try { UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } MainFrame gui= new MainFrame(); centerOnScreen(gui); gui.setVisible(true); } } Index: JRMan.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/main/JRMan.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** JRMan.java 12 Dec 2003 23:50:19 -0000 1.7 --- JRMan.java 11 Feb 2004 16:16:51 -0000 1.8 *************** *** 24,156 **** import org.apache.commons.cli.*; import org.jrman.parser.Parser; - import org.jrman.ui.MainFrame; import org.jrman.util.Format; public class JRMan { ! private static int majorNumber= 0; ! private static int minorNumber= 3; ! private static final String MESSAGE_APPNAME= "jrMan"; ! private static final String MESSAGE_APPDESCRIPTION= "Java REYES based renderer."; ! private static final String MESSAGE_LICENSE= "This program is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License."; ! public static final char OPTION_STATISTICS= 's'; ! public static final char OPTION_LASTFRAME= 'e'; ! public static final char OPTION_FIRSTFRAME= 'f'; ! public static final char OPTION_FRAMEBUFFER= 'd'; ! public static final char OPTION_VERSION= 'v'; ! public static final char OPTION_HELP= 'h'; ! public static final char OPTION_PROGRESS= 'p'; ! public static final char OPTION_QUALITY = 'q'; ! public static void main(String args[]) { ! try { ! Options opts= prepareOptions(); ! // parse command line ! CommandLine cmdLine= new BasicParser().parse(opts, args); ! // deal with help and version options immediately ! if (cmdLine.hasOption(OPTION_HELP)) { ! printUsage(opts); ! System.exit(0); ! } ! if (cmdLine.hasOption(OPTION_VERSION)) { ! printVersion(); ! System.exit(0); ! } ! if (cmdLine.getArgList().isEmpty()) { ! // start basic GUI ! MainFrame frame= new MainFrame(cmdLine); ! frame.setVisible(true); ! } ! else { ! // process arguments (rib files to render) ! Iterator it= cmdLine.getArgList().iterator(); ! long totalStart= System.currentTimeMillis(); ! while (it.hasNext()) ! try { ! String filename= (String)it.next(); ! long start= System.currentTimeMillis(); ! Parser parser= new Parser(cmdLine); ! parser.begin(filename); ! parser.parse(filename); ! parser.end(); ! long end= System.currentTimeMillis(); ! System.out.println(filename + " time: " + Format.time(end - start)); ! } ! catch (IOException ioe) { ! System.err.println("Error on file " + ioe.getLocalizedMessage()); ! } ! catch (Exception e) { ! System.err.println("Error " + e.getLocalizedMessage()); ! } ! long totalEnd= System.currentTimeMillis(); ! System.out.println("Total time: " + Format.time(totalEnd - totalStart)); ! } ! } ! catch (ParseException e) { ! System.err.println(e.getLocalizedMessage()); ! System.exit(1); ! } ! } ! private static Options prepareOptions() { ! Options options= new Options(); ! OptionBuilder.withLongOpt("help"); ! OptionBuilder.withDescription("show this usage information and exits"); ! options.addOption(OptionBuilder.create(OPTION_HELP)); ! OptionBuilder.withLongOpt("version"); ! OptionBuilder.withDescription("show application version and exits"); ! options.addOption(OptionBuilder.create(OPTION_VERSION)); ! OptionBuilder.withLongOpt("display"); ! OptionBuilder.withDescription("always show image in a framebuffer display (implicitly add such " + "display if not already present)"); ! options.addOption(OptionBuilder.create(OPTION_FRAMEBUFFER)); ! OptionBuilder.withLongOpt("progress"); ! OptionBuilder.withDescription("show per frame rendering progress"); ! options.addOption(OptionBuilder.create(OPTION_PROGRESS)); ! OptionBuilder.withLongOpt("first"); ! OptionBuilder.withDescription("start rendering from <frame>"); ! OptionBuilder.hasArg(); ! OptionBuilder.withType(new Integer(1)); ! OptionBuilder.withArgName("frame"); ! options.addOption(OptionBuilder.create(OPTION_FIRSTFRAME)); ! OptionBuilder.withLongOpt("end"); ! OptionBuilder.withDescription("stop rendering after <frame>"); ! OptionBuilder.hasArg(); ! OptionBuilder.withArgName("frame"); ! options.addOption(OptionBuilder.create(OPTION_LASTFRAME)); ! OptionBuilder.withLongOpt("stats"); ! OptionBuilder.withDescription("print end of frame statistics"); ! // TODO implement level of detail for rendering statistics ! //OptionBuilder.hasOptionalArg(); ! //OptionBuilder.withType(new Integer(1)); ! //OptionBuilder.withArgName("level"); ! options.addOption(OptionBuilder.create(OPTION_STATISTICS)); ! OptionBuilder.withLongOpt("quality"); ! OptionBuilder.withDescription("higher rendering quality (slightly slower)"); ! options.addOption(OptionBuilder.create(OPTION_QUALITY)); ! return options; ! } ! private static void printHeader() { ! System.out.print(MESSAGE_APPNAME); ! System.out.print(" v"); ! System.out.print(majorNumber); ! System.out.print('.'); ! System.out.println(minorNumber); ! System.out.println(MESSAGE_APPDESCRIPTION); ! } ! private static void printVersion() { ! printHeader(); ! System.out.println(); ! System.out.println(MESSAGE_LICENSE); ! } ! private static void printUsage(Options options) { ! printHeader(); ! System.out.println(); ! HelpFormatter formatter= new HelpFormatter(); ! formatter.printHelp("jrman [options] [file1.rib] [file2.rib] ...", "Supported options are:", options, "If no rib file is given a basic graphical user interface is presented."); ! System.out.println(); ! System.out.println(MESSAGE_LICENSE); ! } } --- 24,149 ---- import org.apache.commons.cli.*; import org.jrman.parser.Parser; import org.jrman.util.Format; public class JRMan { ! public static int majorNumber= 0; ! public static int minorNumber= 3; ! private static final String MESSAGE_APPNAME= "jrMan"; ! private static final String MESSAGE_APPDESCRIPTION= "Java REYES based renderer."; ! private static final String MESSAGE_LICENSE= "This program is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License."; ! public static final char OPTION_STATISTICS= 's'; ! public static final char OPTION_LASTFRAME= 'e'; ! public static final char OPTION_FIRSTFRAME= 'f'; ! public static final char OPTION_FRAMEBUFFER= 'd'; ! public static final char OPTION_VERSION= 'v'; ! public static final char OPTION_HELP= 'h'; ! public static final char OPTION_PROGRESS= 'p'; ! public static final char OPTION_QUALITY= 'q'; ! public static final Options options= prepareOptions(); ! public static void main(String args[]) { ! try { ! Options opts= prepareOptions(); ! // parse command line ! CommandLine cmdLine= new BasicParser().parse(opts, args); ! // deal with help and version options or no args at all immediately ! if (cmdLine.getArgList().isEmpty() || cmdLine.hasOption(OPTION_HELP)) { ! printUsage(opts); ! System.exit(0); ! } ! if (cmdLine.hasOption(OPTION_VERSION)) { ! printVersion(); ! System.exit(0); ! } ! // process arguments (rib files to render) ! Iterator it= cmdLine.getArgList().iterator(); ! long totalStart= System.currentTimeMillis(); ! while (it.hasNext()) ! try { ! String filename= (String)it.next(); ! long start= System.currentTimeMillis(); ! Parser parser= new Parser(cmdLine); ! parser.begin(filename); ! parser.parse(filename); ! parser.end(); ! long end= System.currentTimeMillis(); ! System.out.println(filename + " time: " + Format.time(end - start)); ! } ! catch (IOException ioe) { ! System.err.println("Error on file " + ioe.getLocalizedMessage()); ! } ! catch (Exception e) { ! System.err.println("Error " + e.getLocalizedMessage()); ! } ! long totalEnd= System.currentTimeMillis(); ! System.out.println("Total time: " + Format.time(totalEnd - totalStart)); ! } ! catch (ParseException e) { ! System.err.println(e.getLocalizedMessage()); ! System.exit(1); ! } ! } ! private static Options prepareOptions() { ! Options options= new Options(); ! OptionBuilder.withLongOpt("help"); ! OptionBuilder.withDescription("show this usage information and exits"); ! options.addOption(OptionBuilder.create(OPTION_HELP)); ! OptionBuilder.withLongOpt("version"); ! OptionBuilder.withDescription("show application version and exits"); ! options.addOption(OptionBuilder.create(OPTION_VERSION)); ! OptionBuilder.withLongOpt("display"); ! OptionBuilder.withDescription("always show image in a framebuffer display (implicitly add such " + "display if not already present)"); ! options.addOption(OptionBuilder.create(OPTION_FRAMEBUFFER)); ! OptionBuilder.withLongOpt("progress"); ! OptionBuilder.withDescription("show per frame rendering progress"); ! options.addOption(OptionBuilder.create(OPTION_PROGRESS)); ! OptionBuilder.withLongOpt("first"); ! OptionBuilder.withDescription("start rendering from <frame>"); ! OptionBuilder.hasArg(); ! OptionBuilder.withType(new Integer(1)); ! OptionBuilder.withArgName("frame"); ! options.addOption(OptionBuilder.create(OPTION_FIRSTFRAME)); ! OptionBuilder.withLongOpt("end"); ! OptionBuilder.withDescription("stop rendering after <frame>"); ! OptionBuilder.hasArg(); ! OptionBuilder.withArgName("frame"); ! options.addOption(OptionBuilder.create(OPTION_LASTFRAME)); ! OptionBuilder.withLongOpt("stats"); ! OptionBuilder.withDescription("print end of frame statistics"); ! // TODO implement level of detail for rendering statistics ! //OptionBuilder.hasOptionalArg(); ! //OptionBuilder.withType(new Integer(1)); ! //OptionBuilder.withArgName("level"); ! options.addOption(OptionBuilder.create(OPTION_STATISTICS)); ! OptionBuilder.withLongOpt("quality"); ! OptionBuilder.withDescription("higher rendering quality (slightly slower)"); ! options.addOption(OptionBuilder.create(OPTION_QUALITY)); ! return options; ! } ! private static void printHeader() { ! System.out.print(MESSAGE_APPNAME); ! System.out.print(" v"); ! System.out.print(majorNumber); ! System.out.print('.'); ! System.out.println(minorNumber); ! System.out.println(MESSAGE_APPDESCRIPTION); ! } ! private static void printVersion() { ! printHeader(); ! System.out.println(); ! System.out.println(MESSAGE_LICENSE); ! } ! private static void printUsage(Options options) { ! printHeader(); ! System.out.println(); ! HelpFormatter formatter= new HelpFormatter(); ! formatter.printHelp("jrman [options] [file1.rib] [file2.rib] ...", "Supported options are:", options, "If no rib file is given a basic graphical user interface is presented."); ! System.out.println(); ! System.out.println(MESSAGE_LICENSE); ! } } |
Update of /cvsroot/jrman/drafts/src/org/jrman/ui/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19019/src/org/jrman/ui/images Added Files: exit.png plus.gif info.png jrman_logo.png help.gif prefs.png minus.gif Log Message: New totally revamped GUI: - needs JDK 1.4.2 (exact) - custom look and feel - Ability to specify rendering options - Better management of the rendering queue - Output messages captured in text area --- NEW FILE: exit.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: plus.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: info.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: jrman_logo.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: help.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: prefs.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: minus.gif --- (This appears to be a binary file; contents omitted.) |
From: <afa...@us...> - 2004-02-11 16:21:03
|
Update of /cvsroot/jrman/drafts/src/org/jrman/ui/texts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19019/src/org/jrman/ui/texts Added Files: disclaimer.txt authors.txt Log Message: New totally revamped GUI: - needs JDK 1.4.2 (exact) - custom look and feel - Ability to specify rendering options - Better management of the rendering queue - Output messages captured in text area --- NEW FILE: disclaimer.txt --- JrManGUI, a basic GUI frontend to JrMan Copyright (C) 2004 Alessandro Falappa This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --- NEW FILE: authors.txt --- JrMan and JrManGUI were written by (alphabetical order): Alessandro Falappa <ale...@fa...> Elmer Garduno <ega...@us...> Gerardo Horvilleur <ma...@mu...> Jorge Vargas <edi...@mu...> |
From: <afa...@us...> - 2004-02-11 16:20:29
|
Update of /cvsroot/jrman/drafts/src/org/jrman/ui/texts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18908/src/org/jrman/ui/texts Log Message: Directory /cvsroot/jrman/drafts/src/org/jrman/ui/texts added to the repository |
From: <afa...@us...> - 2004-02-11 16:12:19
|
Update of /cvsroot/jrman/drafts/src/net/falappa/swing/widgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16986/src/net/falappa/swing/widgets Modified Files: JImageViewerPanel.java Log Message: Removed painting of focus on toolbar buttons Index: JImageViewerPanel.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/net/falappa/swing/widgets/JImageViewerPanel.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** JImageViewerPanel.java 11 Dec 2003 15:08:06 -0000 1.4 --- JImageViewerPanel.java 11 Feb 2004 16:08:06 -0000 1.5 *************** *** 411,414 **** --- 411,415 ---- } }); + bNoZoom.setFocusPainted(false); bNoZoom.setEnabled(false); bNoZoom.setToolTipText(res.getString("bNoZoom_ToolTipText")); *************** *** 416,419 **** --- 417,421 ---- bNoZoom.setIcon(noZoomIcon); bNoZoom.addActionListener(noZoomActionListener); + bZoomOut.setFocusPainted(false); bZoomOut.setEnabled(false); bZoomOut.setToolTipText(res.getString("bZoomOut_ToolTipText")); *************** *** 421,424 **** --- 423,427 ---- bZoomOut.setIcon(zoomOutIcon); bZoomOut.addActionListener(zoomOutActionListener); + bZoomIn.setFocusPainted(false); bZoomIn.setEnabled(false); bZoomIn.setToolTipText(res.getString("bZoomIn_ToolTipText")); *************** *** 426,429 **** --- 429,433 ---- bZoomIn.setIcon(ZoomInIcon); bZoomIn.addActionListener(zoomInActionListener); + bZoomToFit.setFocusPainted(false); bZoomToFit.setEnabled(false); bZoomToFit.setToolTipText(res.getString("bZoomToFit_ToolTipText")); *************** *** 614,617 **** --- 618,622 ---- JButton newlyAdded= super.add(a); newlyAdded.setMargin(new Insets(1, 1, 1, 1)); + newlyAdded.setFocusPainted(false); userActions.put(a, newlyAdded); contextMenu= null; |
From: <ega...@us...> - 2004-02-09 21:38:15
|
Update of /cvsroot/jrman/drafts/sampleData In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19727 Added Files: testBicubic.rib Log Message: test bicubic --- NEW FILE: testBicubic.rib --- Display "bicubic" "framebuffer" "rgba" PixelFilter "gaussian" 2 2 Format 800 600 1 PixelSamples 4 4 Exposure 1 2.2 Projection "perspective" "fov" [20] WorldBegin Translate 0 0 20 Rotate -120 1 0 0 LightSource "ambientlight" 1 "intensity" [0.2] LightSource "distantlight" 2 "intensity" [0.8] "from" [-10 -10 10] "to" [0 0 0] Surface "paintedplastic" "texturename" "checkerboard.txr" Basis "bezier" 2 "bezier" 2 Patch "bicubic" "P" [ -3 -3 0 -1 -3 0 1 -3 0 3 -3 0 -3 -1 0 -1 -1 -5 1 -1 1 3 -1 0 -3 1 0 -1 1 1 1 1 1 3 1 0 -3 3 0 -1 3 0 1 3 -1 3 3 0 ] "s" [0 4 0 4] "t" [0 0 4 4] WorldEnd |
From: <ega...@us...> - 2004-02-09 16:52:46
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15951/src/org/jrman/primitive Modified Files: BicubicPatch.java Log Message: Added all BicubicPatch Basis Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** BicubicPatch.java 2 Feb 2004 19:30:05 -0000 1.8 --- BicubicPatch.java 9 Feb 2004 16:49:32 -0000 1.9 *************** *** 22,25 **** --- 22,27 ---- import javax.vecmath.Point3f; import javax.vecmath.Vector3f; + import javax.vecmath.Matrix4f; + import javax.vecmath.Point4f; import org.jrman.attributes.Attributes; *************** *** 101,104 **** --- 103,110 ---- private static Vector3f vtmp = new Vector3f(); + private static Point4f PV0 = new Point4f(); + + private static Point4f PV1 = new Point4f(); + public BicubicPatch(ParameterList parameters, Attributes attributes) { super(parameters, attributes); *************** *** 125,128 **** --- 131,204 ---- } + private void setPoints() { + VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("P"); + param.setValue(0, P00); + param.setValue(1, P10); + param.setValue(2, P20); + param.setValue(3, P30); + param.setValue(4, P01); + param.setValue(5, P11); + param.setValue(6, P21); + param.setValue(7, P31); + param.setValue(8, P02); + param.setValue(9, P12); + param.setValue(10, P22); + param.setValue(11, P32); + param.setValue(12, P03); + param.setValue(13, P13); + param.setValue(14, P23); + param.setValue(15, P33); + } + + public void applyBasis() { + extractPoints(); + Matrix4f hu = attributes.getUBasis().getToBezier(); + Matrix4f hv = attributes.getVBasis().getToBezier(); + + applyBasis(P00, P10, P20, P30, hu); + applyBasis(P01, P11, P21, P31, hu); + applyBasis(P02, P12, P22, P32, hu); + applyBasis(P03, P13, P23, P33, hu); + + applyBasis(P00, P01, P02, P03, hv); + applyBasis(P10, P11, P12, P13, hv); + applyBasis(P20, P21, P22, P23, hv); + applyBasis(P30, P31, P32, P33, hv); + + setPoints(); + } + + public void applyBasis( + Point3f p0, + Point3f p1, + Point3f p2, + Point3f p3, + Matrix4f h) { + applyBasis(p0.x, p1.x, p2.x, p3.x, h, PV0); + p0.x = PV0.x; + p1.x = PV0.y; + p2.x = PV0.z; + p3.x = PV0.w; + applyBasis(p0.y, p1.y, p2.y, p3.y, h, PV0); + p0.y = PV0.x; + p1.y = PV0.y; + p2.y = PV0.z; + p3.y = PV0.w; + applyBasis(p0.z, p1.z, p2.z, p3.z, h, PV0); + p0.z = PV0.x; + p1.z = PV0.y; + p2.z = PV0.z; + p3.z = PV0.w; + } + + + public void applyBasis(float p0, float p1, float p2, float p3, Matrix4f hu, + Point4f result) { + PV1.set(p0, p1, p2, p3); + hu.transform(PV1, result); + } + + + public BoundingVolume getBoundingVolume() { ConvexHull3f ch = new ConvexHull3f(); |
From: <ega...@us...> - 2004-02-09 16:52:46
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15951/src/org/jrman/parser Modified Files: Parser.java Log Message: Added all BicubicPatch Basis Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** Parser.java 2 Feb 2004 19:30:06 -0000 1.77 --- Parser.java 9 Feb 2004 16:49:32 -0000 1.78 *************** *** 928,941 **** if (inAreaLightSource) return; ! if (!inObject) ! renderer.addPrimitive(new BicubicPatch(parameters, getAttributes())); ! else { final Transform transform = currentAttributes.getTransform(); currentObjectInstanceList .addPrimitiveCreator(new ObjectInstanceList.PrimitiveCreator() { public Primitive create(Attributes attributes) { ! return new BicubicPatch( ! parameters, ! createAttributes(transform, attributes)); } }); --- 928,945 ---- if (inAreaLightSource) return; ! if (!inObject) { ! BicubicPatch patch = new BicubicPatch(parameters, getAttributes()); ! patch.applyBasis(); ! renderer.addPrimitive(patch); ! }else { final Transform transform = currentAttributes.getTransform(); currentObjectInstanceList .addPrimitiveCreator(new ObjectInstanceList.PrimitiveCreator() { public Primitive create(Attributes attributes) { ! BicubicPatch patch = new BicubicPatch(parameters, ! createAttributes(transform, ! attributes)); ! patch.applyBasis(); ! return patch; } }); |
From: <ega...@us...> - 2004-02-09 16:52:45
|
Update of /cvsroot/jrman/drafts/src/org/jrman/attributes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15951/src/org/jrman/attributes Modified Files: Basis.java Log Message: Added all BicubicPatch Basis Index: Basis.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/attributes/Basis.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Basis.java 9 Apr 2003 05:04:57 -0000 1.1 --- Basis.java 9 Feb 2004 16:49:31 -0000 1.2 *************** *** 1,5 **** /* Basis.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or --- 1,5 ---- /* Basis.java ! Copyright (C) 2003, 2004 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or *************** *** 27,30 **** --- 27,38 ---- public class Basis { + private static final Matrix4f bezierInverse; + + static { + bezierInverse = + new Matrix4f(-1f, 3f, -3f, 1, 3f, -6f, 3f, 0f, -3f, 3f, 0f, 0f, 1f, 0f, 0f, 0f); + bezierInverse.invert(); + } + public final static Basis BEZIER = new Basis( *************** *** 80,96 **** private static final Map map = new HashMap(); ! static { map.put("bezier", BEZIER); map.put("b-spline", B_SPLINE); ! map.put("catmullrom", CATMULL_ROM); map.put("hermite", HERMITE); map.put("power", POWER); } ! private Matrix4f matrix; public Basis(Matrix4f matrix) { ! this.matrix = new Matrix4f(matrix); } --- 88,106 ---- private static final Map map = new HashMap(); ! static { map.put("bezier", BEZIER); map.put("b-spline", B_SPLINE); ! map.put("catmull-rom", CATMULL_ROM); map.put("hermite", HERMITE); map.put("power", POWER); } ! private Matrix4f toBezier; public Basis(Matrix4f matrix) { ! toBezier = new Matrix4f(); ! toBezier.mul(matrix, bezierInverse); ! toBezier.transpose(); } *************** *** 102,107 **** } ! public Matrix4f getMatrix() { ! return new Matrix4f(matrix); } --- 112,118 ---- } ! public Matrix4f getToBezier() { ! //return new Matrix4f(toBezier); ! return toBezier; } |
From: <ega...@us...> - 2004-02-08 23:36:43
|
Update of /cvsroot/jrman/drafts/javacc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11873 Modified Files: JPP.java Log Message: Fixed preprocessor comment bug Index: JPP.java =================================================================== RCS file: /cvsroot/jrman/drafts/javacc/JPP.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JPP.java 4 Feb 2004 14:46:51 -0000 1.1 --- JPP.java 8 Feb 2004 23:33:35 -0000 1.2 *************** *** 85,89 **** ************************************************************************* */ ! static class JPPExpandedStream { Vector iDirs = null; --- 85,90 ---- ************************************************************************* */ ! static class JPPExpandedStream ! { Vector iDirs = null; *************** *** 92,96 **** Stack nbStack = null; ! DataInputStream fCur = null; String nameCur = null; int nbCur = -1; --- 93,97 ---- Stack nbStack = null; ! BufferedReader fCur = null; String nameCur = null; int nbCur = -1; *************** *** 98,104 **** JPPExpandedStream (InputStream in, Vector includeDirs) ! throws java.io.IOException { ! fCur = ! new DataInputStream(new BufferedInputStream(in)); iDirs = includeDirs; fStack = new Stack(); --- 99,155 ---- JPPExpandedStream (InputStream in, Vector includeDirs) ! throws java.io.IOException ! { ! StringBuffer sb = new StringBuffer(); ! ! BufferedReader br = new BufferedReader(new InputStreamReader(in)); ! int c = -1; ! int state = 1; ! ! boolean run = true; ! ! while(run) ! { ! c = in.read(); ! switch(state) ! { ! case 1: ! if(c == '/') ! state = 2; ! else if(c == -1) ! run = false; ! else ! sb.append((char) c); ! break; ! case 2: ! if(c == '*') ! state = 3; ! else if(c == -1) ! run = false; ! else ! { ! sb.append('/'); ! sb.append((char) c); ! state = 1; ! } ! break; ! case 3: ! if(c == '*') ! state = 4; ! else if(c == -1) ! throw new IllegalStateException(); ! break; ! case 4: ! if(c == '/') ! state = 1; ! else if(c == -1) ! throw new IllegalStateException(); ! else if(c != '*') ! state = 3; ! break; ! } ! } ! ! fCur = new BufferedReader(new StringReader(sb.toString())); iDirs = includeDirs; fStack = new Stack(); *************** *** 119,123 **** line = "# "+nbCur+" "+"\""+nameCur+"\""+" 2"; nameCur = (String) nameStack.pop(); ! fCur = (DataInputStream) fStack.pop(); } } else { --- 170,174 ---- line = "# "+nbCur+" "+"\""+nameCur+"\""+" 2"; nameCur = (String) nameStack.pop(); ! fCur = (BufferedReader) fStack.pop(); } } else { *************** *** 138,143 **** nbStack.push(new Integer(nbCur)); ! fCur = new DataInputStream ! (new BufferedInputStream(new FileInputStream(fiName))); nameCur = new String(fiName); line = "# "+nbCur+" "+"\""+fiName+"\""+" 1"; --- 189,193 ---- nbStack.push(new Integer(nbCur)); ! fCur = new BufferedReader(new FileReader(fiName)); nameCur = new String(fiName); line = "# "+nbCur+" "+"\""+fiName+"\""+" 1"; *************** *** 165,230 **** void close() throws java.io.IOException { fCur.close(); } } - - /* ************************************************************************* - * This included class provides an inputstream offering a readLine() method. - ************************************************************************* */ - - static class JPPInputStream extends FilterInputStream { - public static final int BUFSIZE = 1024; - public static final String NULLSTRING = ""; - - byte[] buffer = new byte[BUFSIZE]; - boolean isMacFile; - - public JPPInputStream(InputStream iS,boolean isM) { super(iS); isMacFile = isM; } - public JPPInputStream(InputStream iS) { this(iS,false); } - - public int read() throws IOException { - return super.read(); - } - - public String readLine() throws IOException { - int i = readLine(buffer); - if (i == -1) return null; - else return new String(buffer,0,i); - } - - public int readLine(byte[] buf) throws IOException { - boolean escaped = false; - boolean CRLFEscaped = false; - boolean endWhile = false; - int i = -1,car = 0,maxL = buf.length-1; - - while(!endWhile && i<maxL && (car = read())!= -1) { - switch(car) { - default : - if (escaped) { - buf[++i] = (byte) '\\'; - escaped = false; - } - buf[++i] = (byte) car; - if (CRLFEscaped) CRLFEscaped = false; - break; - case '\\' : - if (escaped) { - buf[++i] = (byte) '\\'; - buf[++i] = (byte) '\\'; - } - escaped = !escaped; - if (CRLFEscaped) CRLFEscaped = false; - break; - case '\r' : case '\n' : - if (!escaped) { - if (!CRLFEscaped) endWhile = true; - else CRLFEscaped = false; - } - else if (!CRLFEscaped) CRLFEscaped = true; - else CRLFEscaped = false; - break; - } - } - if (i>= 0 || endWhile) return i+1; else return -1; - } - } public static void --- 215,218 ---- |
From: <ma...@us...> - 2004-02-08 08:57:57
|
Update of /cvsroot/jrman/drafts/src/org/jrman/grid In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22757/src/org/jrman/grid Modified Files: Tuple3fGrid.java FloatGrid.java Vector3fGrid.java Log Message: Added smooth interpolation. "Fixed" null normals bug. Quick fix to avoid exiting jrMan until las frame is closed. Index: Tuple3fGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/Tuple3fGrid.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Tuple3fGrid.java 13 Jan 2004 09:53:23 -0000 1.9 --- Tuple3fGrid.java 8 Feb 2004 08:54:55 -0000 1.10 *************** *** 892,894 **** --- 892,910 ---- } + /* + * toString + */ + public String toString() { + Tuple3f out = new javax.vecmath.Point3f(); + StringBuffer sb = new StringBuffer(); + for (int v = 0; v < vSize; v++) { + for (int u = 0; u < uSize; u++) { + get(u, v, out); + sb.append(out).append(" "); + } + sb.append("\n"); + } + return sb.toString(); + } + } Index: FloatGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/FloatGrid.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** FloatGrid.java 17 Jan 2004 01:10:12 -0000 1.23 --- FloatGrid.java 8 Feb 2004 08:54:55 -0000 1.24 *************** *** 1590,1592 **** --- 1590,1605 ---- } + /* + * toString + */ + public String toString() { + StringBuffer sb = new StringBuffer(); + for (int v = 0; v < vSize; v++) { + for (int u = 0; u < uSize; u++) + sb.append(get(u, v)).append(" "); + sb.append("\n"); + } + return sb.toString(); + } + } Index: Vector3fGrid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/grid/Vector3fGrid.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Vector3fGrid.java 25 Oct 2003 05:46:47 -0000 1.7 --- Vector3fGrid.java 8 Feb 2004 08:54:55 -0000 1.8 *************** *** 131,135 **** Vector3f[] v2data = (Vector3f[]) v2.data; for (int i = 0; i < size; i++) ! vdata[i].cross(v1data[i], v2data[i]); } --- 131,163 ---- Vector3f[] v2data = (Vector3f[]) v2.data; for (int i = 0; i < size; i++) ! vdata[i].cross(v1data[i], v2data[i]); ! ! // Ugly hack to attempt to avoid null normals... ! for (int i = 0; i < uSize; i++) { ! if (vdata[i + uSize].x == 0 && vdata[i + uSize].y == 0 && ! vdata[i + uSize].z == 0) ! vdata[i + uSize].set(vdata[i + uSize * 2]); ! if (vdata[i].x == 0 && vdata[i].y == 0 && vdata[i].z == 0) ! vdata[i].set(vdata[i + uSize]); ! } ! for (int i = size - uSize; i < size; i++) { ! if (vdata[i - uSize].x == 0 && vdata[i - uSize].y == 0 && ! vdata[i - uSize].z == 0) ! vdata[i - uSize].set(vdata[i - uSize * 2]); ! if (vdata[i].x == 0 && vdata[i].y == 0 && vdata[i].z == 0) ! vdata[i].set(vdata[i - uSize]); ! } ! for (int i = 0; i < size; i += uSize) { ! if (vdata[i + 1].x == 0 && vdata[i + 1].y == 0 && vdata[i + 1].z == 0) ! vdata[i + 1].set(vdata[i + 2]); ! if (vdata[i].x == 0 && vdata[i].y == 0 && vdata[i].z == 0) ! vdata[i].set(vdata[i + 1]); ! } ! for (int i = uSize - 1; i < size; i += uSize) { ! if (vdata[i - 1].x == 0 && vdata[i - 1].y == 0 && vdata[i - 1].z == 0) ! vdata[i - 1].set(vdata[i - 2]); ! if (vdata[i].x == 0 && vdata[i].y == 0 && vdata[i].z == 0) ! vdata[i].set(vdata[i - 1]); ! } } |
From: <ma...@us...> - 2004-02-08 08:57:56
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22757/src/org/jrman/render Modified Files: ShaderVariables.java SimpleMicropolygon.java Micropolygon.java Added Files: SmoothMicropolygon.java Log Message: Added smooth interpolation. "Fixed" null normals bug. Quick fix to avoid exiting jrMan until las frame is closed. --- NEW FILE: SmoothMicropolygon.java --- /* SimpleMicropolygon.java Copyright (C) 2003, 2004 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.render; import javax.vecmath.Point2f; import javax.vecmath.Point3f; import org.jrman.util.Calc; public class SmoothMicropolygon extends Micropolygon { private final static float EPSILON = 10E-5f; private float ax; private float ay; private float az; private float bx; private float by; private float bz; private float cx; private float cy; private float cz; private float oneOverDet; private float aColorRed; private float aColorGreen; private float aColorBlue; private float aOpacityRed; private float aOpacityGreen; private float aOpacityBlue; private float bColorRed; private float bColorGreen; private float bColorBlue; private float bOpacityRed; private float bOpacityGreen; private float bOpacityBlue; private float cColorRed; private float cColorGreen; private float cColorBlue; private float cOpacityRed; private float cOpacityGreen; private float cOpacityBlue; public boolean init( Point3f a, Point3f b, Point3f c, float acRed, float acGreen, float acBlue, float bcRed, float bcGreen, float bcBlue, float ccRed, float ccGreen, float ccBlue, float aoRed, float aoGreen, float aoBlue, float boRed, float boGreen, float boBlue, float coRed, float coGreen, float coBlue) { if (aoRed == 0f && aoGreen == 0f && aoBlue == 0f) return false; count++; // get bounds addPointToBounds(a.x, a.y, a.z); addPointToBounds(b.x, b.y, b.z); addPointToBounds(c.x, c.y, c.z); ax = a.x; ay = a.y; az = a.z; bx = b.x - ax; by = b.y - ay; bz = b.z; cx = c.x - ax; cy = c.y - ay; cz = c.z; float det = bx * cy - by * cx; if (det > -EPSILON && det < EPSILON) return false; oneOverDet = 1f / det; aColorRed = acRed; aColorGreen = acGreen; aColorBlue = acBlue; aOpacityRed = aoRed; aOpacityGreen = aoGreen; aOpacityBlue = aoBlue; bColorRed = bcRed; bColorGreen = bcGreen; bColorBlue = bcBlue; bOpacityRed = boRed; bOpacityGreen = boGreen; bOpacityBlue = boBlue; cColorRed = ccRed; cColorGreen = ccGreen; cColorBlue = ccBlue; cOpacityRed = coRed; cOpacityGreen = coGreen; cOpacityBlue = coBlue; return true; } private void addPointToBounds(float x, float y, float z) { minX = Calc.min(minX, x); maxX = Calc.max(maxX, x); minY = Calc.min(minY, y); maxY = Calc.max(maxY, y); minZ = Calc.min(minZ, z); } public void sample(Sampler sampler) { Point2f smin = sampler.getMin(); float mpMinX = minX - smin.x; float mpMaxX = maxX - smin.x; float mpMinY = minY - smin.y; float mpMaxY = maxY - smin.y; int minColumn = Calc.clamp( (int) (mpMinX * sampler.getOneOverSampleWidth()), 0, sampler.getWidth() - 1); int minRow = Calc.clamp( (int) (mpMinY * sampler.getOneOverSampleHeight()), 0, sampler.getHeight() - 1); int maxColumn = Calc.clamp( (int) (mpMaxX * sampler.getOneOverSampleWidth()), 0, sampler.getWidth() - 1); int maxRow = Calc.clamp( (int) (mpMaxY * sampler.getOneOverSampleHeight()), 0, sampler.getHeight() - 1); for (int row = minRow; row <= maxRow; row++) { for (int col = minColumn; col <= maxColumn; col++) { SamplePoint sp = sampler.getSamplePoint(col, row); sampleAtPoint(sp); } } } public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); if (sp.isOpaque() && sp.getZ() < minZ) return; float ox = point.x - ax; float oy = point.y - ay; float u = (ox * cy - oy * cx) * oneOverDet; if (u < 0f || u > 1f) return; float v = (oy * bx - ox * by) * oneOverDet; if (v < 0f || u + v > 1f) return; float w = 1f - u - v; float z = w * az + u * bz + v * cz; float colorRed = w * aColorRed + u * bColorRed + v * cColorRed; float colorGreen = w * aColorGreen + u * bColorGreen + v * cColorGreen; float colorBlue = w * aColorBlue + u * bColorBlue + v * cColorBlue; float opacityRed = w * aOpacityRed + u * bOpacityRed + v * cOpacityRed; float opacityGreen = w * aOpacityGreen + u * bOpacityGreen + v * cOpacityGreen; float opacityBlue = w * aOpacityBlue + u * bOpacityBlue + v * cOpacityBlue; sp.addSample( colorRed, colorGreen, colorBlue, opacityRed, opacityGreen, opacityBlue, z); return; } } Index: ShaderVariables.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/ShaderVariables.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ShaderVariables.java 2 Feb 2004 19:30:05 -0000 1.12 --- ShaderVariables.java 8 Feb 2004 08:54:55 -0000 1.13 *************** *** 27,30 **** --- 27,31 ---- import org.jrman.attributes.Attributes; + import org.jrman.attributes.ShadingInterpolation; import org.jrman.geom.Transform; import org.jrman.grid.Color3fGrid; *************** *** 36,40 **** public class ShaderVariables { ! public Transform cameraToWorld; --- 37,41 ---- public class ShaderVariables { ! public Transform cameraToWorld; *************** *** 78,92 **** public Point3f E = new Point3f(); ! public Attributes attributes; ! public ParameterList parameters; private Map map = new HashMap(); ! public ShaderVariables(Transform worldToCamera) { this.cameraToWorld = worldToCamera; } ! public void set(String name, Grid grid) { map.put(name, grid); --- 79,93 ---- public Point3f E = new Point3f(); ! public Attributes attributes; ! public ParameterList parameters; private Map map = new HashMap(); ! public ShaderVariables(Transform worldToCamera) { this.cameraToWorld = worldToCamera; } ! public void set(String name, Grid grid) { map.put(name, grid); *************** *** 111,144 **** Color3f[] c = (Color3f[]) Ci.data; Color3f[] o = (Color3f[]) Oi.data; ! for (int col = 0; col < columns - 1; col++) ! for (int row = 0; row < rows - 1; row++) { ! int offset = row * columns + col; ! Micropolygon mp = new SimpleMicropolygon(); ! if (mp ! .init( ! p[offset], ! p[offset + 1], ! p[offset + columns], ! c[offset].x, ! c[offset].y, ! c[offset].z, ! o[offset].x, ! o[offset].y, ! o[offset].z)) ! rh.addToBuckets(mp); ! mp = new SimpleMicropolygon(); ! if (mp ! .init( ! p[offset + columns + 1], ! p[offset + 1], ! p[offset + columns], ! c[offset + columns + 1].x, ! c[offset + columns + 1].y, ! c[offset + columns + 1].z, ! o[offset + columns + 1].x, ! o[offset + columns + 1].y, ! o[offset + columns + 1].z)) ! rh.addToBuckets(mp); ! } } --- 112,202 ---- Color3f[] c = (Color3f[]) Ci.data; Color3f[] o = (Color3f[]) Oi.data; ! if (attributes.getShadingInterpolation() == ShadingInterpolation.CONSTANT) { ! for (int col = 0; col < columns - 1; col++) ! for (int row = 0; row < rows - 1; row++) { ! int offset = row * columns + col; ! SimpleMicropolygon mp = new SimpleMicropolygon(); ! if (mp ! .init( ! p[offset], ! p[offset + 1], ! p[offset + columns], ! c[offset].x, ! c[offset].y, ! c[offset].z, ! o[offset].x, ! o[offset].y, ! o[offset].z)) ! rh.addToBuckets(mp); ! mp = new SimpleMicropolygon(); ! if (mp ! .init( ! p[offset + columns + 1], ! p[offset + 1], ! p[offset + columns], ! c[offset + columns + 1].x, ! c[offset + columns + 1].y, ! c[offset + columns + 1].z, ! o[offset + columns + 1].x, ! o[offset + columns + 1].y, ! o[offset + columns + 1].z)) ! rh.addToBuckets(mp); ! } ! } else { ! for (int col = 0; col < columns - 1; col++) ! for (int row = 0; row < rows - 1; row++) { ! int offset = row * columns + col; ! SmoothMicropolygon mp = new SmoothMicropolygon(); ! if (mp ! .init( ! p[offset], ! p[offset + 1], ! p[offset + columns], ! c[offset].x, ! c[offset].y, ! c[offset].z, ! c[offset + 1].x, ! c[offset + 1].y, ! c[offset + 1].z, ! c[offset + columns].x, ! c[offset + columns].y, ! c[offset + columns].z, ! o[offset].x, ! o[offset].y, ! o[offset].z, ! o[offset + 1].x, ! o[offset + 1].y, ! o[offset + 1].z, ! o[offset + columns].x, ! o[offset + columns].y, ! o[offset + columns].z)) ! rh.addToBuckets(mp); ! mp = new SmoothMicropolygon(); ! if (mp ! .init( ! p[offset + columns + 1], ! p[offset + 1], ! p[offset + columns], ! c[offset + columns + 1].x, ! c[offset + columns + 1].y, ! c[offset + columns + 1].z, ! c[offset + 1].x, ! c[offset + 1].y, ! c[offset + 1].z, ! c[offset + columns].x, ! c[offset + columns].y, ! c[offset + columns].z, ! o[offset + columns + 1].x, ! o[offset + columns + 1].y, ! o[offset + columns + 1].z, ! o[offset + 1].x, ! o[offset + 1].y, ! o[offset + 1].z, ! o[offset + columns].x, ! o[offset + columns].y, ! o[offset + columns].z)) ! rh.addToBuckets(mp); ! } ! } } Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** SimpleMicropolygon.java 2 Feb 2004 19:30:05 -0000 1.19 --- SimpleMicropolygon.java 8 Feb 2004 08:54:55 -0000 1.20 *************** *** 144,151 **** public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); - /* - if (point.x < minX || point.x > maxX || point.y < minY || point.y > maxY) - return; - */ if (sp.isOpaque() && sp.getZ() < minZ) return; --- 144,147 ---- Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Micropolygon.java 2 Feb 2004 19:30:05 -0000 1.18 --- Micropolygon.java 8 Feb 2004 08:54:55 -0000 1.19 *************** *** 20,25 **** package org.jrman.render; - import javax.vecmath.Point3f; - import org.jrman.util.Constants; --- 20,23 ---- *************** *** 38,52 **** protected float minZ = Constants.INFINITY; - public abstract boolean init( - Point3f a, - Point3f b, - Point3f c, - float cRed, - float cGreen, - float cBlue, - float oRed, - float oGreen, - float oBlue); - public abstract void sample(Sampler sampler); --- 36,39 ---- |
From: <ma...@us...> - 2004-02-08 08:57:56
|
Update of /cvsroot/jrman/drafts/src/org/jrman/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22757/src/org/jrman/ui Modified Files: Framebuffer.java MainFrame.java Log Message: Added smooth interpolation. "Fixed" null normals bug. Quick fix to avoid exiting jrMan until las frame is closed. Index: Framebuffer.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/ui/Framebuffer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Framebuffer.java 12 Dec 2003 09:54:26 -0000 1.6 --- Framebuffer.java 8 Feb 2004 08:54:55 -0000 1.7 *************** *** 19,22 **** --- 19,24 ---- package org.jrman.ui; + import java.awt.event.WindowAdapter; + import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; *************** *** 39,42 **** --- 41,50 ---- new ImageViewerPanelSaveAction(imagePanel,BufferedImage.TYPE_INT_ARGB); private String name; + + private static int count = 0; + + public static void dontExit() { + count = 1; + } /** *************** *** 47,50 **** --- 55,59 ---- public Framebuffer(String name, BufferedImage image) { super(name); + count++; this.name = name; save.setEnabled(false); *************** *** 57,61 **** setIconImage( new ImageIcon(getClass().getResource("images/framebuffer_icon.png")).getImage()); ! setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getRootPane().setDoubleBuffered(false); getContentPane().add(imagePanel); --- 66,76 ---- setIconImage( new ImageIcon(getClass().getResource("images/framebuffer_icon.png")).getImage()); ! setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); ! addWindowListener(new WindowAdapter() { ! public void windowClosing(WindowEvent event) { ! if (--count == 0) ! System.exit(0); ! } ! }); getRootPane().setDoubleBuffered(false); getContentPane().add(imagePanel); Index: MainFrame.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/ui/MainFrame.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MainFrame.java 12 Dec 2003 09:30:41 -0000 1.3 --- MainFrame.java 8 Feb 2004 08:54:55 -0000 1.4 *************** *** 213,216 **** --- 213,217 ---- }); layComponents(); + Framebuffer.dontExit(); } |
From: <ma...@us...> - 2004-02-08 08:57:55
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22757/src/org/jrman/primitive Modified Files: BilinearPatch.java Log Message: Added smooth interpolation. "Fixed" null normals bug. Quick fix to avoid exiting jrMan until las frame is closed. Index: BilinearPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BilinearPatch.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BilinearPatch.java 2 Feb 2004 19:30:05 -0000 1.5 --- BilinearPatch.java 8 Feb 2004 08:54:55 -0000 1.6 *************** *** 82,87 **** result[1] = new BilinearPatch(linearInterpolateParameters(.5f, 1f, 0f, 1f), attributes); - result[0].setObjectToCamera(objectToCamera); - result[1].setObjectToCamera(objectToCamera); } else { result[0] = --- 82,85 ---- *************** *** 89,94 **** result[1] = new BilinearPatch(linearInterpolateParameters(0f, 1f, .5f, 1f), attributes); - result[0].setObjectToCamera(objectToCamera); - result[1].setObjectToCamera(objectToCamera); } return result; --- 87,90 ---- |
From: <ega...@us...> - 2004-02-04 14:49:15
|
Update of /cvsroot/jrman/drafts/javacc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv784 Modified Files: SLParser.java SLParser.jj SLParserConstants.java SLParserTokenManager.java Added Files: JPP.java Log Message: Begined work in preprocessor. --- NEW FILE: JPP.java --- /*** * Jonathan: an Open Distributed Processing Environment * * The contents of this file are subject to the JOnAS Public License Version * 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License on the JOnAS web site. * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific terms governing rights and limitations under * the License. * * The Original Code is JOnAS application server code released July 1999. * * The Initial Developer of the Original Code is Bull S.A. * The Original Code and portions created by Bull S.A. are * Copyright (C) 1999 Bull S.A. All Rights Reserved. * * Contributor(s): François Horn (rewrite for Jonathan). */ import java.io.*; import java.util.Enumeration; import java.util.StringTokenizer; import java.util.Hashtable; import java.util.Vector; import java.util.Stack; /** * JPP as Java PreProcessor. * This class allows to preprocess a jpp file included the directives * <ul> * <li> * #include * <li> * #ifdef * <li> * #ifndef * <li> * #else * <li> * #endif * </ul> */ public class JPP { private static final int JPP_INST_NB = 9; public static final int NO_JPP_INST = -1; public static final int INST_INCLUDE = 0; public static final int INST_DEFINE = 1; public static final int INST_IFDEF = 2; public static final int INST_IFNDEF = 3; public static final int INST_IF = 4; public static final int INST_ELSE = 5; public static final int INST_ELIF = 6; public static final int INST_ENDIF = 7; public static final int INST_UNDEF = 8; public static final int BUFSIZE = 1024; static final String[] INST_TOKEN = { "#include","#define","#ifdef","#ifndef","#if","#else","#elif","#endif","#undef" }; private static final String JAVA_DELIM = " \t\n\r;,.{}()[]+-*/%<>=&|!?:#"; private static final String NULLSTRING = ""; private static final Object NULLSCOPE = new Object(); private static final Object IFSCOPE = new Object(); private static final Object ELSESCOPE = new Object(); Hashtable defined_names = new Hashtable(); int nb_defs = 0; private static int jppToken(String nm) { for (int i = 0;i<JPP_INST_NB;i++) if (nm.indexOf(INST_TOKEN[i]) >= 0) return i; return -1; } private JPPExpandedStream jpp_fIn; private OutputStream jpp_fOut; private int errorNumber = 0; /* ************************************************************************* * This included class provides an inputstream offering a readLine() method * and handling #include directives. ************************************************************************* */ static class JPPExpandedStream { Vector iDirs = null; Stack fStack = null; Stack nameStack = null; Stack nbStack = null; DataInputStream fCur = null; String nameCur = null; int nbCur = -1; JPPExpandedStream (InputStream in, Vector includeDirs) throws java.io.IOException { fCur = new DataInputStream(new BufferedInputStream(in)); iDirs = includeDirs; fStack = new Stack(); nameStack = new Stack(); nbStack = new Stack(); nameCur = in.toString(); nbCur = 0; } String readLine() throws java.io.IOException { String line = fCur.readLine(); nbCur++; if (line == null) { if (!fStack.empty()) { fCur.close(); nbCur = ((Integer) nbStack.pop()).intValue(); line = "# "+nbCur+" "+"\""+nameCur+"\""+" 2"; nameCur = (String) nameStack.pop(); fCur = (DataInputStream) fStack.pop(); } } else { if (line.indexOf("#include") >= 0) { String fiName; StringTokenizer stLine = new StringTokenizer(line); stLine.nextToken(); fiName = stLine.nextToken(); fiName = this.includeFileName(fiName.substring(1,fiName.length()-1)); if (fiName == null) { System.out.println("Unknown include file : "+fiName); return ""; } else { fStack.push(fCur); nameStack.push(nameCur); nbStack.push(new Integer(nbCur)); fCur = new DataInputStream (new BufferedInputStream(new FileInputStream(fiName))); nameCur = new String(fiName); line = "# "+nbCur+" "+"\""+fiName+"\""+" 1"; nbCur = 0; } } } return(line); } private String includeFileName(String fName) { String fiName = null; Enumeration dirs = iDirs.elements(); while (dirs.hasMoreElements()) { fiName = new String((String)dirs.nextElement()+File.separatorChar+fName); File f = new File(fiName); if (f.exists()) return fiName; } return(null); } String getFileName() { return(nameCur); } int getLineNumber() { return(nbCur); } void close() throws java.io.IOException { fCur.close(); } } /* ************************************************************************* * This included class provides an inputstream offering a readLine() method. ************************************************************************* */ static class JPPInputStream extends FilterInputStream { public static final int BUFSIZE = 1024; public static final String NULLSTRING = ""; byte[] buffer = new byte[BUFSIZE]; boolean isMacFile; public JPPInputStream(InputStream iS,boolean isM) { super(iS); isMacFile = isM; } public JPPInputStream(InputStream iS) { this(iS,false); } public int read() throws IOException { return super.read(); } public String readLine() throws IOException { int i = readLine(buffer); if (i == -1) return null; else return new String(buffer,0,i); } public int readLine(byte[] buf) throws IOException { boolean escaped = false; boolean CRLFEscaped = false; boolean endWhile = false; int i = -1,car = 0,maxL = buf.length-1; while(!endWhile && i<maxL && (car = read())!= -1) { switch(car) { default : if (escaped) { buf[++i] = (byte) '\\'; escaped = false; } buf[++i] = (byte) car; if (CRLFEscaped) CRLFEscaped = false; break; case '\\' : if (escaped) { buf[++i] = (byte) '\\'; buf[++i] = (byte) '\\'; } escaped = !escaped; if (CRLFEscaped) CRLFEscaped = false; break; case '\r' : case '\n' : if (!escaped) { if (!CRLFEscaped) endWhile = true; else CRLFEscaped = false; } else if (!CRLFEscaped) CRLFEscaped = true; else CRLFEscaped = false; break; } } if (i>= 0 || endWhile) return i+1; else return -1; } } public static void main(String[] args) throws IOException { JPP jpp = new JPP(new FileInputStream(args[0]), System.out, new java.util.Vector(), new java.util.Hashtable()); jpp.preprocess(); } /** * JPP Constructor * * @param fileNameIn path of the jpp file * @param outputStream outputStream where to send the result * @param includeDirs list of the 'include' directories * @param definedNames list of the defined names */ public JPP(InputStream in, OutputStream outS, Vector includeDirs, Hashtable defNames) throws java.io.IOException { jpp_fIn = new JPPExpandedStream(in, includeDirs); jpp_fOut = outS; defined_names = defNames; } public boolean preprocess() throws java.io.IOException { String line = null; int negTest = 0,posTest = 0; Stack ifScope = new Stack(); Object curScope = NULLSCOPE; ifScope.push(curScope); while(true) { line = jpp_fIn.readLine(); if (line == null) { jpp_fIn.close(); return (errorNumber == 0); } StringTokenizer stLine; String nom1,nom2; switch(jppToken(line)) { case INST_DEFINE : if (negTest>0) break; stLine = new StringTokenizer(line.trim()); stLine.nextToken(); if (stLine.hasMoreTokens()) nom1 = stLine.nextToken(); else { printErrorMsg(jpp_fIn, "illegal empty definition of preprocessor variable", true); break; } if (stLine.hasMoreTokens()) { nom2 = stLine.nextToken(); while (stLine.hasMoreTokens()) nom2 = nom2 + " " + stLine.nextToken(); } else { nom2 = NULLSTRING; } if (defined_names.containsKey(nom1)) { printErrorMsg(jpp_fIn, "redefinition of preprocessor variable : " + nom1, false); } else { nb_defs++; } defined_names.put(nom1,nom2); break; case INST_UNDEF : if (negTest>0) break; stLine = new StringTokenizer(line); stLine.nextToken(); if (stLine.hasMoreTokens()) nom1 = stLine.nextToken(); else { printErrorMsg(jpp_fIn, "illegal empty (un)definition of preprocessor variable", true); break; } if (defined_names.containsKey(nom1)) { defined_names.remove(nom1); nb_defs--; } else { printErrorMsg(jpp_fIn, "(un)definition of unknown preprocessor variable : " + nom1, false); } break; case INST_IFDEF : curScope = IFSCOPE; ifScope.push(curScope); if (negTest>0) { negTest++; break; } stLine = new StringTokenizer(line); stLine.nextToken(); if (stLine.hasMoreTokens()) nom1 = stLine.nextToken(); else { printErrorMsg(jpp_fIn, "illegal empty #ifdef test of preprocessor variable", true); break; } if (defined_names.containsKey(nom1)) posTest++; else negTest++; break; case INST_IFNDEF : curScope = IFSCOPE; ifScope.push(curScope); if (negTest>0) { negTest++; break; } stLine = new StringTokenizer(line); stLine.nextToken(); if (stLine.hasMoreTokens()) nom1 = stLine.nextToken(); else { printErrorMsg(jpp_fIn, "illegal empty #ifndef test of preprocessor variable", true); break; } if (!defined_names.containsKey(nom1)) posTest++; else negTest++; break; case INST_IF : printErrorMsg(jpp_fIn,"unsupported #if processor directive ",true); break; case INST_ENDIF : if (curScope == NULLSCOPE) { printErrorMsg(jpp_fIn,"unbalanced #endif processor directive ",true); break; } curScope =ifScope.pop(); if (negTest>0) negTest--; else if (posTest>0) posTest--; break; case INST_ELIF : printErrorMsg(jpp_fIn,"unsupported #elif processor directive ",true); break; case INST_ELSE : if (curScope != IFSCOPE) { printErrorMsg(jpp_fIn,"unbalanced #else processor directive ",true); break; } ifScope.pop(); curScope = ELSESCOPE; ifScope.push(curScope); if (negTest>0) negTest--; else { negTest++; posTest--; } break; case NO_JPP_INST : if (negTest>0) break; if (nb_defs == 0) { jpp_fOut.write(line.getBytes()); jpp_fOut.write('\n'); } else { stLine = new StringTokenizer(line.trim(),JAVA_DELIM,true); String line2; if (stLine.hasMoreTokens()) { line2 = ""; while (stLine.hasMoreTokens()) { String tok2 = stLine.nextToken(); String tok3 = (String) defined_names.get(tok2); if (tok3 == null) line2 = line2+tok2; else line2 = line2+tok3; } jpp_fOut.write(line2.getBytes()); } jpp_fOut.write('\n'); } break; case INST_INCLUDE : printErrorMsg(jpp_fIn, "preprocessor ERROR : unexpected #include directive",true); } } } void printErrorMsg(JPPExpandedStream jE,String msg,boolean isErr) { System.out.println("File "+jE.getFileName()+" at line "+jE.getLineNumber()+" : "+msg); if (isErr) errorNumber++; } } Index: SLParser.java =================================================================== RCS file: /cvsroot/jrman/drafts/javacc/SLParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SLParser.java 3 Feb 2004 15:39:34 -0000 1.2 --- SLParser.java 4 Feb 2004 14:46:51 -0000 1.3 *************** *** 2,5 **** --- 2,8 ---- import java.io.FileInputStream; import java.io.IOException; + import java.io.ByteArrayInputStream; + import java.io.ByteArrayOutputStream; + import java.io.InputStream; public class SLParser implements SLParserConstants { *************** *** 7,21 **** main(String args[]) throws ParseException, IOException { if (args.length == 0) ! { ! SLParser parser = new SLParser(System.in); ! parser.compilationUnit(); ! } ! else if (args.length == 1) ! { ! String filename = args[0]; ! SLParser parser = new SLParser(new FileInputStream(filename)); ! parser.compilationUnit(); ! } } --- 10,27 ---- main(String args[]) throws ParseException, IOException { + InputStream in; if (args.length == 0) ! in = System.in; ! else ! in = new FileInputStream(args[0]); ! ! ! ByteArrayOutputStream out = new ByteArrayOutputStream(); ! JPP jpp = new JPP(in, out, new java.util.Vector(), new java.util.Hashtable()); ! jpp.preprocess(); ! ! SLParser parser = new SLParser(new ByteArrayInputStream(out.toByteArray())); ! parser.compilationUnit(); ! } *************** *** 697,701 **** break label_6; } ! jj_consume_token(77); conditionalAndExpression(); } --- 703,707 ---- break label_6; } ! jj_consume_token(74); conditionalAndExpression(); } *************** *** 711,715 **** break label_7; } ! jj_consume_token(78); equalityExpression(); } --- 717,721 ---- break label_7; } ! jj_consume_token(75); equalityExpression(); } *************** *** 726,734 **** } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { ! case 79: ! jj_consume_token(79); break; ! case 80: ! jj_consume_token(80); break; default: --- 732,740 ---- } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { ! case 76: ! jj_consume_token(76); break; ! case 77: ! jj_consume_token(77); break; default: *************** *** 751,765 **** } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { ! case 81: ! jj_consume_token(81); break; ! case 82: ! jj_consume_token(82); break; ! case 83: ! jj_consume_token(83); break; ! case 84: ! jj_consume_token(84); break; default: --- 757,771 ---- } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { ! case 78: ! jj_consume_token(78); break; ! case 79: ! jj_consume_token(79); break; ! case 80: ! jj_consume_token(80); break; ! case 81: ! jj_consume_token(81); break; default: *************** *** 1409,1412 **** --- 1415,1444 ---- } + static final private boolean jj_3_4() { + if (jj_3R_17()) return true; + return false; + } + + static final private boolean jj_3R_56() { + if (jj_3R_69()) return true; + return false; + } + + static final private boolean jj_3_16() { + Token xsp; + xsp = jj_scanpos; + if (jj_scan_token(60)) { + jj_scanpos = xsp; + if (jj_scan_token(61)) return true; + } + if (jj_3R_24()) return true; + return false; + } + + static final private boolean jj_3R_60() { + if (jj_3R_47()) return true; + return false; + } + static final private boolean jj_3R_59() { if (jj_3R_71()) return true; *************** *** 1417,1427 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(76)) { jj_scanpos = xsp; ! if (jj_scan_token(65)) { jj_scanpos = xsp; ! if (jj_scan_token(66)) { jj_scanpos = xsp; ! if (jj_scan_token(67)) return true; } } --- 1449,1459 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(73)) { jj_scanpos = xsp; ! if (jj_scan_token(62)) { jj_scanpos = xsp; ! if (jj_scan_token(63)) { jj_scanpos = xsp; ! if (jj_scan_token(64)) return true; } } *************** *** 1436,1440 **** if (jj_3R_55()) { jj_scanpos = xsp; ! if (jj_scan_token(51)) { jj_scanpos = xsp; if (jj_3R_56()) { --- 1468,1472 ---- if (jj_3R_55()) { jj_scanpos = xsp; ! if (jj_scan_token(48)) { jj_scanpos = xsp; if (jj_3R_56()) { *************** *** 1500,1510 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(81)) { jj_scanpos = xsp; ! if (jj_scan_token(82)) { jj_scanpos = xsp; ! if (jj_scan_token(83)) { jj_scanpos = xsp; ! if (jj_scan_token(84)) return true; } } --- 1532,1542 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(78)) { jj_scanpos = xsp; ! if (jj_scan_token(79)) { jj_scanpos = xsp; ! if (jj_scan_token(80)) { jj_scanpos = xsp; ! if (jj_scan_token(81)) return true; } } *************** *** 1537,1543 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(79)) { jj_scanpos = xsp; ! if (jj_scan_token(80)) return true; } if (jj_3R_22()) return true; --- 1569,1575 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(76)) { jj_scanpos = xsp; ! if (jj_scan_token(77)) return true; } if (jj_3R_22()) return true; *************** *** 1548,1554 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(63)) { jj_scanpos = xsp; ! if (jj_scan_token(64)) return true; } if (jj_3R_25()) return true; --- 1580,1586 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(60)) { jj_scanpos = xsp; ! if (jj_scan_token(61)) return true; } if (jj_3R_25()) return true; *************** *** 1577,1581 **** static final private boolean jj_3_13() { ! if (jj_scan_token(78)) return true; if (jj_3R_21()) return true; return false; --- 1609,1613 ---- static final private boolean jj_3_13() { ! if (jj_scan_token(75)) return true; if (jj_3R_21()) return true; return false; *************** *** 1583,1587 **** static final private boolean jj_3_12() { ! if (jj_scan_token(77)) return true; if (jj_3R_20()) return true; return false; --- 1615,1619 ---- static final private boolean jj_3_12() { ! if (jj_scan_token(74)) return true; if (jj_3R_20()) return true; return false; *************** *** 1589,1593 **** static final private boolean jj_3R_46() { ! if (jj_scan_token(52)) return true; Token xsp; xsp = jj_scanpos; --- 1621,1625 ---- static final private boolean jj_3R_46() { ! if (jj_scan_token(49)) return true; Token xsp; xsp = jj_scanpos; *************** *** 1640,1646 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(28)) { jj_scanpos = xsp; ! if (jj_scan_token(29)) return true; } return false; --- 1672,1678 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(25)) { jj_scanpos = xsp; ! if (jj_scan_token(26)) return true; } return false; *************** *** 1696,1710 **** static final private boolean jj_3_10() { ! if (jj_scan_token(51)) return true; return false; } static final private boolean jj_3_9() { ! if (jj_scan_token(51)) return true; return false; } static final private boolean jj_3_8() { ! if (jj_scan_token(51)) return true; return false; } --- 1728,1742 ---- static final private boolean jj_3_10() { ! if (jj_scan_token(48)) return true; return false; } static final private boolean jj_3_9() { ! if (jj_scan_token(48)) return true; return false; } static final private boolean jj_3_8() { ! if (jj_scan_token(48)) return true; return false; } *************** *** 1713,1717 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(27)) jj_scanpos = xsp; if (jj_3R_29()) return true; if (jj_3R_30()) return true; --- 1745,1749 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(24)) jj_scanpos = xsp; if (jj_3R_29()) return true; if (jj_3R_30()) return true; *************** *** 1728,1732 **** static final private boolean jj_3_7() { ! if (jj_scan_token(51)) return true; return false; } --- 1760,1764 ---- static final private boolean jj_3_7() { ! if (jj_scan_token(48)) return true; return false; } *************** *** 1738,1742 **** static final private boolean jj_3_6() { ! if (jj_scan_token(51)) return true; return false; } --- 1770,1774 ---- static final private boolean jj_3_6() { ! if (jj_scan_token(48)) return true; return false; } *************** *** 1754,1758 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(61)) jj_scanpos = xsp; while (true) { xsp = jj_scanpos; --- 1786,1790 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(58)) jj_scanpos = xsp; while (true) { xsp = jj_scanpos; *************** *** 1797,1800 **** --- 1829,1838 ---- Token xsp; xsp = jj_scanpos; + if (jj_scan_token(16)) { + jj_scanpos = xsp; + if (jj_scan_token(17)) { + jj_scanpos = xsp; + if (jj_scan_token(18)) { + jj_scanpos = xsp; if (jj_scan_token(19)) { jj_scanpos = xsp; *************** *** 1805,1815 **** if (jj_scan_token(22)) { jj_scanpos = xsp; ! if (jj_scan_token(23)) { ! jj_scanpos = xsp; ! if (jj_scan_token(24)) { ! jj_scanpos = xsp; ! if (jj_scan_token(25)) { ! jj_scanpos = xsp; ! if (jj_scan_token(26)) return true; } } --- 1843,1847 ---- if (jj_scan_token(22)) { jj_scanpos = xsp; ! if (jj_scan_token(23)) return true; } } *************** *** 1825,1829 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(34)) jj_scanpos = xsp; if (jj_3R_29()) return true; return false; --- 1857,1861 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(31)) jj_scanpos = xsp; if (jj_3R_29()) return true; return false; *************** *** 1833,1839 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(19)) { jj_scanpos = xsp; ! if (jj_scan_token(20)) { jj_scanpos = xsp; if (jj_3R_81()) { --- 1865,1871 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(16)) { jj_scanpos = xsp; ! if (jj_scan_token(17)) { jj_scanpos = xsp; if (jj_3R_81()) { *************** *** 1909,1921 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(69)) { jj_scanpos = xsp; ! if (jj_scan_token(71)) { jj_scanpos = xsp; ! if (jj_scan_token(72)) { jj_scanpos = xsp; ! if (jj_scan_token(73)) { jj_scanpos = xsp; ! if (jj_scan_token(74)) return true; } } --- 1941,1953 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(66)) { jj_scanpos = xsp; ! if (jj_scan_token(68)) { jj_scanpos = xsp; ! if (jj_scan_token(69)) { jj_scanpos = xsp; ! if (jj_scan_token(70)) { jj_scanpos = xsp; ! if (jj_scan_token(71)) return true; } } *************** *** 1926,1930 **** static final private boolean jj_3R_26() { ! if (jj_scan_token(52)) return true; Token xsp; xsp = jj_scanpos; --- 1958,1962 ---- static final private boolean jj_3R_26() { ! if (jj_scan_token(49)) return true; Token xsp; xsp = jj_scanpos; *************** *** 1955,1959 **** static final private boolean jj_3R_17() { ! if (jj_scan_token(52)) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; --- 1987,1991 ---- static final private boolean jj_3R_17() { ! if (jj_scan_token(49)) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; *************** *** 2028,2034 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(35)) { jj_scanpos = xsp; ! if (jj_scan_token(36)) return true; } return false; --- 2060,2066 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(32)) { jj_scanpos = xsp; ! if (jj_scan_token(33)) return true; } return false; *************** *** 2038,2046 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(30)) { jj_scanpos = xsp; ! if (jj_scan_token(31)) { jj_scanpos = xsp; ! if (jj_scan_token(32)) return true; } } --- 2070,2078 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(27)) { jj_scanpos = xsp; ! if (jj_scan_token(28)) { jj_scanpos = xsp; ! if (jj_scan_token(29)) return true; } } *************** *** 2103,2109 **** Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(44)) { jj_scanpos = xsp; ! if (jj_scan_token(48)) return true; } return false; --- 2135,2141 ---- Token xsp; xsp = jj_scanpos; ! if (jj_scan_token(41)) { jj_scanpos = xsp; ! if (jj_scan_token(45)) return true; } return false; *************** *** 2149,2153 **** static final private boolean jj_3_5() { ! if (jj_scan_token(52)) return true; Token xsp; xsp = jj_scanpos; --- 2181,2185 ---- static final private boolean jj_3_5() { ! if (jj_scan_token(49)) return true; Token xsp; xsp = jj_scanpos; *************** *** 2164,2193 **** } - static final private boolean jj_3_4() { - if (jj_3R_17()) return true; - return false; - } - - static final private boolean jj_3R_56() { - if (jj_3R_69()) return true; - return false; - } - - static final private boolean jj_3_16() { - Token xsp; - xsp = jj_scanpos; - if (jj_scan_token(63)) { - jj_scanpos = xsp; - if (jj_scan_token(64)) return true; - } - if (jj_3R_24()) return true; - return false; - } - - static final private boolean jj_3R_60() { - if (jj_3R_47()) return true; - return false; - } - static private boolean jj_initialized_once = false; static public SLParserTokenManager token_source; --- 2196,2199 ---- *************** *** 2210,2220 **** } private static void jj_la1_0() { ! jj_la1_0 = new int[] {0x7ffc000,0x7ffc000,0x3ff80000,0x7f80000,0x3ff80000,0x7c000,0x7f80000,0x0,0x8000000,0x30000000,0x30000000,0x0,0x0,0xc0000000,0x0,0xc0000000,0x0,0x0,0x0,0x0,0xc0000000,0x0,0xc3f80000,0x0,0x0,0x0,0x0,0x0,0x3f80000,0x0,0x0,0x0,0x0,0x0,0xc3f80000,0xc3f80000,0x0,0x37f80000,0x0,0x0,0x0,0xc3f80000,0xc3f80000,0xc3f80000,0x0,0x0,0x3ff80000,0x37f80000,}; } private static void jj_la1_1() { ! jj_la1_1 = new int[] {0x100000,0x100000,0x0,0x0,0x0,0x0,0x0,0x20000000,0x0,0x0,0x0,0x40000000,0x0,0x991001,0x0,0x91001,0x800000,0x11000,0x8000000,0x40000000,0x1,0x40000000,0x80991001,0x40000000,0x8000000,0x0,0x40000000,0x40000000,0x0,0x0,0x0,0x80000000,0x0,0x80000000,0x80991001,0x991001,0x2000000,0x100fbe,0x1000,0x18,0xf80,0x80991001,0x80991001,0x80991001,0x40000000,0x4,0x2100fbe,0x2100fbe,}; } private static void jj_la1_2() { ! jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x20,0x0,0x7a0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x0,0x0,0x7a0,0x0,0x0,0x0,0x18000,0x1e0000,0x1,0x100e,0x1,0x11,0x10,0x0,0x0,0x0,0x0,0x0,0x11,0x11,0x11,0x0,0x0,0x0,0x0,}; } static final private JJCalls[] jj_2_rtns = new JJCalls[20]; --- 2216,2226 ---- } private static void jj_la1_0() { ! jj_la1_0 = new int[] {0xfff800,0xfff800,0x7ff0000,0xff0000,0x7ff0000,0xf800,0xff0000,0x0,0x1000000,0x6000000,0x6000000,0x0,0x0,0x38000000,0x0,0x38000000,0x0,0x0,0x0,0x0,0x38000000,0x0,0x387f0000,0x0,0x0,0x0,0x0,0x0,0x7f0000,0x0,0x0,0x0,0x0,0x0,0x387f0000,0x387f0000,0x0,0xc6ff0000,0x0,0x0,0x0,0x387f0000,0x387f0000,0x387f0000,0x0,0x80000000,0xc7ff0000,0xc6ff0000,}; } private static void jj_la1_1() { ! jj_la1_1 = new int[] {0x20000,0x20000,0x0,0x0,0x0,0x0,0x0,0x4000000,0x0,0x0,0x0,0x8000000,0x0,0x132200,0x0,0x12200,0x100000,0x2200,0x1000000,0x8000000,0x0,0x8000000,0x30132200,0x8000000,0x1000000,0x0,0x8000000,0x8000000,0x0,0x0,0x0,0x30000000,0xc0000000,0x30000000,0x30132200,0x132200,0x400000,0x201f7,0x200,0x3,0x1f0,0x30132200,0x30132200,0x30132200,0x8000000,0x0,0x4201f7,0x4201f7,}; } private static void jj_la1_2() { ! jj_la1_2 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x4,0x0,0xf4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0xf4,0x0,0x0,0x0,0x3000,0x3c000,0x0,0x201,0x0,0x2,0x2,0x0,0x0,0x0,0x0,0x0,0x2,0x2,0x2,0x0,0x0,0x0,0x0,}; } static final private JJCalls[] jj_2_rtns = new JJCalls[20]; *************** *** 2408,2413 **** static public ParseException generateParseException() { jj_expentries.removeAllElements(); ! boolean[] la1tokens = new boolean[85]; ! for (int i = 0; i < 85; i++) { la1tokens[i] = false; } --- 2414,2419 ---- static public ParseException generateParseException() { jj_expentries.removeAllElements(); ! boolean[] la1tokens = new boolean[82]; ! for (int i = 0; i < 82; i++) { la1tokens[i] = false; } *************** *** 2431,2435 **** } } ! for (int i = 0; i < 85; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; --- 2437,2441 ---- } } ! for (int i = 0; i < 82; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; Index: SLParser.jj =================================================================== RCS file: /cvsroot/jrman/drafts/javacc/SLParser.jj,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SLParser.jj 3 Feb 2004 15:39:34 -0000 1.5 --- SLParser.jj 4 Feb 2004 14:46:51 -0000 1.6 *************** *** 24,30 **** PARSER_BEGIN(SLParser) ! import java.io.FileInputStream; import java.io.IOException; public class SLParser --- 24,33 ---- PARSER_BEGIN(SLParser) ! import java.io.FileInputStream; import java.io.IOException; + import java.io.ByteArrayInputStream; + import java.io.ByteArrayOutputStream; + import java.io.InputStream; public class SLParser *************** *** 33,47 **** main(String args[]) throws ParseException, IOException { if (args.length == 0) ! { ! SLParser parser = new SLParser(System.in); ! parser.compilationUnit(); ! } ! else if (args.length == 1) ! { ! String filename = args[0]; ! SLParser parser = new SLParser(new FileInputStream(filename)); ! parser.compilationUnit(); ! } } } --- 36,53 ---- main(String args[]) throws ParseException, IOException { + InputStream in; if (args.length == 0) ! in = System.in; ! else ! in = new FileInputStream(args[0]); ! ! ! ByteArrayOutputStream out = new ByteArrayOutputStream(); ! JPP jpp = new JPP(in, out, new java.util.Vector(), new java.util.Hashtable()); ! jpp.preprocess(); ! ! SLParser parser = new SLParser(new ByteArrayInputStream(out.toByteArray())); ! parser.compilationUnit(); ! } } *************** *** 58,74 **** | "\r" | "\f" - | "#" : PREPROCESSOR_OUTPUT - } - <PREPROCESSOR_OUTPUT> SKIP: - { - "\n" : DEFAULT - } - - <PREPROCESSOR_OUTPUT> MORE: - { - < ~[] > - } /* COMMENTS */ --- 64,69 ---- Index: SLParserConstants.java =================================================================== RCS file: /cvsroot/jrman/drafts/javacc/SLParserConstants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLParserConstants.java 2 Feb 2004 05:45:30 -0000 1.1 --- SLParserConstants.java 4 Feb 2004 14:46:51 -0000 1.2 *************** *** 3,76 **** int EOF = 0; ! int SINGLE_LINE_COMMENT = 11; ! int MULTI_LINE_COMMENT = 12; ! int LIGHT = 14; ! int SURFACE = 15; ! int VOLUME = 16; ! int DISPLACEMENT = 17; ! int IMAGER = 18; ! int FLOAT = 19; ! int STRING = 20; ! int COLOR = 21; ! int POINT = 22; ! int VECTOR = 23; ! int NORMAL = 24; ! int MATRIX = 25; ! int VOID = 26; ! int OUTPUT = 27; ! int VARYING = 28; ! int UNIFORM = 29; ! int TEXTURE = 30; ! int ENVIRONMENT = 31; ! int SHADOW = 32; ! int RETURN = 33; ! int EXTERN = 34; ! int BREAK = 35; ! int CONTINUE = 36; ! int IF = 37; ! int ELSE = 38; ! int WHILE = 39; ! int FOR = 40; ! int SOLAR = 41; ! int ILLUMINATE = 42; ! int ILLUMINANCE = 43; ! int INTEGER_LITERAL = 44; ! int DECIMAL_LITERAL = 45; ! int HEX_LITERAL = 46; ! int OCTAL_LITERAL = 47; ! int FLOATING_POINT_LITERAL = 48; ! int EXPONENT = 49; ! int CHARACTER_LITERAL = 50; ! int STRING_LITERAL = 51; ! int IDENTIFIER = 52; ! int LETTER = 53; ! int DIGIT = 54; ! int LPAREN = 55; ! int RPAREN = 56; ! int LBRACE = 57; ! int RBRACE = 58; ! int LBRACKET = 59; ! int RBRACKET = 60; ! int SEMICOLON = 61; ! int COMMA = 62; ! int PLUS = 63; ! int MINUS = 64; ! int STAR = 65; ! int SLASH = 66; ! int EXP = 67; ! int BANG = 68; ! int ASSIGN = 69; ! int HOOK = 70; ! int PLUSASSIGN = 71; ! int MINUSASSIGN = 72; ! int STARASSIGN = 73; ! int SLASHASSIGN = 74; ! int COLON = 75; ! int DOT = 76; int DEFAULT = 0; ! int PREPROCESSOR_OUTPUT = 1; ! int IN_SINGLE_LINE_COMMENT = 2; ! int IN_MULTI_LINE_COMMENT = 3; String[] tokenImage = { --- 3,75 ---- int EOF = 0; ! int SINGLE_LINE_COMMENT = 8; ! int MULTI_LINE_COMMENT = 9; ! int LIGHT = 11; ! int SURFACE = 12; ! int VOLUME = 13; ! int DISPLACEMENT = 14; ! int IMAGER = 15; ! int FLOAT = 16; ! int STRING = 17; ! int COLOR = 18; ! int POINT = 19; ! int VECTOR = 20; ! int NORMAL = 21; ! int MATRIX = 22; ! int VOID = 23; ! int OUTPUT = 24; ! int VARYING = 25; ! int UNIFORM = 26; ! int TEXTURE = 27; ! int ENVIRONMENT = 28; ! int SHADOW = 29; ! int RETURN = 30; ! int EXTERN = 31; ! int BREAK = 32; ! int CONTINUE = 33; ! int IF = 34; ! int ELSE = 35; ! int WHILE = 36; ! int FOR = 37; ! int SOLAR = 38; ! int ILLUMINATE = 39; ! int ILLUMINANCE = 40; ! int INTEGER_LITERAL = 41; ! int DECIMAL_LITERAL = 42; ! int HEX_LITERAL = 43; ! int OCTAL_LITERAL = 44; ! int FLOATING_POINT_LITERAL = 45; ! int EXPONENT = 46; ! int CHARACTER_LITERAL = 47; ! int STRING_LITERAL = 48; ! int IDENTIFIER = 49; ! int LETTER = 50; ! int DIGIT = 51; ! int LPAREN = 52; ! int RPAREN = 53; ! int LBRACE = 54; ! int RBRACE = 55; ! int LBRACKET = 56; ! int RBRACKET = 57; ! int SEMICOLON = 58; ! int COMMA = 59; ! int PLUS = 60; ! int MINUS = 61; ! int STAR = 62; ! int SLASH = 63; ! int EXP = 64; ! int BANG = 65; ! int ASSIGN = 66; ! int HOOK = 67; ! int PLUSASSIGN = 68; ! int MINUSASSIGN = 69; ! int STARASSIGN = 70; ! int SLASHASSIGN = 71; ! int COLON = 72; ! int DOT = 73; int DEFAULT = 0; ! int IN_SINGLE_LINE_COMMENT = 1; ! int IN_MULTI_LINE_COMMENT = 2; String[] tokenImage = { *************** *** 81,92 **** "\"\\r\"", "\"\\f\"", - "\"#\"", - "\"\\n\"", - "<token of kind 8>", "\"//\"", "\"/*\"", "<SINGLE_LINE_COMMENT>", "\"*/\"", ! "<token of kind 13>", "\"light\"", "\"surface\"", --- 80,88 ---- "\"\\r\"", "\"\\f\"", "\"//\"", "\"/*\"", "<SINGLE_LINE_COMMENT>", "\"*/\"", ! "<token of kind 10>", "\"light\"", "\"surface\"", Index: SLParserTokenManager.java =================================================================== RCS file: /cvsroot/jrman/drafts/javacc/SLParserTokenManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLParserTokenManager.java 2 Feb 2004 05:45:30 -0000 1.1 --- SLParserTokenManager.java 4 Feb 2004 14:46:51 -0000 1.2 *************** *** 2,5 **** --- 2,8 ---- import java.io.FileInputStream; import java.io.IOException; + import java.io.ByteArrayInputStream; + import java.io.ByteArrayOutputStream; + import java.io.InputStream; public class SLParserTokenManager implements SLParserConstants *************** *** 12,39 **** [...1575 lines suppressed...] ! jjmatchedKind = 13; ! } ! break; ! case 3: ! jjmatchedKind = 0x7fffffff; ! jjmatchedPos = 0; ! curPos = jjMoveStringLiteralDfa0_3(); ! if (jjmatchedPos == 0 && jjmatchedKind > 13) { ! jjmatchedKind = 13; } break; --- 1391,1397 ---- jjmatchedPos = 0; curPos = jjMoveStringLiteralDfa0_2(); ! if (jjmatchedPos == 0 && jjmatchedKind > 10) { ! jjmatchedKind = 10; } break; |
From: <ega...@us...> - 2004-02-03 16:01:02
|
Update of /cvsroot/jrman/drafts/javacc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20035 Modified Files: SLParser.java SLParser.jj Log Message: Fixed bug in tripe and sixteenntuple. Index: SLParser.java =================================================================== RCS file: /cvsroot/jrman/drafts/javacc/SLParser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SLParser.java 2 Feb 2004 05:45:30 -0000 1.1 --- SLParser.java 3 Feb 2004 15:39:34 -0000 1.2 *************** *** 365,376 **** ; } - } else if (jj_2_6(3)) { - single(); - } else if (jj_2_7(3)) { - triple(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: ! sixteentuple(); [...2072 lines suppressed...] static final private void jj_rescan_token() { jj_rescan = true; ! for (int i = 0; i < 22; i++) { JJCalls p = jj_2_rtns[i]; do { --- 2456,2460 ---- static final private void jj_rescan_token() { jj_rescan = true; ! for (int i = 0; i < 20; i++) { JJCalls p = jj_2_rtns[i]; do { *************** *** 2511,2516 **** case 18: jj_3_19(); break; case 19: jj_3_20(); break; - case 20: jj_3_21(); break; - case 21: jj_3_22(); break; } } --- 2482,2485 ---- Index: SLParser.jj =================================================================== RCS file: /cvsroot/jrman/drafts/javacc/SLParser.jj,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SLParser.jj 2 Feb 2004 05:45:30 -0000 1.4 --- SLParser.jj 3 Feb 2004 15:39:34 -0000 1.5 *************** *** 380,388 **** //assignExpression(), identifier() | ! LOOKAHEAD(3) single() ! | ! LOOKAHEAD(3) triple() ! | ! sixteentuple() } --- 380,385 ---- //assignExpression(), identifier() | ! single() ! //triple(), sixteentuple() } *************** *** 468,472 **** {} { ! "("expression()")" } --- 465,469 ---- {} { ! "("expression() [triple()]")" } *************** *** 474,478 **** {} { ! "("expression()","expression()","expression()")" } --- 471,475 ---- {} { ! ","expression()","expression() [sixteentuple()] } *************** *** 480,487 **** {} { ! "("expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() - ","expression()","expression()","expression()","expression()")" } --- 477,484 ---- {} { ! ","expression() ! ","expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() ","expression()","expression()","expression()","expression() } |
From: <ma...@us...> - 2004-02-02 19:32:12
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25763/src/org/jrman/parser Modified Files: Frame.java Parser.java Log Message: Many optimizations. Rewrote oclusion culling. Implemented smaller footprint PointsPolygons. Index: Frame.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Frame.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Frame.java 11 Dec 2003 20:21:11 -0000 1.15 --- Frame.java 2 Feb 2004 19:30:06 -0000 1.16 *************** *** 109,114 **** private boolean endOfFrameStatistics; - private boolean fileBuckets; - private boolean showProgressEnabled; --- 109,112 ---- *************** *** 179,183 **** bucketSizeY = other.bucketSizeY; endOfFrameStatistics = other.endOfFrameStatistics; - fileBuckets = other.fileBuckets; showProgressEnabled = other.showProgressEnabled; framebufferAlways = other.framebufferAlways; --- 177,180 ---- *************** *** 539,549 **** } - public boolean fileBucketsEnabled() { - return fileBuckets; - } - - public void setFileBuckets(boolean b) { - fileBuckets = b; - } - } --- 536,538 ---- Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** Parser.java 28 Jan 2004 07:27:43 -0000 1.76 --- Parser.java 2 Feb 2004 19:30:06 -0000 1.77 *************** *** 79,82 **** --- 79,83 ---- import org.jrman.primitive.Paraboloid; import org.jrman.primitive.Point; + import org.jrman.primitive.PointsPolygons; import org.jrman.primitive.Primitive; import org.jrman.primitive.Sphere; *************** *** 626,634 **** if (param != null) frame.setEndOfFrameStatistics(param.getValue() != 0); - } else if (name.equals("buckets")) { - UniformScalarInteger param = - (UniformScalarInteger) parameters.getParameter("file"); - if (param != null) - frame.setFileBuckets(param.getValue() != 0); } else if (name.equals("quality")) { UniformScalarInteger param = --- 627,630 ---- *************** *** 947,950 **** --- 943,970 ---- } + public void addPointsPolygons( + final int[] nVertices, + final int[] vertices, + final ParameterList parameters) { + if (inAreaLightSource) + return; + if (!inObject) + renderer.addPrimitive( + new PointsPolygons(nVertices, vertices, parameters, getAttributes())); + else { + final Transform transform = currentAttributes.getTransform(); + currentObjectInstanceList + .addPrimitiveCreator(new ObjectInstanceList.PrimitiveCreator() { + public Primitive create(Attributes attributes) { + return new PointsPolygons( + nVertices, + vertices, + parameters, + createAttributes(transform, attributes)); + } + }); + } + } + public void addPointsPolygon( float[] nVertices, |
From: <ma...@us...> - 2004-02-02 19:32:12
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25763/src/org/jrman/primitive Modified Files: Primitive.java BicubicPatch.java BilinearPatch.java Added Files: PointsPolygons.java Log Message: Many optimizations. Rewrote oclusion culling. Implemented smaller footprint PointsPolygons. --- NEW FILE: PointsPolygons.java --- /* PointsPolygon.java Copyright (C) 2004 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.jrman.primitive; import javax.vecmath.Point3f; import org.jrman.attributes.Attributes; import org.jrman.geom.BoundingVolume; import org.jrman.geom.ConvexHull3f; import org.jrman.geom.MutableBounds3f; import org.jrman.parameters.ParameterList; import org.jrman.parameters.VaryingScalarTuple3f; public class PointsPolygons extends Primitive { static Point3f tmpPoint = new Point3f(); int[] nVertices; int[] vertices; VaryingScalarTuple3f points; VaryingScalarTuple3f normals; public PointsPolygons( int[] nVertices, int[] vertices, ParameterList parameters, Attributes attributes) { this.parameters = parameters; this.attributes = attributes; this.nVertices = nVertices; this.vertices = vertices; points = (VaryingScalarTuple3f) parameters.getParameter("P"); parameters.removeParameter("P"); normals = (VaryingScalarTuple3f) parameters.getParameter("N"); parameters.removeParameter("N"); } public BoundingVolume getBoundingVolume() { MutableBounds3f mb = new MutableBounds3f(); for (int i = 0, n = points.getCount(); i < n; i++) { points.getValue(i, tmpPoint); mb.addPoint(tmpPoint); } return mb; } public Primitive[] split() { Primitive[] result = new Primitive[nVertices.length]; int offset = 0; for (int i = 0; i < nVertices.length; i++) { result[i] = new Polygon(nVertices[i], offset, parameters, attributes); offset += nVertices[i]; } return result; } public boolean isReadyToBeDiced(int gridsize) { return false; } private class Polygon extends Primitive { private int n; private int offset; Polygon(int n, int offset, ParameterList parameters, Attributes attributes) { this.n = n; this.offset = offset; this.parameters = parameters; this.attributes = attributes; } public BoundingVolume getBoundingVolume() { ConvexHull3f ch = new ConvexHull3f(); for (int i = 0; i < n; i++) { points.getValue(vertices[offset + i], tmpPoint); ch.addPoint(tmpPoint); } return ch; } public Primitive[] split() { Primitive[] result = new Primitive[n - 3 + 1]; for (int i = 1; i < n - 1; i++) { VaryingScalarTuple3f npoints = new VaryingScalarTuple3f(points.getDeclaration(), new float[4 * 3]); VaryingScalarTuple3f nnormals = null; if (normals != null) nnormals = new VaryingScalarTuple3f(normals.getDeclaration(), new float[4 * 3]); ParameterList newParameters = new ParameterList(parameters); points.getValue(vertices[offset], tmpPoint); npoints.setValue(0, tmpPoint); points.getValue(vertices[offset + i], tmpPoint); npoints.setValue(1, tmpPoint); points.getValue(vertices[offset], tmpPoint); npoints.setValue(2, tmpPoint); points.getValue(vertices[offset + i + 1], tmpPoint); npoints.setValue(3, tmpPoint); if (normals != null) { normals.getValue(vertices[offset], tmpPoint); nnormals.setValue(0, tmpPoint); normals.getValue(vertices[offset + i], tmpPoint); nnormals.setValue(1, tmpPoint); normals.getValue(vertices[offset], tmpPoint); nnormals.setValue(2, tmpPoint); normals.getValue(vertices[offset + i + 1], tmpPoint); nnormals.setValue(3, tmpPoint); } newParameters.removeParameter(npoints.getDeclaration().getName()); newParameters.addParameter(npoints); if (normals != null) { newParameters.removeParameter(nnormals.getDeclaration().getName()); newParameters.addParameter(nnormals); } result[i - 1] = new BilinearPatch(newParameters, attributes); } return result; } public boolean isReadyToBeDiced(int gridsize) { return false; } public boolean shouldSortBucket() { return false; } } } Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Primitive.java 20 Dec 2003 15:35:05 -0000 1.24 --- Primitive.java 2 Feb 2004 19:30:05 -0000 1.25 *************** *** 88,91 **** --- 88,94 ---- protected Transform objectToCamera; + + protected Primitive() { + } protected Primitive(ParameterList parameters, Attributes attributes) { *************** *** 105,109 **** public float getMinGridSize() { ! return 16f; } --- 108,112 ---- public float getMinGridSize() { ! return 9f; } *************** *** 544,546 **** --- 547,553 ---- } + public boolean shouldSortBucket() { + return true; + } + } Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BicubicPatch.java 16 Dec 2003 00:06:41 -0000 1.7 --- BicubicPatch.java 2 Feb 2004 19:30:05 -0000 1.8 *************** *** 186,191 **** float uv11) { ParameterList result = linearInterpolateParameters(uv00, uv10, uv01, uv11); - // result.removeParameter("u"); - // result.removeParameter("v"); extractPoints(); VaryingScalarTuple3f sparam = --- 186,189 ---- Index: BilinearPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BilinearPatch.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BilinearPatch.java 28 Jan 2004 07:27:43 -0000 1.4 --- BilinearPatch.java 2 Feb 2004 19:30:05 -0000 1.5 *************** *** 104,106 **** --- 104,110 ---- } + public float getMinGridSize() { + return 4f; + } + } |
From: <ma...@us...> - 2004-02-02 19:32:11
|
Update of /cvsroot/jrman/drafts/src/org/jrman/render In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25763/src/org/jrman/render Modified Files: Bucket.java MemoryBucket.java RendererHidden.java ShaderVariables.java Sampler.java SimpleMicropolygon.java SamplePoint.java Micropolygon.java Removed Files: FileBucket.java FastSimpleMicropolygon.java Log Message: Many optimizations. Rewrote oclusion culling. Implemented smaller footprint PointsPolygons. Index: Bucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Bucket.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Bucket.java 5 Nov 2003 04:13:12 -0000 1.9 --- Bucket.java 2 Feb 2004 19:30:05 -0000 1.10 *************** *** 38,42 **** void flush(); ! void prefetchMicropolygons(); } --- 38,42 ---- void flush(); ! void sortPrimitives(); } Index: MemoryBucket.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/MemoryBucket.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MemoryBucket.java 26 Nov 2003 01:21:58 -0000 1.5 --- MemoryBucket.java 2 Feb 2004 19:30:05 -0000 1.6 *************** *** 50,60 **** public Primitive getNextPrimitive() { if (primitivesModified) { Collections.sort(primitives); primitivesModified = false; } - Primitive p = (Primitive) primitives.get(primitives.size() - 1); - primitives.remove(primitives.size() - 1); - return p; } --- 50,63 ---- public Primitive getNextPrimitive() { + Primitive p = (Primitive) primitives.get(primitives.size() - 1); + primitives.remove(primitives.size() - 1); + return p; + } + + public void sortPrimitives() { if (primitivesModified) { Collections.sort(primitives); primitivesModified = false; } } *************** *** 76,81 **** } - public void prefetchMicropolygons() { - } - } --- 79,81 ---- Index: RendererHidden.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/RendererHidden.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** RendererHidden.java 28 Jan 2004 07:27:43 -0000 1.61 --- RendererHidden.java 2 Feb 2004 19:30:05 -0000 1.62 *************** *** 101,107 **** private int wExtra; ! private Transform oldObjectToWorld; ! private Transform oldObjectToCamera; --- 101,107 ---- private int wExtra; ! private Transform oldObjectToWorld; ! private Transform oldObjectToCamera; *************** *** 318,322 **** for (int column = 0; column < bucketColumns; column++) { Bucket bucket = getBucket(column, row); ! prefetchNextBucket(column, row); float samplerX = rmin.x + bucketWidth * column; float samplerY = rmin.y + bucketHeight * row; --- 318,322 ---- for (int column = 0; column < bucketColumns; column++) { Bucket bucket = getBucket(column, row); ! bucket.sortPrimitives(); float samplerX = rmin.x + bucketWidth * column; float samplerY = rmin.y + bucketHeight * row; *************** *** 353,357 **** shaderVariables.transform(cameraToRaster); shaderVariables.getMicropolygons(this); ! sampler.sampleBucket(bucket, bucket.hasMorePrimitives()); } else { Primitive[] sub = p.split(); --- 353,357 ---- shaderVariables.transform(cameraToRaster); shaderVariables.getMicropolygons(this); ! sampler.sampleBucket(bucket); } else { Primitive[] sub = p.split(); *************** *** 360,363 **** --- 360,365 ---- internalAddPrimitive(sub[i], column, row, true); } + if (p.shouldSortBucket()) + bucket.sortPrimitives(); } } else { *************** *** 367,371 **** } if (bucket.hasMoreMicropolygons()) ! sampler.sampleBucket(bucket, false); bucket.flush(); if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { --- 369,373 ---- } if (bucket.hasMoreMicropolygons()) ! sampler.sampleBucket(bucket); bucket.flush(); if (displayMode == Display.Mode.RGB || displayMode == Display.Mode.RGBA) { *************** *** 521,531 **** } - private void prefetchNextBucket(int column, int row) { - if (column < bucketColumns - 1) - getBucket(column + 1, row).prefetchMicropolygons(); - else if (row < bucketRows - 1) - getBucket(0, row + 1).prefetchMicropolygons(); - } - private boolean isPrimitiveVisible(Primitive p, Sampler sampler) { return sampler.isVisible(p.getRasterBounds(), p.getDistance()); --- 523,526 ---- *************** *** 655,665 **** else hExtra = 0; ! if (frame.fileBucketsEnabled()) ! for (int i = 0; i < buckets.length; i++) ! buckets[i] = new FileBucket(i); ! else { ! for (int i = 0; i < buckets.length; i++) ! buckets[i] = new MemoryBucket(); ! } } --- 650,655 ---- else hExtra = 0; ! for (int i = 0; i < buckets.length; i++) ! buckets[i] = new MemoryBucket(); } Index: ShaderVariables.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/ShaderVariables.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ShaderVariables.java 14 Jan 2004 03:06:35 -0000 1.11 --- ShaderVariables.java 2 Feb 2004 19:30:05 -0000 1.12 *************** *** 114,118 **** for (int row = 0; row < rows - 1; row++) { int offset = row * columns + col; ! Micropolygon mp = new FastSimpleMicropolygon(); if (mp .init( --- 114,118 ---- for (int row = 0; row < rows - 1; row++) { int offset = row * columns + col; ! Micropolygon mp = new SimpleMicropolygon(); if (mp .init( *************** *** 127,131 **** o[offset].z)) rh.addToBuckets(mp); ! mp = new FastSimpleMicropolygon(); if (mp .init( --- 127,131 ---- o[offset].z)) rh.addToBuckets(mp); ! mp = new SimpleMicropolygon(); if (mp .init( Index: Sampler.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Sampler.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Sampler.java 14 Jan 2004 03:06:35 -0000 1.20 --- Sampler.java 2 Feb 2004 19:30:05 -0000 1.21 *************** *** 61,64 **** --- 61,68 ---- private boolean modified; + + private int samplesPerPixel; + + private int pixelsPerBucket; private boolean hasSamples; *************** *** 79,87 **** boolean modified; void reset() { z = Constants.INFINITY; opaque = false; ! modified = false; } --- 83,93 ---- boolean modified; + + int count; void reset() { z = Constants.INFINITY; opaque = false; ! count = 0; } *************** *** 91,98 **** --- 97,106 ---- this.bucketWidth = bucketWidth; this.bucketHeight = bucketHeight; + pixelsPerBucket = bucketWidth * bucketHeight; width = (int) Math.ceil(bucketWidth * hSamples); height = (int) Math.ceil(bucketHeight * vSamples); pixelWidth = width / bucketWidth; pixelHeight = height / bucketHeight; + samplesPerPixel = pixelWidth * pixelHeight; sampleWidth = 1f / hSamples; oneOverSampleWidth = hSamples; *************** *** 129,213 **** pixelsVisibility[i].reset(); hasSamples = false; } ! public void sampleBucket(Bucket bucket, boolean hasMorePrimitives) { bucketSamplesCount++; - modified = false; while (bucket.hasMoreMicropolygons()) { Micropolygon mp = bucket.getNextMicropolygon(); mp.sample(this); - } - if (modified) hasSamples = true; - if (modified && hasMorePrimitives) { - modifiedSampleBucketsCount++; - updatePyramid(); - } - } - - /* - public void sampleBucket(Bucket bucket, boolean hasMorePrimitives) { - bucketSamplesCount++; - modified = false; - int minRow = height; - int maxRow = -1; - int minCol = width; - int maxCol = -1; - while (bucket.hasMoreMicropolygons()) { - Micropolygon mp = bucket.getNextMicropolygon(); - int col = Calc.max((int) ((mp.getMinX() - min.x) / sampleWidth), 0); - mp.startCol = col; - int row = Calc.max((int) ((mp.getMinY() - min.y) / sampleHeight), 0); - getSamplePoint(col, row).addMicropolygon(mp); - minCol = Calc.min(minCol, col); - maxCol = Calc.max(maxCol, - Calc.min((int) ((mp.getMaxX() - min.x) / sampleWidth), - width - 1)); - minRow = Calc.min(minRow, row); - maxRow = Calc.max(maxRow, - Calc.min((int) ((mp.getMaxY() - min.y) / sampleHeight), - height - 1)); - } - float y = min.y + minRow * sampleHeight + sampleHeight; - int rowOffset = minRow * width; - for (int row = minRow; row <= maxRow; row++) { - float x = min.x + minCol * sampleWidth + sampleWidth; - for (int col = minCol; col <= maxCol; col++) { - SamplePoint sp = samplePoints[rowOffset + col]; - while (sp.hasMoreMicropolygons()) { - Micropolygon mp = sp.getNextMicropolygon(); - if (!sp.isOpaque() || sp.getZ() >= mp.getMinZ()) - mp.sampleAtPoint(sp); - if (mp.getMaxX() >= x) { - if (col < maxCol) { - samplePoints[rowOffset + col + 1].addMicropolygon(mp); - } - else if (mp.getMaxY() >= y && row < maxRow) { - samplePoints[rowOffset + width + mp.startCol].addMicropolygon(mp); - } - } else if (mp.getMaxY() >= y && row < maxRow) { - samplePoints[rowOffset + width + mp.startCol].addMicropolygon(mp); - } - } - x += sampleWidth; - } - y += sampleHeight; - rowOffset += width; - } - for (int row = 0; row < height; row++) - for (int col = 0; col < width; col++) { - SamplePoint sp = getSamplePoint(col, row); - if (sp.hasMoreMicropolygons()) { - System.out.println("(" + col + ", " + row + ")"); - System.out.println("col: " + minCol + " : " + maxCol); - System.out.println("row: " + minRow + " : " + maxRow); - } - } - if (modified && hasMorePrimitives) { - modifiedSampleBucketsCount++; - updatePyramid(); } } - */ public void getColors( --- 137,152 ---- pixelsVisibility[i].reset(); hasSamples = false; + modified = false; + rootVisibility.z = -Constants.INFINITY; } ! public void sampleBucket(Bucket bucket) { bucketSamplesCount++; while (bucket.hasMoreMicropolygons()) { Micropolygon mp = bucket.getNextMicropolygon(); mp.sample(this); hasSamples = true; } } public void getColors( *************** *** 246,269 **** } - /* - public void getColors( - float[] dst, - int dstOffset, - int rowLength, - int bands, - int bandOffset) { - int srcOffset = 0; - int destOffset = dstOffset + bandOffset; - for (int row = 0; row < height; row++) { - for (int col = 0; col < width; col++) { - int offset = destOffset + col * bands; - samplePoints[srcOffset + col].getColor(dst, offset); - } - srcOffset += width; - destOffset += rowLength * bands; - } - } - */ - public void getDepths(float[] depths) { for (int row = 0; row < height; row++) --- 185,188 ---- *************** *** 306,407 **** } ! public void updateDepth(int offset, float z) { MaskElement me = pixelsVisibility[offset]; if (z < me.z) { ! me.modified = true; ! modified = true; ! } ! } ! ! private void updatePyramid() { ! int rowOffset = 0; ! boolean changed = false; ! for (int row = 0; row < bucketHeight; row++) { ! for (int column = 0; column < bucketWidth; column++) { ! MaskElement me = pixelsVisibility[rowOffset + column]; ! if (!me.modified) ! continue; ! boolean opaque = true; ! float z = -Constants.INFINITY; ! int cOffset = column * pixelWidth; ! int rOffset = row * pixelHeight; ! CheckOpacity : for (int r = 0; r < pixelHeight; r++) { ! for (int c = 0; c < pixelWidth; c++) { ! SamplePoint sp = ! getSamplePoint(cOffset + c, rOffset + r); ! if (!sp.isOpaque()) { ! opaque = false; ! break CheckOpacity; ! } else ! z = Calc.max(z, sp.getZ()); ! } ! } ! if (opaque) { ! if (z < me.z) { ! me.opaque = true; ! me.z = z; ! changed = true; ! } ! } ! } ! rowOffset += bucketWidth; ! } ! if (changed) ! updateRoot(); ! } ! ! /* ! private void updatePyramid() { ! int rowOffset = 0; ! boolean rootOpaque = true; ! float rootZ = -Constants.INFINITY; ! for (int row = 0; row < bucketHeight; row++) { ! for (int column = 0; column < bucketWidth; column++) { ! MaskElement me = pixelsVisibility[rowOffset + column]; ! if (!me.modified) ! continue; ! boolean opaque = true; ! float z = -Constants.INFINITY; ! int cOffset = column * pixelWidth; ! int rOffset = row * pixelHeight; ! CheckOpacity : for (int r = 0; r < pixelHeight; r++) { ! for (int c = 0; c < pixelWidth; c++) { ! SamplePoint sp = ! getSamplePoint(cOffset + c, rOffset + r); ! if (!sp.isOpaque()) { ! opaque = false; ! break CheckOpacity; ! } else ! z = Calc.max(z, sp.getZ()); ! } ! } ! if (opaque) { ! if (z < me.z) { ! me.opaque = true; ! me.z = z; ! rootZ = Calc.max(rootZ, z); ! } ! } else ! rootOpaque = false; ! } ! rowOffset += bucketWidth; } ! rootVisibility.opaque = rootOpaque; ! rootVisibility.z = rootZ; ! } ! */ ! ! private void updateRoot() { ! rootVisibility.opaque = true; ! float z = -Constants.INFINITY; ! for (int i = 0; i < pixelsVisibility.length; i++) { ! if (!pixelsVisibility[i].opaque) { ! rootVisibility.opaque = false; ! break; } - z = Calc.max(z, pixelsVisibility[i].z); } - if (rootVisibility.opaque) - rootVisibility.z = z; } --- 225,243 ---- } ! public void updateDepth(int offset, float z, boolean firstTime) { MaskElement me = pixelsVisibility[offset]; if (z < me.z) { ! me.z = z; ! rootVisibility.z = Calc.max(rootVisibility.z, z); } ! if (firstTime) { ! me.count++; ! if (me.count == samplesPerPixel) { ! me.opaque = true; ! rootVisibility.count++; ! if (rootVisibility.count == pixelsPerBucket) ! rootVisibility.opaque = true; } } } Index: SimpleMicropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SimpleMicropolygon.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SimpleMicropolygon.java 14 Jan 2004 03:06:35 -0000 1.18 --- SimpleMicropolygon.java 2 Feb 2004 19:30:05 -0000 1.19 *************** *** 1,5 **** /* SimpleMicropolygon.java ! Copyright (C) 2003 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or --- 1,5 ---- /* SimpleMicropolygon.java ! Copyright (C) 2003, 2004 Gerardo Horvilleur Martinez This program is free software; you can redistribute it and/or *************** *** 20,30 **** package org.jrman.render; - import java.io.DataInputStream; - import java.io.DataOutputStream; - import java.io.IOException; - import javax.vecmath.Point2f; import javax.vecmath.Point3f; - import javax.vecmath.Vector3f; import org.jrman.util.Calc; --- 20,25 ---- *************** *** 32,41 **** public class SimpleMicropolygon extends Micropolygon { ! // These static Vector3f are not thead safe!!! ! private static Vector3f ab = new Vector3f(); ! ! private static Vector3f ac = new Vector3f(); ! ! private static Vector3f cp = new Vector3f(); private float ax; --- 27,31 ---- public class SimpleMicropolygon extends Micropolygon { ! private final static float EPSILON = 10E-5f; private float ax; *************** *** 49,73 **** private float by; private float cx; private float cy; ! /* ! private float ayby; ! ! private float bxax; ! ! private float bycy; ! ! private float cxbx; ! ! private float cyay; ! ! private float axcx; ! */ ! ! private float nxOverZ; ! private float nyOverZ; private float colorRed; --- 39,51 ---- private float by; + private float bz; + private float cx; private float cy; ! private float cz; ! private float oneOverDet; private float colorRed; *************** *** 83,148 **** private float opacityBlue; - public void write(DataOutputStream dos) throws IOException { - dos.writeFloat(ax); - dos.writeFloat(ay); - dos.writeFloat(az); - dos.writeFloat(bx); - dos.writeFloat(by); - dos.writeFloat(cx); - dos.writeFloat(cy); - /* - dos.writeFloat(ayby); - dos.writeFloat(bxax); - dos.writeFloat(bycy); - dos.writeFloat(cxbx); - dos.writeFloat(cyay); - dos.writeFloat(axcx); - */ - dos.writeFloat(nxOverZ); - dos.writeFloat(nyOverZ); - dos.writeFloat(colorRed); - dos.writeFloat(colorGreen); - dos.writeFloat(colorBlue); - dos.writeFloat(opacityRed); - dos.writeFloat(opacityGreen); - dos.writeFloat(opacityBlue); - dos.writeFloat(minX); - dos.writeFloat(maxX); - dos.writeFloat(minY); - dos.writeFloat(maxY); - dos.writeFloat(minZ); - } - - public void read(DataInputStream dis) throws IOException { - ax = dis.readFloat(); - ay = dis.readFloat(); - az = dis.readFloat(); - bx = dis.readFloat(); - by = dis.readFloat(); - cx = dis.readFloat(); - cy = dis.readFloat(); - /* - ayby = dis.readFloat(); - bxax = dis.readFloat(); - bycy = dis.readFloat(); - cxbx = dis.readFloat(); - cyay = dis.readFloat(); - axcx = dis.readFloat(); - */ - nxOverZ = dis.readFloat(); - nyOverZ = dis.readFloat(); - colorRed = dis.readFloat(); - colorGreen = dis.readFloat(); - colorBlue = dis.readFloat(); - opacityRed = dis.readFloat(); - opacityGreen = dis.readFloat(); - opacityBlue = dis.readFloat(); - minX = dis.readFloat(); - maxX = dis.readFloat(); - minY = dis.readFloat(); - maxY = dis.readFloat(); - minZ = dis.readFloat(); - } - public boolean init( Point3f a, --- 61,64 ---- *************** *** 158,174 **** return false; count++; - // Face forward - ab.sub(b, a); - ac.sub(c, a); - cp.cross(ab, ac); - if (cp.z == 0f) - return false; - if (cp.z > 0) { - Point3f tmp = b; - b = c; - c = tmp; - } - nxOverZ = cp.x / cp.z; - nyOverZ = cp.y / cp.z; // get bounds addPointToBounds(a.x, a.y, a.z); --- 74,77 ---- *************** *** 178,193 **** ay = a.y; az = a.z; ! bx = b.x; ! by = b.y; ! cx = c.x; ! cy = c.y; ! /* ! ayby = ay - by; ! bxax = bx - ax; ! bycy = by - cy; ! cxbx = cx - bx; ! cyay = cy - ay; ! axcx = ax - cx; ! */ colorRed = cRed; colorGreen = cGreen; --- 81,94 ---- ay = a.y; az = a.z; ! bx = b.x - ax; ! by = b.y - ay; ! bz = b.z; ! cx = c.x - ax; ! cy = c.y - ay; ! cz = c.z; ! float det = bx * cy - by * cx; ! if (det > -EPSILON && det < EPSILON) ! return false; ! oneOverDet = 1f / det; colorRed = cRed; colorGreen = cGreen; *************** *** 214,224 **** float mpMaxY = maxY - smin.y; int minColumn = ! Calc.clamp((int) (mpMinX * sampler.getOneOverSampleWidth()), 0, sampler.getWidth() - 1); int minRow = ! Calc.clamp((int) (mpMinY * sampler.getOneOverSampleHeight()), 0, sampler.getHeight() - 1); int maxColumn = ! Calc.clamp((int) (mpMaxX * sampler.getOneOverSampleWidth()), 0, sampler.getWidth() - 1); int maxRow = ! Calc.clamp((int) (mpMaxY * sampler.getOneOverSampleHeight()), 0, sampler.getHeight() - 1); for (int row = minRow; row <= maxRow; row++) { for (int col = minColumn; col <= maxColumn; col++) { --- 115,137 ---- float mpMaxY = maxY - smin.y; int minColumn = ! Calc.clamp( ! (int) (mpMinX * sampler.getOneOverSampleWidth()), ! 0, ! sampler.getWidth() - 1); int minRow = ! Calc.clamp( ! (int) (mpMinY * sampler.getOneOverSampleHeight()), ! 0, ! sampler.getHeight() - 1); int maxColumn = ! Calc.clamp( ! (int) (mpMaxX * sampler.getOneOverSampleWidth()), ! 0, ! sampler.getWidth() - 1); int maxRow = ! Calc.clamp( ! (int) (mpMaxY * sampler.getOneOverSampleHeight()), ! 0, ! sampler.getHeight() - 1); for (int row = minRow; row <= maxRow; row++) { for (int col = minColumn; col <= maxColumn; col++) { *************** *** 231,247 **** public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); if (point.x < minX || point.x > maxX || point.y < minY || point.y > maxY) return; if (sp.isOpaque() && sp.getZ() < minZ) return; ! float z = nxOverZ * (ax - point.x) + nyOverZ * (ay - point.y) + az; ! if (z < minZ) ! return; ! if ((cy - ay) * (point.x - cx) + (ax - cx) * (point.y - cy) > 0f) ! return; ! if ((by - cy) * (point.x - bx) + (cx - bx) * (point.y - by) > 0f) return; ! if ((ay - by) * (point.x - ax) + (bx - ax) * (point.y - ay) > 0f) return; sp.addSample( colorRed, --- 144,162 ---- public void sampleAtPoint(SamplePoint sp) { Point2f point = sp.getPoint(); + /* if (point.x < minX || point.x > maxX || point.y < minY || point.y > maxY) return; + */ if (sp.isOpaque() && sp.getZ() < minZ) return; ! float ox = point.x - ax; ! float oy = point.y - ay; ! float u = (ox * cy - oy * cx) * oneOverDet; ! if (u < 0f || u > 1f) return; ! float v = (oy * bx - ox * by) * oneOverDet; ! if (v < 0f || u + v > 1f) return; + float z = (1f - u - v) * az + u * bz + v * cz; sp.addSample( colorRed, Index: SamplePoint.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/SamplePoint.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** SamplePoint.java 14 Jan 2004 03:06:35 -0000 1.22 --- SamplePoint.java 2 Feb 2004 19:30:05 -0000 1.23 *************** *** 101,109 **** private void update(float nz) { ! // if (nz < z || !opaque) { z = nz; opaque = true; ! sampler.updateDepth(offset, z); ! // } } --- 101,109 ---- private void update(float nz) { ! if (nz < z || !opaque) { z = nz; + sampler.updateDepth(offset, z, !opaque); opaque = true; ! } } Index: Micropolygon.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/render/Micropolygon.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Micropolygon.java 14 Jan 2004 03:06:35 -0000 1.17 --- Micropolygon.java 2 Feb 2004 19:30:05 -0000 1.18 *************** *** 20,27 **** package org.jrman.render; - import java.io.DataInputStream; - import java.io.DataOutputStream; - import java.io.IOException; - import javax.vecmath.Point3f; --- 20,23 ---- *************** *** 32,41 **** public static int count; - /* - public Micropolygon next; - - public int startCol; - */ - protected float minX = Constants.INFINITY; --- 28,31 ---- *************** *** 61,70 **** public abstract void sample(Sampler sampler); - public abstract void write(DataOutputStream dos) throws IOException; - - public abstract void read(DataInputStream dis) throws IOException; - - public abstract void sampleAtPoint(SamplePoint sp); - public final float getMaxX() { return maxX; --- 51,54 ---- --- FileBucket.java DELETED --- --- FastSimpleMicropolygon.java DELETED --- |