[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Command.java, 1.12, 1.13
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-10-24 06:48:27
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11879/src/net/sourceforge/bprocessor/model Modified Files: Command.java Log Message: Translate and Rotate commands Index: Command.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Command.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Command.java 22 Oct 2007 19:26:32 -0000 1.12 --- Command.java 24 Oct 2007 06:48:23 -0000 1.13 *************** *** 233,237 **** normals.add(normal); } ! //surface.setNormals(normals); world.insert(surface); } --- 233,237 ---- normals.add(normal); } ! surface.setNormals(normals); world.insert(surface); } *************** *** 314,318 **** this.vertices = new LinkedList(vertices); this.system = system; - parameters.put("vertices", vertices); parameters.put("system", system); parameters.put("scale x", 1.0); --- 314,317 ---- *************** *** 342,344 **** --- 341,429 ---- } } + + /** + * + * + */ + public static class Translate extends Command { + private List<Vertex> vertices; + private CoordinateSystem system; + + /** + * Scale a collection of vertices + * @param vertices The list of verts + * @param system The system to translate into + */ + public Translate(Collection<Vertex> vertices, CoordinateSystem system) { + this.vertices = new LinkedList(vertices); + this.system = system; + parameters.put("system", system); + parameters.put("translate x", 0.0); + parameters.put("translate y", 0.0); + parameters.put("translate z", 0.0); + } + + /** {@inheritDoc} */ + @Override + public void evaluate() { + List<Vertex> locals = system.translate(vertices); + double sx = parameters.getDouble("translate x"); + double sy = parameters.getDouble("translate y"); + double sz = parameters.getDouble("translate z"); + for (Vertex current : locals) { + current.setX(current.getX() + sx); + current.setY(current.getY() + sy); + current.setZ(current.getZ() + sz); + } + locals = system.unTranslate(locals, false); + for (int i = 0; i < locals.size(); i++) { + Vertex v1 = vertices.get(i); + Vertex v2 = locals.get(i); + v1.set(v2); + } + Project.getInstance().changed(Project.getInstance()); + } + } + + /** + * + * + */ + public static class Rotate extends Command { + private List<Vertex> vertices; + private CoordinateSystem system; + + /** + * Scale a collection of vertices + * @param vertices The list of verts + * @param system The system to translate into + */ + public Rotate(Collection<Vertex> vertices, CoordinateSystem system) { + this.vertices = new LinkedList(vertices); + this.system = system; + parameters.put("system", system); + parameters.put("angle", 0.0); + } + + /** {@inheritDoc} */ + @Override + public void evaluate() { + List<Vertex> locals = system.translate(vertices); + double angle = parameters.getDouble("angle"); + AxisRotate rotate = new AxisRotate(); + rotate.angle(angle); + for (Vertex current : locals) { + Vertex rotated = rotate.transform(current); + current.set(rotated); + } + locals = system.unTranslate(locals, false); + for (int i = 0; i < locals.size(); i++) { + Vertex v1 = vertices.get(i); + Vertex v2 = locals.get(i); + v1.set(v2); + } + Project.getInstance().changed(Project.getInstance()); + } + } + } |