Author: paperwing
Date: 2012-03-05 15:08:38 -0800 (Mon, 05 Mar 2012)
New Revision: 28429

Added:
   
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
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/lighting/Light.java
Log:
Added javadoc and light state to light class; incorporated light object 
instances into GraphicsData via LightingData to be read by RenderingProcedures

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-03-05 20:59:14 UTC (rev 28428)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/GraphicsData.java
        2012-03-05 23:08:38 UTC (rev 28429)
@@ -90,6 +90,13 @@
         */
        private PickingData pickingData;
        
+       /**
+        * A {@link LightingData} object responsible for storing data related to
+        * lighting and lights, such as the states of lights and their color
+        * values.
+        */
+       private LightingData lightingData;
+       
        private GL2 glContext;
        
        private VisualLexicon visualLexicon;

Added: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
                                (rev 0)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
        2012-03-05 23:08:38 UTC (rev 28429)
@@ -0,0 +1,30 @@
+package org.cytoscape.paperwing.internal.data;
+
+import org.cytoscape.paperwing.internal.lighting.Light;
+
+/**
+ * This class is used to hold data relevant to lighting, such as the colors 
and states of lights.
+ */
+public class LightingData {
+       
+       /** The total number of lights. OpenGL specifies 8 as the minimum 
number of lights supported by hardware. */
+       private static int NUM_LIGHTS = 8;
+       
+       /** The array of lights present in the scene */
+       private Light[] lights;
+       
+       /** Obtain the light with the given index */
+       public Light getLight(int index) {
+               return lights[index];
+       }
+       
+       /**
+        * Create a default {@link LightingData} object with default lights, 
all turned off.
+        */
+       public LightingData() {
+               lights = new Light[NUM_LIGHTS];
+               for (int i = 0; i < NUM_LIGHTS; i++) {
+                       lights[i] = new Light();
+               }
+       }
+}


Property changes on: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/data/LightingData.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/lighting/Light.java
===================================================================
--- 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/lighting/Light.java
   2012-03-05 20:59:14 UTC (rev 28428)
+++ 
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/lighting/Light.java
   2012-03-05 23:08:38 UTC (rev 28429)
@@ -6,7 +6,13 @@
  * This class represents a light described by the Phong illumination model
  */
 public class Light {
+
+       /** Default value for a color */
+       private static float DEFAULT_COLOR_VALUE = 1.0f;
        
+       /** Default alpha value for light colors */
+       private static float DEFAULT_ALPHA_VALUE = 1.0f;
+       
        /** An array containing the color of the ambient component of the light 
in RGBA format */
        private float[] ambient;
        
@@ -19,6 +25,39 @@
        /** The position of the light in 3D space */
        private Vector3 position;
        
+       /** A boolean indicating whether the light is turned on. */
+       private boolean turnedOn;
+       
+       /**
+        * Creates a light with its position at the origin and white values for 
all colors
+        */
+       public Light() {
+               position = new Vector3();
+               turnedOn = false;
+               
+               ambient = new float[4]; 
+               diffuse = new float[4];
+               specular = new float[4];
+               
+               for (int i = 0; i < 3; i++) {
+                       ambient[i] = DEFAULT_COLOR_VALUE;
+                   diffuse[i] = DEFAULT_COLOR_VALUE;
+                       specular[i] = DEFAULT_COLOR_VALUE;
+               }
+               
+               ambient[3] = DEFAULT_ALPHA_VALUE;
+           diffuse[3] = DEFAULT_ALPHA_VALUE;
+               specular[3] = DEFAULT_ALPHA_VALUE;
+       }
+       
+       /**
+        * Creates a new light object with the specified ambient, diffuse, and 
specular components.
+        * 
+        * @param ambient An array containing the color and alpha of the 
ambient light component, in the form (r, g, b, a)
+        * @param diffuse An array containing the color and alpha of the 
diffuse light component, in the form (r, g, b, a)
+        * @param specular An array containing the color and alpha of the 
specular light component, in the form (r, g, b, a)
+        * @param position The position of the light
+        */
        public Light(float[] ambient, float[] diffuse, float[] specular, 
Vector3 position) {
                // Require 4 parameters for ambient, diffuse, and specular 
lighting
                if (ambient.length < 4) {
@@ -34,6 +73,7 @@
                }
                
                this.position = new Vector3(position);
+               turnedOn = false;
                
                this.ambient = new float[4]; 
                this.diffuse = new float[4];
@@ -136,4 +176,22 @@
        public void setPosition(Vector3 position) {
                this.position.set(position);
        }
+       
+       /**
+        * Check whether the light is considered to be turned on.
+        * 
+        * @return <code>true</code> if the light is considered to be on, 
<code>false</code> otherwise.
+        */
+       public boolean isTurnedOn() {
+               return turnedOn;
+       }
+       
+       /**
+        * Sets the on/off state associated with the light.
+        * 
+        * @param turnedOn Whether the light is considered as on or off.
+        */
+       public void setTurnedOn(boolean turnedOn) {
+               this.turnedOn = turnedOn;
+       }
 }

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