Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21885
Modified Files:
ExtrusionTool.java
Log Message:
better extrution in 3D
Index: ExtrusionTool.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ExtrusionTool.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ExtrusionTool.java 2 Sep 2005 13:35:32 -0000 1.5
--- ExtrusionTool.java 6 Sep 2005 13:32:11 -0000 1.6
***************
*** 9,12 ****
--- 9,13 ----
import net.sourceforge.bprocessor.gl.GLView;
import net.sourceforge.bprocessor.gl.view.View;
+ import net.sourceforge.bprocessor.gl.view.Transformation;
import net.sourceforge.bprocessor.kernel.notification.Notification;
***************
*** 20,23 ****
--- 21,25 ----
import net.sourceforge.bprocessor.model.FunctionalSpace;
import net.sourceforge.bprocessor.model.Space;
+ import net.sourceforge.bprocessor.model.Plane;
import java.awt.event.MouseEvent;
***************
*** 32,36 ****
* The extrusion tool
*/
! public class ExtrusionTool extends MoveTool {
/** The logger */
private static Logger log = Logger.getLogger(ExtrusionTool.class);
--- 34,38 ----
* The extrusion tool
*/
! public class ExtrusionTool extends SelectTool {
/** The logger */
private static Logger log = Logger.getLogger(ExtrusionTool.class);
***************
*** 42,45 ****
--- 44,50 ----
private static Surface selectedSurface = null;
+ /** the dragplane */
+ private Plane dragplane;
+
/**
* The Constructor
***************
*** 81,90 ****
}
} else {
double dX = pressPos[0] - e.getX();
double dY = pressPos[1] - e.getY();
double delta = (dX - dY) / 60;
Vertex normal = dragSurface.normal();
normal.scale(1 / normal.length());
! normal.scale(delta);
List l = Util.traverse(dragSurface);
//moving the dragged surface along its normal vector
--- 86,106 ----
}
} else {
+ /*
+ old style code.
double dX = pressPos[0] - e.getX();
double dY = pressPos[1] - e.getY();
double delta = (dX - dY) / 60;
+ */
Vertex normal = dragSurface.normal();
normal.scale(1 / normal.length());
! View view = glv.getView();
! double[] from = view.toPlaneCoords(new double[] {pressPos[0], pressPos[1]}, dragplane);
! double[] to = view.toPlaneCoords(new double[] {e.getX(), e.getY()}, dragplane);
! double[] delta = new double[] {to[0] - from[0], to[1] - from[1], to[2] - from[2]};
! double normDotDelta = ((normal.getX() * delta[0]) +
! (normal.getY() * delta[1]) +
! (normal.getZ() * delta[2]));
! normal.scale(normDotDelta / (normal.length() * normal.length()));
! //normal.scale(delta);
List l = Util.traverse(dragSurface);
//moving the dragged surface along its normal vector
***************
*** 158,163 ****
protected void pressed(MouseEvent e) {
super.pressed(e);
if (target instanceof Surface) {
! selectedSurface = (Surface)target;
} else {
selectedSurface = null;
--- 174,197 ----
protected void pressed(MouseEvent e) {
super.pressed(e);
+ pressPos[0] = e.getX();
+ pressPos[1] = e.getY();
if (target instanceof Surface) {
! selectedSurface = (Surface)target;
! View view = glv.getView();
! Transformation trans = view.transformation();
! int x = pressPos[0];
! int y = pressPos[1];
! Vertex near = new Vertex("near", 0.5, 0.5, 0.0);
! Vertex far = new Vertex("far", 0.5, 0.5, 1.0);
! Edge ray = new Edge("ray", near, far);
! ray = trans.unProject(ray);
! double[] norm = new double[] {(ray.getFrom().getX() - ray.getTo().getX()),
! (ray.getFrom().getY() - ray.getTo().getY()),
! (ray.getFrom().getZ() - ray.getTo().getZ())};
! double[] clickPoint = view.toPlaneCoords(new double[] {x, y}, selectedSurface.plane());
! dragplane = new Plane(norm[0], norm[1], norm[2],
! (-1 * (norm[0] * clickPoint[0] +
! norm[1] * clickPoint[1] +
! norm[2] * clickPoint[2])));
} else {
selectedSurface = null;
|