Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2528/src/net/sourceforge/bprocessor/gl/view
Modified Files:
View.java
Log Message:
Accurately computes to the placement of the tip of a vector for hit-detection to be able to rotate a vector by moving the tip
Index: View.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v
retrieving revision 1.113
retrieving revision 1.114
diff -C2 -d -r1.113 -r1.114
*** View.java 18 Jul 2006 14:04:41 -0000 1.113
--- View.java 18 Jul 2006 21:50:49 -0000 1.114
***************
*** 943,956 ****
Collection cons = active.getConstructors();
Iterator iter = cons.iterator();
! Camera current = Project.getInstance().getCurrentCamera();
! Vertex v = new Vertex(current.getCamera());
! double scale = scale = current.getFocalwidth() / 65;
! double dist = v.minus(new Vertex(current.getCenter())).length() * scale;
while (iter.hasNext()) {
Object o = iter.next();
Constructor c = (Constructor)o;
! if (current.getType() == Camera.PERSPECTIVE) {
dist = (c.getOrigin().minus(v)).length() * scale;
}
if (o instanceof Point) {
drawConstructorPoint(((Point)o).getOrigin(), dist);
--- 943,961 ----
Collection cons = active.getConstructors();
Iterator iter = cons.iterator();
!
!
! Camera camera = Project.getInstance().getCurrentCamera();
! Vertex v = new Vertex(camera.getCamera());
! double scale = (camera.getFocalwidth() / 65) * (500 / height);
! double dist = v.minus(new Vertex(camera.getCenter())).length() * scale;
!
while (iter.hasNext()) {
Object o = iter.next();
Constructor c = (Constructor)o;
!
! if (camera.getType() == Camera.PERSPECTIVE) {
dist = (c.getOrigin().minus(v)).length() * scale;
}
+
if (o instanceof Point) {
drawConstructorPoint(((Point)o).getOrigin(), dist);
***************
*** 1003,1009 ****
private void drawConstructorVector(Vertex from, Vertex direction, double dist) {
gl.glLineWidth(2);
- double scale = 500 / height;
Vertex d = direction.copy();
! d.scale(scale * dist / 16);
Vertex to = from.add(d);
gl.glBegin(GL.GL_LINES);
--- 1008,1013 ----
private void drawConstructorVector(Vertex from, Vertex direction, double dist) {
gl.glLineWidth(2);
Vertex d = direction.copy();
! d.scale(dist / 16);
Vertex to = from.add(d);
gl.glBegin(GL.GL_LINES);
***************
*** 1020,1024 ****
gl.glRotated(-Math.toDegrees(Geometry.degreesAboutY(d)), 0, 1, 0);
gl.glRotated(90, 0, 1, 0);
! glu.gluCylinder(quad, (dist / 90) * scale, 0, (dist / 20) * scale, 10, 10);
gl.glPopMatrix();
gl.glDisable(GL.GL_LIGHTING);
--- 1024,1028 ----
gl.glRotated(-Math.toDegrees(Geometry.degreesAboutY(d)), 0, 1, 0);
gl.glRotated(90, 0, 1, 0);
! glu.gluCylinder(quad, (dist / 90), 0, (dist / 20), 10, 10);
gl.glPopMatrix();
gl.glDisable(GL.GL_LIGHTING);
***************
*** 1591,1594 ****
--- 1595,1604 ----
if (selectMode == CONSTRUCTORS || selectMode == ALL) {
{
+ Camera camera = Project.getInstance().getCurrentCamera();
+ Vertex v = new Vertex(camera.getCamera());
+ double scale = (camera.getFocalwidth() / 65) * (500 / height);
+ double dist = v.minus(new Vertex(camera.getCenter())).length() * scale;
+
+
Iterator iter = space.getConstructors().iterator();
while (iter.hasNext()) {
***************
*** 1599,1603 ****
if (current instanceof Line) {
Line line = (Line) current;
! Vertex tip = line.tip();
pushName(gl, tip);
drawVertexHit(tip);
--- 1609,1616 ----
if (current instanceof Line) {
Line line = (Line) current;
! if (camera.getType() == Camera.PERSPECTIVE) {
! dist = (line.getOrigin().minus(v)).length() * scale;
! }
! Vertex tip = line.tip(dist / 16 + dist / 20);
pushName(gl, tip);
drawVertexHit(tip);
|