From 818582d389f504c915be0c9052fafa33e3e76c92 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 7 Mar 2012 16:48:48 -0800 Subject: File IO --- js/lib/rdge/materials/plasma-material.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'js/lib/rdge/materials/plasma-material.js') diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js index 9ecc2b48..62d0db70 100644 --- a/js/lib/rdge/materials/plasma-material.js +++ b/js/lib/rdge/materials/plasma-material.js @@ -54,7 +54,10 @@ var PlasmaMaterial = function PlasmaMaterial() { return new PlasmaMaterial(); }; - this.init = function() { + this.init = function( world) + { + this.setWorld( world ); + // set up the shader this._shader = new jshader(); this._shader.def = plasmaShaderDef; @@ -66,7 +69,7 @@ var PlasmaMaterial = function PlasmaMaterial() { this.setProperty( "color", [this._time, 0, 0, 1] ); // set up the material node - this._materialNode = createMaterialNode("plasmaMaterial"); + this._materialNode = createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); this._materialNode.setShader(this._shader); }; -- cgit v1.2.3 From 9e812f35ffa751e9215c5427c0c44005bd357924 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 7 Mar 2012 17:18:38 -0800 Subject: Fixed a few problems with Plasma material. --- js/lib/rdge/materials/plasma-material.js | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'js/lib/rdge/materials/plasma-material.js') diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js index 62d0db70..86b1a93c 100644 --- a/js/lib/rdge/materials/plasma-material.js +++ b/js/lib/rdge/materials/plasma-material.js @@ -17,8 +17,6 @@ var PlasmaMaterial = function PlasmaMaterial() { this._dTime = 0.01; this._speed = 1.0; - this._color = [1,0,0,1]; - /////////////////////////////////////////////////////////////////////// // Property Accessors @@ -30,20 +28,12 @@ var PlasmaMaterial = function PlasmaMaterial() { /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// - this._propNames = ["color"]; - this._propLabels = ["Color"]; - this._propTypes = ["color"]; - this._propValues = []; - - this._propValues[ this._propNames[0] ] = this._color; - - this.setProperty = function( prop, value ) { - // make sure we have legitimate imput - if (this.validateProperty( prop, value )) { - this._color = value.slice(0); - this._shader['default'][prop].set(value); - } + + this.setProperty = function( prop, value ) + { + // plasma has no properties }; + /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// @@ -65,8 +55,7 @@ var PlasmaMaterial = function PlasmaMaterial() { // set the default value this._time = 0; - this._shader['default'].u_time = this._time; - this.setProperty( "color", [this._time, 0, 0, 1] ); + this._shader['default'].u_time.set( [this._time] ); // set up the material node this._materialNode = createMaterialNode("plasmaMaterial" + "_" + world.generateUniqueNodeID()); @@ -74,11 +63,7 @@ var PlasmaMaterial = function PlasmaMaterial() { }; this.update = function( time ) { - this._shader['default'].u_time = this._time; - var color = this.getProperty( "color" ); - color[0] = this._time; - this.setProperty( "color", color ); - //console.log( "update color to: " + color ); + this._shader['default'].u_time.set( [this._time] ); this._time += this._dTime; } @@ -112,7 +97,6 @@ var plasmaShaderDef = 'params' : { 'u_time' : { 'type' : 'float' }, - 'color' : { 'type' : 'vec4' } }, // render states -- cgit v1.2.3 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/plasma-material.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/lib/rdge/materials/plasma-material.js') diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js index 86b1a93c..b04d8451 100644 --- a/js/lib/rdge/materials/plasma-material.js +++ b/js/lib/rdge/materials/plasma-material.js @@ -67,6 +67,24 @@ var PlasmaMaterial = function PlasmaMaterial() { this._time += this._dTime; } + this.exportJSON = function() + { + var jObj = + { + 'material' : this.getShaderName(), + 'name' : this.getName(), + 'speed' : this._speed, + 'dTime' : this._dTime + } + + return jObj; + } + + this.importJSON = function( jObj ) + { + this._speed = jObj.speed; + this._dTime = jObj.dTime; + } }; /////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3