[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Material.java, 1.15, 1.16 Project.ja
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2009-06-23 12:08:48
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32757/src/net/sourceforge/bprocessor/model Modified Files: Material.java Project.java Container.java Log Message: Saves materials when exporting to obj Index: Material.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Material.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Material.java 19 Dec 2007 09:03:41 -0000 1.15 --- Material.java 23 Jun 2009 12:08:45 -0000 1.16 *************** *** 7,10 **** --- 7,12 ---- package net.sourceforge.bprocessor.model; + import java.io.OutputStream; + import java.io.PrintStream; import java.util.LinkedList; import java.util.List; *************** *** 283,285 **** --- 285,313 ---- return "[Material " + name + "]"; } + + + + /** + * + * @param out Stream + */ + public void export(OutputStream out) { + PrintStream printer = new PrintStream(out); + printer.println("newmtl " + name); + printer.println("Ka " + + ambientColor[0] + " " + + ambientColor[1] + " " + + ambientColor[2]); + printer.println("Kd " + + diffuseColor[0] + " " + + diffuseColor[1] + " " + + diffuseColor[2]); + printer.println("Ks " + + specularColor[0] + " " + + specularColor[1] + " " + + specularColor[2]); + printer.println("d " + opacity); + printer.println("Ns " + shininess); + printer.println("illum " + (int) illumination); + } } Index: Container.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Container.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** Container.java 29 May 2009 11:57:59 -0000 1.26 --- Container.java 23 Jun 2009 12:08:45 -0000 1.27 *************** *** 54,61 **** /** * ! * @param surfaces list of surfaces to export * @param out PrintStream to export to */ ! public static void export(List<Surface> surfaces, PrintStream out) { List<Edge> edges = new LinkedList(Surface.edges(surfaces)); List<Vertex> vertices = new LinkedList(Edge.vertices(edges)); --- 54,65 ---- /** * ! * @param containers list of surfaces to export * @param out PrintStream to export to */ ! public static void export(List<Container> containers, PrintStream out) { ! List<Surface> surfaces = new LinkedList(); ! for (Container container : containers) { ! surfaces.addAll(container.getSurfaces()); ! } List<Edge> edges = new LinkedList(Surface.edges(surfaces)); List<Vertex> vertices = new LinkedList(Edge.vertices(edges)); *************** *** 68,79 **** " " + current.getY() + " " + current.getZ()); } ! for (Surface current : surfaces) { ! List<Vertex> verts = current.getVertices(); ! out.print("f"); ! for (Vertex v : verts) { ! int i = vmap.get(v); ! out.print(" " + i); } - out.println(); } } --- 72,88 ---- " " + current.getY() + " " + current.getZ()); } ! for (Container container : containers) { ! if (container.getMaterial() != null) { ! out.println("usemtl " + container.getMaterial().getName()); ! } ! for (Surface current : container.getSurfaces()) { ! List<Vertex> verts = current.getVertices(); ! out.print("f"); ! for (Vertex v : verts) { ! int i = vmap.get(v); ! out.print(" " + i); ! } ! out.println(); } } } *************** *** 1649,1654 **** */ public void export(PrintStream out) { ! List<Surface> surfaces = new LinkedList(getSurfaces()); ! export(surfaces, out); } } --- 1658,1664 ---- */ public void export(PrintStream out) { ! List<Container> containers = new LinkedList(); ! containers.add(this); ! export(containers, out); } } Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.176 retrieving revision 1.177 diff -C2 -d -r1.176 -r1.177 *** Project.java 19 May 2009 10:33:45 -0000 1.176 --- Project.java 23 Jun 2009 12:08:45 -0000 1.177 *************** *** 1612,1622 **** } } ! List<Surface> surfaces = new LinkedList(); for (Container current : constructs) { System.out.println("-- " + current.getName() + " --"); Container tesselation = current.tesselate(); ! surfaces.addAll(tesselation.getSurfaces()); } ! Container.export(surfaces, printer); } --- 1612,1623 ---- } } ! List<Container> containers = new LinkedList(); for (Container current : constructs) { System.out.println("-- " + current.getName() + " --"); Container tesselation = current.tesselate(); ! tesselation.setMaterial(current.getMaterial()); ! containers.add(tesselation); } ! Container.export(containers, printer); } *************** *** 1625,1639 **** */ public void export() { ! System.out.println("export to " + getExportPath()); try { ! OutputStream out = new FileOutputStream(new File(getExportPath())); ! exportOBJ(out); ! out.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block ! System.out.println("cannot export to " + getExportPath()); } catch (IOException e) { // TODO Auto-generated catch block ! System.out.println("cannot export to " + getExportPath()); } isExporting = false; --- 1626,1653 ---- */ public void export() { ! System.out.println("export to " + getExportPath() + ".obj"); ! String objname = getExportPath() + ".obj"; ! String mtlname = getExportPath() + ".mtl"; try { ! { ! OutputStream out = new FileOutputStream(new File(mtlname)); ! for (Material current : getMaterials()) { ! current.export(out); ! } ! out.close(); ! } ! { ! OutputStream out = new FileOutputStream(new File(objname)); ! PrintStream printer = new PrintStream(out); ! printer.println("mtllib " + mtlname); ! exportOBJ(out); ! out.close(); ! } } catch (FileNotFoundException e) { // TODO Auto-generated catch block ! System.out.println("cannot export to " + objname); } catch (IOException e) { // TODO Auto-generated catch block ! System.out.println("cannot export to " + objname); } isExporting = false; |