From 7433f0bfbc3a7ea44320550ed2c1d90dc5e6f170 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 16:27:01 -0700 Subject: Removed the dependence on an "assets" directory for the RDGE runtime. Now Ninja does not need to create duplicate files when it sets up the users Ninja Projects directory for RDGE support. --- assets/canvas-runtime.js | 38 ++++++++++++-------------------------- assets/rdge-compiled.js | 12 ++++++------ 2 files changed, 18 insertions(+), 32 deletions(-) (limited to 'assets') diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index 6278fdac..a35f473d 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -104,6 +104,7 @@ NinjaCvsRt.GLRuntime = function ( canvas, jObj, assetPath ) this._initialized = false; this._useWebGL = false; + this._assetPath = undefined; // view parameters this._fov = 45.0; @@ -120,13 +121,17 @@ NinjaCvsRt.GLRuntime = function ( canvas, jObj, assetPath ) // all "live" materials this._materials = []; - // provide the mapping for the asset directory - if (assetPath) - { - this._assetPath = assetPath.slice(); - if (this._assetPath[this._assetPath.length-1] != '/') - this._assetPath += '/'; - } + // provide the mapping for the asset directory + if (assetPath) + { + this._assetPath = assetPath.slice(); + if (this._assetPath[this._assetPath.length-1] != '/') + this._assetPath += '/'; + } + + if(this._assetPath !== undefined) { + RDGE.globals.engine.setAssetPath(this._assetPath); + } /////////////////////////////////////////////////////////////////////// // accessors @@ -366,21 +371,6 @@ NinjaCvsRt.GLRuntime = function ( canvas, jObj, assetPath ) } }; - 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; - - return url; - }; - this.findMaterialNode = function( nodeName, node ) { if (node.transformNode) @@ -1257,7 +1247,6 @@ NinjaCvsRt.RuntimePulseMaterial = function () technique.u_resolution.set( res ); var wrap = 'REPEAT', mips = true; - this._texMap = world.remapAssetFolder( this._texMap ); var tex = renderer.getTextureByName(this._texMap, wrap, mips ); if (tex) technique.u_tex0.set( tex ); @@ -1399,19 +1388,16 @@ NinjaCvsRt.RuntimeBumpMetalMaterial = function () var wrap = 'REPEAT', mips = true; if (this._diffuseTexture) { - this._diffuseTexture = world.remapAssetFolder( this._diffuseTexture ); tex = renderer.getTextureByName(this._diffuseTexture, wrap, mips ); if (tex) technique.u_colMap.set( tex ); } if (this._normalTexture) { - this._normalTexture = world.remapAssetFolder( this._normalTexture ); tex = renderer.getTextureByName(this._normalTexture, wrap, mips ); if (tex) technique.u_normalMap.set( tex ); } if (this._specularTexture) { - this._specularTexture = world.remapAssetFolder( this._specularTexture ); tex = renderer.getTextureByName(this._specularTexture, wrap, mips ); technique.u_glowMap.set( tex ); } diff --git a/assets/rdge-compiled.js b/assets/rdge-compiled.js index 66bf5a42..0bbcb05b 100755 --- a/assets/rdge-compiled.js +++ b/assets/rdge-compiled.js @@ -107,11 +107,11 @@ t);this.def[t]=null;break}for(var n in RDGE.rdgeGlobalParameters){l=new globalPa 0,o;for(o in RDGE.globals.engine.lightManager.lightUniforms[m]){loc=this.ctx.getUniformLocation(h,o);if(loc!=null){this[t].passes[g].lightParams[m]||(this[t].passes[g].lightParams[m]=[]);this[t].passes[g].lightParams[m].push({loc:loc,name:o,dataIndex:p})}p++}}for(n in d[g].params)if(typeof d[g].params[n]!="string"){l=new paramType(this.ctx,n,d[g].params,h,t);this[t].passes[g].params[n]=l;this[t][n]=l}for(n in d[g].params)typeof d[g].params[n]=="string"&&(this[t][n]=this[t].passes[g].params[n]);g++}}for(t in a){f= this[t].passes.length;for(g=0;g");var c=this.def.shaders[a.vshader],d=this.def.shaders[a.fshader];this.ctx.useProgram(null);var f=null,g=null;if(c.indexOf("{")!=-1)g=c;else{g=new XMLHttpRequest;g.open("GET",c,false);g.send(null);g=g.responseText}f=this.buildShader(this.ctx.VERTEX_SHADER,g);g=null;if(c.indexOf("{")!=-1)g=d;else{g=new XMLHttpRequest;g.open("GET",d,false);g.send(null);g=g.responseText}g=this.buildShader(this.ctx.FRAGMENT_SHADER, -g);if(!f||!g)return null;this.compiledShaders[a.vshader]=f;this.compiledShaders[a.fshader]=g;c=this.ctx.createProgram();if(!c)return null;this.ctx.attachShader(c,f);this.ctx.attachShader(c,g);d=0;a.attribPairs=[];for(var h in a.attributes){a.attribPairs.push({loc:d,name:h});this.ctx.bindAttribLocation(c,d++,h)}this.ctx.linkProgram(c);if(!this.ctx.getProgramParameter(c,this.ctx.LINK_STATUS)){a=this.ctx.getProgramInfoLog(c);window.console.log("Error in program linking:"+a);this.ctx.deleteProgram(c); -this.ctx.deleteProgram(g);this.ctx.deleteProgram(f);return null}return c};this.setLightContext=function(a){for(t in this.technique)for(var c=this.technique.passes.length,d=0;d");var c=RDGE.globals.engine.remapAssetFolder(this.def.shaders[a.vshader]),d=RDGE.globals.engine.remapAssetFolder(this.def.shaders[a.fshader]);this.ctx.useProgram(null);var f=null,g=null;if(c.indexOf("{")!=-1)g=c;else{g=new XMLHttpRequest;g.open("GET",c,false);g.send(null);g=g.responseText}f=this.buildShader(this.ctx.VERTEX_SHADER,g);g=null;if(c.indexOf("{")!=-1)g=d;else{g=new XMLHttpRequest;g.open("GET", +d,false);g.send(null);g=g.responseText}g=this.buildShader(this.ctx.FRAGMENT_SHADER,g);if(!f||!g)return null;this.compiledShaders[a.vshader]=f;this.compiledShaders[a.fshader]=g;c=this.ctx.createProgram();if(!c)return null;this.ctx.attachShader(c,f);this.ctx.attachShader(c,g);d=0;a.attribPairs=[];for(var h in a.attributes){a.attribPairs.push({loc:d,name:h});this.ctx.bindAttribLocation(c,d++,h)}this.ctx.linkProgram(c);if(!this.ctx.getProgramParameter(c,this.ctx.LINK_STATUS)){a=this.ctx.getProgramInfoLog(c); +window.console.log("Error in program linking:"+a);this.ctx.deleteProgram(c);this.ctx.deleteProgram(g);this.ctx.deleteProgram(f);return null}return c};this.setLightContext=function(a){for(t in this.technique)for(var c=this.technique.passes.length,d=0;d