Author: paperwing
Date: 2012-01-18 11:43:41 -0800 (Wed, 18 Jan 2012)
New Revision: 28040

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/rendering/RenderArcEdgesProcedure.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ScalableShapeDrawer.java
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderToolkit.java
Log:
Modified several drawing algorithms to call OpenGL with floats as most GPU's 
don't have native support for doubles, initial implementation of cube drawing 
using connected triangle strips

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-01-18 15:31:39 UTC (rev 28039)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/Graphics.java
 2012-01-18 19:43:41 UTC (rev 28040)
@@ -230,6 +230,8 @@
                gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_SPECULAR,
                                FloatBuffer.wrap(specularReflection));
                gl.glMateriali(GL2.GL_FRONT, GL2.GL_SHININESS, 31);
+               
+               gl.glLightModeli(GL2.GL_LIGHT_MODEL_TWO_SIDE, 0);
        }
 
        @Override

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
        2012-01-18 15:31:39 UTC (rev 28039)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderArcEdgesProcedure.java
        2012-01-18 19:43:41 UTC (rev 28040)
@@ -206,17 +206,17 @@
                                        
                                        edgeRadialAngle = (double) 
(container.edgeNumber - Math.pow(edgeLevel, 2)) / edgesInLevel * Math.PI * 2;
                                        
-                                       if (graphicsData.getFramesElapsed() == 
500) {
-                                               System.out.println("edgeNumber: 
" + container.edgeNumber);
-                                               
System.out.println("totalCoincidentEdges: " + container.totalCoincidentEdges);
-                                               System.out.println("edgeLevel: 
" + edgeLevel);
-                                               System.out.println("maxLevel: " 
+ maxLevel);
-                                               
System.out.println("edgesInLevel: " + edgesInLevel);
-                                               
System.out.println("curvedEdgeRadius: " + curvedEdgeRadius);
-                                               
System.out.println("edgeRadialAngle: " + edgeRadialAngle);
-                                               
System.out.println("==================================");
-                                       }
-                                       
+//                                     if (graphicsData.getFramesElapsed() == 
500) {
+//                                             System.out.println("edgeNumber: 
" + container.edgeNumber);
+//                                             
System.out.println("totalCoincidentEdges: " + container.totalCoincidentEdges);
+//                                             System.out.println("edgeLevel: 
" + edgeLevel);
+//                                             System.out.println("maxLevel: " 
+ maxLevel);
+//                                             
System.out.println("edgesInLevel: " + edgesInLevel);
+//                                             
System.out.println("curvedEdgeRadius: " + curvedEdgeRadius);
+//                                             
System.out.println("edgeRadialAngle: " + edgeRadialAngle);
+//                                             
System.out.println("==================================");
+//                                     }
+
                                        drawArcSegments(gl, start, end, 
curvedEdgeRadius, edgeRadialAngle, NUM_SEGMENTS);
                                }
                        }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
   2012-01-18 15:31:39 UTC (rev 28039)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderNodesProcedure.java
   2012-01-18 19:43:41 UTC (rev 28040)
@@ -11,6 +11,8 @@
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNode;
 import org.cytoscape.paperwing.internal.data.GraphicsData;
+import org.cytoscape.paperwing.internal.rendering.shapes.ScalableShapeDrawer;
+import 
org.cytoscape.paperwing.internal.rendering.shapes.ScalableShapeDrawer.ShapeType;
 import org.cytoscape.paperwing.internal.tools.NetworkToolkit;
 import org.cytoscape.paperwing.internal.tools.RenderColor;
 import org.cytoscape.view.model.CyNetworkView;
@@ -41,6 +43,12 @@
 
        private int nodeListIndex;
 
+       private ScalableShapeDrawer shapeDrawer;
+       
+       public RenderNodesProcedure() {
+               shapeDrawer = new ScalableShapeDrawer();
+       }
+       
        @Override
        public void initialize(GraphicsData graphicsData) {
                GL2 gl = graphicsData.getGlContext();
@@ -62,6 +70,8 @@
                // glut.glutSolidSphere(SMALL_SPHERE_RADIUS, NODE_SLICES_DETAIL,
                // NODE_STACKS_DETAIL);
                gl.glEndList();
+               
+               shapeDrawer.initialize(gl);
 
        }
 
@@ -113,8 +123,11 @@
                                gl.glLoadName(index);
                                
                                chooseColor(gl, nodeView, graphicsData);
-                               gl.glCallList(nodeListIndex);
+                               //gl.glCallList(nodeListIndex);
                                
+                               gl.glScalef(SMALL_SPHERE_RADIUS, 
SMALL_SPHERE_RADIUS, SMALL_SPHERE_RADIUS);
+                               shapeDrawer.drawShape(gl, 
ShapeType.SHAPE_CUBIC);
+                               
                                gl.glPopMatrix();
                        }
                }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
    2012-01-18 15:31:39 UTC (rev 28039)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/ResetSceneProcedure.java
    2012-01-18 19:43:41 UTC (rev 28040)
@@ -30,8 +30,9 @@
                Vector3 target = camera.getTarget();
                Vector3 up = camera.getUp();
 
