From fdeed8051c3af538d28ca3bc599121cea483c22c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 22 Mar 2012 15:47:56 -0700 Subject: Squashed commit of the following GL integration Signed-off-by: Valerio Virgillito --- js/lib/rdge/materials/pulse-material.js | 44 ++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'js/lib/rdge/materials/pulse-material.js') diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 81db36c6..2075d1ff 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -125,18 +125,6 @@ var PulseMaterial = function PulseMaterial() { var texMapName = this._propValues[this._propNames[0]]; var wrap = 'REPEAT', mips = true; var tex = this.loadTexture( texMapName, wrap, mips ); - - /* - var glTex = new GLTexture( this.getWorld() ); - var prevWorld = this.findPreviousWorld(); - if (prevWorld) - { - var srcCanvas = prevWorld.getCanvas(); - tex = glTex.loadFromCanvas( srcCanvas ); - } - else - tex = glTex.loadFromFile( texMapName, wrap, mips ); - */ if (tex) { technique.u_tex0.set( tex ); @@ -174,6 +162,38 @@ var PulseMaterial = function PulseMaterial() { } }; + // JSON export + this.exportJSON = function() + { + var jObj = + { + 'material' : this.getShaderName(), + 'name' : this.getName(), + 'texture' : this._propValues[this._propNames[0]], + 'dTime' : this._dTime + }; + + return jObj; + }; + + this.importJSON = function( jObj ) + { + if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); + this.setName( jObj.name ); + + try { + this._propValues[this._propNames[0]] = jObj.texture; + this._texMap = jObj.texture; + if (jObj.dTime) + this._dTime = jObj.dTime; + } + catch (e) + { + throw new Error( "could not import material: " + jObj ); + } + } + + this.export = function() { // every material needs the base type and instance name var exportStr = "material: " + this.getShaderName() + "\n"; -- cgit v1.2.3 From fb0a659c9ca3479fd6799325498b11f074689936 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Mon, 2 Apr 2012 14:57:31 -0700 Subject: -Namespaced all RDGE javascript. -Removed the following unused files from the build script /core/script/fx/blur.js /core/script/fx/ssao.js /core/script/animation.js - Fully removed the following from the build and from source control as they are unused or no longer needed /core/script/util/dbgpanel.js /core/script/util/fpsTracker.js /core/script/util/statTracker.js /core/script/input.js /core/script/TextureManager.js /core/script/ubershader.js --- js/lib/rdge/materials/pulse-material.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/lib/rdge/materials/pulse-material.js') diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 63cab2f4..89cbaea4 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -96,12 +96,12 @@ var PulseMaterial = function PulseMaterial() { this._dTime = 0.01; // set up the shader - this._shader = new jshader(); + this._shader = new RDGE.jshader(); this._shader.def = pulseMaterialDef; this._shader.init(); // set up the material node - this._materialNode = createMaterialNode("pulseMaterial"); + this._materialNode = RDGE.createMaterialNode("pulseMaterial"); this._materialNode.setShader(this._shader); this._time = 0; @@ -120,7 +120,7 @@ var PulseMaterial = function PulseMaterial() { var material = this._materialNode; if (material) { var technique = material.shaderProgram['default']; - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { var texMapName = this._propValues[this._propNames[0]]; var wrap = 'REPEAT', mips = true; @@ -151,7 +151,7 @@ var PulseMaterial = function PulseMaterial() { if (material) { var technique = material.shaderProgram['default']; - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { if (this._shader && this._shader['default']) { this._shader['default'].u_time.set( [this._time] ); @@ -167,7 +167,7 @@ var PulseMaterial = function PulseMaterial() { var material = this._materialNode; if (material) { var technique = material.shaderProgram['default']; - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { technique.u_resolution.set( res ); } -- cgit v1.2.3 From 8d1cc709340da845d76f84220fe92c11e6217ff3 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 09:36:14 -0700 Subject: Made use of semicolons consistent and updated new files to use the new RDGE namespace --- js/lib/rdge/materials/pulse-material.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'js/lib/rdge/materials/pulse-material.js') diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 47059533..6dabc759 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -66,9 +66,8 @@ var PulseMaterial = function PulseMaterial() { /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// - // duplcate method requirde - this.dup = function( world ) - { + // duplicate method required + this.dup = function( world ) { // save the world if (world) this.setWorld( world ); @@ -86,8 +85,7 @@ var PulseMaterial = function PulseMaterial() { return newMat; }; - this.init = function( world ) - { + this.init = function( world ) { // save the world if (world) this.setWorld( world ); @@ -233,7 +231,7 @@ var PulseMaterial = function PulseMaterial() { } return rtnStr; - } + }; }; /////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 18609d375e7aab9cb48c9b3f5b291f85cbd28683 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 13:39:32 -0700 Subject: removed old unused import and export functions. --- js/lib/rdge/materials/pulse-material.js | 42 --------------------------------- 1 file changed, 42 deletions(-) (limited to 'js/lib/rdge/materials/pulse-material.js') diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 6dabc759..f26aa16c 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -190,48 +190,6 @@ var PulseMaterial = function PulseMaterial() { throw new Error( "could not import material: " + jObj ); } }; - - - this.export = function() { - // every material needs the base type and instance name - var exportStr = "material: " + this.getShaderName() + "\n"; - exportStr += "name: " + this.getName() + "\n"; - - var world = this.getWorld(); - if (!world) - throw new Error( "no world in material.export, " + this.getName() ); - - var texMapName = this._propValues[this._propNames[0]]; - exportStr += "texture: " +texMapName + "\n"; - - // every material needs to terminate like this - exportStr += "endMaterial\n"; - - return exportStr; - }; - - this.import = function( importStr ) { - var pu = new MaterialParser( importStr ); - var material = pu.nextValue( "material: " ); - if (material != this.getShaderName()) throw new Error( "ill-formed material" ); - this.setName( pu.nextValue( "name: ") ); - - var rtnStr; - try { - this._propValues[this._propNames[0]] = pu.nextValue( "texture: " ); - - var endKey = "endMaterial\n"; - var index = importStr.indexOf( endKey ); - index += endKey.length; - rtnStr = importStr.substr( index ); - } - catch (e) - { - throw new Error( "could not import material: " + importStr ); - } - - return rtnStr; - }; }; /////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3