[Opengeoscience-developers] OpenGeoscience branch, enhance_map_api, updated. 2a9f3465e2f164b9e7cb848947d40e45fcd11a2b

Aashish Chaudhary aashish.chaudhary at kitware.com
Fri Mar 1 10:51:57 EST 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenGeoscience".

The branch, enhance_map_api has been updated
       via  2a9f3465e2f164b9e7cb848947d40e45fcd11a2b (commit)
       via  1bc586ea2e6eb2e090671c0d5f2e4e00f807c7e5 (commit)
      from  c6e36c118843dd9f45c34564e664118585fc90d8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=2a9f3465e2f164b9e7cb848947d40e45fcd11a2b
commit 2a9f3465e2f164b9e7cb848947d40e45fcd11a2b
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Fri Mar 1 10:51:18 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Fri Mar 1 10:51:18 2013 -0500

    Various fixes to the get the layer api working

diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index f64bd56..05d8b4a 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -266,11 +266,10 @@ geoModule.map = function(node, options) {
   // TODO use zoom and center options
 
   var m_baseLayer = (function() {
-    var mapActor = ogs.vgl.utils.createPlane(
+    var mapActor = ogs.vgl.utils.createTexturePlane(
                       -180.0, -90.0, 0.0,
                        180.0, -90.0, 0.0,
-                      -180.0, 90.0, 0.0
-                    );
+                      -180.0, 90.0, 0.0);
 
     // Setup texture
     worldImage = new Image();
diff --git a/web/lib/vgl/geomData.js b/web/lib/vgl/geomData.js
index d8aab78..39bb380 100644
--- a/web/lib/vgl/geomData.js
+++ b/web/lib/vgl/geomData.js
@@ -497,10 +497,7 @@ inherit(vglModule.sourceDataP3fv, vglModule.sourceData);
 //////////////////////////////////////////////////////////////////////////////
 
 vglModule.sourceDataT2fv = function() {
-  /**
-   * Check
-   *
-   */
+
   if (!(this instanceof vglModule.sourceDataT2fv)) {
     return new vglModule.sourceDataT2fv();
   }
@@ -511,10 +508,6 @@ vglModule.sourceDataT2fv = function() {
                     gl.FLOAT, 4,  0, 2 * 4, 2, false);
 
 
-  /**
-   *
-   *
-   */
   this.pushBack = function(value) {
     this.insert(value);
   };
@@ -526,6 +519,32 @@ inherit(vglModule.sourceDataT2fv, vglModule.sourceData);
 
 //////////////////////////////////////////////////////////////////////////////
 //
+// sourceDataC3fv
+//
+//////////////////////////////////////////////////////////////////////////////
+
+vglModule.sourceDataC3fv = function() {
+
+  if (!(this instanceof vglModule.sourceDataC3fv)) {
+    return new vglModule.sourceDataC3fv();
+  }
+
+  vglModule.sourceData.call(this);
+
+  this.addAttribute(vertexAttributeKeys.Color,
+                    gl.FLOAT, 4,  0, 3 * 4, 3, false);
+
+  this.pushBack = function(value) {
+    this.insert(value);
+  };
+
+  return this;
+};
+
+inherit(vglModule.sourceDataC3fv, vglModule.sourceData);
+
+//////////////////////////////////////////////////////////////////////////////
+//
 // geometryData
 //
 //////////////////////////////////////////////////////////////////////////////
diff --git a/web/lib/vgl/planeSource.js b/web/lib/vgl/planeSource.js
index ce9f051..f04d4ef 100644
--- a/web/lib/vgl/planeSource.js
+++ b/web/lib/vgl/planeSource.js
@@ -78,10 +78,11 @@ vglModule.planeSource = function() {
     var i, j, k, ii;
     var numPts;
     var numPolys;
-    var posIndex = 0, normIndex = 0, texCoordIndex = 0;
+    var posIndex = 0, normIndex = 0, colorIndex = 0, texCoordIndex = 0;
 
     var positions = [];
     var normals = [];
+    var colors = [];
     var texCoords = [];
     var indices = [];
 
@@ -115,6 +116,10 @@ vglModule.planeSource = function() {
         positions[posIndex++] = x[1];
         positions[posIndex++] = x[2];
 
+        colors[colorIndex++] = 1.0;
+        colors[colorIndex++] = 1.0;
+        colors[colorIndex++] = 1.0;
+
         normals[normIndex++] = m_normal[0];
         normals[normIndex++] = m_normal[1];
         normals[normIndex++] = m_normal[2];
@@ -144,10 +149,14 @@ vglModule.planeSource = function() {
     var sourcePositions = vglModule.sourceDataP3fv();
     sourcePositions.pushBack(positions);
 
+    var sourceColors = vglModule.sourceDataC3fv();
+    sourceColors.pushBack(colors);
+
     var sourceTexCoords = vglModule.sourceDataT2fv();
     sourceTexCoords.pushBack(texCoords);
 
     m_geom.addSource(sourcePositions);
+    m_geom.addSource(sourceColors);
     m_geom.addSource(sourceTexCoords);
     m_geom.addPrimitive(tristrip);
 
diff --git a/web/lib/vgl/shaderProgram.js b/web/lib/vgl/shaderProgram.js
index 5aecf94..e6f5a05 100644
--- a/web/lib/vgl/shaderProgram.js
+++ b/web/lib/vgl/shaderProgram.js
@@ -214,6 +214,9 @@ vglModule.shaderProgram.prototype.bindUniforms = function() {
   for (var i = 0; i < this.m_uniforms.length; ++i) {
     this.m_uniformNameToLocation[this.m_uniforms[i].name()] =
       this.queryUniformLocation(this.m_uniforms[i].name());
+
+    console.log(this.m_uniforms[i].name());
+    console.log(this.queryUniformLocation(this.m_uniforms[i].name()));
   }
 };
 ///---------------------------------------------------------------------------
@@ -224,4 +227,4 @@ vglModule.shaderProgram.prototype.bindAttributes = function() {
     gl.bindAttribLocation(this.m_programHandle, index, name);
     this.m_vertexAttributeNameToLocation[name] = index++;
   }
-};
\ No newline at end of file
+};
diff --git a/web/lib/vgl/uniform.js b/web/lib/vgl/uniform.js
index b304466..eb737d9 100644
--- a/web/lib/vgl/uniform.js
+++ b/web/lib/vgl/uniform.js
@@ -62,21 +62,18 @@ vglModule.uniform = function(type, name) {
   this.m_numberOfElements = 1;
 };
 
-///---------------------------------------------------------------------------
 vglModule.uniform.prototype.name = function() {
   return this.m_name;
 };
 
-///---------------------------------------------------------------------------
 vglModule.uniform.prototype.type = function() {
   return this.m_type;
 };
 
-///---------------------------------------------------------------------------
 vglModule.uniform.prototype.get = function() {
   // TODO
 };
-///---------------------------------------------------------------------------
+
 vglModule.uniform.prototype.set = function(value) {
   var i = 0;
   if (value instanceof mat4.constructor) {
@@ -109,7 +106,6 @@ vglModule.uniform.prototype.set = function(value) {
   }
 };
 
-///---------------------------------------------------------------------------
 vglModule.uniform.prototype.callGL = function(location) {
   if (this.m_numberElements < 1)
     return;
@@ -142,18 +138,16 @@ vglModule.uniform.prototype.callGL = function(location) {
   }
 };
 
-///---------------------------------------------------------------------------
 vglModule.uniform.prototype.update = function(renderState, program) {
   // Should be implemented by the derived class
 };
 
 //////////////////////////////////////////////////////////////////////////////
 //
-// vglModelViewUniform class
+// modelViewUniform class
 //
 //////////////////////////////////////////////////////////////////////////////
 
-///---------------------------------------------------------------------------
 vglModule.modelViewUniform = function(name) {
 
   if (name.length === 0) {
@@ -166,14 +160,13 @@ vglModule.modelViewUniform = function(name) {
 
 inherit(vglModule.modelViewUniform, vglModule.uniform);
 
-///---------------------------------------------------------------------------
 vglModule.modelViewUniform.prototype.update = function(renderState, program) {
   this.set(renderState.m_modelViewMatrix);
 };
 
 //////////////////////////////////////////////////////////////////////////////
 //
-// vesProjectionUniform class
+// projectionUniform class
 //
 //////////////////////////////////////////////////////////////////////////////
 
@@ -188,7 +181,23 @@ vglModule.projectionUniform  = function(name) {
 
 inherit(vglModule.projectionUniform, vglModule.uniform);
 
-///---------------------------------------------------------------------------
 vglModule.projectionUniform.prototype.update = function(renderState, program) {
   this.set(renderState.m_projectionMatrix);
-};
\ No newline at end of file
+};
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  floatUniform class
+//
+//////////////////////////////////////////////////////////////////////////////
+
+vglModule.floatUniform  = function(name) {
+  if (name.length === 0) {
+    name = "floatUniform";
+  }
+
+  vglModule.uniform.call(this, gl.FLOAT, name);
+  this.set(1.0);
+};
+
+inherit(vglModule.floatUniform, vglModule.uniform);
diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index ffd51a0..ac0aac3 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -17,6 +17,11 @@
  ========================================================================*/
 
 ///////////////////////////////////////////////////////////////////////////////
+//
+// utils class
+//
+///////////////////////////////////////////////////////////////////////////////
+
 /**
  * Utility class provides helper functions to create geometry objects
  *
@@ -33,19 +38,39 @@ vglModule.utils = function() {
 
 inherit(vglModule.utils, vglModule.object);
 
-///////////////////////////////////////////////////////////////////////////////
+/**
+ * Helper function to create default fragment shader with sampler
+ *
+ * @param context
+ * @returns {vglModule.shader}
+ */
+vglModule.utils.createTextureFragmentShader = function(context) {
+ var fragmentShaderSource = [
+   'varying highp vec3 iTextureCoord;',
+   'uniform sampler2D sampler2d;',
+   'uniform mediump float opacity;',
+   'void main(void) {',
+     'gl_FragColor = vec4(texture2D(sampler2d, vec2(iTextureCoord.s, iTextureCoord.t)).xyz, opacity);',
+   '}'
+  ].join('\n');
+
+ var shader = new vglModule.shader(gl.FRAGMENT_SHADER);
+ shader.setShaderSource(fragmentShaderSource);
+ return shader;
+};
+
 /**
  * Helper function to create default fragment shader
  *
  * @param context
  * @returns {vglModule.shader}
  */
-vglModule.utils.createDefaultFragmentShader = function(context) {
+vglModule.utils.createFragmentShader = function(context) {
  var fragmentShaderSource = [
-   'varying highp vec3 vTextureCoord;',
-   'uniform sampler2D uSampler;',
+   'varying mediump vec3 iVertexColor;',
+   'uniform mediump float opacity;',
    'void main(void) {',
-     'gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));',
+     'gl_FragColor = vec4(iVertexColor, opacity);',
    '}'
   ].join('\n');
 
@@ -54,24 +79,51 @@ vglModule.utils.createDefaultFragmentShader = function(context) {
  return shader;
 };
 
-///////////////////////////////////////////////////////////////////////////////
+/**
+ * Helper function to create default vertex shader (
+ *
+ * @param context
+ * @returns {vglModule.shader}
+ */
+vglModule.utils.createTextureVertexShader = function(context) {
+ var vertexShaderSource = [
+   'attribute vec3 vertexPosition;',
+   'attribute vec3 textureCoord;',
+   'uniform mat4 modelViewMatrix;',
+   'uniform mat4 projectionMatrix;',
+   'varying highp vec3 iTextureCoord;',
+   'void main(void)',
+   '{',
+   'gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);',
+   ' iTextureCoord = textureCoord;',
+   '}'
+ ].join('\n');
+
+ var shader = new vglModule.shader(gl.VERTEX_SHADER);
+ shader.setShaderSource(vertexShaderSource);
+ return shader;
+};
+
 /**
  * Helper function to create default vertex shader
  *
  * @param context
  * @returns {vglModule.shader}
  */
-vglModule.utils.createDefaultVertexShader = function(context) {
+vglModule.utils.createVertexShader = function(context) {
  var vertexShaderSource = [
-   'attribute vec3 aVertexPosition;',
-   'attribute vec3 aTextureCoord;',
+   'attribute vec3 vertexPosition;',
+   'attribute vec3 textureCoord;',
+   'attribute vec3 vertexColor;',
    'uniform mat4 modelViewMatrix;',
    'uniform mat4 projectionMatrix;',
-   'varying highp vec3 vTextureCoord;',
+   'varying mediump vec3 iVertexColor;',
+   'varying highp vec3 iTextureCoord;',
    'void main(void)',
    '{',
-   'gl_Position = projectionMatrix * modelViewMatrix * vec4(aVertexPosition, 1.0);',
-   ' vTextureCoord = aTextureCoord;',
+   'gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);',
+   ' iTextureCoord = textureCoord;',
+   ' iVertexColor = vertexColor;',
    '}'
  ].join('\n');
 
@@ -80,7 +132,6 @@ vglModule.utils.createDefaultVertexShader = function(context) {
  return shader;
 };
 
-///////////////////////////////////////////////////////////////////////////////
 /**
  * Helper function to create a plane node
  *
@@ -102,19 +153,74 @@ vglModule.utils.createPlane = function(originX, originY, originZ,
 
   var mat = new vglModule.material();
   var prog = new vglModule.shaderProgram();
-  var vertexShader = vglModule.utils.createDefaultVertexShader(gl);
-  var fragmentShader = vglModule.utils.createDefaultFragmentShader(gl);
-  var posVertAttr = new vglModule.vertexAttribute("aVertexPosition");
-  var texCoordVertAttr = new vglModule.vertexAttribute("aTextureCoord");
+  var vertexShader = vglModule.utils.createVertexShader(gl);
+  var fragmentShader = vglModule.utils.createFragmentShader(gl);
+  var posVertAttr = new vglModule.vertexAttribute("vertexPosition");
+  var texCoordVertAttr = new vglModule.vertexAttribute("textureCoord");
+  var colorVertAttr = new vglModule.vertexAttribute("vertexColor");
+  var opacityUniform = new vglModule.floatUniform("opacity");
+  opacityUniform.set(0.5);
+  var modelViewUniform = new vglModule.modelViewUniform("modelViewMatrix");
+  var projectionUniform = new vglModule.projectionUniform("projectionMatrix");
+
+  prog.addVertexAttribute(posVertAttr,
+    vglModule.vertexAttributeKeys.Position);
+  prog.addVertexAttribute(colorVertAttr,
+    vglModule.vertexAttributeKeys.Color);
+  prog.addVertexAttribute(texCoordVertAttr,
+    vglModule.vertexAttributeKeys.TextureCoordinate);
+  prog.addUniform(opacityUniform);
+  prog.addUniform(modelViewUniform);
+  prog.addUniform(projectionUniform);
+  prog.addShader(fragmentShader);
+  prog.addShader(vertexShader);
+  mat.addAttribute(prog);
+
+  var actor = new vglModule.actor();
+  console.log(actor);
+  actor.setMapper(mapper);
+  actor.setMaterial(mat);
+
+  return actor;
+};
+
+/**
+ * Helper function to create a plane textured node
+ *
+ * This method will create a plane actor with texture coordinates,
+ * eventually normal, and plane material.
+ *
+ * @returns actor
+ *
+ */
+vglModule.utils.createTexturePlane = function(originX, originY, originZ,
+                                               point1X, point1Y, point1Z,
+                                               point2X, point2Y, point2Z) {
+
+  var mapper = new vglModule.mapper();
+  var planeSource = new vglModule.planeSource();
+  planeSource.setOrigin(originX, originY, originZ);
+  planeSource.setPoint1(point1X, point1Y, point1Z);
+  planeSource.setPoint2(point2X, point2Y, point2Z);
+  mapper.setGeometryData(planeSource.create());
+
+  var mat = new vglModule.material();
+  var prog = new vglModule.shaderProgram();
+  var vertexShader = vglModule.utils.createTextureVertexShader(gl);
+  var fragmentShader = vglModule.utils.createTextureFragmentShader(gl);
+  var posVertAttr = new vglModule.vertexAttribute("vertexPosition");
+  var texCoordVertAttr = new vglModule.vertexAttribute("textureCoord");
+  var opacityUniform = new vglModule.floatUniform("opacity");
   var modelViewUniform = new vglModule.modelViewUniform("modelViewMatrix");
   var projectionUniform = new vglModule.projectionUniform("projectionMatrix");
-  var samplerUniform = new vglModule.uniform(gl.INT, "uSampler");
+  var samplerUniform = new vglModule.uniform(gl.INT, "sampler2d");
   samplerUniform.set(0);
 
   prog.addVertexAttribute(posVertAttr,
     vglModule.vertexAttributeKeys.Position);
   prog.addVertexAttribute(texCoordVertAttr,
     vglModule.vertexAttributeKeys.TextureCoordinate);
+  prog.addUniform(opacityUniform);
   prog.addUniform(modelViewUniform);
   prog.addUniform(projectionUniform);
   prog.addUniform(samplerUniform);
@@ -128,4 +234,4 @@ vglModule.utils.createPlane = function(originX, originY, originZ,
   actor.setMaterial(mat);
 
   return actor;
-};
\ No newline at end of file
+};

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=1bc586ea2e6eb2e090671c0d5f2e4e00f807c7e5
commit 1bc586ea2e6eb2e090671c0d5f2e4e00f807c7e5
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Fri Mar 1 00:45:08 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Fri Mar 1 00:45:08 2013 -0500

    Fixing some more style

diff --git a/web/lib/geo/layer.js b/web/lib/geo/layer.js
index c5e3105..938a33d 100644
--- a/web/lib/geo/layer.js
+++ b/web/lib/geo/layer.js
@@ -53,10 +53,9 @@ geoModule.layer = function(options) {
     return new geoModule.layer(options);
   }
 
-  /// Register with base class
   ogs.vgl.object.call(this);
 
-  /// Members initialization
+  /// Member variables
   var m_opacity = options.opacity || 1.0;
   if (m_opacity > 1.0) {
     m_opacity = 1.0;
diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index 9d8f797..f64bd56 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -27,10 +27,11 @@ geoModule.latlng = function(lat, lng) {
     return new geoModule.latlng(lat, lng);
   }
 
-  /// Initialize member varibles
+  /// Member variables
   var m_lat = lat;
   var m_lng = lng;
 
+  /// Member methods
   this.lat = function() {
       return m_lat;
   };
@@ -47,11 +48,11 @@ geoModule.latlng = function(lat, lng) {
  *
  */
 geoModule.mapOptions = function() {
-  // Check against no use of new()
   if (!(this instanceof geoModule.mapOptions)) {
     return new geoModule.mapOptions();
   }
 
+  /// Member variables
   this.zoom  = 10;
   this.center = geoModule.latlng(0.0, 0.0);
 };
@@ -66,7 +67,7 @@ geoModule.map = function(node, options) {
     return new geoModule.map(node, options);
   }
 
-  /// Initialize member variables
+  /// Member variables
   var m_that = this;
   var m_node = node;
   var m_leftMouseButtonDown = false;
diff --git a/web/lib/vgl/renderer.js b/web/lib/vgl/renderer.js
index 4d4a05c..ab00b83 100644
--- a/web/lib/vgl/renderer.js
+++ b/web/lib/vgl/renderer.js
@@ -18,7 +18,7 @@
 
 //////////////////////////////////////////////////////////////////////////////
 //
-// vglRenderStage class
+// renderState class
 //
 //////////////////////////////////////////////////////////////////////////////
 
@@ -48,8 +48,7 @@ vglModule.renderer = function() {
 
   vglModule.object.call(this);
 
-  /// Private member variables
-
+  /// Member variables
   this.m_width = 1280;
   this.m_height = 1024;
   this.m_clippingRange = [0.1, 1000.0];
@@ -58,8 +57,7 @@ vglModule.renderer = function() {
 
   this.m_camera.addChild(this.m_sceneRoot);
 
-  /// Public member variables
-
+  /// Member methods
   /**
    * Get scene root
    *

-----------------------------------------------------------------------

Summary of changes:
 web/lib/geo/layer.js         |    3 +-
 web/lib/geo/map.js           |   12 ++--
 web/lib/vgl/geomData.js      |   35 ++++++++---
 web/lib/vgl/planeSource.js   |   11 +++-
 web/lib/vgl/renderer.js      |    8 +--
 web/lib/vgl/shaderProgram.js |    5 +-
 web/lib/vgl/uniform.js       |   33 ++++++----
 web/lib/vgl/utils.js         |  144 ++++++++++++++++++++++++++++++++++++------
 8 files changed, 197 insertions(+), 54 deletions(-)


hooks/post-receive
-- 
OpenGeoscience



More information about the Opengeoscience-developers mailing list