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/star-material.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/lib/rdge/materials/star-material.js') diff --git a/js/lib/rdge/materials/star-material.js b/js/lib/rdge/materials/star-material.js index d7d797e4..1506927b 100644 --- a/js/lib/rdge/materials/star-material.js +++ b/js/lib/rdge/materials/star-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 StarMaterial = function StarMaterial() { /////////////////////////////////////////////////////////////////////// @@ -63,6 +64,10 @@ var StarMaterial = function StarMaterial() { 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/star-material.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'js/lib/rdge/materials/star-material.js') diff --git a/js/lib/rdge/materials/star-material.js b/js/lib/rdge/materials/star-material.js index c4ff08c8..000d44b0 100644 --- a/js/lib/rdge/materials/star-material.js +++ b/js/lib/rdge/materials/star-material.js @@ -31,16 +31,17 @@ var StarMaterial = function StarMaterial() { /////////////////////////////////////////////////////////////////////// // duplcate method requirde this.dup = function () { - // allocate a new uber material - var newMat = new StarMaterial(); - - // 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 StarMaterial(); + + // 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/star-material.js | 44 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'js/lib/rdge/materials/star-material.js') diff --git a/js/lib/rdge/materials/star-material.js b/js/lib/rdge/materials/star-material.js index 000d44b0..9f94b8c3 100644 --- a/js/lib/rdge/materials/star-material.js +++ b/js/lib/rdge/materials/star-material.js @@ -14,37 +14,32 @@ var StarMaterial = function StarMaterial() { this._name = "StarMaterial"; this._shaderName = "star"; - this._texMap = 'assets/images/rocky-normal.jpg'; + this._defaultTexMap = 'assets/images/rocky-normal.jpg'; this._time = 0.0; this._dTime = 0.01; - /////////////////////////////////////////////////////////////////////// - // Properties - /////////////////////////////////////////////////////////////////////// - // all defined in parent PulseMaterial.js - // load the local default value - this._propValues[this._propNames[0]] = this._texMap.slice(0); + /////////////////////////////////////////////////////////////////////// + // Property Accessors + /////////////////////////////////////////////////////////////////////// + this.isAnimated = function() { return true; }; + this.getShaderDef = function() { return starMaterialDef; } + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + 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 /////////////////////////////////////////////////////////////////////// - // duplcate method requirde - this.dup = function () { - // get the current values; - var propNames = [], propValues = [], propTypes = [], propLabels = []; - this.getAllProperties(propNames, propValues, propTypes, propLabels); - - // allocate a new material - var newMat = new StarMaterial(); - - // 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 @@ -69,7 +64,7 @@ var StarMaterial = function StarMaterial() { 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 +99,7 @@ var starMaterialDef = { '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/star-material.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/lib/rdge/materials/star-material.js') diff --git a/js/lib/rdge/materials/star-material.js b/js/lib/rdge/materials/star-material.js index 9f94b8c3..c99a1639 100644 --- a/js/lib/rdge/materials/star-material.js +++ b/js/lib/rdge/materials/star-material.js @@ -19,6 +19,9 @@ var StarMaterial = function StarMaterial() { this._time = 0.0; this._dTime = 0.01; + // array textures indexed by shader uniform name + this._glTextures = []; + /////////////////////////////////////////////////////////////////////// // 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/star-material.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/rdge/materials/star-material.js') diff --git a/js/lib/rdge/materials/star-material.js b/js/lib/rdge/materials/star-material.js index c99a1639..760cf128 100644 --- a/js/lib/rdge/materials/star-material.js +++ b/js/lib/rdge/materials/star-material.js @@ -11,7 +11,7 @@ var StarMaterial = function StarMaterial() { /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// - this._name = "StarMaterial"; + this._name = "Star"; this._shaderName = "star"; this._defaultTexMap = 'assets/images/rocky-normal.jpg'; -- cgit v1.2.3