-               glu.gluLookAt(position.x(), position.y(), position.z(), 
target.x(),
-                               target.y(), target.z(), up.x(), up.y(), up.z());
+               glu.gluLookAt((float) position.x(), (float) position.y(), 
(float) position.z(), 
+                               (float) target.x(), (float) target.y(), (float) 
target.z(), 
+                               (float) up.x(), (float) up.y(), (float) up.z());
        }
 
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ScalableShapeDrawer.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ScalableShapeDrawer.java
     2012-01-18 15:31:39 UTC (rev 28039)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/shapes/ScalableShapeDrawer.java
     2012-01-18 19:43:41 UTC (rev 28040)
@@ -41,11 +41,12 @@
                GLUquadric quadric = glu.gluNewQuadric();
                glu.gluQuadricDrawStyle(quadric, GLU.GLU_FILL);
                glu.gluQuadricNormals(quadric, GLU.GLU_SMOOTH);
-
+               
                gl.glNewList(shapeListIndex, GL2.GL_COMPILE);
                glu.gluSphere(quadric, 0.5, SPHERE_SLICES_DETAIL, 
SPHERE_STACKS_DETAIL); 
                gl.glEndList();
                
+               
                shapeLists.put(ShapeType.SHAPE_SPHERICAL, shapeListIndex);
        }
        
@@ -53,18 +54,68 @@
        private void initializeCube(GL2 gl) {
                int shapeListIndex = gl.glGenLists(1);
 
-               double cornerCoordinate = 0.5 / Math.sqrt(2);
+               float halfLength = (float) (1.0 / Math.sqrt(2) / 2);
                
                gl.glNewList(shapeListIndex, GL2.GL_COMPILE);
                gl.glBegin(GL2.GL_TRIANGLE_STRIP);
                
+               // +y face
+               gl.glNormal3f(0, 1, 0);
+               gl.glVertex3f(-halfLength, halfLength, -halfLength); // -x, -z
+               gl.glVertex3f(halfLength, halfLength, -halfLength); // +x, -z
+               gl.glVertex3f(-halfLength, halfLength, halfLength); // -x, +z
+               gl.glVertex3f(halfLength, halfLength, halfLength); // +x, +z
+               
+               // +z face
+               gl.glNormal3f(0, 0, 1);
+               gl.glVertex3f(halfLength, -halfLength, halfLength);
+               
+               // +x face
+               gl.glNormal3f(1, 0, 0);
+               gl.glVertex3f(halfLength, halfLength, -halfLength);
+               gl.glVertex3f(halfLength, -halfLength, -halfLength);
+               
+               // -z face
+               gl.glNormal3f(0, 0, -1);
+               gl.glVertex3f(-halfLength, halfLength, -halfLength);
+               gl.glVertex3f(-halfLength, -halfLength, -halfLength);
+               
+               // -x face
+               gl.glNormal3f(-1, 0, 0);
+               gl.glVertex3f(-halfLength, halfLength, halfLength);
+               gl.glVertex3f(-halfLength, -halfLength, halfLength);
+               
+               // +z face
+               gl.glNormal3f(0, 0, 1);
+               gl.glVertex3f(halfLength, -halfLength, halfLength);
+               
+               // -y face
+               gl.glNormal3f(0, -1, 0);
+               gl.glVertex3f(-halfLength, -halfLength, -halfLength);
+               gl.glVertex3f(halfLength, -halfLength, -halfLength);
+               
+//             // -y face
+//             gl.glNormal3f(0, -1, 0);
+//             gl.glVertex3f(halfLength, -halfLength, -halfLength);
+//             gl.glVertex3f(-halfLength, -halfLength, -halfLength);
+               
+               
+               
+               // gl.glVertex3f(-cornerCoordinate, -cornerCoordinate, 
cornerCoordinate);
+               // gl.glNorm
+               
                gl.glEnd();
+               
                gl.glEndList();
                
                shapeLists.put(ShapeType.SHAPE_CUBIC, shapeListIndex);
        }
        
-       public void drawShape(ShapeType shapeType) {
+       public void drawShape(GL2 gl, ShapeType shapeType) {
+               Integer listIndex = shapeLists.get(shapeType);
                
+               if (listIndex != null) {
+                       gl.glCallList(listIndex);
+               }
        }
 }

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderToolkit.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderToolkit.java
      2012-01-18 15:31:39 UTC (rev 28039)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/tools/RenderToolkit.java
      2012-01-18 19:43:41 UTC (rev 28040)
@@ -17,13 +17,15 @@
         *                      
         */
        public static void setUpFacingTransformation(GL2 gl, Vector3 location, 
Vector3 direction) {
-               gl.glTranslated(location.x(), location.y(), location.z());
+               gl.glTranslatef((float) location.x(), (float) location.y(), 
(float) location.z());
                
                Vector3 current = new Vector3(0, 0, 1);
                Vector3 rotateAxis = current.cross(direction);
                
-               gl.glRotated(Math.toDegrees(direction.angle(current)), 
rotateAxis.x(), rotateAxis.y(),
-                               rotateAxis.z());
+               gl.glRotatef((float) Math.toDegrees(direction.angle(current)), 
+                               (float) rotateAxis.x(),
+                               (float) rotateAxis.y(),
+                               (float) rotateAxis.z());
        }
 
 }

-- 
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