static public void writeDXF(final Collection contents, final Writer w) throws IOException { w.write("0\nSECTION\n2\nENTITIES\n"); // header of file for (final Iterator it = contents.iterator(); it.hasNext();) { final Content ob = (Content) it.next(); CustomMesh cmesh = null; if (ob.getContent() instanceof CustomMeshNode) { final CustomMeshNode cmeshnode = (CustomMeshNode) ob.getContent(); cmesh = cmeshnode.getMesh(); } else if (ob.getContent() instanceof MeshGroup) { final MeshGroup mg = (MeshGroup) ob.getContent(); cmesh = mg.getMesh(); } else continue; final List triangles = cmesh.getMesh(); final String title = ob.getName().replaceAll(" ", "_").replaceAll("#", "--"); final Mtl mat = new Mtl(1 - ob.getTransparency(), cmesh.getColor()); writeTrianglesDXF(w, triangles, title, "" + mat.getAsSingle()); } w.append("0\nENDSEC\n0\nEOF\n"); // TRAILER of the file }
@Override public void contentSelected(final Content arg0) { if (null == arg0) { return; } Color3f color = arg0.getColor(); if (null == color) color = new Color3f(1, 1, 0); // default to yellow final float[] co = new float[3]; color.get(co); for (int i=0; i<3; ++i) { // Disallow the slider from firing an event when its value is adjusted sliders[i].setValueIsAdjusting(true); final int val = (int)(co[i] * 255); typers[i].setText(Integer.toString(val)); sliders[i].setValue(val); } // After all are set, re-enable, which triggers events (the color will be set three times...) for (int i=0; i<3; ++i) { sliders[i].setValueIsAdjusting(false); } // Alpha slider: alphaSlider.setValueIsAdjusting(true); final int alpha = (int)((1 - arg0.getTransparency()) * 255); alphaTyper.setText(Integer.toString(alpha)); alphaSlider.setValue(alpha); alphaSlider.setValueIsAdjusting(false); }
final Content c = (Content) content; final Mesh m = new Mesh(ctm, c.getName(), c.getColor(), c.getTransparency()); m.getMinMax(min, max); meshes.add(m);