[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/actions ImportFileReader.java, 1.5, 1.6
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-10-22 15:20:34
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20930/src/net/sourceforge/bprocessor/gui/actions Modified Files: ImportFileReader.java Log Message: minor fixes and changes Index: ImportFileReader.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/actions/ImportFileReader.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ImportFileReader.java 22 Oct 2007 10:00:17 -0000 1.5 --- ImportFileReader.java 22 Oct 2007 15:20:37 -0000 1.6 *************** *** 82,86 **** Set<Surface> surfaces = new HashSet<Surface>(); Map<Vertex, Set<Edge>> v2es = new HashMap<Vertex, Set<Edge>>(); - Map<Vertex, Vertex> v2normal = new HashMap<Vertex, Vertex>(); List<Space> groups = new LinkedList<Space>(); Map<String, Material> materialMap = new HashMap<String, Material>(); --- 82,85 ---- *************** *** 118,122 **** double y = Double.parseDouble(lineContent[2]); double z = Double.parseDouble(lineContent[3]); ! Vertex v = new Vertex(z, x, y); vertexNormals.add(v); v2es.put(v, new HashSet<Edge>()); --- 117,135 ---- double y = Double.parseDouble(lineContent[2]); double z = Double.parseDouble(lineContent[3]); ! switch (basisPlane) { ! case FileImportActionListener.YZ: ! double tmpy = y; ! y = x; ! x = z; ! z = tmpy; ! break; ! case FileImportActionListener.ZX: ! double tmpx = x; ! x = z; ! z = y; ! y = tmpx; ! break; ! } ! Vertex v = new Vertex(x, y, z); vertexNormals.add(v); v2es.put(v, new HashSet<Edge>()); *************** *** 129,158 **** } else if (lineContent[0].equals("f")) { LinkedList<Edge> edge = new LinkedList<Edge>(); ! int index = 0; String[] vert = lineContent[1].split("/"); ! Vertex first = verts.get(Integer.parseInt(vert[index]) - 1); Vertex cur = first; - if (!vertexTexture.isEmpty()) { - index++; - } if (!vertexNormals.isEmpty()) { ! index++; ! Vertex normal = ! vertexNormals.get(Integer.parseInt(vert[index]) - 1); ! v2normal.put(cur, normal); } Vertex prev = first; for (int i = 2; i < lineContent.length; i++) { - index = 0; vert = lineContent[i].split("/"); ! cur = verts.get(Integer.parseInt(vert[index]) - 1); ! if (!vertexTexture.isEmpty()) { ! index++; ! } if (!vertexNormals.isEmpty()) { ! index++; ! Vertex normal = ! vertexNormals.get(Integer.parseInt(vert[index]) - 1); ! v2normal.put(cur, normal); } Edge e = findEdge(prev, cur, v2es); --- 142,158 ---- } else if (lineContent[0].equals("f")) { LinkedList<Edge> edge = new LinkedList<Edge>(); ! LinkedList<Vertex> normals = new LinkedList<Vertex>(); String[] vert = lineContent[1].split("/"); ! Vertex first = verts.get(Integer.parseInt(vert[0]) - 1); Vertex cur = first; if (!vertexNormals.isEmpty()) { ! normals.add(vertexNormals.get(Integer.parseInt(vert[2]) - 1)); } Vertex prev = first; for (int i = 2; i < lineContent.length; i++) { vert = lineContent[i].split("/"); ! cur = verts.get(Integer.parseInt(vert[0]) - 1); if (!vertexNormals.isEmpty()) { ! normals.add(vertexNormals.get(Integer.parseInt(vert[2]) - 1)); } Edge e = findEdge(prev, cur, v2es); *************** *** 162,167 **** edge.add(findEdge(prev, first, v2es)); Surface s = new Surface(edge); - surfaces.add(s); s.setBackDomain(currentGroup); if (currentMaterial == null) { currentMaterial = new Material("Object", new float[]{0f, 0.9f, 0f}); --- 162,170 ---- edge.add(findEdge(prev, first, v2es)); Surface s = new Surface(edge); s.setBackDomain(currentGroup); + if (!normals.isEmpty()) { + s.setNormals(normals); + } + surfaces.add(s); if (currentMaterial == null) { currentMaterial = new Material("Object", new float[]{0f, 0.9f, 0f}); *************** *** 187,191 **** } for (Space s : groups) { ! into.add(s); } for (Material m : materialMap.values()) { --- 190,194 ---- } for (Space s : groups) { ! into.addProtected(s); } for (Material m : materialMap.values()) { *************** *** 193,203 **** } for (Vertex v : verts) { ! into.add(v); } for (Edge e : edges) { ! into.add(e); } for (Surface s : surfaces) { ! into.add(s); } into.changed(); --- 196,206 ---- } for (Vertex v : verts) { ! into.addProtected(v); } for (Edge e : edges) { ! into.addProtected(e); } for (Surface s : surfaces) { ! into.addProtected(s); } into.changed(); |