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/julia-material.js | 52 ++++++++++----------------------- 1 file changed, 15 insertions(+), 37 deletions(-) (limited to 'js/lib/rdge/materials/julia-material.js') diff --git a/js/lib/rdge/materials/julia-material.js b/js/lib/rdge/materials/julia-material.js index a06b1771..63367e16 100644 --- a/js/lib/rdge/materials/julia-material.js +++ b/js/lib/rdge/materials/julia-material.js @@ -14,7 +14,7 @@ var JuliaMaterial = function JuliaMaterial() { this._name = "JuliaMaterial"; this._shaderName = "julia"; - this._texMap = 'assets/images/rocky-normal.jpg'; + this._defaultTexMap = 'assets/images/rocky-normal.jpg'; this._time = 0.0; this._dTime = 0.01; @@ -22,27 +22,22 @@ var JuliaMaterial = function JuliaMaterial() { /////////////////////////////////////////////////////////////////////// // Properties /////////////////////////////////////////////////////////////////////// - // properties inherited from PulseMaterial + var u_speed_index = 0; + this._propNames = [ "u_speed" ]; + this._propLabels = [ "Speed" ]; + this._propTypes = [ "float" ]; + this._propValues = []; + this._propValues[this._propNames[u_speed_index]] = 1.0; + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + this.isAnimated = function() { return true; }; + this.getShaderDef = function() { return JuliaMaterialDef; } /////////////////////////////////////////////////////////////////////// // 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 JuliaMaterial(); - - // 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 @@ -62,28 +57,11 @@ var JuliaMaterial = function JuliaMaterial() { 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.setShaderValues(); this.setResolution( [world.getViewportWidth(),world.getViewportHeight()] ); this.update( 0 ); }; - - this.update = function( time ) { - 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_time.set( [this._time] ); - } - this._time = time; - } - } - }; } /////////////////////////////////////////////////////////////////////////////////////// @@ -113,8 +91,8 @@ var JuliaMaterialDef = // parameters 'params' : { - 'u_tex0': { 'type' : 'tex2d' }, 'u_time' : { 'type' : 'float' }, + 'u_speed' : { 'type' : 'float' }, 'u_resolution' : { 'type' : 'vec2' }, }, -- cgit v1.2.3