[Opengeoscience-developers] OpenGeoscience branch, enhance_map_api, updated. 3754f834428aa9a448156b1645cdef308effe881

Aashish Chaudhary aashish.chaudhary at kitware.com
Sat Mar 2 19:21:30 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  3754f834428aa9a448156b1645cdef308effe881 (commit)
      from  a882e6b5d1094a76cdc340f3967f1f5966fb2241 (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=3754f834428aa9a448156b1645cdef308effe881
commit 3754f834428aa9a448156b1645cdef308effe881
Author:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
AuthorDate: Sat Mar 2 19:21:06 2013 -0500
Commit:     Aashish Chaudhary <aashish.chaudhary at kitware.com>
CommitDate: Sat Mar 2 19:21:06 2013 -0500

    Removed hard-coded width and height

diff --git a/web/lib/geo/map.js b/web/lib/geo/map.js
index 8910630..a7285c9 100644
--- a/web/lib/geo/map.js
+++ b/web/lib/geo/map.js
@@ -93,6 +93,7 @@ geoModule.map = function(node, options) {
   $(this).on('mapUpdated', draw);
 
   var m_renderer = new ogs.vgl.renderer();
+  m_renderer.resize($(node).width(), $(node).height());
   var m_camera = m_renderer.camera();
 
   /**
@@ -193,7 +194,7 @@ geoModule.map = function(node, options) {
       focalPoint[2], 1);
 
       var focusDisplayPt = ogs.vgl.renderer.worldToDisplay(focusWorldPt,
-      m_camera.viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
+      m_camera.viewMatrix(), m_camera.projectionMatrix(), width, height);
 
       var displayPt1 = vec4.createFrom(currentMousePos.x, currentMousePos.y,
       focusDisplayPt[2], 1.0);
@@ -201,9 +202,9 @@ geoModule.map = function(node, options) {
       focusDisplayPt[2], 1.0);
 
       var worldPt1 = ogs.vgl.renderer.displayToWorld(displayPt1, m_camera
-      .viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
+      .viewMatrix(), m_camera.projectionMatrix(), width, height);
       var worldPt2 = ogs.vgl.renderer.displayToWorld(displayPt2, m_camera
-      .viewMatrix(), m_camera.projectionMatrix(), 1680, 1050);
+      .viewMatrix(), m_camera.projectionMatrix(), width, height);
 
       dx = worldPt1[0] - worldPt2[0];
       dy = worldPt1[1] - worldPt2[1];
diff --git a/web/lib/vgl/renderer.js b/web/lib/vgl/renderer.js
index 7e77e5b..d8f5706 100644
--- a/web/lib/vgl/renderer.js
+++ b/web/lib/vgl/renderer.js
@@ -21,7 +21,6 @@
 // renderState class
 //
 //////////////////////////////////////////////////////////////////////////////
-
 ///---------------------------------------------------------------------------
 vglModule.renderState = function() {
   this.m_modelViewMatrix = mat4.create();
@@ -30,11 +29,11 @@ vglModule.renderState = function() {
   this.m_mapper = null;
 };
 
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
 //
 // renderer class
 //
-//////////////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////////////
 
 /**
  * renderer class provides key functionality to render a scene
@@ -48,16 +47,16 @@ vglModule.renderer = function() {
 
   vglModule.object.call(this);
 
-  /// Private member variables
+  // / Private member variables
   var m_width = 1280;
   var m_height = 1024;
-  var m_clippingRange = [0.1, 1000.0];
+  var m_clippingRange = [ 0.1, 1000.0 ];
   var m_sceneRoot = new vglModule.groupNode();
   var m_camera = new vglModule.camera();
 
   m_camera.addChild(m_sceneRoot);
 
-  /// Public member methods
+  // / Public member methods
 
   /**
    * Get scene root
@@ -101,19 +100,17 @@ vglModule.renderer = function() {
     gl.depthFunc(gl.LEQUAL);
     gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
 
-    // TODO Call it only once
-    this.resize();
-
-    perspectiveMatrix = m_camera.computeProjectionMatrix(
-      (m_width / m_height), 0.1, 10000.0);
+    perspectiveMatrix = m_camera.computeProjectionMatrix((m_width / m_height),
+    0.1, 10000.0);
 
     var renSt = new vglModule.renderState();
     renSt.m_projectionMatrix = perspectiveMatrix;
     var children = m_sceneRoot.children();
-    for (var i = 0; i < children.length; ++i) {
+    for ( var i = 0; i < children.length; ++i) {
       console.log('actor index ' + i);
       var actor = children[i];
-      mat4.multiply(m_camera.computeViewMatrix(), actor.matrix(), renSt.m_modelViewMatrix);
+      mat4.multiply(m_camera.computeViewMatrix(), actor.matrix(),
+      renSt.m_modelViewMatrix);
       renSt.m_material = actor.material();
       renSt.m_mapper = actor.mapper();
 
@@ -137,7 +134,9 @@ vglModule.renderer = function() {
    * Resize viewport based on the new width and height of the window
    *
    */
-  this.resize = function() {
+  this.resize = function(width, height) {
+    m_width = width;
+    m_height = height;
     gl.viewport(0, 0, m_width, m_height);
   };
 
@@ -171,8 +170,8 @@ vglModule.renderer = function() {
    * Transform a point in the world space to display space
    *
    */
-  vglModule.renderer.worldToDisplay = function(
-    worldPt, viewMatrix, projectionMatrix, width, height) {
+  vglModule.renderer.worldToDisplay = function(worldPt, viewMatrix,
+  projectionMatrix, width, height) {
     var viewProjectionMatrix = mat4.create();
     mat4.multiply(projectionMatrix, viewMatrix, viewProjectionMatrix);
 
@@ -185,12 +184,12 @@ vglModule.renderer = function() {
       clipPt[1] = clipPt[1] / clipPt[3];
       clipPt[2] = clipPt[2] / clipPt[3];
       clipPt[3] = 1.0;
-      }
+    }
 
-    var winX = Math.round( ( ( ( clipPt[0]) + 1 ) / 2.0) * width );
-    /// We calculate -point3D.getY() because the screen Y axis is
-    /// oriented top->down
-    var winY = Math.round((( 1 - clipPt[1] ) / 2.0) *  height );
+    var winX = Math.round((((clipPt[0]) + 1) / 2.0) * width);
+    // / We calculate -point3D.getY() because the screen Y axis is
+    // / oriented top->down
+    var winY = Math.round(((1 - clipPt[1]) / 2.0) * height);
     var winZ = clipPt[2];
     var winW = clipPt[3];
 
@@ -201,27 +200,27 @@ vglModule.renderer = function() {
    * Transform a point in display space to world space
    *
    */
-  vglModule.renderer.displayToWorld = function(
-    displayPt, viewMatrix, projectionMatrix, width, height) {
-      var x =  ( 2.0 * displayPt[0] / width )  - 1;
-      var y = -( 2.0 * displayPt[1] / height ) + 1;
-      var z =  displayPt[2];
-
-      var viewProjectionInverse = mat4.create();
-      mat4.multiply(projectionMatrix, viewMatrix, viewProjectionInverse);
-      mat4.inverse(viewProjectionInverse, viewProjectionInverse);
-
-      var worldPt = vec4.createFrom(x, y, z, 1);
-      mat4.multiplyVec4(viewProjectionInverse, worldPt, worldPt);
-
-      if (worldPt[3] !== 0.0) {
-        worldPt[0] = worldPt[0] / worldPt[3];
-        worldPt[1] = worldPt[1] / worldPt[3];
-        worldPt[2] = worldPt[2] / worldPt[3];
-        worldPt[3] = 1.0;
-      }
-
-      return worldPt;
+  vglModule.renderer.displayToWorld = function(displayPt, viewMatrix,
+  projectionMatrix, width, height) {
+    var x = (2.0 * displayPt[0] / width) - 1;
+    var y = -(2.0 * displayPt[1] / height) + 1;
+    var z = displayPt[2];
+
+    var viewProjectionInverse = mat4.create();
+    mat4.multiply(projectionMatrix, viewMatrix, viewProjectionInverse);
+    mat4.inverse(viewProjectionInverse, viewProjectionInverse);
+
+    var worldPt = vec4.createFrom(x, y, z, 1);
+    mat4.multiplyVec4(viewProjectionInverse, worldPt, worldPt);
+
+    if (worldPt[3] !== 0.0) {
+      worldPt[0] = worldPt[0] / worldPt[3];
+      worldPt[1] = worldPt[1] / worldPt[3];
+      worldPt[2] = worldPt[2] / worldPt[3];
+      worldPt[3] = 1.0;
+    }
+
+    return worldPt;
   };
 
   return this;

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

Summary of changes:
 web/lib/geo/map.js      |    7 ++--
 web/lib/vgl/renderer.js |   83 +++++++++++++++++++++++------------------------
 2 files changed, 45 insertions(+), 45 deletions(-)


hooks/post-receive
-- 
OpenGeoscience



More information about the Opengeoscience-developers mailing list