From: Gerardo H. <ma...@us...> - 2007-02-26 19:36:22
|
Update of /cvsroot/jrman/drafts/src/org/jrman/maps In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30698/src/org/jrman/maps Modified Files: MipMap.java ShadowMap.java Log Message: Check for Catmull Clark scheme before trying to instance a Subdivision Mesh. Started reformatting source code to fit in 80 columns, remove tabs and ugly formatting done by Eclipse. Index: ShadowMap.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/maps/ShadowMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ShadowMap.java 24 Oct 2004 21:14:38 -0000 1.7 --- ShadowMap.java 26 Feb 2007 19:35:47 -0000 1.8 *************** *** 1,19 **** /* ! ShadowMap.java ! Copyright (C) 2003 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. */ --- 1,19 ---- /* ! ShadowMap.java ! Copyright (C) 2003 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. */ *************** *** 56,62 **** public static class Projection { ! public final static Projection PERSPECTIVE = new Projection(1, "perspective"); ! public final static Projection ORTHOGRAPHIC = new Projection(2, "orthographic"); private int code; --- 56,64 ---- public static class Projection { ! public final static Projection PERSPECTIVE = ! new Projection(1, "perspective"); ! public final static Projection ORTHOGRAPHIC = ! new Projection(2, "orthographic"); private int code; *************** *** 74,78 **** Projection result = (Projection) map.get(name); if (result == null) ! throw new IllegalArgumentException("No such ShadowMap projection: " + name); return result; } --- 76,81 ---- Projection result = (Projection) map.get(name); if (result == null) ! throw new IllegalArgumentException("No such ShadowMap projection: " ! + name); return result; } *************** *** 83,87 **** if (code == 2) return ORTHOGRAPHIC; ! throw new IllegalArgumentException("No such ShadowMap projection code: " + code); } --- 86,91 ---- if (code == 2) return ORTHOGRAPHIC; ! throw new IllegalArgumentException("No such ShadowMap proj code: " ! + code); } *************** *** 109,119 **** } ! public static void writeShadowMap( ! String filename, ! Transform worldToCamera, ! Transform cameraToRaster, ! int width, ! int height, ! float[] depths) throws IOException { Transform worldToRaster = cameraToRaster.concat(worldToCamera); --- 113,122 ---- } ! public static void writeShadowMap(String filename, ! Transform worldToCamera, ! Transform cameraToRaster, ! int width, ! int height, ! float[] depths) throws IOException { Transform worldToRaster = cameraToRaster.concat(worldToCamera); *************** *** 187,198 **** } ! public float get( ! Point3f p1, ! Point3f p2, ! float bias, ! int samples, ! float oneOverSamples, ! float blur, ! float halfBlur) { float total = 0f; float dx = p2.x - p1.x + blur; --- 190,200 ---- } ! public float get(Point3f p1, ! Point3f p2, ! float bias, ! int samples, ! float oneOverSamples, ! float blur, ! float halfBlur) { float total = 0f; float dx = p2.x - p1.x + blur; Index: MipMap.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/maps/MipMap.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MipMap.java 24 Oct 2004 21:14:38 -0000 1.7 --- MipMap.java 26 Feb 2007 19:35:47 -0000 1.8 *************** *** 1,19 **** /* ! MipMap.java ! Copyright (C) 2003 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. */ --- 1,19 ---- /* ! MipMap.java ! Copyright (C) 2003 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. */ *************** *** 95,99 **** Mode result = (Mode) map.get(name); if (result == null) ! throw new IllegalArgumentException("No such MipMap mode: " + name); return result; } --- 95,100 ---- Mode result = (Mode) map.get(name); if (result == null) ! throw new IllegalArgumentException("No such MipMap mode: " + ! name); return result; } *************** *** 106,110 **** if (code == 3) return PERIODIC; ! throw new IllegalArgumentException("No such MipMap mode code: " + code); } --- 107,112 ---- if (code == 3) return PERIODIC; ! throw new IllegalArgumentException("No such MipMap mode code: " + ! code); } *************** *** 132,162 **** } ! private static byte[] scaleDown( ! byte[] data, ! int size, ! Mode sMode, ! Mode tMode, ! SamplesFilter samplesFilter) { byte[] result = new byte[data.length / 4]; ! samplesFilter.doFilter( ! data, ! size, ! result, ! size / 2, ! size / 2, ! size / 2, ! 2, ! 2, ! sMode, ! tMode); return result; } ! public static void makeMipMap( ! BufferedImage image, ! String filename, ! Mode sMode, ! Mode tMode, ! Filter filter) throws IOException { int largerSide = Math.max(image.getWidth(), image.getHeight()); --- 134,161 ---- } ! private static byte[] scaleDown(byte[] data, ! int size, ! Mode sMode, ! Mode tMode, ! SamplesFilter samplesFilter) { byte[] result = new byte[data.length / 4]; ! samplesFilter.doFilter(data, ! size, ! result, ! size / 2, ! size / 2, ! size / 2, ! 2, ! 2, ! sMode, ! tMode); return result; } ! public static void makeMipMap(BufferedImage image, ! String filename, ! Mode sMode, ! Mode tMode, ! Filter filter) throws IOException { int largerSide = Math.max(image.getWidth(), image.getHeight()); *************** *** 173,178 **** dos.writeByte(tMode.getCode()); AffineTransform af = new AffineTransform(); ! af.scale((float) size / image.getWidth(), (float) size / image.getHeight()); ! AffineTransformOp afop = new AffineTransformOp(af, AffineTransformOp.TYPE_BILINEAR); BufferedImage squareImage = afop.filter(image, null); image = null; // Release memory --- 172,179 ---- dos.writeByte(tMode.getCode()); AffineTransform af = new AffineTransform(); ! af.scale((float) size / image.getWidth(), ! (float) size / image.getHeight()); ! AffineTransformOp afop = ! new AffineTransformOp(af, AffineTransformOp.TYPE_BILINEAR); BufferedImage squareImage = afop.filter(image, null); image = null; // Release memory *************** *** 191,199 **** int width = Calc.ceil(filter.getHorizontalWidth() * 2); int height = Calc.ceil(filter.getVerticalWidth() * 2); ! samplesFilter.init( ! width, ! height, ! filter.getHorizontalWidth(), ! filter.getVerticalWidth()); while (size >= 1) { dos.write(data); --- 192,199 ---- int width = Calc.ceil(filter.getHorizontalWidth() * 2); int height = Calc.ceil(filter.getVerticalWidth() * 2); ! samplesFilter.init(width, ! height, ! filter.getHorizontalWidth(), ! filter.getVerticalWidth()); while (size >= 1) { dos.write(data); *************** *** 204,215 **** } ! public static void makeMipMap( ! String imageFilename, ! String filename, ! Mode sMode, ! Mode tMode, ! String filterType, ! float sWidth, ! float tWidth) throws IOException { flushMipMap(filename); --- 204,214 ---- } ! public static void makeMipMap(String imageFilename, ! String filename, ! Mode sMode, ! Mode tMode, ! String filterType, ! float sWidth, ! float tWidth) throws IOException { flushMipMap(filename); *************** *** 218,227 **** File file = new File(imageFilename); BufferedImage image = ImageIO.read(file); ! makeMipMap( ! image, ! filename, ! sMode, ! tMode, ! new Filter(Filter.Type.getNamed(filterType), sWidth, tWidth)); } --- 217,226 ---- File file = new File(imageFilename); BufferedImage image = ImageIO.read(file); ! makeMipMap(image, ! filename, ! sMode, ! tMode, ! new Filter(Filter.Type.getNamed(filterType), ! sWidth, tWidth)); } *************** *** 274,278 **** } ! private void getDataDirect(int s, int t, int level, int levelSize, float[] data) { int offset = levelOffsets[level]; offset += (t * levelSize + s) * 4; --- 273,278 ---- } ! private void getDataDirect(int s, int t, int level, int levelSize, ! float[] data) { int offset = levelOffsets[level]; offset += (t * levelSize + s) * 4; *************** *** 323,327 **** } ! private void getData(float s, float t, int level, float interp, float[] data) { getData(s, t, level, ll); getData(s, t, level + 1, lh); --- 323,328 ---- } ! private void getData(float s, float t, int level, float interp, ! float[] data) { getData(s, t, level, ll); getData(s, t, level + 1, lh); |