From 9e048d2cf359c305e895fe7c0bebf09016896531 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 15:11:48 -0800 Subject: remap hard coded strings in rdge internal code. --- js/helper-classes/RDGE/src/core/script/engine.js | 15 +++++++++++++++ js/helper-classes/RDGE/src/core/script/fx/ssao.js | 2 +- js/helper-classes/RDGE/src/core/script/init_state.js | 12 ++++++------ js/helper-classes/RDGE/src/core/script/jshader.js | 8 ++++---- js/helper-classes/RDGE/src/core/script/renderer.js | 1 + js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | 2 +- js/helper-classes/RDGE/src/core/script/utilities.js | 4 ++-- 7 files changed, 30 insertions(+), 14 deletions(-) (limited to 'js/helper-classes/RDGE/src/core/script') diff --git a/js/helper-classes/RDGE/src/core/script/engine.js b/js/helper-classes/RDGE/src/core/script/engine.js index 5bc9305c..f5724665 100755 --- a/js/helper-classes/RDGE/src/core/script/engine.js +++ b/js/helper-classes/RDGE/src/core/script/engine.js @@ -89,6 +89,8 @@ stateManager = function() g_enableBenchmarks = true; function Engine() { + this._assetPath = "assets/"; + // map of scene graphs to names this.sceneMap = []; @@ -228,6 +230,19 @@ function Engine() contextManager.currentCtx = savedCtx; } + + this.remapAssetFolder = function( url ) + { + var searchStr = "assets/"; + var index = url.indexOf( searchStr ); + var rtnPath = url; + if (index >= 0) + { + rtnPath = url.substr( index + searchStr.length ); + rtnPath = this._assetPath + rtnPath; + } + return rtnPath; + } } diff --git a/js/helper-classes/RDGE/src/core/script/fx/ssao.js b/js/helper-classes/RDGE/src/core/script/fx/ssao.js index 05793594..9761b02d 100755 --- a/js/helper-classes/RDGE/src/core/script/fx/ssao.js +++ b/js/helper-classes/RDGE/src/core/script/fx/ssao.js @@ -32,7 +32,7 @@ function fxSSAO(enHRDepth) } // Load random normal texture - this.randTexture = createTexture(gl, "assets/images/random_normal.png"); + this.randTexture = createTexture(gl, g_Engine._assetPath+"images/random_normal.png"); gl.bindTexture(gl.TEXTURE_2D, this.randTexture); gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.REPEAT); diff --git a/js/helper-classes/RDGE/src/core/script/init_state.js b/js/helper-classes/RDGE/src/core/script/init_state.js index 4b97a4f4..5ffbbd13 100755 --- a/js/helper-classes/RDGE/src/core/script/init_state.js +++ b/js/helper-classes/RDGE/src/core/script/init_state.js @@ -42,16 +42,16 @@ LoadState.prototype.Init = function() if(this.sceneName) { this.loadScene("assets_web/mesh/" + this.sceneName + ".json", this.sceneName); - } - - if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) - this.userRunState.onLoadState(); + } + + if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) + this.userRunState.onLoadState(); } LoadState.prototype.ReInit = function() { - if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) - this.userRunState.onLoadState(); + if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) + this.userRunState.onLoadState(); } LoadState.prototype.Resize = function() diff --git a/js/helper-classes/RDGE/src/core/script/jshader.js b/js/helper-classes/RDGE/src/core/script/jshader.js index 36c5939e..ceb67536 100755 --- a/js/helper-classes/RDGE/src/core/script/jshader.js +++ b/js/helper-classes/RDGE/src/core/script/jshader.js @@ -191,8 +191,8 @@ jshader = function(addr) { case "mat2": this.data = [0, 0, 0, 0]; break; case "float": this.data = [0]; break; case "int": this.data = [0]; break; - case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; - case "texCube": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; + case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; + case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; } } else { @@ -243,8 +243,8 @@ jshader = function(addr) { case "mat2": this.data = [0, 0, 0, 0]; break; case "float": this.data = [0]; break; case "int": this.data = [0]; break; - case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; - case "texCube": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; + case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; + case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break; } } else { diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index a50b8a68..c01068a4 100755 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js @@ -338,6 +338,7 @@ _renderer = function(canvas) { if (tex === undefined) { // load the texture + name = g_Engine.remapAssetFolder( name ); tex = this.createTexture(name + ext, wrap, mips); this.textureMap[name] = tex; tex.lookUpName = name; diff --git a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js index e80a14fb..93ee12bf 100755 --- a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js +++ b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js @@ -336,7 +336,7 @@ materialNodeTemplate = function(matNode) matNode.setTexture = function(texType, texName) { var renderer = g_Engine.getContext().renderer; - this.textureList[texType].handle = renderer.getTextureByName("assets/images/" + texName); + this.textureList[texType].handle = renderer.getTextureByName(g_Engine._assetPath+"/images/" + texName); this.textureList[texType].unit = texType; this.textureList[texType].type = UNIFORMTYPE.TEXTURE2D; diff --git a/js/helper-classes/RDGE/src/core/script/utilities.js b/js/helper-classes/RDGE/src/core/script/utilities.js index e19c727f..e55f2b33 100755 --- a/js/helper-classes/RDGE/src/core/script/utilities.js +++ b/js/helper-classes/RDGE/src/core/script/utilities.js @@ -159,7 +159,7 @@ function createShader(ctx, strVertShaderName, strFragShaderName, attribs) } else { var vshaderRequest = new XMLHttpRequest(); - vshaderRequest.open("GET", 'assets/shaders/' + strVertShaderName + '.glsl', false); + vshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strVertShaderName + '.glsl', false); vshaderRequest.send(null); vShader = vshaderRequest.responseText; } @@ -169,7 +169,7 @@ function createShader(ctx, strVertShaderName, strFragShaderName, attribs) } else { var fshaderRequest = new XMLHttpRequest(); - fshaderRequest.open("GET", 'assets/shaders/' + strFragShaderName + '.glsl', false); + fshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strFragShaderName + '.glsl', false); fshaderRequest.send(null); fShader = fshaderRequest.responseText; } -- cgit v1.2.3