aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge')
-rwxr-xr-xjs/lib/rdge/materials/material.js7
-rw-r--r--js/lib/rdge/materials/pulse-material.js14
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js24
-rw-r--r--js/lib/rdge/texture.js25
4 files changed, 66 insertions, 4 deletions
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 ) {
257 return tex; 257 return tex;
258 }; 258 };
259 259
260 this.updateTextures = function()
261 {
262 // this function is called whenever a world that generates textuers for
263 // the current world changes in some way. Sub-classes with textures
264 // should override this function.
265 }
266
260 this.export = function() { 267 this.export = function() {
261 // this function should be overridden by subclasses 268 // this function should be overridden by subclasses
262 var exportStr = "material: " + this.getShaderName() + "\n" + "endMaterial\n"; 269 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()
150 } 150 }
151 }; 151 };
152 152
153
154 this.updateTextures = function()
155 {
156 if (this._glTex)
157 {
158 if (!this._glTex.isAnimated())
159 {
160 this._glTex.rerender();
161 this.updateTexture();
162 }
163 }
164 }
165
166
153 this.update = function( time ) 167 this.update = function( time )
154 { 168 {
155 var material = this._materialNode; 169 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() {
286 } 286 }
287 }; 287 };
288 288
289
290 this.updateTextures = function()
291 {
292 var material = this._materialNode;
293 if (material)
294 {
295 var technique = material.shaderProgram.defaultTechnique;
296 var renderer = g_Engine.getContext().renderer;
297 if (renderer && technique)
298 {
299 if (this._diffuseTexture)
300 {
301 if (!this._diffuseTexture.isAnimated())
302 {
303 this._diffuseTexture.rerender();
304 var tex = this._diffuseTexture.getTexture();
305 technique.s_diffuseMap.set( tex );
306 }
307 }
308 }
309 }
310 }
311
312
289 this.updateSpecularMap = function() { 313 this.updateSpecularMap = function() {
290 var value = this._propValues[ "specularMap" ]; 314 var value = this._propValues[ "specularMap" ];
291 this._specularMapOb.texture = value; 315 this._specularMapOb.texture = value;
diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js
index d2f66efa..f1448195 100644
--- a/js/lib/rdge/texture.js
+++ b/js/lib/rdge/texture.js
@@ -6,6 +6,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
6 6
7var Material = require("js/lib/rdge/materials/material").Material; 7var Material = require("js/lib/rdge/materials/material").Material;
8 8
9var __textureCounter = 0;
10
9/////////////////////////////////////////////////////////////////////// 11///////////////////////////////////////////////////////////////////////
10// Class GLTexture 12// Class GLTexture
11// GL representation of a texture. 13// GL representation of a texture.
@@ -38,6 +40,9 @@ function Texture( dstWorld, texMapName, wrap, mips )
38 // the destination world that will use the texture map 40 // the destination world that will use the texture map
39 this._dstWorld = dstWorld; 41 this._dstWorld = dstWorld;
40 42
43 this._texCount = __textureCounter;
44 __textureCounter++;
45
41 /////////////////////////////////////////////////////////////////////// 46 ///////////////////////////////////////////////////////////////////////
42 // Property Accessors 47 // Property Accessors
43 /////////////////////////////////////////////////////////////////////// 48 ///////////////////////////////////////////////////////////////////////
@@ -89,7 +94,8 @@ function Texture( dstWorld, texMapName, wrap, mips )
89 console.log( "texture callback, type: " + type ); 94 console.log( "texture callback, type: " + type );
90 if (calleeData.srcWorld) 95 if (calleeData.srcWorld)
91 { 96 {
92 var srcWorld = calleeData.srcWorld; 97 var srcWorld = callbackObj.getSrcWorld();
98 var dstWorld = callbackObj.getDstWorld();
93 var notifier = srcWorld._notifier; 99 var notifier = srcWorld._notifier;
94 var texture = this.callbackObj; 100 var texture = this.callbackObj;
95 if (texture) 101 if (texture)
@@ -103,9 +109,20 @@ function Texture( dstWorld, texMapName, wrap, mips )
103 break; 109 break;
104 110
105 case notifier.OBJECT_CHANGE: 111 case notifier.OBJECT_CHANGE:
106 if (!texture.isAnimated()) 112// this._isAnimated = srcWorld._hasAnimatedMaterials;
107 texture.rerender(); 113// if (!srcWorld.hasAnimatedMaterials())
108 texture.getDstWorld().restartRenderLoop(); 114// srcWorld.restartRenderLoop();
115// else if (!dstWorld.hasAnimatedMaterials())
116// {
117// dstWorld.refreshTextures();
118// dstWorld.restartRenderLoop();
119// }
120 break;
121
122 case notifier.FIRST_RENDER:
123 texture._isAnimated = srcWorld.hasAnimatedMaterials();
124 dstWorld.refreshTextures();
125 dstWorld.restartRenderLoop();
109 break; 126 break;
110 127
111 default: 128 default: