[Opengeoscience-developers] OpenGeoscience branch, add_point_source, updated. 21d8020a06413710f3ed68a59c9cbbb3637c7bf9

Aashish Chaudhary aashish.chaudhary at kitware.com
Thu Mar 7 15:45:28 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  21d8020a06413710f3ed68a59c9cbbb3637c7bf9 (commit)
       via  b180acc90f65a7c224bac606c6dfdd00b4590de9 (commit)
      from  cb31e4223f1c80e69b4cc874445a75fdcff60d97 (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=21d8020a06413710f3ed68a59c9cbbb3637c7bf9
commit 21d8020a06413710f3ed68a59c9cbbb3637c7bf9
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Thu Mar 7 15:45:10 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Thu Mar 7 15:45:10 2013 -0500

    Work in progress to clean up the mapper

diff --git a/web/lib/vgl/mapper.js b/web/lib/vgl/mapper.js
index 62398cf..30929b2 100644
--- a/web/lib/vgl/mapper.js
+++ b/web/lib/vgl/mapper.js
@@ -26,13 +26,11 @@
 /// actor.
 ///
 /// \see boundingObject actor vglGeometryData
-
 //////////////////////////////////////////////////////////////////////////////
 //
 // mapper class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 vglModule.mapper = function() {
 
   if (!(this instanceof vglModule.mapper)) {
@@ -65,7 +63,7 @@ vglModule.mapper = function() {
    *
    */
   this.setGeometryData = function(geom) {
-    if (m_geomData !== geom )   {
+    if (m_geomData !== geom) {
       m_geomData = geom;
 
       // TODO we need
@@ -79,7 +77,7 @@ vglModule.mapper = function() {
    */
   this.render = function(renderState) {
     if (m_dirty) {
-      this.setupDrawObjects(renderState);
+      setupDrawObjects(renderState);
     }
 
     // TODO Use renderState
@@ -90,8 +88,8 @@ vglModule.mapper = function() {
       if (m_bufferVertexAttributeMap.hasOwnProperty(i)) {
         gl.bindBuffer(gl.ARRAY_BUFFER, m_buffers[bufferIndex]);
         for (j = 0; j < m_bufferVertexAttributeMap[i].length; ++j) {
-          renderState.m_material.bindVertexData(
-            renderState, m_bufferVertexAttributeMap[i][j]);
+          renderState.m_material
+              .bindVertexData(renderState, m_bufferVertexAttributeMap[i][j]);
         }
         ++bufferIndex;
       }
@@ -102,7 +100,7 @@ vglModule.mapper = function() {
       gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, m_buffers[bufferIndex++]);
       var primitive = m_geomData.primitive(j);//
       gl.drawElements(primitive.primitiveType(), primitive.numberOfIndices(),
-                      primitive.indicesValueType(),  0);
+                      primitive.indicesValueType(), 0);
     }
   };
 
@@ -110,17 +108,17 @@ vglModule.mapper = function() {
    * Delete cached VBO if any
    *
    */
-  this.deleteVertexBufferObjects = function() {
-    for (var i = 0 ; i < m_buffers.length; ++i)   {
+  function deleteVertexBufferObjects() {
+    for ( var i = 0; i < m_buffers.length; ++i) {
       gl.deleteBuffer(m_buffers[i]);
     }
-  };
+  }
 
   /**
    * Create new VBO for all its geometryData sources and primitives
    *
    */
-  this.createVertexBufferObjects = function() {
+  function createVertexBufferObjects() {
     if (m_geomData) {
       var numberOfSources = m_geomData.numberOfSources();
       var i = 0;
@@ -133,50 +131,54 @@ vglModule.mapper = function() {
 
         keys = m_geomData.source(i).keys();
         ks = [];
-        for (var j = 0; j < keys.length; ++j) {
+        for ( var j = 0; j < keys.length; ++j) {
           ks.push(keys[j]);
         }
 
-      m_bufferVertexAttributeMap[i] = ks;
+        m_bufferVertexAttributeMap[i] = ks;
         m_buffers[i] = bufferId;
       }
 
       var numberOfPrimitives = m_geomData.numberOfPrimitives();
-      for (var k = 0; k < numberOfPrimitives; ++k) {
+      for ( var k = 0; k < numberOfPrimitives; ++k) {
         bufferId = gl.createBuffer();
         gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, bufferId);
-        gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, m_geomData.primitive(k).indices(),
-                     gl.STATIC_DRAW);
+        gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, m_geomData.primitive(k)
+            .indices(), gl.STATIC_DRAW);
         m_buffers[i++] = bufferId;
       }
     }
-  };
+  }
 
   /**
    * Clear cache related to buffers
    *
    */
-  this.cleanUpDrawObjects = function() {
-  m_bufferVertexAttributeMap = {};
+  function cleanUpDrawObjects() {
+    m_bufferVertexAttributeMap = {};
     m_buffers = [];
-  };
+  }
+
+  /**
+   * Internal methods
+   */
 
   /**
    * Setup draw objects; Delete old ones and create new ones
    *
    */
-  this.setupDrawObjects = function(renderState) {
+  function setupDrawObjects(renderState) {
     // Delete buffer objects from past if any.
-    this.deleteVertexBufferObjects();
+    deleteVertexBufferObjects();
 
     // Clear any cache related to buffers
-    this.cleanUpDrawObjects();
+    cleanUpDrawObjects();
 
     // Now construct the new ones.
-    this.createVertexBufferObjects();
+    createVertexBufferObjects();
 
     m_dirty = false;
-  };
+  }
 
   return this;
 };

http://public.kitware.com/gitweb?p=OpenGeoscience/opengeoscience.git;a=commitdiff;h=b180acc90f65a7c224bac606c6dfdd00b4590de9
commit b180acc90f65a7c224bac606c6dfdd00b4590de9
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Thu Mar 7 15:37:28 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Thu Mar 7 15:37:28 2013 -0500

    Optimize the code a bit

diff --git a/web/lib/vgl/utils.js b/web/lib/vgl/utils.js
index 3476c37..9cb4ae5 100644
--- a/web/lib/vgl/utils.js
+++ b/web/lib/vgl/utils.js
@@ -129,24 +129,47 @@ vglModule.utils.createVertexShader = function(context) {
 };
 
 /**
- * Helper function to create a plane node
- *
- * This method will create a plane actor with texture coordinates,
- * eventually normal, and plane material.
- *
- * @returns actor
+ * Create a texture material
  *
+ * @returns {vglModule.material}
  */
-vglModule.utils.createPlane = 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());
+vglModule.utils.createTextureMaterial = function() {
+  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 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");
+  var samplerUniform = new vglModule.uniform(gl.INT, "sampler2d");
+  samplerUniform.set(0);
+  prog.addVertexAttribute(posVertAttr, vglModule.vertexAttributeKeys.Position);
+  prog.addVertexAttribute(colorVertAttr, vglModule.vertexAttributeKeys.Color);
+  prog.addVertexAttribute(texCoordVertAttr,
+                          vglModule.vertexAttributeKeys.TextureCoordinate);
+  prog.addUniform(pointsizeUniform);
+  prog.addUniform(opacityUniform);
+  prog.addUniform(modelViewUniform);
+  prog.addUniform(projectionUniform);
+  prog.addShader(fragmentShader);
+  prog.addShader(vertexShader);
+  mat.addAttribute(prog);
+  mat.addAttribute(blend);
 
+  return mat;
+};
+
+/**
+ * Create a geometry material
+ *
+ * @returns {vglModule.material}
+ */
+vglModule.utils.createGeometryMaterial = function() {
   var mat = new vglModule.material();
   var blend = new vglModule.blend();
   var prog = new vglModule.shaderProgram();
@@ -173,6 +196,29 @@ vglModule.utils.createPlane = function(originX, originY, originZ, point1X,
   mat.addAttribute(prog);
   mat.addAttribute(blend);
 
+  return mat;
+};
+
+/**
+ * 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.createPlane = 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 = vglModule.utils.createGeometryMaterial();
   var actor = new vglModule.actor();
   actor.setMapper(mapper);
   actor.setMaterial(mat);
@@ -200,34 +246,7 @@ vglModule.utils.createTexturePlane = function(originX, originY, originZ,
   planeSource.setPoint2(point2X, point2Y, point2Z);
   mapper.setGeometryData(planeSource.create());
 
-  var mat = new vglModule.material();
-  var blend = new vglModule.blend();
-  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 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");
-  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(pointsizeUniform);
-  prog.addUniform(opacityUniform);
-  prog.addUniform(modelViewUniform);
-  prog.addUniform(projectionUniform);
-  prog.addUniform(samplerUniform);
-  prog.addShader(fragmentShader);
-  prog.addShader(vertexShader);
-
-  mat.addAttribute(prog);
-  mat.addAttribute(blend);
-
+  var mat = vglModule.utils.createTextureMaterial();
   var actor = new vglModule.actor();
   actor.setMapper(mapper);
   actor.setMaterial(mat);

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

Summary of changes:
 web/lib/vgl/mapper.js |   52 +++++++++++++------------
 web/lib/vgl/utils.js  |  105 +++++++++++++++++++++++++++++--------------------
 2 files changed, 89 insertions(+), 68 deletions(-)


hooks/post-receive
-- 
OpenGeoscience



More information about the Opengeoscience-developers mailing list