From f83a04cda688cc9680749fffae6c0b9fa0c2087f Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 13:29:01 -0800 Subject: Added asset folder replacement to runtime load. --- assets/CanvasRuntime.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/assets/CanvasRuntime.js b/assets/CanvasRuntime.js index d16613ca..5caf72ee 100644 --- a/assets/CanvasRuntime.js +++ b/assets/CanvasRuntime.js @@ -11,8 +11,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot /////////////////////////////////////////////////////////////////////// function CanvasDataManager() { - this.loadGLData = function(root, valueArray ) + this.loadGLData = function(root, valueArray, assetPath ) { + this._assetPath = assetPath.slice(); + var value = valueArray; var nWorlds = value.length; for (var i=0; i= 0) + { + rtnPath = url.substr( index + searchStr.length ); + rtnPath = this._assetPath + rtnPath; + } + return rtnPath; + } + this.findMaterialNode = function( nodeName, node ) { if (node.transformNode) @@ -1121,7 +1141,7 @@ function RuntimePulseMaterial() this._texMap = this.getPropertyFromString( "texture: ", importStr ); } - this.init = function() + this.init = function( world ) { var material = this._materialNode; if (material) @@ -1136,6 +1156,7 @@ function RuntimePulseMaterial() 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 ); @@ -1284,17 +1305,20 @@ function RuntimeBumpMetalMaterial() 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 ); } -- cgit v1.2.3 From e92a6da7b84c58803489d70efedf74837ddfe4cd Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 9 Mar 2012 13:34:09 -0800 Subject: Removed asset path replacement at authortime. --- js/document/html-document.js | 6 +++--- js/lib/drawing/world.js | 23 +---------------------- js/lib/rdge/materials/bump-metal-material.js | 6 +++--- js/lib/rdge/materials/pulse-material.js | 2 +- js/lib/rdge/materials/radial-blur-material.js | 2 +- js/lib/rdge/materials/uber-material.js | 8 ++++---- 6 files changed, 13 insertions(+), 34 deletions(-) diff --git a/js/document/html-document.js b/js/document/html-document.js index aa56fd0e..f57c61ee 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -197,7 +197,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { //if (path) { //this.collectGLData(elt, this._glData, path); //} else { - this.collectGLData(elt, this._glData, "assets/"); + this.collectGLData(elt, this._glData ); //} } else { this._glData = null @@ -368,11 +368,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { collectGLData: { - value: function( elt, dataArray, imagePath ) + value: function( elt, dataArray ) { if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) { - var data = elt.elementModel.shapeModel.GLWorld.export( imagePath ); + var data = elt.elementModel.shapeModel.GLWorld.export(); dataArray.push( data ); } diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index cffd0083..44c9e37d 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -727,7 +727,7 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { } }; -World.prototype.export = function( imagePath ) +World.prototype.export = function() { var exportStr = "GLWorld 1.0\n"; var id = this.getCanvas().getAttribute( "data-RDGE-id" ); @@ -747,13 +747,6 @@ World.prototype.export = function( imagePath ) var exportForPublish = true; exportStr += "publish: " + exportForPublish + "\n"; - // the relative path for local assets needs to be modified to - // the path specified by argument 'imagePath'. Save that path - // so exporting functions can call newPath = world.cleansePath( oldPath ); - this._imagePath = imagePath.slice(); - var endchar = this._imagePath[this._imagePath.length-1] - if (endchar != '/') this._imagePath += '/'; - if (exportForPublish && this._useWebGL) { exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; @@ -937,20 +930,6 @@ World.prototype.importSubObject = function( objStr, parentNode ) { return trNode; }; -World.prototype.cleansePath = function( url ) -{ - //this._imagePath - var searchStr = "assets/"; - var index = url.indexOf( searchStr ); - var rtnPath = url; - if (index >= 0) - { - rtnPath = url.substr( index + searchStr.length ); - rtnPath = this._imagePath + rtnPath; - } - return rtnPath; -} - if (typeof exports === "object") { exports.World = World; } \ No newline at end of file diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index 70873885..fa6f5300 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js @@ -163,9 +163,9 @@ var BumpMetalMaterial = function BumpMetalMaterial() { throw new Error( "no world in material.export, " + this.getName() ); exportStr += "lightDiff: " + this.getLightDiff() + "\n"; - exportStr += "diffuseTexture: " + world.cleansePath(this.getDiffuseTexture()) + "\n"; - exportStr += "specularTexture: " + world.cleansePath(this.getSpecularTexture()) + "\n"; - exportStr += "normalMap: " + world.cleansePath(this.getNormalTexture()) + "\n"; + exportStr += "diffuseTexture: " + this.getDiffuseTexture() + "\n"; + exportStr += "specularTexture: " + this.getSpecularTexture() + "\n"; + exportStr += "normalMap: " + this.getNormalTexture() + "\n"; // every material needs to terminate like this exportStr += "endMaterial\n"; diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 8ad78bd4..81db36c6 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -183,7 +183,7 @@ var PulseMaterial = function PulseMaterial() { if (!world) throw new Error( "no world in material.export, " + this.getName() ); - var texMapName = world.cleansePath( this._propValues[this._propNames[0]] ); + var texMapName = this._propValues[this._propNames[0]]; exportStr += "texture: " +texMapName + "\n"; // every material needs to terminate like this diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index f23f0712..46cdda74 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js @@ -166,7 +166,7 @@ var RadialBlurMaterial = function RadialBlurMaterial() { if (!world) throw new Error( "no world in material.export, " + this.getName() ); - var texMapName = world.cleansePath( this._propValues[this._propNames[0]] ); + var texMapName = this._propValues[this._propNames[0]]; exportStr += "texture: " + texMapName + "\n"; // every material needs to terminate like this diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js index d120ffa1..655d8e2a 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js @@ -457,16 +457,16 @@ var UberMaterial = function UberMaterial() { throw new Error( "no world in material.export, " + this.getName() ); if(typeof caps.diffuseMap != 'undefined') - exportStr += "diffuseMap: " + world.cleansePath(caps.diffuseMap.texture) + "\n"; + exportStr += "diffuseMap: " + caps.diffuseMap.texture + "\n"; if(typeof caps.normalMap != 'undefined') - exportStr += "normalMap: " + world.cleansePath(caps.normalMap.texture) + "\n"; + exportStr += "normalMap: " + caps.normalMap.texture + "\n"; if(typeof caps.specularMap != 'undefined') - exportStr += "specularMap: " + world.cleansePath(caps.specularMap.texture) + "\n"; + exportStr += "specularMap: " + caps.specularMap.texture + "\n"; if(typeof caps.environmentMap != 'undefined') - exportStr += "environmentMap: " + world.cleansePath(caps.environmentMap.texture) + "\n"; + exportStr += "environmentMap: " + caps.environmentMap.texture + "\n"; // every material needs to terminate like this exportStr += "endMaterial\n"; -- cgit v1.2.3