From 947bad893335e1023bcbe177ff8db454c27c4bf8 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 30 Mar 2012 06:23:53 -0700 Subject: converted materials to new texture structure --- js/lib/rdge/materials/deform-material.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/lib/rdge/materials/deform-material.js') diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index dfd89d12..c7bfe67a 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js @@ -5,6 +5,7 @@ */ var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; +var Texture = require("js/lib/rdge/texture").Texture; var DeformMaterial = function DeformMaterial() { /////////////////////////////////////////////////////////////////////// @@ -68,6 +69,10 @@ var DeformMaterial = function DeformMaterial() { this._shader['default'].u_time.set( [this._time] ); } + // set up the texture + var texMapName = this._propValues[this._propNames[0]]; + this._glTex = new Texture( world, texMapName ); + // set the shader values in the shader this.updateTexture(); this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); -- cgit v1.2.3 From 5a1965bf2ed9a54601ca16fd67555335c510ce08 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 26 Apr 2012 16:40:05 -0700 Subject: Update materials to the new texture model. Create local world for deleted source canvases --- js/lib/rdge/materials/deform-material.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'js/lib/rdge/materials/deform-material.js') diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index a7a0c178..c7f9cadc 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js @@ -37,13 +37,16 @@ var DeformMaterial = function DeformMaterial() { // Methods /////////////////////////////////////////////////////////////////////// // duplcate method requirde - this.dup = function (world) { - // allocate a new uber material - var newMat = new DeformMaterial(); - - // copy over the current values; + this.dup = function (world) + { + // get the current values; var propNames = [], propValues = [], propTypes = [], propLabels = []; this.getAllProperties(propNames, propValues, propTypes, propLabels); + + // allocate a new material + var newMat = new DeformMaterial(); + + // copy over the current values; var n = propNames.length; for (var i = 0; i < n; i++) newMat.setProperty(propNames[i], propValues[i]); -- cgit v1.2.3 From 6c994c4b90023cecf4fd0caafb404b859fe28f54 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 6 Jun 2012 16:34:41 -0700 Subject: material cleanup and rearchitecture --- js/lib/rdge/materials/deform-material.js | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'js/lib/rdge/materials/deform-material.js') diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index c7f9cadc..70742c77 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js @@ -37,22 +37,6 @@ var DeformMaterial = function DeformMaterial() { // Methods /////////////////////////////////////////////////////////////////////// // duplcate method requirde - this.dup = function (world) - { - // get the current values; - var propNames = [], propValues = [], propTypes = [], propLabels = []; - this.getAllProperties(propNames, propValues, propTypes, propLabels); - - // allocate a new material - var newMat = new DeformMaterial(); - - // copy over the current values; - var n = propNames.length; - for (var i = 0; i < n; i++) - newMat.setProperty(propNames[i], propValues[i]); - - return newMat; - }; this.init = function (world) { // save the world -- cgit v1.2.3 From db2bb0ab5d2747f0d07878e3b8a7d2d10c755110 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 7 Jun 2012 17:07:21 -0700 Subject: Material cleanup --- js/lib/rdge/materials/deform-material.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'js/lib/rdge/materials/deform-material.js') diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index 70742c77..91202b24 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js @@ -14,7 +14,7 @@ var DeformMaterial = function DeformMaterial() { this._name = "DeformMaterial"; this._shaderName = "deform"; - this._texMap = 'assets/images/rocky-normal.jpg'; + this._defaultTexMap = 'assets/images/rocky-normal.jpg'; this._time = 0.0; this._dTime = 0.01; @@ -24,11 +24,21 @@ var DeformMaterial = function DeformMaterial() { /////////////////////////////////////////////////////////////////////// // all defined in parent PulseMaterial.js // load the local default value - this._propValues[this._propNames[0]] = this._texMap.slice(0); + var u_tex0_index = 0; + this._propNames = ["u_tex0", "u_speed" ]; + this._propLabels = ["Texture map", "Speed" ]; + this._propTypes = ["file", "float" ]; + this._propValues = []; + this._propValues[this._propNames[0]] = this._defaultTexMap.slice(0); + this._propValues[this._propNames[1]] = 1.0; + + this._propValues[ this._propNames[ u_tex0_index] ] = this._defaultTexMap.slice(0); /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// + this.isAnimated = function() { return true; }; + this.getShaderDef = function() { return pulseMaterialDef; } /////////////////////////////////////////////////////////////////////// @@ -56,12 +66,8 @@ var DeformMaterial = function DeformMaterial() { this._shader['default'].u_time.set([this._time]); } - // set up the texture - var texMapName = this._propValues[this._propNames[0]]; - this._glTex = new Texture( world, texMapName ); - // set the shader values in the shader - this.updateTexture(); + this.setShaderValues(); this.setResolution([world.getViewportWidth(), world.getViewportHeight()]); this.update(0); }; @@ -96,6 +102,7 @@ var deformMaterialDef = { 'u_tex0': { 'type' : 'tex2d' }, 'u_time' : { 'type' : 'float' }, + 'u_speed' : { 'type' : 'float' }, 'u_resolution' : { 'type' : 'vec2' } }, -- cgit v1.2.3 From a7aa51e6b91623772eef54b827616432838b560e Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 13 Jun 2012 13:56:10 -0700 Subject: Material bug fixes - reset texture array. --- js/lib/rdge/materials/deform-material.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/lib/rdge/materials/deform-material.js') diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index 91202b24..7ff5b3e3 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js @@ -19,6 +19,9 @@ var DeformMaterial = function DeformMaterial() { this._time = 0.0; this._dTime = 0.01; + // array textures indexed by shader uniform name + this._glTextures = []; + /////////////////////////////////////////////////////////////////////// // Properties /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From f0fc7a5678093cce986bd99fef2c5c88add19b68 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 14 Jun 2012 16:09:31 -0700 Subject: Fix for line color. Name change for all materials --- js/lib/rdge/materials/deform-material.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/rdge/materials/deform-material.js') diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js index 7ff5b3e3..4354408d 100644 --- a/js/lib/rdge/materials/deform-material.js +++ b/js/lib/rdge/materials/deform-material.js @@ -11,7 +11,7 @@ var DeformMaterial = function DeformMaterial() { /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// - this._name = "DeformMaterial"; + this._name = "Deform"; this._shaderName = "deform"; this._defaultTexMap = 'assets/images/rocky-normal.jpg'; -- cgit v1.2.3