[Opengeoscience-developers] OpenGeoscience branch, add_point_source, updated. b216c6223dfee9e33b5f35d8871d85053a37c472

Aashish Chaudhary aashish.chaudhary at kitware.com
Wed Mar 6 22:30:21 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, add_point_source has been updated
       via  b216c6223dfee9e33b5f35d8871d85053a37c472 (commit)
       via  97abc95b4f87db9fc6be96c13be030d158d68031 (commit)
      from  ba062ae8f8d12d534b38c026a782944a5a70560d (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=b216c6223dfee9e33b5f35d8871d85053a37c472
commit b216c6223dfee9e33b5f35d8871d85053a37c472
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Wed Mar 6 22:29:36 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Wed Mar 6 22:29:36 2013 -0500

    Got the points to show up

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9929fb..0dfd70e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,7 @@ set(JS_LINT_FILES
     ${CMAKE_SOURCE_DIR}/web/lib/vgl/vtkUnpack.js
     ${CMAKE_SOURCE_DIR}/web/lib/vgl/source.js
     ${CMAKE_SOURCE_DIR}/web/lib/vgl/planeSource.js
+    ${CMAKE_SOURCE_DIR}/web/lib/vgl/pointSource.js
     ${CMAKE_SOURCE_DIR}/web/lib/vgl/utils.js
 )
 
@@ -96,6 +97,7 @@ set(JS_UGLIFY_FILES
   ${CMAKE_SOURCE_DIR}/web/lib/vgl/vertexAttribute.js
   ${CMAKE_SOURCE_DIR}/web/lib/vgl/source.js
   ${CMAKE_SOURCE_DIR}/web/lib/vgl/planeSource.js
+  ${CMAKE_SOURCE_DIR}/web/lib/vgl/pointSource.js
   ${CMAKE_SOURCE_DIR}/web/lib/vgl/utils.js
   ${CMAKE_SOURCE_DIR}/web/lib/geo/init.js
   ${CMAKE_SOURCE_DIR}/web/lib/geo/latlng.js
diff --git a/web/lib/app.js b/web/lib/app.js
index d627843..5a47654 100644
--- a/web/lib/app.js
+++ b/web/lib/app.js
@@ -38,7 +38,14 @@ function main() {
   }, ogs.geo.planeFeature(ogs.geo.latlng(-90.0, 0.0), ogs.geo.latlng(90.0,
                                                                      180.0)));
 
+  var pointLayer = ogs.geo.featureLayer({
+    "opacity" : 1,
+    "showAttribution" : 1,
+    "visible" : 1
+  }, ogs.geo.pointFeature([ 0.0, 0.0, 0.0 ], [ 1.0, 0.0, 0.0 ]));
+
   myMap.addLayer(planeLayer);
+  myMap.addLayer(pointLayer);
 
   // Listen for slider slidechange event
   $('#slider-vertical').slider().bind('slide', function(event, ui) {
@@ -49,17 +56,12 @@ function main() {
   (function() {
     var canvas = document.getElementById('glcanvas');
 
-    // resize the canvas to fill browser window dynamically
+    // Resize the canvas to fill browser window dynamically
     window.addEventListener('resize', resizeCanvas, false);
 
     function resizeCanvas() {
       canvas.width = window.innerWidth;
       canvas.height = window.innerHeight * 0.85;
-
-      /**
-       * Your drawings need to be inside this function otherwise they will be reset when
-       * you resize the browser window and the canvas goes will be cleared.
-       */
       updateAndDraw(canvas.width, canvas.height);
     }
     resizeCanvas();
diff --git a/web/lib/geo/feature.js b/web/lib/geo/feature.js
index bdf47c9..e0aba2f 100644
--- a/web/lib/geo/feature.js
+++ b/web/lib/geo/feature.js
@@ -86,7 +86,6 @@ geoModule.pointFeature = function(positions, colors) {
   ogs.vgl.actor.call(this);
 
   // Initialize
-
   var actor = ogs.vgl.utils.createPoints(positions, colors);
 
   this.setMapper(actor.mapper());
@@ -95,4 +94,4 @@ geoModule.pointFeature = function(positions, colors) {
   return this;
 };
 
-inherit(geoModule.planeFeature, geoModule.feature);
+inherit(geoModule.pointFeature, geoModule.feature);
diff --git a/web/lib/vgl/geomData.js b/web/lib/vgl/geomData.js
index 3f4e690..06278c1 100644
--- a/web/lib/vgl/geomData.js
+++ b/web/lib/vgl/geomData.js
@@ -117,7 +117,7 @@ vglModule.primitive = function() {
 
   /*
    * Return primitive type
-   *
+   *g
    */
   this.primitiveType = function() {
     return m_primitiveType;
@@ -156,7 +156,7 @@ vglModule.primitive = function() {
   };
   /*
    * Set indices value type
-   *
+   *g
    */
   this.setIndicesValueType = function(type) {
     m_indicesValueType = type;
@@ -191,6 +191,8 @@ vglModule.triangleStrip = function() {
   this.setPrimitiveType(gl.TRIANGLE_STRIP);
   this.setIndicesValueType(gl.UNSIGNED_SHORT);
   this.setIndexCount(3);
+
+  return this;
 };
 
 inherit(vglModule.triangleStrip, vglModule.primitive);
@@ -211,16 +213,17 @@ vglModule.triangles = function() {
   this.setPrimitiveType(gl.TRIANGLES);
   this.setIndicesValueType(gl.UNSIGNED_SHORT);
   this.setIndexCount(3);
+
+  return this;
 };
 
 inherit(vglModule.triangles, vglModule.primitive);
 
-// ////////////////////////////////////////////////////////////////////////////
-//
-// Point
-//
-// ////////////////////////////////////////////////////////////////////////////
-
+/**
+ * Point primitive
+ *g
+ * @returns {vglModule.points}
+ */
 vglModule.points = function() {
 
   if (!(this instanceof vglModule.points)) {
@@ -231,16 +234,17 @@ vglModule.points = function() {
   this.setPrimitiveType(gl.POINTS);
   this.setIndicesValueType(gl.UNSIGNED_SHORT);
   this.setIndexCount(3);
+
+  return this;
 };
 
 inherit(vglModule.points, vglModule.primitive);
 
-// ////////////////////////////////////////////////////////////////////////////
-//
-// vglVertexData
-//
-// ////////////////////////////////////////////////////////////////////////////
-
+/**
+ * VertexData
+ *g
+ * @returns {vglModule.vertexDataP3f}
+ */
 vglModule.vertexDataP3f = function() {
   if (!(this instanceof vglModule.vertexDataP3f)) {
     return new vglModule.vertexDataP3f();
@@ -268,12 +272,10 @@ vglModule.vertexDataP3T3f = function() {
   this.m_texCoordinate = [];
 };
 
-// ////////////////////////////////////////////////////////////////////////////
-//
-// sourceData
-//
-// ////////////////////////////////////////////////////////////////////////////
-
+/**
+ * Source datag
+ * @returns {vglModule.sourceData}
+ */
 vglModule.sourceData = function() {
 
   if (!(this instanceof vglModule.sourceData)) {
diff --git a/web/lib/vgl/pointSource.js b/web/lib/vgl/pointSource.js
index 7969eb5..869cc79 100644
--- a/web/lib/vgl/pointSource.js
+++ b/web/lib/vgl/pointSource.js
@@ -53,7 +53,7 @@ vglModule.pointSource = function() {
    */
   this.setColors = function(colors) {
     if (colors instanceof Array) {
-      m_colors = colorscolors;
+      m_colors = colors;
     }
     else {
       console.log("[ERROR] Invalid data type for colors. Array is required.");
@@ -96,29 +96,29 @@ vglModule.pointSource = function() {
     }
 
     var pointsPrimitive = new vglModule.points();
-    points.setIndices(indices);
+    pointsPrimitive.setIndices(indices);
 
     var sourcePositions = vglModule.sourceDataP3fv();
     sourcePositions.pushBack(m_positions);
     m_geom.addSource(sourcePositions);
 
-    if (m_colors.length && m_colors.length === m_positions.length) {
+    if ((m_colors.length > 0) && m_colors.length === m_positions.length) {
       var sourceColors = vglModule.sourceDataC3fv();
-      sourceColors.pushBack(colors);
+      sourceColors.pushBack(m_colors);
       m_geom.addSource(sourceColors);
     }
-    else if (m_colors.length && m_colors.length !== m_positions.length) {
+    else if ((m_colors.length > 0) && m_colors.length !== m_positions.length) {
       console
           .log("[ERROR] Number of colors are different than number of points");
     }
 
-    if (m_textureCoords.length
+    if ((m_textureCoords.length > 0)
         && m_textureCoords.length === m_textureCoords.length) {
       var sourceTexCoords = vglModule.sourceDataT2fv();
       sourceTexCoords.pushBack(texCoords);
       m_geom.addSource(sourceTexCoords);
     }
-    else if (m_colors.length
+    else if ((m_textureCoords.length > 0)
              && (m_textureCoords.length / 2) !== (m_positions.length / 3)) {
       console
           .log("[ERROR] Number of texture coordinates are different than number of points");
diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index 62336cb..3476c37 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -85,11 +85,13 @@ vglModule.utils.createTextureVertexShader = function(context) {
   var vertexShaderSource = [
                             'attribute vec3 vertexPosition;',
                             'attribute vec3 textureCoord;',
+                            'uniform float pointSize;',
                             'uniform mat4 modelViewMatrix;',
                             'uniform mat4 projectionMatrix;',
                             'varying highp vec3 iTextureCoord;',
                             'void main(void)',
                             '{',
+                            'gl_PointSize = pointSize;',
                             'gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);',
                             ' iTextureCoord = textureCoord;', '}' ].join('\n');
 
@@ -109,12 +111,14 @@ vglModule.utils.createVertexShader = function(context) {
                             'attribute vec3 vertexPosition;',
                             'attribute vec3 textureCoord;',
                             'attribute vec3 vertexColor;',
+                            'uniform float pointSize;',
                             'uniform mat4 modelViewMatrix;',
                             'uniform mat4 projectionMatrix;',
                             'varying mediump vec3 iVertexColor;',
                             'varying highp vec3 iTextureCoord;',
                             'void main(void)',
                             '{',
+                            'gl_PointSize = pointSize;',
                             'gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);',
                             ' iTextureCoord = textureCoord;',
                             ' iVertexColor = vertexColor;', '}' ].join('\n');
@@ -151,6 +155,7 @@ vglModule.utils.createPlane = function(originX, originY, originZ, point1X,
   var posVertAttr = new vglModule.vertexAttribute("vertexPosition");
   var texCoordVertAttr = new vglModule.vertexAttribute("textureCoord");
   var colorVertAttr = new vglModule.vertexAttribute("vertexColor");
+  var pointsizeUniform = new vglModule.floatUniform("pointSize", 5.0);
   var opacityUniform = new vglModule.floatUniform("opacity", 0.5);
   var modelViewUniform = new vglModule.modelViewUniform("modelViewMatrix");
   var projectionUniform = new vglModule.projectionUniform("projectionMatrix");
@@ -159,6 +164,7 @@ vglModule.utils.createPlane = function(originX, originY, originZ, point1X,
   prog.addVertexAttribute(colorVertAttr, vglModule.vertexAttributeKeys.Color);
   prog.addVertexAttribute(texCoordVertAttr,
                           vglModule.vertexAttributeKeys.TextureCoordinate);
+  prog.addUniform(pointsizeUniform);
   prog.addUniform(opacityUniform);
   prog.addUniform(modelViewUniform);
   prog.addUniform(projectionUniform);
@@ -201,6 +207,7 @@ vglModule.utils.createTexturePlane = function(originX, originY, originZ,
   var fragmentShader = vglModule.utils.createTextureFragmentShader(gl);
   var posVertAttr = new vglModule.vertexAttribute("vertexPosition");
   var texCoordVertAttr = new vglModule.vertexAttribute("textureCoord");
+  var pointsizeUniform = new vglModule.floatUniform("pointSize", 5.0);
   var opacityUniform = new vglModule.floatUniform("opacity");
   var modelViewUniform = new vglModule.modelViewUniform("modelViewMatrix");
   var projectionUniform = new vglModule.projectionUniform("projectionMatrix");
@@ -210,6 +217,7 @@ vglModule.utils.createTexturePlane = function(originX, originY, originZ,
   prog.addVertexAttribute(posVertAttr, vglModule.vertexAttributeKeys.Position);
   prog.addVertexAttribute(texCoordVertAttr,
                           vglModule.vertexAttributeKeys.TextureCoordinate);
+  prog.addUniform(pointsizeUniform);
   prog.addUniform(opacityUniform);
   prog.addUniform(modelViewUniform);
   prog.addUniform(projectionUniform);
@@ -233,8 +241,7 @@ vglModule.utils.createTexturePlane = function(originX, originY, originZ,
  * This method will create a plane actor with texture coordinates,
  * eventually normal, and plane material.
  *
- * @returns actor
- *
+ * @returns {vglModule.actor}
  */
 vglModule.utils.createPoints = function(positions, colors, texcoords) {
   var mapper = new vglModule.mapper();
@@ -246,11 +253,11 @@ vglModule.utils.createPoints = function(positions, colors, texcoords) {
   }
 
   pointSource.setPositions(positions);
-  if (!colors) {
+  if (colors) {
     pointSource.setColors(colors);
   }
 
-  if (!texcoords) {
+  if (texcoords) {
     pointSource.setTextureCoordinates(texcoords);
   }
 
@@ -265,6 +272,7 @@ vglModule.utils.createPoints = function(positions, colors, texcoords) {
   var texCoordVertAttr = new vglModule.vertexAttribute("textureCoord");
   var colorVertAttr = new vglModule.vertexAttribute("vertexColor");
   var opacityUniform = new vglModule.floatUniform("opacity", 1.0);
+  var pointsizeUniform = new vglModule.floatUniform("pointSize", 5.0);
   var modelViewUniform = new vglModule.modelViewUniform("modelViewMatrix");
   var projectionUniform = new vglModule.projectionUniform("projectionMatrix");
 
@@ -272,6 +280,7 @@ vglModule.utils.createPoints = function(positions, colors, texcoords) {
   prog.addVertexAttribute(colorVertAttr, vglModule.vertexAttributeKeys.Color);
   prog.addVertexAttribute(texCoordVertAttr,
                           vglModule.vertexAttributeKeys.TextureCoordinate);
+  prog.addUniform(pointsizeUniform);
   prog.addUniform(opacityUniform);
   prog.addUniform(modelViewUniform);
   prog.addUniform(projectionUniform);

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=97abc95b4f87db9fc6be96c13be030d158d68031
commit 97abc95b4f87db9fc6be96c13be030d158d68031
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Wed Mar 6 22:03:50 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Wed Mar 6 22:03:50 2013 -0500

    Adding high level api for drawing points

diff --git a/web/lib/geo/feature.js b/web/lib/geo/feature.js
index d5591aa..bdf47c9 100644
--- a/web/lib/geo/feature.js
+++ b/web/lib/geo/feature.js
@@ -21,31 +21,30 @@
 // Feature base class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 geoModule.feature = function() {
 
   if (!(this instanceof geoModule.feature)) {
     return new geoModule.feature();
   }
 
-  /// Register with base class
+  // / Register with base class
   ogs.vgl.actor.call(this);
 
-
   return this;
 };
 
 inherit(geoModule.feature, ogs.vgl.actor);
 
-//////////////////////////////////////////////////////////////////////////////
-//
-// Plane feature class
-//
-// Create a plane feature given a lower left corner point {ogs.geo.latlng} and
-// and upper right corner point {ogs.geo.latlng}
-//
-//////////////////////////////////////////////////////////////////////////////
-
+/**
+ * Plane feature class
+ *
+ * Create a plane feature given a lower left corner point {ogs.geo.latlng} and
+ * and upper right corner point {ogs.geo.latlng}
+ *
+ * @param lowerleft
+ * @param upperright
+ * @returns {geoModule.planeFeature}
+ */
 geoModule.planeFeature = function(lowerleft, upperright) {
 
   if (!(this instanceof geoModule.planeFeature)) {
@@ -54,15 +53,41 @@ geoModule.planeFeature = function(lowerleft, upperright) {
 
   ogs.vgl.actor.call(this);
 
-  /// Initialize
-  var origin = [lowerleft.lng(), lowerleft.lat(), 0.0];
-  var pt2 = [lowerleft.lng(), upperright.lat(), 0.0];
-  var pt1 = [upperright.lng(), lowerleft.lat(), 0.0];
+  // Initialize
+  var origin = [ lowerleft.lng(), lowerleft.lat(), 0.0 ];
+  var pt2 = [ lowerleft.lng(), upperright.lat(), 0.0 ];
+  var pt1 = [ upperright.lng(), lowerleft.lat(), 0.0 ];
 
   var actor = ogs.vgl.utils.createPlane(origin[0], origin[1], origin[2],
-                                         pt1[0], pt1[1], pt1[2],
-                                         pt2[0], pt2[1], pt2[2]);
+                                        pt1[0], pt1[1], pt1[2], pt2[0], pt2[1],
+                                        pt2[2]);
+
+  this.setMapper(actor.mapper());
+  this.setMaterial(actor.material());
+
+  return this;
+};
+
+inherit(geoModule.planeFeature, geoModule.feature);
+
+/**
+ * Point feature class
+ *
+ * @param positions
+ * @param colors
+ * @returns {geoModule.pointFeature}
+ */
+geoModule.pointFeature = function(positions, colors) {
+
+  if (!(this instanceof geoModule.pointFeature)) {
+    return new geoModule.pointFeature(positions, colors);
+  }
+
+  ogs.vgl.actor.call(this);
+
+  // Initialize
 
+  var actor = ogs.vgl.utils.createPoints(positions, colors);
 
   this.setMapper(actor.mapper());
   this.setMaterial(actor.material());
diff --git a/web/lib/vgl/pointSource.js b/web/lib/vgl/pointSource.js
index f46b97b..7969eb5 100644
--- a/web/lib/vgl/pointSource.js
+++ b/web/lib/vgl/pointSource.js
@@ -34,15 +34,16 @@ vglModule.pointSource = function() {
   var m_geom = null;
 
   /**
-   * Set points for the source
+   * Set positions for the source
    *
    */
-  this.setPoints = function(positions) {
+  this.setPositions = function(positions) {
     if (positions instanceof Array) {
       m_positions = positions;
     }
     else {
-      console.log("[ERROR] Invalid data type. Require data type is Array");
+      console
+          .log("[ERROR] Invalid data type for positions. Array is required.");
     }
   };
 
@@ -55,7 +56,21 @@ vglModule.pointSource = function() {
       m_colors = colorscolors;
     }
     else {
-      console.log("[ERROR] Invalid data type. Require data type is Array");
+      console.log("[ERROR] Invalid data type for colors. Array is required.");
+    }
+  };
+
+  /**
+   * Set texture coordinates for the points
+   *
+   */
+  this.setTextureCoordinates = function(texcoords) {
+    if (texcoords instanceof Array) {
+      m_textureCoords = texcoords;
+    }
+    else {
+      console.log("[ERROR] Invalid data type for "
+                  + "texture coordinates. Array is required.");
     }
   };
 
diff --git a/web/lib/vgl/uniform.js b/web/lib/vgl/uniform.js
index cc984e2..45fc393 100644
--- a/web/lib/vgl/uniform.js
+++ b/web/lib/vgl/uniform.js
@@ -21,7 +21,6 @@
 // uniform class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.uniform = function(type, name) {
 
   if (!(this instanceof vglModule.uniform)) {
@@ -57,13 +56,13 @@ vglModule.uniform = function(type, name) {
         return 16;
 
       default:
-          return 0;
+        return 0;
     }
   };
 
   var m_type = type;
   var m_name = name;
-  var m_dataArray = [this.getTypeNumberOfComponents(m_type)];
+  var m_dataArray = [ this.getTypeNumberOfComponents(m_type) ];
   var m_numberOfElements = 1;
 
   this.name = function() {
@@ -111,8 +110,9 @@ vglModule.uniform = function(type, name) {
   };
 
   this.callGL = function(location) {
-    if (this.m_numberElements < 1)
+    if (this.m_numberElements < 1) {
       return;
+    }
 
     switch (m_type) {
       case gl.BOOL:
@@ -138,7 +138,7 @@ vglModule.uniform = function(type, name) {
         gl.uniformMatrix4fv(location, gl.FALSE, m_dataArray);
         break;
       default:
-          break;
+        break;
     }
   };
 
@@ -149,13 +149,6 @@ vglModule.uniform = function(type, name) {
   return this;
 };
 
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// modelViewUniform class
-//
-//////////////////////////////////////////////////////////////////////////////
-
 vglModule.modelViewUniform = function(name) {
 
   if (!(this instanceof vglModule.modelViewUniform)) {
@@ -179,13 +172,7 @@ vglModule.modelViewUniform = function(name) {
 
 inherit(vglModule.modelViewUniform, vglModule.uniform);
 
-//////////////////////////////////////////////////////////////////////////////
-//
-// projectionUniform class
-//
-//////////////////////////////////////////////////////////////////////////////
-
-vglModule.projectionUniform  = function(name) {
+vglModule.projectionUniform = function(name) {
 
   if (!(this instanceof vglModule.projectionUniform)) {
     return new vglModule.projectionUniform(name);
@@ -208,26 +195,23 @@ vglModule.projectionUniform  = function(name) {
 
 inherit(vglModule.projectionUniform, vglModule.uniform);
 
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  floatUniform class
-//
-//////////////////////////////////////////////////////////////////////////////
-
-vglModule.floatUniform  = function(name) {
+vglModule.floatUniform = function(name, value) {
 
   if (!(this instanceof vglModule.floatUniform)) {
-    return new vglModule.floatUniform(name);
+    return new vglModule.floatUniform(name, value);
   }
 
   if (name.length === 0) {
     name = "floatUniform";
   }
 
+  if (!value) {
+    value = 1.0;
+  }
+
   vglModule.uniform.call(this, gl.FLOAT, name);
 
-  this.set(1.0);
+  this.set(value);
 };
 
 inherit(vglModule.floatUniform, vglModule.uniform);
diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index 38f1d5c..62336cb 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -151,8 +151,7 @@ vglModule.utils.createPlane = function(originX, originY, originZ, point1X,
   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 opacityUniform = new vglModule.floatUniform("opacity", 0.5);
   var modelViewUniform = new vglModule.modelViewUniform("modelViewMatrix");
   var projectionUniform = new vglModule.projectionUniform("projectionMatrix");
 
@@ -227,3 +226,63 @@ vglModule.utils.createTexturePlane = function(originX, originY, originZ,
 
   return actor;
 };
+
+/**
+ * Helper function to create a plane node
+ *
+ * This method will create a plane actor with texture coordinates,
+ * eventually normal, and plane material.
+ *
+ * @returns actor
+ *
+ */
+vglModule.utils.createPoints = function(positions, colors, texcoords) {
+  var mapper = new vglModule.mapper();
+  var pointSource = new vglModule.pointSource();
+
+  if (!positions) {
+    console.log("[ERROR] Cannot create points without positions");
+    return null;
+  }
+
+  pointSource.setPositions(positions);
+  if (!colors) {
+    pointSource.setColors(colors);
+  }
+
+  if (!texcoords) {
+    pointSource.setTextureCoordinates(texcoords);
+  }
+
+  mapper.setGeometryData(pointSource.create());
+
+  var mat = new vglModule.material();
+  var blend = new vglModule.blend();
+  var prog = new vglModule.shaderProgram();
+  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", 1.0);
+  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);
+  mat.addAttribute(blend);
+
+  var actor = new vglModule.actor();
+  actor.setMapper(mapper);
+  actor.setMaterial(mat);
+
+  return actor;
+};
\ No newline at end of file

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

Summary of changes:
 CMakeLists.txt             |    2 +
 web/lib/app.js             |   14 +++++----
 web/lib/geo/feature.js     |   62 ++++++++++++++++++++++++++-----------
 web/lib/vgl/geomData.js    |   42 +++++++++++++------------
 web/lib/vgl/pointSource.js |   37 ++++++++++++++++-------
 web/lib/vgl/uniform.js     |   42 ++++++++-----------------
 web/lib/vgl/utils.js       |   72 ++++++++++++++++++++++++++++++++++++++++++-
 7 files changed, 184 insertions(+), 87 deletions(-)


hooks/post-receive
-- 
OpenGeoscience



More information about the Opengeoscience-developers mailing list