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/material.js | 7 +++++++ js/lib/rdge/materials/pulse-material.js | 14 ++++++++++++++ js/lib/rdge/materials/uber-material.js | 24 ++++++++++++++++++++++++ 3 files changed, 45 insertions(+) (limited to 'js/lib/rdge/materials') diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index a81ca18f..bc4c8e6b 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js @@ -257,6 +257,13 @@ var Material = function GLMaterial( world ) { return tex; }; + this.updateTextures = function() + { + // this function is called whenever a world that generates textuers for + // the current world changes in some way. Sub-classes with textures + // should override this function. + } + this.export = function() { // this function should be overridden by subclasses var exportStr = "material: " + this.getShaderName() + "\n" + "endMaterial\n"; 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; diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js index ca244629..71354216 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js @@ -286,6 +286,30 @@ var UberMaterial = function UberMaterial() { } }; + + this.updateTextures = function() + { + var material = this._materialNode; + if (material) + { + var technique = material.shaderProgram.defaultTechnique; + var renderer = g_Engine.getContext().renderer; + if (renderer && technique) + { + if (this._diffuseTexture) + { + if (!this._diffuseTexture.isAnimated()) + { + this._diffuseTexture.rerender(); + var tex = this._diffuseTexture.getTexture(); + technique.s_diffuseMap.set( tex ); + } + } + } + } + } + + this.updateSpecularMap = function() { var value = this._propValues[ "specularMap" ]; this._specularMapOb.texture = value; -- cgit v1.2.3