From 09030b2230631961e972bd3ee8537239741b243d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 08:50:42 -0800 Subject: Reversed the orientation of one of the triangles for WebGL rendering. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/GLLine.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'js/helper-classes/RDGE/GLLine.js') diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index bd3cbc26..67379b52 100644 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js @@ -77,11 +77,16 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro this.getStrokeMaterial = function() { return this._strokeMaterial; } this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } - this.getStrokeColor = function() { return this._strokeColor; } + this.getStrokeColor = function() { return this._strokeColor; } //this.setStrokeColor = function(c) { this._strokeColor = c; } - this.getStrokeStyle = function() { return this._strokeStyle; } - this.setStrokeStyle = function(s) { this._strokeStyle = s; } + this.getStrokeStyle = function() { return this._strokeStyle; } + this.setStrokeStyle = function(s) { this._strokeStyle = s; } + + this.getFillMaterial = function() { return null; } + + this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } + this.getStrokeMaterial = function() { return this._strokeMaterial; } this.getWidth = function() { return this._width; } this.setWidth = function(w) { this._width = w; } @@ -184,9 +189,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro xFill+x, yFill+y, 0.0, -xFill+x, -yFill+y, 0.0, - xFill+x, yFill+y, 0.0, + xFill+x, -yFill+y, 0.0, -xFill+x, -yFill+y, 0.0, - xFill+x, -yFill+y, 0.0 + xFill+x, yFill+y, 0.0 ]; } else if(this._slope === "horizontal") @@ -199,10 +204,10 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro xFill+x, yFill+y, 0.0, -xFill+x, -yFill+y, 0.0, - xFill+x, yFill+y, 0.0, + xFill+x, -yFill+y, 0.0, -xFill+x, -yFill+y, 0.0, - xFill+x, -yFill+y, 0.0 - ]; + xFill+x, yFill+y, 0.0 + ]; } else if(this._slope > 0) { @@ -212,9 +217,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro -xFill+2*xAdj+x, yFill+y, 0.0, xFill-2*xAdj+x, -yFill+y, 0.0, - -xFill+2*xAdj+x, yFill+y, 0.0, + xFill+x, -yFill+2*yAdj+y, 0.0, xFill-2*xAdj+x, -yFill+y, 0.0, - xFill+x, -yFill+2*yAdj+y, 0.0 + -xFill+2*xAdj+x, yFill+y, 0.0 ]; } else @@ -225,9 +230,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro -xFill+2*xAdj+x, -yFill+y, 0.0, xFill-2*xAdj+x, yFill+y, 0.0, - -xFill+2*xAdj+x, -yFill+y, 0.0, + xFill+x, yFill-2*yAdj+y, 0.0, xFill-2*xAdj+x, yFill+y, 0.0, - xFill+x, yFill-2*yAdj+y, 0.0 + -xFill+2*xAdj+x, -yFill+y, 0.0 ]; } } -- cgit v1.2.3 From 191cb96b3b4e1e5aa805211e5ab8dbd6aa075881 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 10:09:13 -0800 Subject: Merging WebGL changes that allow users to modify different shape instances. Also, merging in changes that improve rendering performance by not updating static materials. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/GLLine.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/helper-classes/RDGE/GLLine.js') diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index bd3cbc26..f01e1610 100644 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js @@ -109,6 +109,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro var world = this.getWorld(); if (!world) throw( "null world in buildBuffers" ); if (!world._useWebGL) return; + + // make sure RDGE has the correct context + g_Engine.setContext( world.getCanvas().uuid ); // create the gl buffer var gl = world.getGLContext(); -- cgit v1.2.3 From 9e40945a5bf4330d1088b56b8011ee625b1adab9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 10 Feb 2012 10:23:48 -0800 Subject: Support export/import of GLLine data. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/GLLine.js | 67 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 6 deletions(-) (limited to 'js/helper-classes/RDGE/GLLine.js') diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index 1cd70575..5ec51230 100644 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js @@ -28,6 +28,8 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro this._strokeWidth = 0.25; this._strokeStyle = "Solid"; + this._scaleX = 1.0; + this._scaleY = 1.0; if (arguments.length > 0) { @@ -44,13 +46,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro this._strokeColor = strokeColor; this._strokeStyle = strokeStyle; + this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); } - this._scaleX = 1.0; - this._scaleY = 1.0; - - this._scaleX = (world._viewportWidth)/(world._viewportHeight); - this._strokeVerticesLen = 0; this.m_world = world; @@ -104,7 +102,64 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro this.setSlope = function(m) { this._slope = m; } this.geomType = function() { return this.GEOM_TYPE_LINE; } - + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + this.export = function() + { + var rtnStr = "type: " + this.geomType() + "\n"; + + rtnStr += "xoff: " + this._xOffset + "\n"; + rtnStr += "yoff: " + this._yOffset + "\n"; + rtnStr += "width: " + this._width + "\n"; + rtnStr += "height: " + this._height + "\n"; + rtnStr += "xAdj: " + this._xAdj + "\n"; + rtnStr += "yAdj: " + this._yAdj + "\n"; + rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; + rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; + rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; + rtnStr += "slope: " + String(this._slope) + "\n"; + + rtnStr += "strokeMat: "; + if (this._strokeMaterial) + rtnStr += this._strokeMaterial.getName(); + else + rtnStr += "flatMaterial"; + rtnStr += "\n"; + + return rtnStr; + } + + this.import = function( importStr ) + { + this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) ); + this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); + this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); + this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); + this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) ); + this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) ); + this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); + var slope = this.getPropertyFromString( "slope: ", importStr ); + if(isNaN(Number(slope))) + this._slope = slope; + else + this._slope = Number(slope); + + var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); + this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); + this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); + + var strokeMat = MaterialsLibrary.getMaterial( strokeMaterialName ); + if (!strokeMat) + { + console.log( "object material not found in library: " + strokeMaterialName ); + strokeMat = new FlatMaterial(); + } + this._strokeMaterial = strokeMat; + + } + /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3