From 2f66a9ab38f761b7796800bb37f8146f140db40b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 26 Mar 2012 11:31:23 -0700 Subject: WebGL & Canvas as data for texture maps. --- js/lib/rdge/materials/pulse-material.js | 42 +++++++++++++++++++++++++++++---- 1 file changed, 37 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 2075d1ff..5461c5fb 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -5,19 +5,28 @@ */ var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; +var Texture = require("js/lib/rdge/texture").Texture; var Material = require("js/lib/rdge/materials/material").Material; /////////////////////////////////////////////////////////////////////// // Class GLMaterial // RDGE representation of a material. /////////////////////////////////////////////////////////////////////// -var PulseMaterial = function PulseMaterial() { +var PulseMaterial = function PulseMaterial() +{ + var MaterialLibrary = require("js/models/materials-model").MaterialsModel; + + // initialize the inherited members + this.inheritedFrom = Material; + this.inheritedFrom(); + /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// this._name = "PulseMaterial"; this._shaderName = "pulse"; - this._texMap = 'assets/images/cubelight.png'; + //this._texMap = 'assets/images/cubelight.png'; + this._texMap = 'texture'; this._time = 0.0; this._dTime = 0.01; @@ -109,6 +118,16 @@ var PulseMaterial = function PulseMaterial() { this._shader['default'].u_time.set( [this._time] ); } + // check if the texture uses a canvas as the source + var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; + var root = viewUtils.application.ninja.currentDocument.documentRoot; + var texMapName = this._propValues[this._propNames[0]]; + var texWorld = this.findWorld( texMapName, root ); + if (texWorld) + { + this._glTex = new Texture( this.getWorld() ); + this._glTex.loadFromCanvas( texWorld.getCanvas() ); + } // set the shader values in the shader this.updateTexture(); @@ -122,9 +141,18 @@ var PulseMaterial = function PulseMaterial() { var technique = material.shaderProgram['default']; var renderer = g_Engine.getContext().renderer; if (renderer && technique) { - var texMapName = this._propValues[this._propNames[0]]; var wrap = 'REPEAT', mips = true; - var tex = this.loadTexture( texMapName, wrap, mips ); + var tex; + if (this._glTex) + { + this._glTex.rerender(); + tex = this._glTex.getTexture(); + } + else + { + var texMapName = this._propValues[this._propNames[0]]; + tex = this.loadTexture( texMapName, wrap, mips ); + } if (tex) { technique.u_tex0.set( tex ); @@ -138,6 +166,9 @@ var PulseMaterial = function PulseMaterial() { var material = this._materialNode; if (material) { + if (this._glTex && this._glTex.isAnimated()) + this.updateTexture(); + var technique = material.shaderProgram['default']; var renderer = g_Engine.getContext().renderer; if (renderer && technique) { @@ -279,7 +310,8 @@ var pulseMaterialDef = } }; -PulseMaterial.prototype = new Material(); +// doing the inheritance here introtudes bugs. Local instance variables are overwritten in the base class +//PulseMaterial.prototype = new Material(); if (typeof exports === "object") { exports.PulseMaterial = PulseMaterial; -- cgit v1.2.3 From d7269673dc1f5caf6df3765c6b669d3d1a93bdb1 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 27 Mar 2012 04:53:27 -0700 Subject: Integrated texture wrapper into pulse and bump-metal materials. --- js/lib/rdge/materials/pulse-material.js | 38 +++++++++++++++------------------ 1 file changed, 17 insertions(+), 21 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 5461c5fb..e3490134 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -25,8 +25,8 @@ var PulseMaterial = function PulseMaterial() this._name = "PulseMaterial"; this._shaderName = "pulse"; - //this._texMap = 'assets/images/cubelight.png'; - this._texMap = 'texture'; + this._texMap = 'assets/images/cubelight.png'; + //this._texMap = 'texture'; this._time = 0.0; this._dTime = 0.01; @@ -118,16 +118,8 @@ var PulseMaterial = function PulseMaterial() this._shader['default'].u_time.set( [this._time] ); } - // check if the texture uses a canvas as the source - var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; - var root = viewUtils.application.ninja.currentDocument.documentRoot; var texMapName = this._propValues[this._propNames[0]]; - var texWorld = this.findWorld( texMapName, root ); - if (texWorld) - { - this._glTex = new Texture( this.getWorld() ); - this._glTex.loadFromCanvas( texWorld.getCanvas() ); - } + this._glTex = new Texture( world, texMapName ); // set the shader values in the shader this.updateTexture(); @@ -145,14 +137,10 @@ var PulseMaterial = function PulseMaterial() var tex; if (this._glTex) { - this._glTex.rerender(); + if (this._glTex.isAnimated()) + this._glTex.rerender(); tex = this._glTex.getTexture(); } - else - { - var texMapName = this._propValues[this._propNames[0]]; - tex = this.loadTexture( texMapName, wrap, mips ); - } if (tex) { technique.u_tex0.set( tex ); @@ -166,12 +154,20 @@ var PulseMaterial = function PulseMaterial() var material = this._materialNode; if (material) { - if (this._glTex && this._glTex.isAnimated()) - this.updateTexture(); - var technique = material.shaderProgram['default']; var renderer = g_Engine.getContext().renderer; - if (renderer && technique) { + if (renderer && technique) + { + if (this._glTex) + { + //this.updateTexture(); + if (this._glTex.isAnimated()) + this._glTex.rerender(); + tex = this._glTex.getTexture(); + if (tex) + technique.u_tex0.set( tex ); + } + if (this._shader && this._shader['default']) { this._shader['default'].u_time.set( [this._time] ); } -- cgit v1.2.3 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/pulse-material.js | 4 ++-- 1 file changed, 2 insertions(+), 2 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 e3490134..b12e9dd5 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -4,7 +4,6 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; var Texture = require("js/lib/rdge/texture").Texture; var Material = require("js/lib/rdge/materials/material").Material; /////////////////////////////////////////////////////////////////////// @@ -220,7 +219,7 @@ var PulseMaterial = function PulseMaterial() } } - + /* this.export = function() { // every material needs the base type and instance name var exportStr = "material: " + this.getShaderName() + "\n"; @@ -261,6 +260,7 @@ var PulseMaterial = function PulseMaterial() return rtnStr; } + */ }; /////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 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/pulse-material.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 b12e9dd5..f7f6c7ae 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -4,8 +4,9 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Texture = require("js/lib/rdge/texture").Texture; var Material = require("js/lib/rdge/materials/material").Material; +var Texture = require("js/lib/rdge/texture").Texture; + /////////////////////////////////////////////////////////////////////// // Class GLMaterial // RDGE representation of a material. @@ -24,8 +25,8 @@ var PulseMaterial = function PulseMaterial() this._name = "PulseMaterial"; this._shaderName = "pulse"; - this._texMap = 'assets/images/cubelight.png'; - //this._texMap = 'texture'; + //this._texMap = 'assets/images/cubelight.png'; + this._texMap = 'texture'; this._time = 0.0; this._dTime = 0.01; @@ -117,6 +118,7 @@ var PulseMaterial = function PulseMaterial() 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 ); -- cgit v1.2.3 From b6a8f72f670a8edee35554a4ca3a0618c526d651 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 5 Apr 2012 05:30:55 -0700 Subject: Re-added taper and twist-vert materials. --- js/lib/rdge/materials/pulse-material.js | 1 - 1 file changed, 1 deletion(-) (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 f7f6c7ae..276f7de6 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -308,7 +308,6 @@ var pulseMaterialDef = } }; -// doing the inheritance here introtudes bugs. Local instance variables are overwritten in the base class //PulseMaterial.prototype = new Material(); if (typeof exports === "object") { -- cgit v1.2.3 From 416ce9d4954e0a7f4ee7b9afe43bf691fdb276f4 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 6 Apr 2012 05:18:48 -0700 Subject: texture notifications --- js/lib/rdge/materials/pulse-material.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (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 276f7de6..0a7a5dd8 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -150,6 +150,20 @@ var PulseMaterial = function PulseMaterial() } }; + + this.updateTextures = function() + { + if (this._glTex) + { + if (!this._glTex.isAnimated()) + { + this._glTex.rerender(); + this.updateTexture(); + } + } + } + + this.update = function( time ) { var material = this._materialNode; -- cgit v1.2.3 From 5b878fdfaa696c1a01afa191c1d65c0ccb006b65 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Sun, 8 Apr 2012 05:26:08 -0700 Subject: Clouds --- js/lib/rdge/materials/pulse-material.js | 6 +++--- 1 file changed, 3 insertions(+), 3 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 0a7a5dd8..9cb500c8 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -139,7 +139,7 @@ var PulseMaterial = function PulseMaterial() if (this._glTex) { if (this._glTex.isAnimated()) - this._glTex.rerender(); + this._glTex.render(); tex = this._glTex.getTexture(); } @@ -157,7 +157,7 @@ var PulseMaterial = function PulseMaterial() { if (!this._glTex.isAnimated()) { - this._glTex.rerender(); + this._glTex.render(); this.updateTexture(); } } @@ -177,7 +177,7 @@ var PulseMaterial = function PulseMaterial() { //this.updateTexture(); if (this._glTex.isAnimated()) - this._glTex.rerender(); + this._glTex.render(); tex = this._glTex.getTexture(); if (tex) technique.u_tex0.set( tex ); -- cgit v1.2.3 From ae7eb87564632ce7c676bd728b8ff2710ff0bb83 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 18 Apr 2012 15:44:26 -0700 Subject: Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Snapping_II Conflicts: js/tools/Rotate3DToolBase.js js/tools/RotateStage3DTool.js js/tools/Translate3DToolBase.js js/tools/modifier-tool-base.js --- js/lib/rdge/materials/pulse-material.js | 5 +++-- 1 file changed, 3 insertions(+), 2 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 9cb500c8..4ba5110e 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -25,8 +25,9 @@ var PulseMaterial = function PulseMaterial() this._name = "PulseMaterial"; this._shaderName = "pulse"; - //this._texMap = 'assets/images/cubelight.png'; - this._texMap = 'texture'; + this._texMap = 'assets/images/cubelight.png'; + //this._texMap = 'assets/images/cloud10.png'; + //this._texMap = 'texture'; this._time = 0.0; this._dTime = 0.01; -- 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/pulse-material.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 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 eedccf71..bb8833b4 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -81,18 +81,19 @@ var PulseMaterial = function PulseMaterial() // save the world if (world) this.setWorld( world ); - // allocate a new uber material - var newMat = new PulseMaterial(); + // get the current values; + var propNames = [], propValues = [], propTypes = [], propLabels = []; + this.getAllProperties(propNames, propValues, propTypes, propLabels); + + // allocate a new material + var newMat = new PulseMaterial(); // copy over the current values; - var propNames = [], propValues = [], propTypes = [], propLabels = []; - this.getAllProperties( propNames, propValues, propTypes, propLabels); - var n = propNames.length; - for (var i=0; i 200.0) this._time = 0.0; + if (this._time > 200.0) this._time = 0.0; } } }; @@ -198,27 +249,35 @@ var PulseMaterial = function PulseMaterial() 'material' : this.getShaderName(), 'name' : this.getName(), 'texture' : this._propValues[this._propNames[0]], - 'dTime' : this._dTime + 'dTime' : this._dTime, + 'speed' : this._speed, + 'xScale' : this._xScale, + 'yScale' : this._yScale }; return jObj; }; this.importJSON = function( jObj ) { - if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); - this.setName( jObj.name ); + if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); + this.setName( jObj.name ); - try { + 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 ); - } + if (jObj.dTime) { + this._dTime = jObj.dTime; + } + + this._speed = jObj.speed; + this._xScale = jObj.xScale; + this._yScale = jObj.yScale; + this.updateParameters(); + } + catch (e) + { + throw new Error( "could not import material: " + jObj ); + } }; }; @@ -249,9 +308,12 @@ var pulseMaterialDef = // parameters 'params' : { - 'u_tex0': { 'type' : 'tex2d' }, - 'u_time' : { 'type' : 'float' }, - 'u_resolution' : { 'type' : 'vec2' }, + 'u_tex0' : { 'type' : 'tex2d' }, + 'u_time' : { 'type' : 'float' }, + 'u_speed' : { 'type' : 'float' }, + 'u_xscale' : { 'type' : 'float' }, + 'u_yscale' : { 'type' : 'float' }, + 'u_resolution' : { 'type' : 'vec2' } }, // render states @@ -268,6 +330,6 @@ var pulseMaterialDef = //PulseMaterial.prototype = new Material(); if (typeof exports === "object") { - exports.PulseMaterial = PulseMaterial; + exports.PulseMaterial = PulseMaterial; } -- cgit v1.2.3 From 50ede4afa801f53caff7939dad0408f9a0a8b744 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 22 May 2012 15:44:51 -0700 Subject: Editable parameters for flag, pulse, uber, and radial gradient materials. --- js/lib/rdge/materials/pulse-material.js | 2 -- 1 file changed, 2 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 56c10f21..28f3ee5e 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -224,8 +224,6 @@ var PulseMaterial = function PulseMaterial() this._shader['default'].u_time.set( [this._time] ); } this._time += this._dTime; - - if (this._time > 200.0) this._time = 0.0; } } }; -- cgit v1.2.3 From f0bbd7688bcf2c6b8f749c7c6061ac09640ab08c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 4 Jun 2012 11:35:17 -0700 Subject: Avoid throwing shader errors in the console for 'color' property at a base class level. --- js/lib/rdge/materials/pulse-material.js | 4 ++-- 1 file changed, 2 insertions(+), 2 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 28f3ee5e..374a5eae 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -61,8 +61,8 @@ var PulseMaterial = function PulseMaterial() this.setProperty = function( prop, value ) { // make sure we have legitimate imput var ok = this.validateProperty( prop, value ); - if (!ok) { - console.log( "invalid property in Radial Gradient Material:" + prop + " : " + value ); + if (!ok && (prop != 'color')) { + console.log( "invalid property in Material:" + prop + " : " + value ); } switch (prop) -- 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/pulse-material.js | 189 ++++---------------------------- 1 file changed, 23 insertions(+), 166 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 374a5eae..7c00b836 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -30,69 +30,30 @@ var PulseMaterial = function PulseMaterial() this._time = 0.0; this._dTime = 0.01; - this._xScale = 0.5; - this._yScale = 0.4; - this._speed = 1.0; - /////////////////////////////////////////////////////////////////////// // Property Accessors /////////////////////////////////////////////////////////////////////// - this.getName = function() { return this._name; }; - this.getShaderName = function() { return this._shaderName; }; - - this.getTextureMap = function() { return this._propValues[this._propNames[0]] ? this._propValues[this._propNames[0]].slice() : null }; - this.setTextureMap = function(m) { this._propValues[this._propNames[0]] = m ? m.slice(0) : null; this.updateTexture(); }; - - this.isAnimated = function() { return true; }; + this.isAnimated = function() { return true; }; + this.getShaderDef = function() { return pulseMaterialDef; } /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// - this._propNames = ["texmap", "xscale", "yscale", "speed" ]; + + var u_tex0_index = 0, + u_xScale_index = 1, + u_yScale_index = 2, + u_speed_index = 3; + + this._propNames = ["u_tex0", "u_xscale", "u_yscale", "u_speed" ]; this._propLabels = ["Texture map", "X Range", "Y Range", "Speed" ]; this._propTypes = ["file", "float", "float", "float"]; this._propValues = []; - this._propValues[ this._propNames[0] ] = this._texMap.slice(0); - this._propValues[ this._propNames[1] ] = this._xScale; - this._propValues[ this._propNames[2] ] = this._yScale; - this._propValues[ this._propNames[3] ] = this._speed; - - this.setProperty = function( prop, value ) { - // make sure we have legitimate imput - var ok = this.validateProperty( prop, value ); - if (!ok && (prop != 'color')) { - console.log( "invalid property in Material:" + prop + " : " + value ); - } - - switch (prop) - { - case "texmap": - this.setTextureMap(value); - break; - - case "speed": - this._speed = value; - this._propValues[ this._propNames[3] ] = this._speed; - this.updateParameters(); - break; - - case "xscale": - this._xScale = value; - this._propValues[ this._propNames[1] ] = this._xScale; - this.updateParameters(); - break; - - case "yscale": - this._yScale = value; - this._propValues[ this._propNames[2] ] = this._yScale; - this.updateParameters(); - break; - - case "color": - break; - } - }; + this._propValues[ this._propNames[ u_tex0_index] ] = this._texMap.slice(0); + this._propValues[ this._propNames[u_xScale_index] ] = 0.5; + this._propValues[ this._propNames[u_yScale_index] ] = 0.4; + this._propValues[ this._propNames[ u_speed_index] ] = 1.0; /////////////////////////////////////////////////////////////////////// @@ -100,26 +61,9 @@ var PulseMaterial = function PulseMaterial() // Methods /////////////////////////////////////////////////////////////////////// // duplicate method required - this.dup = function( world ) { - // save the world - if (world) this.setWorld( world ); - - // get the current values; - var propNames = [], propValues = [], propTypes = [], propLabels = []; - this.getAllProperties(propNames, propValues, propTypes, propLabels); - - // allocate a new material - var newMat = new PulseMaterial(); - - // 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 ) { + this.init = function( world ) + { // save the world if (world) this.setWorld( world ); @@ -140,67 +84,17 @@ var PulseMaterial = function PulseMaterial() if (this._shader && this._shader['default']) { this._shader['default'].u_time.set( [this._time] ); } - this.updateParameters(); // set up the texture - var texMapName = this._propValues[this._propNames[0]]; - this._glTex = new Texture( world, texMapName ); + //var texMapName = this._propValues[this._propNames[0]]; + //this.setProperty( "u_tex0", texMapName ); // set the shader values in the shader - this.updateTexture(); + this.setShaderValues(); this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); this.update( 0 ); }; - this.updateParameters = function() - { - this._propValues[ this._propNames[1] ] = this._xScale; - this._propValues[ this._propNames[2] ] = this._yScale; - this._propValues[ this._propNames[3] ] = this._speed; - - var material = this._materialNode; - if (material) - { - var technique = material.shaderProgram['default']; - var renderer = RDGE.globals.engine.getContext().renderer; - if (renderer && technique) - { - - if (this._shader && this._shader['default']) { - this._shader['default'].u_speed.set( [this._speed] ); - this._shader['default'].u_xscale.set( [this._xScale] ); - this._shader['default'].u_yscale.set( [this._yScale] ); - } - } - } - } - - this.updateTexture = function() { - - var texMapName = this._propValues[this._propNames[0]]; - this._glTex = new Texture( this.getWorld(), texMapName ); - - var material = this._materialNode; - if (material) { - var technique = material.shaderProgram['default']; - var renderer = RDGE.globals.engine.getContext().renderer; - if (renderer && technique) { - var wrap = 'REPEAT', mips = true; - var tex; - if (this._glTex) - { - if (this._glTex.isAnimated()) - this._glTex.render(); - tex = this._glTex.getTexture(); - } - - if (tex) { - technique.u_tex0.set( tex ); - } - } - } - }; - this.update = function( time ) { var material = this._materialNode; @@ -210,12 +104,13 @@ var PulseMaterial = function PulseMaterial() var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { - if (this._glTex) + var glTex = this._glTextures["u_tex0"]; + if (glTex) { //this.updateTexture(); - if (this._glTex.isAnimated()) - this._glTex.render(); - tex = this._glTex.getTexture(); + if (glTex.isAnimated()) + glTex.render(); + tex = glTex.getTexture(); if (tex) technique.u_tex0.set( tex ); } @@ -239,44 +134,6 @@ 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, - 'speed' : this._speed, - 'xScale' : this._xScale, - 'yScale' : this._yScale - }; - - 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; - } - - this._speed = jObj.speed; - this._xScale = jObj.xScale; - this._yScale = jObj.yScale; - this.updateParameters(); - } - catch (e) - { - throw new Error( "could not import material: " + jObj ); - } - }; }; /////////////////////////////////////////////////////////////////////////////////////// -- 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/pulse-material.js | 4 ---- 1 file changed, 4 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 7c00b836..ca4b940b 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -85,10 +85,6 @@ var PulseMaterial = function PulseMaterial() this._shader['default'].u_time.set( [this._time] ); } - // set up the texture - //var texMapName = this._propValues[this._propNames[0]]; - //this.setProperty( "u_tex0", texMapName ); - // set the shader values in the shader this.setShaderValues(); this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); -- 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/pulse-material.js | 2 ++ 1 file changed, 2 insertions(+) (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 ca4b940b..2c0fc04c 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -30,6 +30,8 @@ var PulseMaterial = function PulseMaterial() this._time = 0.0; this._dTime = 0.01; + 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/pulse-material.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 2c0fc04c..155bd8a9 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -22,7 +22,7 @@ var PulseMaterial = function PulseMaterial() /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// - this._name = "PulseMaterial"; + this._name = "Pulse"; this._shaderName = "pulse"; this._texMap = 'assets/images/cubelight.png'; -- cgit v1.2.3