Author: paperwing
Date: 2012-02-29 11:51:04 -0800 (Wed, 29 Feb 2012)
New Revision: 28400

Modified:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngineFactory.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/ViewingVolume.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
Log:
Method for viewing volume calculation partially completed; added invert() 
method in Vector3 to invert a vector; about to add horizontal field of view 
calculations

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-02-29 19:18:40 UTC (rev 28399)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-02-29 19:51:04 UTC (rev 28400)
@@ -246,7 +246,7 @@
                gl.glLoadIdentity();
 
                GLU glu = new GLU();
-               glu.gluPerspective(graphicsData.getVerticalFov(), (float) width 
/ height, 0.2f, 50.0f);
+               glu.gluPerspective(graphicsData.getVerticalFov(), (float) width 
/ height, graphicsData.getNearZ(), graphicsData.getFarZ());
 
                gl.glMatrixMode(GL2.GL_MODELVIEW);
                gl.glLoadIdentity();

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngineFactory.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngineFactory.java
       2012-02-29 19:18:40 UTC (rev 28399)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/WindRenderingEngineFactory.java
       2012-02-29 19:51:04 UTC (rev 28400)
@@ -42,8 +42,6 @@
                this.visualLexicon = lexicon;
                
                this.serviceRegistrar = serviceRegistrar;
-               
-               Graphics.initSingleton();
        }
        
        @Override

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
        2012-02-29 19:18:40 UTC (rev 28399)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
        2012-02-29 19:51:04 UTC (rev 28400)
@@ -37,6 +37,12 @@
 
        private float verticalFov = 45.0f;
        
+       /** Distance from eye to the near clipping plane */
+       private float nearZ = 0.2f;
+       
+       /** Distance from eye to the far clipping plane */
+       private float farZ = 50f;
+       
        /** The camera to use for transformation of 3D scene */
        private SimpleCamera camera;
        
@@ -204,7 +210,23 @@
        public void setVerticalFov(float verticalFov) {
                this.verticalFov = verticalFov;
        }
+       
+       public float getNearZ() {
+               return nearZ;
+       }
 
+       public void setNearZ(float nearZ) {
+               this.nearZ = nearZ;
+       }
+
+       public float getFarZ() {
+               return farZ;
+       }
+
+       public void setFarZ(float farZ) {
+               this.farZ = farZ;
+       }
+
        public PickingData getPickingData() {
                return pickingData;
        }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
        2012-02-29 19:18:40 UTC (rev 28399)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/Vector3.java
        2012-02-29 19:51:04 UTC (rev 28400)
@@ -275,6 +275,14 @@
                return (x * x + y * y + z * z);
        }
        
+       /** Inverts this vector so that the result points in the opposite 
direction.
+        * 
+        * @return A vector representing the invert of this vector.
+        */
+       public Vector3 invert() {
+               return multiply(-1);
+       }
+       
        /** Set this vector to be equal to itself divided by its magnitude
         */
        public void normalizeLocal() {

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/ViewingVolume.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/ViewingVolume.java
  2012-02-29 19:18:40 UTC (rev 28399)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/geometric/ViewingVolume.java
  2012-02-29 19:51:04 UTC (rev 28400)
@@ -6,10 +6,22 @@
 public class ViewingVolume {
        
        /**
-        * A class representing a plane, stored using its parameters A, B, C, D 
in the equation Ax + By + Cz + D = 0.
+        * A class representing a plane, stored in the format Ax + By + Cz + D 
= 0.
+        * The parameters A, B, C are represented by the normal vector.
         */
        private class Plane {
-               public double a, b, c, d = 0;
+               Vector3 normal = new Vector3(0, 0, 0);
+               double parameterD = 0;
+               
+               /**
+                * Sets the plane's normal and D parameter to the given values
+                * @param normal The plane's new normal
+                * @param parameterD The plane's new D parameter in the 
equation Ax + By + Cz + D = 0
+                */
+               public void set(Vector3 normal, double parameterD) {
+                       this.normal.set(normal);
+                       this.parameterD = parameterD;
+               }
        }
        
        // The 6 planes that bound the viewing volume. The normals of the plane 
face outward.
@@ -48,7 +60,7 @@
                // Determine which side the point lies on using the distance 
formula
                // For information see 
http://www.lighthouse3d.com/tutorials/maths/plane/
                
-               double signedDistance = point.x() * plane.a + point.y() * 
plane.b + point.z() * plane.c + plane.d;
+               double signedDistance = plane.normal.dot(point) + 
plane.parameterD;
                
                if (signedDistance > 0) {
                        return false;
@@ -60,11 +72,41 @@
        /**
         * Calculate the boundaries of the viewing volume given the camera 
orientation, the distance to the near and far clipping planes,
         * and the vertical and horizontal fields of view.
+        * 
+        * @param cameraPosition The position of the camera or eye
+        * @param cameraDirection The camera's direction vector
+        * @param cameraUp The camera's up vector
+        * @param zNear The distance between the camera and the near clipping 
plane
+        * @param zFar The distance between the camera and the far clipping 
plane
+        * @param verticalFieldOfView The vertical field of view, in degrees
+        * @param horizontalFieldOfView The horizontal field of view, in degrees
         */
        public void calculateViewingVolume(Vector3 cameraPosition, Vector3 
cameraDirection, Vector3 cameraUp, 
                        double zNear, double zFar, double verticalFieldOfView, 
double horizontalFieldOfView) {
                
+               // Calculate the camera's left vector
+               Vector3 cameraLeft = cameraUp.cross(cameraDirection);
                
+               // Calculate near z plane
+               Vector3 nearNormal = cameraDirection.invert();
+               nearNormal.normalize();
+               
+               double nearParameterD = 
-nearNormal.dot(cameraPosition.plus(cameraDirection.multiply(zNear)));
+               near.set(nearNormal, nearParameterD);
+               
+               // Calculate far z plane
+               Vector3 farNormal = nearNormal.invert();
+               
+               double farParameterD = 
-farNormal.dot(cameraPosition.plus(cameraDirection.multiply(zFar)));
+               far.set(farNormal, farParameterD);
+               
+               // Calculate left plane
+               
+               // Rotate 90 degrees past the left plane to obtain the normal
+               Vector3 leftNormal = cameraDirection.rotate(cameraUp, 
Math.toRadians(horizontalFieldOfView / 2 + 90));
+               
+               // Find a point on the plane to find the D parameter
+               
        }
 
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
    2012-02-29 19:18:40 UTC (rev 28399)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/GeometryToolkit.java
    2012-02-29 19:51:04 UTC (rev 28400)
@@ -31,7 +31,7 @@
                // Project mouse coordinates into 3d space for mouse 
interactions
                // 
--------------------------------------------------------------
                
-               // Hnear = 2 * tan(fov / 2) * nearDist
+               // Hnear = 2 * tan(fovy / 2) * nearDist
                // in our case: 
                //   fov = 45 deg
                //   nearDist = 0.2
@@ -194,4 +194,9 @@
                
                return Math.abs(Math.cos(angle) * hypotenuse);
        }
+       
+       /*
+       public static double findHorizontalFieldOfView(double 
verticalFieldOfView, int screenWidth, int screenHeight) { 
+       }
+       */
 }

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to