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/water-material.js | 45 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'js/lib/rdge/materials/water-material.js') diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js index 1f0aa46e..8dbb3233 100644 --- a/js/lib/rdge/materials/water-material.js +++ b/js/lib/rdge/materials/water-material.js @@ -50,22 +50,6 @@ var WaterMaterial = function WaterMaterial() { /////////////////////////////////////////////////////////////////////// // 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 WaterMaterial(); - - // 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.setProperty = function( prop, value ) { // make sure we have legitimate imput @@ -142,6 +126,32 @@ var WaterMaterial = function WaterMaterial() { this.updateTexture(); } + 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.setEmboss = function( value ) { this._emboss = value; @@ -251,6 +261,7 @@ var waterMaterialDef = } }; +/* var ParisMaterial = function ParisMaterial() { // initialize the inherited members this.inheritedFrom = WaterMaterial; @@ -349,7 +360,7 @@ var parisMaterialDef = ] } }; - +*/ WaterMaterial.prototype = new PulseMaterial(); -- cgit v1.2.3