From 2acd77dac475a5197cb67b0257c758c357dfd443 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 27 Mar 2012 10:39:34 -0700 Subject: texture abstraction integration --- js/lib/rdge/materials/relief-tunnel-material.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'js/lib/rdge/materials/relief-tunnel-material.js') diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index 52c40543..24fc885f 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js @@ -6,8 +6,10 @@ var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; +var Texture = require("js/lib/rdge/texture").Texture; -var ReliefTunnelMaterial = function ReliefTunnelMaterial() { +var ReliefTunnelMaterial = function ReliefTunnelMaterial() +{ /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// @@ -62,6 +64,9 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() { this._shader['default'].u_time.set( [this._time] ); } + 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/relief-tunnel-material.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'js/lib/rdge/materials/relief-tunnel-material.js') diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index cb433562..4587b3fd 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js @@ -32,16 +32,17 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() /////////////////////////////////////////////////////////////////////// // duplcate method requirde this.dup = function (world) { - // allocate a new uber material - var newMat = new ReliefTunnelMaterial(); - - // copy over the current values; + // get the current values; var propNames = [], propValues = [], propTypes = [], propLabels = []; this.getAllProperties(propNames, propValues, propTypes, propLabels); + + // allocate a new material + var newMat = new ReliefTunnelMaterial(); + + // copy over the current values; var n = propNames.length; - for (var i = 0; i < n; i++) { + for (var i = 0; i < n; i++) newMat.setProperty(propNames[i], propValues[i]); - } return newMat; }; -- cgit v1.2.3 From d4ca478ad313c6c20834e410ba14ad3a5e7b20bf Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 12 Jun 2012 10:28:26 -0700 Subject: Material cleanup & bug fixes. --- js/lib/rdge/materials/relief-tunnel-material.js | 44 ++++++++++--------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'js/lib/rdge/materials/relief-tunnel-material.js') diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index 4587b3fd..9404e359 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js @@ -16,37 +16,31 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() this._name = "ReliefTunnelMaterial"; this._shaderName = "reliefTunnel"; - this._texMap = 'assets/images/rocky-normal.jpg'; + this._defaultTexMap = 'assets/images/rocky-normal.jpg'; this._time = 0.0; this._dTime = 0.01; /////////////////////////////////////////////////////////////////////// - // Properties + // Material Property Accessors /////////////////////////////////////////////////////////////////////// - // 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, u_speed_index = 1; + this._propNames = ["u_tex0", "u_speed" ]; + this._propLabels = ["Texture map", "Speed" ]; + this._propTypes = ["file", "float" ]; + this._propValues = []; + this._propValues[this._propNames[u_tex0_index]] = this._defaultTexMap.slice(0); + this._propValues[this._propNames[u_speed_index]] = 1.0; + /////////////////////////////////////////////////////////////////////// - // Methods + // Material Property Accessors /////////////////////////////////////////////////////////////////////// - // 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 ReliefTunnelMaterial(); - - // 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.isAnimated = function() { return true; }; + this.getShaderDef = function() { return reliefTunnelMaterialDef; }; + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// this.init = function (world) { // save the world if (world) this.setWorld(world); @@ -65,11 +59,8 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() this._shader['default'].u_time.set([this._time]); } - 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); }; @@ -104,6 +95,7 @@ var reliefTunnelMaterialDef = { '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/relief-tunnel-material.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/lib/rdge/materials/relief-tunnel-material.js') diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index 9404e359..0390337e 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js @@ -21,6 +21,9 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() this._time = 0.0; this._dTime = 0.01; + // array textures indexed by shader uniform name + this._glTextures = []; + /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// -- 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/relief-tunnel-material.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/rdge/materials/relief-tunnel-material.js') diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js index 0390337e..ab6b142e 100644 --- a/js/lib/rdge/materials/relief-tunnel-material.js +++ b/js/lib/rdge/materials/relief-tunnel-material.js @@ -13,7 +13,7 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// - this._name = "ReliefTunnelMaterial"; + this._name = "Relief Tunnel"; this._shaderName = "reliefTunnel"; this._defaultTexMap = 'assets/images/rocky-normal.jpg'; -- cgit v1.2.3