bprocessor-commit Mailing List for B-processor (Page 163)
Status: Pre-Alpha
Brought to you by:
henryml
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(117) |
Aug
(151) |
Sep
(157) |
Oct
(81) |
Nov
(117) |
Dec
(119) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(183) |
Feb
(130) |
Mar
(117) |
Apr
(61) |
May
(82) |
Jun
(45) |
Jul
(149) |
Aug
(173) |
Sep
(199) |
Oct
(165) |
Nov
(107) |
Dec
(137) |
2007 |
Jan
(124) |
Feb
(58) |
Mar
(123) |
Apr
(80) |
May
(130) |
Jun
(64) |
Jul
(31) |
Aug
(42) |
Sep
(114) |
Oct
(167) |
Nov
(239) |
Dec
(200) |
2008 |
Jan
(43) |
Feb
(43) |
Mar
(4) |
Apr
(9) |
May
(5) |
Jun
(1) |
Jul
(3) |
Aug
(3) |
Sep
(13) |
Oct
(9) |
Nov
(12) |
Dec
|
2009 |
Jan
|
Feb
(20) |
Mar
(7) |
Apr
(12) |
May
(34) |
Jun
(72) |
Jul
|
Aug
(3) |
Sep
(31) |
Oct
(2) |
Nov
(8) |
Dec
(4) |
2010 |
Jan
(5) |
Feb
(32) |
Mar
(8) |
Apr
(7) |
May
(36) |
Jun
|
Jul
(11) |
Aug
(15) |
Sep
(7) |
Oct
(2) |
Nov
(13) |
Dec
(80) |
2011 |
Jan
|
Feb
|
Mar
(8) |
Apr
(12) |
May
(32) |
Jun
(9) |
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(8) |
2012 |
Jan
|
Feb
|
Mar
(3) |
Apr
(5) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(22) |
Jun
(5) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: rimestad <rim...@us...> - 2005-09-02 13:36:53
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16621 Modified Files: GLView.java Log Message: small change Index: GLView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/GLView.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** GLView.java 31 Aug 2005 14:56:33 -0000 1.11 --- GLView.java 2 Sep 2005 13:36:44 -0000 1.12 *************** *** 17,20 **** --- 17,21 ---- import net.java.games.jogl.GLDrawableFactory; import net.java.games.jogl.GLCanvas; + import java.awt.Dimension; import org.apache.log4j.Logger; *************** *** 46,49 **** --- 47,51 ---- glc = GLDrawableFactory.getFactory().createGLCanvas(glCap); + glc.setPreferredSize(new Dimension(0, 0)); view = ViewFactory.getFactory(this).getDefault(); glc.addGLEventListener(view); *************** *** 111,115 **** glc.display(); } else { ! glc.display(); } } --- 113,117 ---- glc.display(); } else { ! repaint(); } } |
From: rimestad <rim...@us...> - 2005-09-02 13:35:41
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16245 Modified Files: ExtrusionTool.java Log Message: Works with the new move tool and selecttool Index: ExtrusionTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ExtrusionTool.java 30 Aug 2005 12:49:34 -0000 1.4 --- ExtrusionTool.java 2 Sep 2005 13:35:32 -0000 1.5 *************** *** 16,19 **** --- 16,23 ---- import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.model.ConstructionSpace; + import net.sourceforge.bprocessor.model.ConstructionSpaceFacade; + import net.sourceforge.bprocessor.model.FunctionalSpace; + import net.sourceforge.bprocessor.model.Space; import java.awt.event.MouseEvent; *************** *** 28,32 **** * The extrusion tool */ ! public class ExtrusionTool extends SelectTool { /** The logger */ private static Logger log = Logger.getLogger(ExtrusionTool.class); --- 32,36 ---- * The extrusion tool */ ! public class ExtrusionTool extends MoveTool { /** The logger */ private static Logger log = Logger.getLogger(ExtrusionTool.class); *************** *** 35,38 **** --- 39,45 ---- private static Surface dragSurface = null; + /** the selected surface */ + private static Surface selectedSurface = null; + /** * The Constructor *************** *** 151,154 **** --- 158,166 ---- protected void pressed(MouseEvent e) { super.pressed(e); + if (target instanceof Surface) { + selectedSurface = (Surface)target; + } else { + selectedSurface = null; + } } *************** *** 167,170 **** --- 179,184 ---- */ private Surface extendSurface(Surface extendSurf) { + ConstructionSpace newCSpace = new ConstructionSpace("innerSpace"); + Space outer = selectedSurface.getFrontSpace(); Edge previousEdge = null; Vertex previousVertex = null; *************** *** 173,176 **** --- 187,191 ---- List edges = extendSurf.getEdges(); List top = new ArrayList(edges.size()); + newCSpace.addSurface(selectedSurface); Iterator i = edges.iterator(); Edge current = null; *************** *** 223,227 **** } } ! createSurface(newEdges); newEdges = new ArrayList(); --- 238,246 ---- } } ! Surface sur = createSurface(newEdges); ! newCSpace.addSurface(sur); ! if (outer != null) { ! outer.addSurface(sur); ! } newEdges = new ArrayList(); *************** *** 239,243 **** } } ! return createSurface(top); } --- 258,279 ---- } } ! ConstructionSpaceFacade.getInstance().create(newCSpace); ! dragSurface = createSurface(top); ! if (outer != null) { ! outer.addSurface(dragSurface); ! } ! newCSpace.addSurface(dragSurface); ! Notification n = new Notification(Notification.SURFACE_SELECTED, dragSurface.getId()); ! Notifier.getInstance().sendNotification(n); ! if (outer instanceof FunctionalSpace) { ! n = new Notification(Notification.FUNCTIONAL_SPACE_MODIFIED, outer.getId()); ! } else if (outer instanceof ConstructionSpace) { ! n = new Notification(Notification.CONSTRUCTION_SPACE_MODIFIED, outer.getId()); ! } ! Notifier.getInstance().sendNotification(n); ! n = new Notification(Notification.CONSTRUCTION_SPACE_MODIFIED, newCSpace.getId()); ! Notifier.getInstance().sendNotification(n); ! ! return dragSurface; } *************** *** 258,263 **** } dragSurface = top; - Notification n = new Notification(Notification.SURFACE_SELECTED, dragSurface.getId()); - Notifier.getInstance().sendNotification(n); } } --- 294,297 ---- |
From: rimestad <rim...@us...> - 2005-09-02 13:30:33
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14633 Modified Files: MoveTool.java Log Message: Now the move works with the select tool Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MoveTool.java 31 Aug 2005 14:56:33 -0000 1.6 --- MoveTool.java 2 Sep 2005 13:30:23 -0000 1.7 *************** *** 9,13 **** --- 9,16 ---- import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.View; + import net.sourceforge.bprocessor.gl.view.Transformation; + import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.Surface; *************** *** 47,50 **** --- 50,56 ---- private int lastY = 0; + /** The plane to drag according to */ + private Plane dragPlane; + /** * The Constructor *************** *** 63,66 **** --- 69,104 ---- lastX = e.getX(); lastY = e.getY(); + + if (target instanceof Vertex) { + dragPlane = new Plane(0, 0, 1, 0); + } else if (target instanceof Edge) { + dragPlane = new Plane(0, 0, 1, 0); + } else if (target instanceof Surface) { + Surface sel = (Surface)target; + dragPlane = sel.plane(); + log.info("" + dragPlane); + } + // make a orthogonal plane to the current one + if (moveMode == XZ) { + log.info("orthogonal"); + Transformation trans = glv.getView().transformation(); + int x = lastX; + int y = lastY; + Vertex near = new Vertex("near", x, y, 0.0); + Vertex far = new Vertex("far", x, y, 1.0); + Edge ray = new Edge("ray", near, far); + ray = trans.unProject(ray); + dragPlane = dragPlane.orthogonalPlane(ray); + } + } + + /** + * Invoked when a mouse button has been released on a component. + * @param e The MouseEvent + */ + protected void released(MouseEvent e) { + super.released(e); + + dragPlane = null; } *************** *** 69,74 **** * @param e The MouseEvent object */ ! protected void dragged(MouseEvent e) { ! int x = e.getX(); int y = e.getY(); if (viewType == View.VIEW_3D) { --- 107,131 ---- * @param e The MouseEvent object */ ! protected void dragged(MouseEvent e) { ! if (dragPlane != null) { ! int x = e.getX(); ! int y = e.getY(); ! ! View view = glv.getView(); ! double[] from = view.toPlaneCoords(new double[] {lastX, lastY}, dragPlane); ! log.info("from " + from[0] + ", " + from[1] + ", " + from[2]); ! double[] to = view.toPlaneCoords(new double[] {x, y}, dragPlane); ! log.info("to " + to[0] + ", " + to[1] + ", " + to[2]); ! double[] delta = new double[] {to[0] - from[0], to[1] - from[1], to[2] - from[2]}; ! log.info("delta " + delta[0] + ", " + delta[1] + ", " + delta[2]); ! move(selection, delta); ! } else { ! log.warn("There were no plane to drag according to"); ! } ! ! lastX = e.getX(); ! lastY = e.getY(); ! } ! /* int x = e.getX(); int y = e.getY(); if (viewType == View.VIEW_3D) { *************** *** 180,186 **** lastX = x; lastY = y; ! } ! /** * Invoked when a key has been pressed. Lets user control the speed * and mode of movement. --- 237,320 ---- lastX = x; lastY = y; ! }*/ ! /** ! * Move the entire selection ! * @param sel The selection list ! * @param delta The movement ! */ ! private void move(List sel, double[] delta) { ! Iterator it = sel.iterator(); ! while (it.hasNext()) { ! Object elm = it.next(); ! if (elm instanceof Vertex) { ! move((Vertex)elm, delta); ! } else if (elm instanceof Edge) { ! move((Edge)elm, delta); ! } else if (elm instanceof Surface) { ! move((Surface)elm, delta); ! } ! } ! } ! ! /** ! * Move the give surface and its inner surfaces ! * @param surface The surface to move ! * @param delta The movement ! */ ! private void move(Surface surface, double[] delta) { ! log.info("moved surface"); ! List l = Util.traverse(surface); ! double[] coords; ! for (int i = 0; i < l.size(); i++) { ! Vertex v = (Vertex)l.get(i); ! coords = new double[] {v.getX() + delta[0], ! v.getY() + delta[1], ! v.getZ() + delta[2]}; ! updateVertex(v, coords); ! } ! ! Set innerSurfaces = surface.getInnerSurfaces(); ! if (innerSurfaces != null) { ! Iterator innerIt = innerSurfaces.iterator(); ! while (innerIt.hasNext()) { ! move((Surface)innerIt.next(), delta); ! } ! } ! } ! ! /** ! * Move the give edge ! * @param edge The surface to move ! * @param delta The movement ! */ ! private void move(Edge edge, double[] delta) { ! Vertex to = edge.getTo(); ! Vertex from = edge.getFrom(); ! ! double[] coords = new double[] {to.getX() + delta[0], ! to.getY() + delta[1], ! to.getZ() + delta[2]}; ! updateVertex(to, coords); ! coords = new double[] {from.getX() + delta[0], ! from.getY() + delta[1], ! from.getZ() + delta[2]}; ! updateVertex(from, coords); ! } ! ! /** ! * Move the give vertex ! * @param vertex The surface to move ! * @param delta The movement ! */ ! private void move(Vertex vertex, double[] delta) { ! double[] coords = new double[] {vertex.getX() + delta[0], ! vertex.getY() + delta[1], ! vertex.getZ() + delta[2]}; ! coords = snapToGrid(coords); ! updateVertex(vertex, coords); ! } ! ! /** * Invoked when a key has been pressed. Lets user control the speed * and mode of movement. |
From: rimestad <rim...@us...> - 2005-09-02 13:29:53
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14367 Modified Files: SelectTool.java Log Message: Changed selection to select an entire list of objects with shift Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** SelectTool.java 1 Sep 2005 06:05:15 -0000 1.14 --- SelectTool.java 2 Sep 2005 13:29:44 -0000 1.15 *************** *** 9,16 **** import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.View; - import net.sourceforge.bprocessor.gl.view.View3D; - import net.sourceforge.bprocessor.gl.view.ViewXY; - import net.sourceforge.bprocessor.gl.view.ViewXZ; - import net.sourceforge.bprocessor.gl.view.ViewYZ; import net.sourceforge.bprocessor.kernel.notification.Notification; --- 9,12 ---- *************** *** 19,32 **** import net.sourceforge.bprocessor.model.Edge; ! import net.sourceforge.bprocessor.model.EdgeFacade; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.VertexFacade; import net.sourceforge.bprocessor.model.Surface; ! import net.sourceforge.bprocessor.model.SurfaceFacade; import java.awt.event.MouseEvent; import java.awt.event.KeyEvent; import java.util.Iterator; import java.util.Set; --- 15,31 ---- import net.sourceforge.bprocessor.model.Edge; ! //import net.sourceforge.bprocessor.model.EdgeFacade; import net.sourceforge.bprocessor.model.Vertex; import net.sourceforge.bprocessor.model.VertexFacade; import net.sourceforge.bprocessor.model.Surface; ! //import net.sourceforge.bprocessor.model.SurfaceFacade; import java.awt.event.MouseEvent; import java.awt.event.KeyEvent; + import java.awt.event.InputEvent; import java.util.Iterator; + import java.util.List; + import java.util.ArrayList; import java.util.Set; *************** *** 40,51 **** private static Logger log = Logger.getLogger(SelectTool.class); /** The selected vertex */ ! protected static Vertex selectedVertex = null; /** The selected edge */ ! protected static Edge selectedEdge = null; /** The selected surface */ ! protected static Surface selectedSurface = null; /** the Viewtype */ --- 39,53 ---- private static Logger log = Logger.getLogger(SelectTool.class); + /** The selected objects */ + protected static List selection; + /** The selected vertex */ ! //protected static Vertex selectedVertex = null; /** The selected edge */ ! //protected static Edge selectedEdge = null; /** The selected surface */ ! //protected static Surface selectedSurface = null; /** the Viewtype */ *************** *** 55,59 **** protected Object target; ! /** * The constructor --- 57,63 ---- protected Object target; ! static { ! selection = new ArrayList(); ! } /** * The constructor *************** *** 88,92 **** */ protected void dragged(MouseEvent e) { ! findTarget(e); } --- 92,96 ---- */ protected void dragged(MouseEvent e) { ! //findTarget(e); } *************** *** 95,147 **** * @param e The MouseEvent object */ ! protected void pressed(MouseEvent e) { ! if (e.getButton() == MouseEvent.BUTTON1) { findTarget(e); ! if (selectedVertex != null) { ! Notification n = new Notification(Notification.VERTEX_DESELECTED, ! selectedVertex.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! if (selectedEdge != null) { ! Notification n = new Notification(Notification.EDGE_DESELECTED, ! selectedEdge.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! if (selectedSurface != null) { ! Notification n = new Notification(Notification.SURFACE_DESELECTED, ! selectedSurface.getId()); ! Notifier.getInstance().sendNotification(n); ! } ! int x = e.getX(); ! int y = e.getY(); ! viewType = 0; ! View view = glv.getView(); ! if (view instanceof View3D) { ! viewType = View.VIEW_3D; ! } else if (view instanceof ViewXY) { ! viewType = View.VIEW_XY; ! } else if (view instanceof ViewXZ) { ! viewType = View.VIEW_XZ; ! } else if (view instanceof ViewYZ) { ! viewType = View.VIEW_YZ; ! } ! ! if (target instanceof Vertex) { ! Vertex v = (Vertex)target; ! Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (target instanceof Surface) { ! Surface surface = (Surface)target; ! Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (target instanceof Edge) { ! Edge edge = (Edge)target; ! Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); ! Notifier.getInstance().sendNotification(n); } } } /** --- 99,167 ---- * @param e The MouseEvent object */ ! protected void pressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { findTarget(e); ! if (target == null) { ! log.info("target was null"); ! Iterator it = selection.iterator(); ! while (it.hasNext()) { ! deselect(it.next()); ! } ! selection = new ArrayList(); ! } else if ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK) { ! select(target); ! if (!selection.contains(target)) { ! selection.add(target); ! } ! } else { ! Iterator it = selection.iterator(); ! while (it.hasNext()) { ! deselect(it.next()); ! } ! select(target); ! selection.add(target); } } } + /** + * Sends the notification for select + * @param obj The selected object + */ + private void select(Object obj) { + if (obj instanceof Vertex) { + Vertex v = (Vertex)obj; + Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Surface) { + Surface surface = (Surface)obj; + Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Edge) { + Edge edge = (Edge)obj; + Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); + Notifier.getInstance().sendNotification(n); + } + } + + /** + * Sends the notification for deselect + * @param obj The selected object + */ + private void deselect(Object obj) { + if (obj instanceof Vertex) { + Vertex v = (Vertex)obj; + Notification n = new Notification(Notification.VERTEX_DESELECTED, v.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Surface) { + Surface surface = (Surface)obj; + Notification n = new Notification(Notification.SURFACE_DESELECTED, surface.getId()); + Notifier.getInstance().sendNotification(n); + } else if (obj instanceof Edge) { + Edge edge = (Edge)obj; + Notification n = new Notification(Notification.EDGE_DESELECTED, edge.getId()); + Notifier.getInstance().sendNotification(n); + } + } /** *************** *** 188,197 **** public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { ! if (selectedSurface != null) { Notification n = new Notification(Notification.SURFACE_DESELECTED, selectedSurface.getId()); Notifier.getInstance().sendNotification(n); deleteSurface(selectedSurface); ! } else if (selectedEdge != null) { if (selectedEdge.getSurfaces().size() < 1) { Notification n = new Notification(Notification.EDGE_DESELECTED, --- 208,219 ---- public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { ! if (target instanceof Surface) { ! Surface selectedSurface = (Surface)target; Notification n = new Notification(Notification.SURFACE_DESELECTED, selectedSurface.getId()); Notifier.getInstance().sendNotification(n); deleteSurface(selectedSurface); ! } else if (target instanceof Edge) { ! Edge selectedEdge = (Edge)target; if (selectedEdge.getSurfaces().size() < 1) { Notification n = new Notification(Notification.EDGE_DESELECTED, *************** *** 212,226 **** public void handleNotification(Notification n) { if (n.getType().equals(Notification.VERTEX_SELECTED)) { ! selectedVertex = VertexFacade.getInstance().findById(n.getObject()); } else if (n.getType().equals(Notification.VERTEX_DESELECTED)) { ! selectedVertex = null; } else if (n.getType().equals(Notification.EDGE_SELECTED)) { ! selectedEdge = EdgeFacade.getInstance().findById(n.getObject()); } else if (n.getType().equals(Notification.EDGE_DESELECTED)) { ! selectedEdge = null; } else if (n.getType().equals(Notification.SURFACE_SELECTED)) { ! selectedSurface = SurfaceFacade.getInstance().findById(n.getObject()); } else if (n.getType().equals(Notification.SURFACE_DESELECTED)) { ! selectedSurface = null; } } --- 234,248 ---- public void handleNotification(Notification n) { if (n.getType().equals(Notification.VERTEX_SELECTED)) { ! //selection.add(VertexFacade.getInstance().findById(n.getObject())); } else if (n.getType().equals(Notification.VERTEX_DESELECTED)) { ! //selectedVertex = null; } else if (n.getType().equals(Notification.EDGE_SELECTED)) { ! // selection.add(EdgeFacade.getInstance().findById(n.getObject())); } else if (n.getType().equals(Notification.EDGE_DESELECTED)) { ! //selectedEdge = null; } else if (n.getType().equals(Notification.SURFACE_SELECTED)) { ! //selection.add(SurfaceFacade.getInstance().findById(n.getObject())); } else if (n.getType().equals(Notification.SURFACE_DESELECTED)) { ! //selectedSurface = null; } } |
From: rimestad <rim...@us...> - 2005-09-02 13:21:28
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12369 Modified Files: View.java View3D.java AbstractView.java Log Message: Added toPlaneCoords for the views Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** AbstractView.java 1 Sep 2005 06:05:15 -0000 1.18 --- AbstractView.java 2 Sep 2005 13:21:19 -0000 1.19 *************** *** 11,14 **** --- 11,15 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.EdgeFacade; *************** *** 134,138 **** /** The drawing mode. Either wireframe, solid og lighting */ ! protected int drawMode = WIREFRAME_MODE; /** The transparency of surfaces */ --- 135,139 ---- /** The drawing mode. Either wireframe, solid og lighting */ ! protected int drawMode = View.WIREFRAME_MODE; /** The transparency of surfaces */ *************** *** 148,155 **** */ public static void setTransparency(int percent) { ! byte b = (byte)0xff; //(byte)(255 * (percent / 100)); ! log.info("value = " + b); for (int i = 0; i < transparency.length; i++) { ! transparency[i] = b; } } --- 149,160 ---- */ public static void setTransparency(int percent) { ! byte b1 = (byte)0xaa; ! byte b2 = (byte)0x55; for (int i = 0; i < transparency.length; i++) { ! if (((int)(i / 4)) % 2 == 0) { ! transparency[i] = b1; ! } else { ! transparency[i] = b2; ! } } } *************** *** 225,234 **** // set up lighting for the model if (drawMode == LIGHTING_MODE) { ! gl.glShadeModel(GL.GL_SMOOTH); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); gl.glEnable(GL.GL_COLOR_MATERIAL); gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1); ! //gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE); gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] {0.3f, 0.3f, 0.3f, 1.0f}); --- 230,239 ---- // set up lighting for the model if (drawMode == LIGHTING_MODE) { ! //gl.glShadeModel(GL.GL_SMOOTH); gl.glEnable(GL.GL_LIGHTING); gl.glEnable(GL.GL_LIGHT0); gl.glEnable(GL.GL_COLOR_MATERIAL); gl.glLightModeli(GL.GL_LIGHT_MODEL_TWO_SIDE, 1); ! gl.glLightModeli(GL.GL_LIGHT_MODEL_LOCAL_VIEWER, 1); gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE); gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] {0.3f, 0.3f, 0.3f, 1.0f}); *************** *** 314,319 **** --- 319,327 ---- if (selectedSurface != null) { gl.glColor3fv(SELECTED_COLOR); + gl.glEnable(GL.GL_POLYGON_STIPPLE); + gl.glPolygonStipple(transparency); selectedSurface = SurfaceFacade.getInstance().findById(selectedSurface.getId()); drawSurface(selectedSurface); + gl.glDisable(GL.GL_POLYGON_STIPPLE); } *************** *** 330,333 **** --- 338,342 ---- } + gl.glDisable(GL.GL_LIGHTING); // draw activeEdge different if it is parallel with axis if (activeEdge != null) { *************** *** 409,415 **** } } ! ! // HERE STARTS SELECTION MODE DRAWING } else { if (selectMode == SURFACES) { Iterator it = surfaces.iterator(); --- 418,424 ---- } } ! gl.glEnable(GL.GL_LIGHTING); } else { + // HERE STARTS SELECTION MODE DRAWING if (selectMode == SURFACES) { Iterator it = surfaces.iterator(); *************** *** 455,462 **** */ private void drawSurface(Surface s) { - //gl.glEnable(GL.GL_POLYGON_STIPPLE); - //gl.glDisable(GL.GL_BLEND); - //glblend.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - //gl.glPolygonStipple(transparency); List l = s.getEdges(); if (l != null) { --- 464,467 ---- *************** *** 895,898 **** --- 900,913 ---- /** + * Return the 3D coordinates for the canvas matching the given 2D coords + * @param coords The coordinate to convert + * @param plane The plane to find intersection with + * @return The point in 3D + */ + public double[] toPlaneCoords(double[] coords, Plane plane) { + return toCanvasCoords(coords); + } + + /** * representation of a 3D point. */ Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** View3D.java 31 Aug 2005 08:33:55 -0000 1.13 --- View3D.java 2 Sep 2005 13:21:19 -0000 1.14 *************** *** 164,188 **** */ public double[] toCanvasCoords(double[] coords) { ! if (coords.length == 2) { ! double x = coords[0]; double y = AbstractView.getHeight() - coords[1]; ! Transformation transformation = transformation(); ! ! Plane xy = new Plane(0, 0, 1, 0); Vertex near = new Vertex("near", x, y, 0.0); Vertex far = new Vertex("far", x, y, 1.0); Edge ray = new Edge("ray", near, far); ray = transformation.unProject(ray); ! Vertex vertex = xy.intersection(ray); ! return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; ! } else { ! log.warn("Too many arguments"); ! return new double[] {0.0, 0.0, 0.0}; ! } } ! /** * Get transformation for model to screen coordinates --- 164,197 ---- */ public double[] toCanvasCoords(double[] coords) { ! return toPlaneCoords(coords, new Plane(0, 0, 1, 0)); ! } ! ! /** ! * Return the point in the space that intersects with the given plane ! * @return The intersection between the ray through the space and the given plane ! * @param coords The screen coordinate ! * @param plane The plane in the space to intersect with ! */ ! public double[] toPlaneCoords(double[] coords, Plane plane) { ! if (coords.length == 2 && plane != null) { double x = coords[0]; double y = AbstractView.getHeight() - coords[1]; ! Transformation transformation = transformation(); ! Vertex near = new Vertex("near", x, y, 0.0); Vertex far = new Vertex("far", x, y, 1.0); Edge ray = new Edge("ray", near, far); ray = transformation.unProject(ray); ! Vertex vertex = plane.intersection(ray); ! if (vertex != null) { ! return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; ! } ! } ! log.warn("Too many arguments"); ! return new double[] {0.0, 0.0, 0.0}; } ! /** * Get transformation for model to screen coordinates Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** View.java 30 Aug 2005 13:20:08 -0000 1.8 --- View.java 2 Sep 2005 13:21:19 -0000 1.9 *************** *** 11,14 **** --- 11,15 ---- import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.model.Plane; import net.java.games.jogl.GLEventListener; *************** *** 76,79 **** --- 77,88 ---- /** + * Return the 3D coordinates for the canvas matching the given 2D coords + * @param coords The window coordinates + * @param plane The plane to find intersection with + * @return The relative 3D coordinates + */ + public double[] toPlaneCoords(double[] coords, Plane plane); + + /** * Return the distance on the canvas matching the given double * @param dist The window coordinates |
From: Michael L. <he...@us...> - 2005-09-01 13:16:19
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23320/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Log Message: Implemented Surface.coordinateSystem() Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Surface.java 1 Sep 2005 12:44:01 -0000 1.17 --- Surface.java 1 Sep 2005 13:16:12 -0000 1.18 *************** *** 228,231 **** --- 228,232 ---- } + /** * Returns the normal to this *************** *** 234,262 **** public Vertex normal() { if (edges.size() > 1) { ! EdgeFacade ef = EdgeFacade.getInstance(); ! Edge e1 = ef.findById(((Edge)edges.get(0)).getId()); ! Edge e2 = ef.findById(((Edge)edges.get(1)).getId()); ! Vertex v1 = e1.getFrom(); ! Vertex v2 = e1.getTo(); ! Vertex v3 = null; ! ! if (e2.otherVertex(v1) == null) { ! v3 = e2.otherVertex(v2); ! // v2 is the center ! Vertex v2v1 = v2.minus(v1); ! Vertex v2v3 = v2.minus(v3); ! return v2v3.cross(v2v1); ! } else if (e2.otherVertex(v2) == null) { ! // v1 is the center ! v3 = e2.otherVertex(v1); ! Vertex v1v2 = v1.minus(v2); ! Vertex v1v3 = v1.minus(v3); ! return v1v3.cross(v1v2); ! } return null; } - return null; } - /** * Returns the Plane that this Surface lies in --- 235,247 ---- public Vertex normal() { if (edges.size() > 1) { ! Edge e0 = (Edge) edges.get(0); ! Edge e1 = (Edge) edges.get(1); ! Vertex v0 = e0.getTo().minus(e0.getFrom()); ! Vertex v1 = e1.getTo().minus(e1.getFrom()); ! return v0.cross(v1); ! } else { return null; } } /** * Returns the Plane that this Surface lies in *************** *** 289,297 **** Edge e1 = (Edge) edges.get(1); origin = e0.getFrom(); ! Vertex p = e0.getTo(); ! Vertex q = e1.otherVertex(p); ! i = p.minus(origin); i.scale(1 / i.length()); ! Vertex v = q.minus(p); n = i.cross(v); n.scale(1 / n.length()); --- 274,280 ---- Edge e1 = (Edge) edges.get(1); origin = e0.getFrom(); ! i = e0.getTo().minus(origin);; i.scale(1 / i.length()); ! Vertex v = e1.getTo().minus(e1.getFrom()); n = i.cross(v); n.scale(1 / n.length()); |
From: Michael L. <he...@us...> - 2005-09-01 12:44:22
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32143/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Log Message: Implemented Surface.coordinateSystem() Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Surface.java 31 Aug 2005 10:30:15 -0000 1.16 --- Surface.java 1 Sep 2005 12:44:01 -0000 1.17 *************** *** 279,282 **** --- 279,307 ---- /** + * Returns a CoordinateSystem where the xy-plane is + * co-planar to this Surface + * @return The local coordinate system for this Surface + */ + public CoordinateSystem coordinateSystem() { + if (edges.size() > 1) { + Vertex i, j, n, origin; + Edge e0 = (Edge) edges.get(0); + Edge e1 = (Edge) edges.get(1); + origin = e0.getFrom(); + Vertex p = e0.getTo(); + Vertex q = e1.otherVertex(p); + i = p.minus(origin); + i.scale(1 / i.length()); + Vertex v = q.minus(p); + n = i.cross(v); + n.scale(1 / n.length()); + j = i.cross(n); + j.scale(1 / j.length()); + return new CoordinateSystem(i, j, n, origin); + } else { + return null; + } + } + /** * Returns the projection on the surface normal * @param p The point to project on the normal |
From: Michael L. <he...@us...> - 2005-09-01 12:20:50
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12125/src/net/sourceforge/bprocessor/model Added Files: CoordinateSystem.java Log Message: Added the CoordinateSystem class --- NEW FILE: CoordinateSystem.java --- //--------------------------------------------------------------------------------- // $Id: CoordinateSystem.java,v 1.1 2005/09/01 12:17:16 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; /** * The CoordinateSystem is represented by * three orthogonal unit vectors, i, j and n. * i, and j represents the xy-plane of the * coordinate system and n is a normal vector * to that plane. * The origin places the CoordinateSystem relative * to the global coordinate system. */ public class CoordinateSystem { /** The i unit vector (x-direction) */ protected Vertex i; /** The j unit vector (y-direction) */ protected Vertex j; /** The n unit vector (z-direction) */ protected Vertex n; /** The origin of the coordinate system */ protected Vertex origin; /** * Constructor * @param i The i vector * @param j The j vector * @param n The n vector * @param origin The origin */ public CoordinateSystem(Vertex i, Vertex j, Vertex n, Vertex origin) { super(); this.i = i; this.j = j; this.n = n; this.origin = origin; } /** * Returns the projection of vector on z-axis (n vector) * @param vector The vector to project on z * @return The projectet vector */ public Vertex perpendicular(Vertex vector) { Vertex projection = new Vertex("n projection of vector"); projection.setX(n.getX()); projection.setY(n.getY()); projection.setZ(n.getZ()); double scalar = n.dot(vector); projection.scale(scalar); return projection; } /** * Returns the projection of vector on the xy-plane * @param vector The vector to project * @return The projected vector */ public Vertex projection(Vertex vector) { Vertex p = perpendicular(vector); return vector.minus(p); } /** * Return the vertex translated to this CoordinateSystem * @param vertex The vertex to translate * @return The translated vertex */ public Vertex translate(Vertex vertex) { Vertex v = vertex.minus(origin); double x = i.dot(v); double y = j.dot(v); double z = n.dot(v); v.setX(x); v.setY(y); v.setZ(z); return v; } } |
From: Michael L. <he...@us...> - 2005-09-01 08:34:06
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12562/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Pencil Tool now finished surface when clicking edge. Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PencilTool.java 1 Sep 2005 06:05:15 -0000 1.10 --- PencilTool.java 1 Sep 2005 08:33:58 -0000 1.11 *************** *** 102,105 **** --- 102,113 ---- glv.getView().setActiveEdge(active); } else { + // The following lines of code are there to make sure + // that a Surface is finished when clicking an edge.. + + if (target != null) { + if (target instanceof Edge) { + intern(vertex); + } + } if (vertex.getId() == null) { intern(vertex); |
From: Michael L. <he...@us...> - 2005-09-01 06:05:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32458/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java SelectTool.java Log Message: Small improvements to PencilTool Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SelectTool.java 31 Aug 2005 13:14:12 -0000 1.13 --- SelectTool.java 1 Sep 2005 06:05:15 -0000 1.14 *************** *** 80,84 **** */ protected void moved(MouseEvent e) { ! //findTarget(e); } --- 80,84 ---- */ protected void moved(MouseEvent e) { ! findTarget(e); } *************** *** 88,92 **** */ protected void dragged(MouseEvent e) { ! //findTarget(e); } --- 88,92 ---- */ protected void dragged(MouseEvent e) { ! findTarget(e); } Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PencilTool.java 31 Aug 2005 13:14:12 -0000 1.9 --- PencilTool.java 1 Sep 2005 06:05:15 -0000 1.10 *************** *** 38,41 **** --- 38,45 ---- protected Vertex to = null; + /** The current */ + + protected Vertex current = null; + /** The edges */ *************** *** 120,132 **** } } - /** ! * Invoked when a mouse button has been pressed on a component. ! * @param e The MouseEvent object */ ! protected void pressed(MouseEvent e) { ! super.pressed(e); ! double x = e.getX(); ! double y = AbstractView.getHeight() - e.getY(); View v = glv.getView(); Transformation transformation = v.transformation(); --- 124,147 ---- } } /** ! * Round to grid ! * @param value The value ! * @return The rounded value */ ! protected double round(double value) { ! int i = (int) value; ! if (Math.abs(i - value) < 0.2) { ! return Math.round(value); ! } else { ! return value; ! } ! } ! /** ! * Set current vertex to an appropriate vertex ! * @param event Tne MouseEvent ! */ ! protected void findVertex(MouseEvent event) { ! double x = event.getX(); ! double y = AbstractView.getHeight() - event.getY(); View v = glv.getView(); Transformation transformation = v.transformation(); *************** *** 138,142 **** if (target != null) { if (target instanceof Vertex) { ! onVertex((Vertex) target); } if (target instanceof Surface) { --- 153,157 ---- if (target != null) { if (target instanceof Vertex) { ! current = (Vertex) target; } if (target instanceof Surface) { *************** *** 145,149 **** Vertex vertex = plane.intersection(ray); vertex.setName("V" + vertexNum++); ! onVertex(vertex); } if (target instanceof Edge) { --- 160,164 ---- Vertex vertex = plane.intersection(ray); vertex.setName("V" + vertexNum++); ! current = vertex; } if (target instanceof Edge) { *************** *** 152,156 **** Vertex vertex = intersection.getFrom(); vertex.setName("V" + vertexNum++); ! onVertex(vertex); } } else { --- 167,171 ---- Vertex vertex = intersection.getFrom(); vertex.setName("V" + vertexNum++); ! current = vertex; } } else { *************** *** 158,164 **** Vertex vertex = xy.intersection(ray); vertex.setName("V" + vertexNum++); ! onVertex(vertex); } } /** * Invoked when the mouse cursor has been moved --- 173,193 ---- Vertex vertex = xy.intersection(ray); vertex.setName("V" + vertexNum++); ! current = vertex; ! } ! if (current.getId() == null) { ! current.setX(round(current.getX())); ! current.setY(round(current.getY())); ! current.setZ(round(current.getZ())); } } + + /** + * Invoked when a mouse button has been pressed on a component. + * @param e The MouseEvent object + */ + protected void pressed(MouseEvent e) { + super.pressed(e); + onVertex(current); + } /** * Invoked when the mouse cursor has been moved *************** *** 166,177 **** */ protected void moved(MouseEvent e) { ! int x = e.getX(); ! int y = e.getY(); ! View v = glv.getView(); if (to != null) { ! double[] xyz = v.toCanvasCoords(new double[]{e.getX(), e.getY()}); ! to.setX(xyz[0]); ! to.setY(xyz[1]); ! to.setZ(xyz[2]); } } --- 195,204 ---- */ protected void moved(MouseEvent e) { ! super.moved(e); ! findVertex(e); if (to != null) { ! to.setX(current.getX()); ! to.setY(current.getY()); ! to.setZ(current.getZ()); } } |
From: Michael L. <he...@us...> - 2005-09-01 06:05:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32458/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java Log Message: Small improvements to PencilTool Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AbstractView.java 31 Aug 2005 14:56:31 -0000 1.17 --- AbstractView.java 1 Sep 2005 06:05:15 -0000 1.18 *************** *** 826,832 **** //display(glv.getGLDrawable()); - System.out.println("Calling repaint"); glv.repaint(true); - System.out.println("Done"); id = processSelect(); if (id != null) { --- 826,830 ---- |
From: Michael L. <he...@us...> - 2005-08-31 14:56:42
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508/src/net/sourceforge/bprocessor/gl Modified Files: GLView.java Log Message: Reduced flickering in hit-detection Index: GLView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/GLView.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** GLView.java 17 Aug 2005 11:06:47 -0000 1.10 --- GLView.java 31 Aug 2005 14:56:33 -0000 1.11 *************** *** 14,17 **** --- 14,18 ---- import net.java.games.jogl.GLCapabilities; + import net.java.games.jogl.GLDrawable; import net.java.games.jogl.GLDrawableFactory; import net.java.games.jogl.GLCanvas; *************** *** 55,58 **** --- 56,60 ---- GUI.getInstance().registerPanel(glc, GUI.SPLIT_MIDDLE); log.info("Done Creating GlView"); + glc.setAutoSwapBufferMode(false); } *************** *** 91,95 **** } getView().reset(); ! this.repaint(); } --- 93,97 ---- } getView().reset(); ! this.repaint(true); } *************** *** 98,102 **** */ public void repaint() { ! glc.repaint(); } --- 100,104 ---- */ public void repaint() { ! glc.display(); } *************** *** 109,113 **** glc.display(); } else { ! glc.repaint(); } } --- 111,115 ---- glc.display(); } else { ! glc.display(); } } *************** *** 130,132 **** --- 132,142 ---- return tool; } + + /** + * Return the GLDrawable + * @return The GlDrawable + */ + public GLDrawable getGLDrawable() { + return glc; + } } |
From: Michael L. <he...@us...> - 2005-08-31 14:56:40
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java MoveTool.java CameraZoomTimer.java CameraMoveTimer.java Log Message: Reduced flickering in hit-detection Index: CameraZoomTimer.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/CameraZoomTimer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CameraZoomTimer.java 5 Aug 2005 10:48:30 -0000 1.1 --- CameraZoomTimer.java 31 Aug 2005 14:56:33 -0000 1.2 *************** *** 44,48 **** v.zoom(1.0); } ! glv.repaint(); } } --- 44,48 ---- v.zoom(1.0); } ! glv.repaint(true); } } Index: MoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/MoveTool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MoveTool.java 30 Aug 2005 12:52:06 -0000 1.5 --- MoveTool.java 31 Aug 2005 14:56:33 -0000 1.6 *************** *** 201,205 **** super.keyPressed(e); } ! glv.repaint(); } } --- 201,205 ---- super.keyPressed(e); } ! glv.repaint(true); } } Index: CameraMoveTimer.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/CameraMoveTimer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CameraMoveTimer.java 5 Aug 2005 10:48:30 -0000 1.1 --- CameraMoveTimer.java 31 Aug 2005 14:56:33 -0000 1.2 *************** *** 41,45 **** v.translateRotationX(10 * at.getdy()); v.translateRotationY(10 * at.getdx()); ! glv.repaint(); } } --- 41,45 ---- v.translateRotationX(10 * at.getdy()); v.translateRotationY(10 * at.getdx()); ! glv.repaint(true); } } Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AbstractTool.java 31 Aug 2005 13:14:12 -0000 1.12 --- AbstractTool.java 31 Aug 2005 14:56:32 -0000 1.13 *************** *** 123,127 **** glv.getView().changeDrawMode(View.LIGHTING_MODE); } ! glv.repaint(); } --- 123,127 ---- glv.getView().changeDrawMode(View.LIGHTING_MODE); } ! glv.repaint(true); } *************** *** 152,156 **** dragged(e); ! glv.repaint(); } --- 152,156 ---- dragged(e); ! glv.repaint(true); } *************** *** 161,165 **** public void mouseMoved(MouseEvent e) { moved(e); ! glv.repaint(); } --- 161,165 ---- public void mouseMoved(MouseEvent e) { moved(e); ! glv.repaint(true); } *************** *** 201,205 **** pressed(e); ! glv.repaint(); } --- 201,205 ---- pressed(e); ! glv.repaint(true); } *************** *** 220,224 **** } released(e); ! glv.repaint(); } --- 220,224 ---- } released(e); ! glv.repaint(true); } |
From: Michael L. <he...@us...> - 2005-08-31 14:56:39
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1508/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java ViewFactory.java Log Message: Reduced flickering in hit-detection Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** AbstractView.java 31 Aug 2005 07:02:51 -0000 1.16 --- AbstractView.java 31 Aug 2005 14:56:31 -0000 1.17 *************** *** 246,251 **** gl.glFlush(); hits = gl.glRenderMode(GL.GL_RENDER); ! glv.repaint(); ! } long after = System.currentTimeMillis(); --- 246,253 ---- gl.glFlush(); hits = gl.glRenderMode(GL.GL_RENDER); ! //glv.repaint(); ! } else { ! gld.swapBuffers(); ! } long after = System.currentTimeMillis(); *************** *** 747,751 **** selectedSurface = null; } ! glv.repaint(); } --- 749,753 ---- selectedSurface = null; } ! glv.repaint(true); } *************** *** 822,826 **** --- 824,832 ---- selectMode = VERTICES; //repainting to get selection buffer + //display(glv.getGLDrawable()); + + System.out.println("Calling repaint"); glv.repaint(true); + System.out.println("Done"); id = processSelect(); if (id != null) { Index: ViewFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ViewFactory.java 25 Aug 2005 16:08:12 -0000 1.4 --- ViewFactory.java 31 Aug 2005 14:56:31 -0000 1.5 *************** *** 250,254 **** public void actionPerformed(ActionEvent e) { glv.getView().changeDrawMode(View.WIREFRAME_MODE); ! glv.repaint(); } } --- 250,254 ---- public void actionPerformed(ActionEvent e) { glv.getView().changeDrawMode(View.WIREFRAME_MODE); ! glv.repaint(true); } } *************** *** 279,283 **** public void actionPerformed(ActionEvent e) { glv.getView().changeDrawMode(View.SOLID_MODE); ! glv.repaint(); } } --- 279,283 ---- public void actionPerformed(ActionEvent e) { glv.getView().changeDrawMode(View.SOLID_MODE); ! glv.repaint(true); } } *************** *** 308,312 **** public void actionPerformed(ActionEvent e) { glv.getView().changeDrawMode(View.LIGHTING_MODE); ! glv.repaint(); } } --- 308,312 ---- public void actionPerformed(ActionEvent e) { glv.getView().changeDrawMode(View.LIGHTING_MODE); ! glv.repaint(true); } } |
From: Michael L. <he...@us...> - 2005-08-31 13:14:20
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24828/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java PencilTool.java SelectTool.java Log Message: Progress on PencilTool Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SelectTool.java 31 Aug 2005 12:49:40 -0000 1.12 --- SelectTool.java 31 Aug 2005 13:14:12 -0000 1.13 *************** *** 64,67 **** --- 64,78 ---- } + /** + * Find the object under the mouse and set target + * @param event The MouseEvent + */ + protected void findTarget(MouseEvent event) { + int x = event.getX(); + int y = event.getY(); + View view = glv.getView(); + target = view.getObjectAtPoint(x, y); + } + /** * Invoked when the mouse cursor has been moved *************** *** 69,72 **** --- 80,84 ---- */ protected void moved(MouseEvent e) { + //findTarget(e); } *************** *** 76,79 **** --- 88,92 ---- */ protected void dragged(MouseEvent e) { + //findTarget(e); } *************** *** 83,88 **** */ protected void pressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { ! target = null; if (selectedVertex != null) { Notification n = new Notification(Notification.VERTEX_DESELECTED, --- 96,102 ---- */ protected void pressed(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { ! findTarget(e); if (selectedVertex != null) { Notification n = new Notification(Notification.VERTEX_DESELECTED, *************** *** 114,130 **** } ! Object selectObject; ! selectObject = view.getObjectAtPoint(x, y); ! target = selectObject; ! if (selectObject instanceof Vertex) { ! Vertex v = (Vertex)selectObject; Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); Notifier.getInstance().sendNotification(n); ! } else if (selectObject instanceof Surface) { ! Surface surface = (Surface)selectObject; Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); Notifier.getInstance().sendNotification(n); ! } else if (selectObject instanceof Edge) { ! Edge edge = (Edge)selectObject; Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); Notifier.getInstance().sendNotification(n); --- 128,141 ---- } ! if (target instanceof Vertex) { ! Vertex v = (Vertex)target; Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); Notifier.getInstance().sendNotification(n); ! } else if (target instanceof Surface) { ! Surface surface = (Surface)target; Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); Notifier.getInstance().sendNotification(n); ! } else if (target instanceof Edge) { ! Edge edge = (Edge)target; Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); Notifier.getInstance().sendNotification(n); *************** *** 139,142 **** --- 150,154 ---- */ protected void released(MouseEvent e) { + //findTarget(e); } Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PencilTool.java 31 Aug 2005 10:31:40 -0000 1.8 --- PencilTool.java 31 Aug 2005 13:14:12 -0000 1.9 *************** *** 9,12 **** --- 9,14 ---- import java.awt.event.MouseEvent; + import java.util.ArrayList; + import java.util.List; import net.sourceforge.bprocessor.gl.GLView; *************** *** 15,21 **** --- 17,26 ---- import net.sourceforge.bprocessor.gl.view.View; import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.EdgeFacade; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Surface; + import net.sourceforge.bprocessor.model.SurfaceFacade; import net.sourceforge.bprocessor.model.Vertex; + import net.sourceforge.bprocessor.model.VertexFacade; /** *************** *** 24,27 **** --- 29,45 ---- public class PencilTool extends SelectTool { + /** The active */ + protected Edge active = null; + + /** The from */ + protected Vertex from = null; + + /** The to */ + protected Vertex to = null; + + /** The edges */ + + protected List edges = null; + /** * Constructor *************** *** 32,37 **** --- 50,84 ---- } + /** + * Intern the vertex + * @param vertex The vertex + */ + protected void intern(Vertex vertex) { + if (vertex.getId() == null) { + VertexFacade.getInstance().create(vertex); + } + } + + /** + * Intern the edge + * @param edge The edge + */ + protected void intern(Edge edge) { + if (edge.getId() == null) { + EdgeFacade.getInstance().create(edge); + edges.add(edge); + } + } /** + * Intern the surface + * @param surface The surface + */ + protected void intern(Surface surface) { + if (surface.getId() == null) { + SurfaceFacade.getInstance().create(surface); + } + } + /** * Called with the vertex that are clicked on - either: * - A vertex on the xy-plane *************** *** 43,46 **** --- 90,122 ---- void onVertex(Vertex vertex) { System.out.println(vertex); + if (active == null) { + edges = new ArrayList(); + intern(vertex); + from = vertex; + to = new Vertex("Mouse", vertex.getX(), vertex.getY(), vertex.getZ()); + active = new Edge("E" + edgeNum++, from, to); + glv.getView().setActiveEdge(active); + } else { + if (vertex.getId() == null) { + intern(vertex); + active.setTo(vertex); + intern(active); + + from = vertex; + active = new Edge("E" + edgeNum++, from, to); + + glv.getView().setActiveEdge(active); + } else { + active.setTo(vertex); + intern(active); + Surface surface = new Surface("S" + surfaceNum++, edges); + intern(surface); + edges = null; + active = null; + glv.getView().setActiveEdge(null); + from = null; + to = null; + } + } } *************** *** 68,71 **** --- 144,148 ---- Plane plane = surface.plane(); Vertex vertex = plane.intersection(ray); + vertex.setName("V" + vertexNum++); onVertex(vertex); } *************** *** 73,81 **** Edge edge = (Edge) target; Edge intersection = edge.intersection(ray); ! onVertex(intersection.getFrom()); } } else { Plane xy = new Plane(0, 0, 1, 0); Vertex vertex = xy.intersection(ray); onVertex(vertex); } --- 150,161 ---- Edge edge = (Edge) target; Edge intersection = edge.intersection(ray); ! Vertex vertex = intersection.getFrom(); ! vertex.setName("V" + vertexNum++); ! onVertex(vertex); } } else { Plane xy = new Plane(0, 0, 1, 0); Vertex vertex = xy.intersection(ray); + vertex.setName("V" + vertexNum++); onVertex(vertex); } *************** *** 89,93 **** int y = e.getY(); View v = glv.getView(); ! } --- 169,178 ---- int y = e.getY(); View v = glv.getView(); ! if (to != null) { ! double[] xyz = v.toCanvasCoords(new double[]{e.getX(), e.getY()}); ! to.setX(xyz[0]); ! to.setY(xyz[1]); ! to.setZ(xyz[2]); ! } } Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AbstractTool.java 30 Aug 2005 12:46:14 -0000 1.11 --- AbstractTool.java 31 Aug 2005 13:14:12 -0000 1.12 *************** *** 44,54 **** /** An vertex counter */ ! private static long vertexNum = 1; /** An edge counter */ ! private static long edgeNum = 1; /** An surface counter */ ! private static long surfaceNum = 1; /** The snap variable */ --- 44,54 ---- /** An vertex counter */ ! protected static long vertexNum = 1; /** An edge counter */ ! protected static long edgeNum = 1; /** An surface counter */ ! protected static long surfaceNum = 1; /** The snap variable */ |
From: Nordholt <nor...@us...> - 2005-08-31 12:52:00
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9956 Modified Files: HoleTool.java Log Message: fixed method of determining if a hole is inside a surface Index: HoleTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/HoleTool.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HoleTool.java 30 Aug 2005 13:00:33 -0000 1.1 --- HoleTool.java 31 Aug 2005 12:51:51 -0000 1.2 *************** *** 201,205 **** if (tHoleFrom > tHole) { contained = false; ! } else if (tSurfFrom > tSurf) { crossings++; } --- 201,205 ---- if (tHoleFrom > tHole) { contained = false; ! } else if (tSurfFrom >= tSurf) { crossings++; } |
From: Nordholt <nor...@us...> - 2005-08-31 12:49:51
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8497 Modified Files: SelectTool.java Log Message: changed method for determining the view used Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SelectTool.java 31 Aug 2005 10:31:40 -0000 1.11 --- SelectTool.java 31 Aug 2005 12:49:40 -0000 1.12 *************** *** 9,12 **** --- 9,16 ---- import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.view.View; + import net.sourceforge.bprocessor.gl.view.View3D; + import net.sourceforge.bprocessor.gl.view.ViewXY; + import net.sourceforge.bprocessor.gl.view.ViewXZ; + import net.sourceforge.bprocessor.gl.view.ViewYZ; import net.sourceforge.bprocessor.kernel.notification.Notification; *************** *** 100,119 **** viewType = 0; View view = glv.getView(); ! double[] coords = view.toCanvasCoords(new double[]{x, y}); ! double[] coordsx = view.toCanvasCoords(new double[] {x + 1, y}); ! double[] coordsy = view.toCanvasCoords(new double[] {x , y + 1}); ! if (coords[0] == 0 && coordsx[0] == 0 && coordsy[0] == 0) { ! viewType = View.VIEW_YZ; ! } ! if (coords[1] == 0 && coordsx[1] == 0 && coordsy[1] == 0) { ! viewType = View.VIEW_XZ; ! } ! if (coords[2] == 0 && coordsx[2] == 0 && coordsy[2] == 0) { ! viewType = View.VIEW_XY; ! } ! if (coords[0] == 0 && coords[1] == 0 && coords[2] == 0 && ! coordsx[0] == 0 && coordsx[1] == 0 && coordsx[2] == 0 && ! coordsy[0] == 0 && coordsy[1] == 0 && coordsy[2] == 0) { viewType = View.VIEW_3D; } --- 104,115 ---- viewType = 0; View view = glv.getView(); ! if (view instanceof View3D) { viewType = View.VIEW_3D; + } else if (view instanceof ViewXY) { + viewType = View.VIEW_XY; + } else if (view instanceof ViewXZ) { + viewType = View.VIEW_XZ; + } else if (view instanceof ViewYZ) { + viewType = View.VIEW_YZ; } *************** *** 135,139 **** } } ! } --- 131,135 ---- } } ! } |
From: Michael L. <he...@us...> - 2005-08-31 10:31:54
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6461/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java SelectTool.java Log Message: Target added to SelectTool (target is object under mouse) PencilTool implemented to find a Vertex Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SelectTool.java 30 Aug 2005 12:59:36 -0000 1.10 --- SelectTool.java 31 Aug 2005 10:31:40 -0000 1.11 *************** *** 47,50 **** --- 47,54 ---- /** the Viewtype */ protected int viewType; + + /** the object corresponding to the mouse */ + protected Object target; + /** *************** *** 76,79 **** --- 80,84 ---- protected void pressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { + target = null; if (selectedVertex != null) { Notification n = new Notification(Notification.VERTEX_DESELECTED, *************** *** 115,118 **** --- 120,124 ---- Object selectObject; selectObject = view.getObjectAtPoint(x, y); + target = selectObject; if (selectObject instanceof Vertex) { Vertex v = (Vertex)selectObject; Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PencilTool.java 31 Aug 2005 08:33:55 -0000 1.7 --- PencilTool.java 31 Aug 2005 10:31:40 -0000 1.8 *************** *** 9,15 **** import java.awt.event.MouseEvent; - import java.util.ArrayList; - import java.util.LinkedList; - import java.util.List; import net.sourceforge.bprocessor.gl.GLView; --- 9,12 ---- *************** *** 27,43 **** public class PencilTool extends SelectTool { - /** The height */ - private int height = 0; - - /** The current number of surfaces */ - private int number = 0; - - /** The current factor */ - private int factor = 0; - - /** The current Edge list */ - protected List edges; - - /** * Constructor --- 24,27 ---- *************** *** 46,87 **** public PencilTool(GLView glv) { super(glv); - edges = new ArrayList(); } /** ! * Create n surfaces to test performance. ! * @param n The number of surfaces to create */ ! void createSurfaces(int n) { ! double coords[] = new double[3]; ! coords[0] = -1; ! coords[1] = height; ! coords[2] = -1; ! Vertex a = createVertex(coords); ! coords[0] = 1; ! coords[1] = height; ! coords[2] = -1; ! Vertex b = createVertex(coords); ! coords[0] = 1; ! coords[1] = height; ! coords[2] = 1; ! Vertex c = createVertex(coords); ! coords[0] = -1; ! coords[1] = height; ! coords[2] = 1; ! height++; ! Vertex d = createVertex(coords); ! Edge e1 = createEdge(a, b); ! Edge e2 = createEdge(b, c); ! Edge e3 = createEdge(c, d); ! Edge e4 = createEdge(d, a); ! LinkedList edges = new LinkedList(); ! edges.add(e1); ! edges.add(e2); ! edges.add(e3); ! edges.add(e4); ! Surface s = createSurface(edges); } /** * Invoked when a mouse button has been pressed on a component. --- 30,48 ---- public PencilTool(GLView glv) { super(glv); } /** ! * Called with the vertex that are clicked on - either: ! * - A vertex on the xy-plane ! * - A vertex in the model ! * - A vertex that lies on an edge from the model ! * - A vertex that lies on a surface from the model ! * @param vertex The vertex */ ! void onVertex(Vertex vertex) { ! System.out.println(vertex); } + /** * Invoked when a mouse button has been pressed on a component. *************** *** 94,106 **** View v = glv.getView(); Transformation transformation = v.transformation(); ! if (selectedVertex != null) { ! System.out.println(selectedVertex); } else { Plane xy = new Plane(0, 0, 1, 0); - Vertex near = new Vertex("near", x, y, 0.0); - Vertex far = new Vertex("far", x, y, 1.0); - Edge ray = new Edge("ray", near, far); - ray = transformation.unProject(ray); Vertex vertex = xy.intersection(ray); } } --- 55,82 ---- View v = glv.getView(); Transformation transformation = v.transformation(); ! Vertex near = new Vertex("near", x, y, 0.0); ! Vertex far = new Vertex("far", x, y, 1.0); ! Edge ray = new Edge("ray", near, far); ! ray = transformation.unProject(ray); ! ! if (target != null) { ! if (target instanceof Vertex) { ! onVertex((Vertex) target); ! } ! if (target instanceof Surface) { ! Surface surface = (Surface) target; ! Plane plane = surface.plane(); ! Vertex vertex = plane.intersection(ray); ! onVertex(vertex); ! } ! if (target instanceof Edge) { ! Edge edge = (Edge) target; ! Edge intersection = edge.intersection(ray); ! onVertex(intersection.getFrom()); ! } } else { Plane xy = new Plane(0, 0, 1, 0); Vertex vertex = xy.intersection(ray); + onVertex(vertex); } } |
From: Michael L. <he...@us...> - 2005-08-31 10:30:30
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5456/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Surface.java Log Message: Edge.intersection(Edge) implemented Plane.intersection(Edge) made public Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Surface.java 31 Aug 2005 08:33:17 -0000 1.15 --- Surface.java 31 Aug 2005 10:30:15 -0000 1.16 *************** *** 264,268 **** */ ! Plane plane() { double d = 0; Vertex n = normal(); --- 264,268 ---- */ ! public Plane plane() { double d = 0; Vertex n = normal(); Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Edge.java 31 Aug 2005 08:33:17 -0000 1.7 --- Edge.java 31 Aug 2005 10:30:15 -0000 1.8 *************** *** 176,179 **** --- 176,244 ---- return this.id.equals(e.getId()); } + + /** + * Find the intersection between this Edge and the Other. + * The intersection is considered to be the shortest Edge + * connecting this Edge and the other Edge. + * @param other The other edge to intersect with + * @return The shortes Edge connecting this Edge and the other + */ + public Edge intersection(Edge other) { + + Vertex p1 = this.getFrom(); + Vertex p2 = this.getTo(); + Vertex p3 = other.getFrom(); + Vertex p4 = other.getTo(); + + Vertex pa = new Vertex("pa"); + Vertex pb = new Vertex("pb"); + + Vertex p13 = new Vertex("p13"); + Vertex p43 = new Vertex("p43"); + Vertex p21 = new Vertex("p21"); + double d1343, d4321, d1321, d4343, d2121; + double numer, denom; + double mua, mub; + double eps = 0.0000000001; + p13.setX(p1.getX() - p3.getX()); + p13.setY(p1.getY() - p3.getY()); + p13.setZ(p1.getZ() - p3.getZ()); + p43.setX(p4.getX() - p3.getX()); + p43.setY(p4.getY() - p3.getY()); + p43.setZ(p4.getZ() - p3.getZ()); + if (Math.abs(p43.getX()) < eps && Math.abs(p43.getY()) < eps && Math.abs(p43.getZ()) < eps) { + return null; + } + p21.setX(p2.getX() - p1.getX()); + p21.setY(p2.getY() - p1.getY()); + p21.setZ(p2.getZ() - p1.getZ()); + if (Math.abs(p21.getX()) < eps && Math.abs(p21.getY()) < eps && Math.abs(p21.getZ()) < eps) { + return null; + } + + d1343 = p13.getX() * p43.getX() + p13.getY() * p43.getY() + p13.getZ() * p43.getZ(); + d4321 = p43.getX() * p21.getX() + p43.getY() * p21.getY() + p43.getZ() * p21.getZ(); + d1321 = p13.getX() * p21.getX() + p13.getY() * p21.getY() + p13.getZ() * p21.getZ(); + d4343 = p43.getX() * p43.getX() + p43.getY() * p43.getY() + p43.getZ() * p43.getZ(); + d2121 = p21.getX() * p21.getX() + p21.getY() * p21.getY() + p21.getZ() * p21.getZ(); + + denom = d2121 * d4343 - d4321 * d4321; + if (Math.abs(denom) < eps) { + return null; + } + numer = d1343 * d4321 - d1321 * d4343; + + mua = numer / denom; + mub = (d1343 + d4321 * (mua)) / d4343; + + pa.setX(p1.getX() + mua * p21.getX()); + pa.setY(p1.getY() + mua * p21.getY()); + pa.setZ(p1.getZ() + mua * p21.getZ()); + pb.setX(p3.getX() + mub * p43.getX()); + pb.setY(p3.getY() + mub * p43.getY()); + pb.setZ(p3.getZ() + mub * p43.getZ()); + + return new Edge("intersection", pa, pb); + } /** |
From: Michael L. <he...@us...> - 2005-08-31 08:34:03
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20077/src/net/sourceforge/bprocessor/gl/view Modified Files: View3D.java Log Message: Refractoring of ray-plane intersection code using new constructors for Vertex and Edge Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** View3D.java 31 Aug 2005 08:03:32 -0000 1.12 --- View3D.java 31 Aug 2005 08:33:55 -0000 1.13 *************** *** 167,188 **** double x = coords[0]; ! double y = coords[1]; Transformation transformation = transformation(); Plane xy = new Plane(0, 0, 1, 0); ! Vertex near = new Vertex("near"); ! near.setX(x); ! near.setY(AbstractView.getHeight() - y); ! near.setZ(0.0); ! Vertex far = new Vertex("far"); ! far.setX(x); ! far.setY(AbstractView.getHeight() - y); ! far.setZ(1.0); ! Edge ray = new Edge("ray"); ! ray.setFrom(near); ! ray.setTo(far); ray = transformation.unProject(ray); Vertex vertex = xy.intersection(ray); return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; } else { --- 167,181 ---- double x = coords[0]; ! double y = AbstractView.getHeight() - coords[1]; Transformation transformation = transformation(); Plane xy = new Plane(0, 0, 1, 0); ! Vertex near = new Vertex("near", x, y, 0.0); ! Vertex far = new Vertex("far", x, y, 1.0); ! Edge ray = new Edge("ray", near, far); ray = transformation.unProject(ray); Vertex vertex = xy.intersection(ray); + return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; } else { |
From: Michael L. <he...@us...> - 2005-08-31 08:34:03
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20077/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Refractoring of ray-plane intersection code using new constructors for Vertex and Edge Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PencilTool.java 31 Aug 2005 08:03:32 -0000 1.6 --- PencilTool.java 31 Aug 2005 08:33:55 -0000 1.7 *************** *** 90,95 **** protected void pressed(MouseEvent e) { super.pressed(e); ! int x = e.getX(); ! int y = e.getY(); View v = glv.getView(); Transformation transformation = v.transformation(); --- 90,95 ---- protected void pressed(MouseEvent e) { super.pressed(e); ! double x = e.getX(); ! double y = AbstractView.getHeight() - e.getY(); View v = glv.getView(); Transformation transformation = v.transformation(); *************** *** 98,112 **** } else { Plane xy = new Plane(0, 0, 1, 0); ! Vertex near = new Vertex("near"); ! near.setX(x); ! near.setY(AbstractView.getHeight() - y); ! near.setZ(0.0); ! Vertex far = new Vertex("far"); ! far.setX(x); ! far.setY(AbstractView.getHeight() - y); ! far.setZ(1.0); ! Edge ray = new Edge("ray"); ! ray.setFrom(near); ! ray.setTo(far); ray = transformation.unProject(ray); Vertex vertex = xy.intersection(ray); --- 98,104 ---- } else { Plane xy = new Plane(0, 0, 1, 0); ! Vertex near = new Vertex("near", x, y, 0.0); ! Vertex far = new Vertex("far", x, y, 1.0); ! Edge ray = new Edge("ray", near, far); ray = transformation.unProject(ray); Vertex vertex = xy.intersection(ray); |
From: Michael L. <he...@us...> - 2005-08-31 08:33:26
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19606/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Vertex.java Surface.java Log Message: More constructors for Vertex, Edge and Surface Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Surface.java 30 Aug 2005 13:14:01 -0000 1.14 --- Surface.java 31 Aug 2005 08:33:17 -0000 1.15 *************** *** 63,66 **** --- 63,76 ---- setInnerSurfaces(null); } + + /** + * Constructor + * @param name The name + * @param edges The edges + */ + public Surface(String name, List edges) { + this(name); + setEdges(edges); + } /** Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Edge.java 23 Aug 2005 12:11:03 -0000 1.6 --- Edge.java 31 Aug 2005 08:33:17 -0000 1.7 *************** *** 53,56 **** --- 53,68 ---- setTo(null); } + + /** + * Constructor + * @param name The name + * @param from The to vertex + * @param to The from vertex + */ + public Edge(String name, Vertex from, Vertex to) { + this(name); + setFrom(from); + setTo(to); + } /** Index: Vertex.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Vertex.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Vertex.java 30 Aug 2005 13:14:55 -0000 1.6 --- Vertex.java 31 Aug 2005 08:33:17 -0000 1.7 *************** *** 60,63 **** --- 60,78 ---- setW(0.0); } + + /** + * + * Constructor + * @param name The name + * @param x The x + * @param y The y + * @param z The z + */ + public Vertex(String name, double x, double y, double z) { + this(name); + setX(x); + setY(y); + setZ(z); + } /** |
From: Michael L. <he...@us...> - 2005-08-31 08:03:40
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv504/src/net/sourceforge/bprocessor/gl/view Modified Files: View3D.java Log Message: Minor refactoring of ray-plane intersection code Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** View3D.java 31 Aug 2005 07:02:51 -0000 1.11 --- View3D.java 31 Aug 2005 08:03:32 -0000 1.12 *************** *** 8,11 **** --- 8,12 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Vertex; *************** *** 171,186 **** Plane xy = new Plane(0, 0, 1, 0); ! Vertex origin = new Vertex("origin"); ! origin.setX(x); ! origin.setY(AbstractView.getHeight() - y); ! origin.setZ(0.0); ! origin = transformation.unProject(origin); ! Vertex direction = new Vertex("direction"); ! direction.setX(x); ! direction.setY(AbstractView.getHeight() - y); ! direction.setZ(1.0); ! direction = transformation.unProject(direction); ! direction = direction.minus(origin); ! Vertex vertex = xy.intersection(origin, direction); return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; } else { --- 172,188 ---- Plane xy = new Plane(0, 0, 1, 0); ! Vertex near = new Vertex("near"); ! near.setX(x); ! near.setY(AbstractView.getHeight() - y); ! near.setZ(0.0); ! Vertex far = new Vertex("far"); ! far.setX(x); ! far.setY(AbstractView.getHeight() - y); ! far.setZ(1.0); ! Edge ray = new Edge("ray"); ! ray.setFrom(near); ! ray.setTo(far); ! ray = transformation.unProject(ray); ! Vertex vertex = xy.intersection(ray); return new double[] {vertex.getX(), vertex.getY(), vertex.getZ()}; } else { |
From: Michael L. <he...@us...> - 2005-08-31 08:03:40
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv504/src/net/sourceforge/bprocessor/gl/tool Modified Files: PencilTool.java Log Message: Minor refactoring of ray-plane intersection code Index: PencilTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/PencilTool.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PencilTool.java 31 Aug 2005 07:02:52 -0000 1.5 --- PencilTool.java 31 Aug 2005 08:03:32 -0000 1.6 *************** *** 98,113 **** } else { Plane xy = new Plane(0, 0, 1, 0); ! Vertex origin = new Vertex("origin"); ! origin.setX(x); ! origin.setY(AbstractView.getHeight() - y); ! origin.setZ(0.0); ! origin = transformation.unProject(origin); ! Vertex direction = new Vertex("direction"); ! direction.setX(x); ! direction.setY(AbstractView.getHeight() - y); ! direction.setZ(1.0); ! direction = transformation.unProject(direction); ! direction = direction.minus(origin); ! Vertex vertex = xy.intersection(origin, direction); } } --- 98,114 ---- } else { Plane xy = new Plane(0, 0, 1, 0); ! Vertex near = new Vertex("near"); ! near.setX(x); ! near.setY(AbstractView.getHeight() - y); ! near.setZ(0.0); ! Vertex far = new Vertex("far"); ! far.setX(x); ! far.setY(AbstractView.getHeight() - y); ! far.setZ(1.0); ! Edge ray = new Edge("ray"); ! ray.setFrom(near); ! ray.setTo(far); ! ray = transformation.unProject(ray); ! Vertex vertex = xy.intersection(ray); } } |
From: Michael L. <he...@us...> - 2005-08-31 07:52:35
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28386/src/net/sourceforge/bprocessor/model Modified Files: Plane.java Log Message: Plane.intersection(Edge) implemented Index: Plane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Plane.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Plane.java 30 Aug 2005 13:11:32 -0000 1.3 --- Plane.java 31 Aug 2005 07:52:28 -0000 1.4 *************** *** 86,89 **** --- 86,101 ---- } } + + /** + * Find the intersection with the edge + * @param edge The edge to intersect + * @return The intersection point + */ + public Vertex intersection(Edge edge) { + Vertex p0 = edge.getFrom(); + Vertex p1 = edge.getTo(); + p1 = p1.minus(p0); + return intersection(p0, p1); + } } |