aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/engine.js15
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/fx/ssao.js2
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/init_state.js12
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/jshader.js8
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/renderer.js1
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/scenegraphNodes.js2
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/utilities.js4
-rw-r--r--js/helper-classes/RDGE/src/tools/rdge-compiled.js64
8 files changed, 62 insertions, 46 deletions
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()
89g_enableBenchmarks = true; 89g_enableBenchmarks = true;
90function Engine() 90function Engine()
91{ 91{
92 this._assetPath = "assets/";
93
92 // map of scene graphs to names 94 // map of scene graphs to names
93 this.sceneMap = []; 95 this.sceneMap = [];
94 96
@@ -228,6 +230,19 @@ function Engine()
228 contextManager.currentCtx = savedCtx; 230 contextManager.currentCtx = savedCtx;
229 231
230 } 232 }
233
234 this.remapAssetFolder = function( url )
235 {
236 var searchStr = "assets/";
237 var index = url.indexOf( searchStr );
238 var rtnPath = url;
239 if (index >= 0)
240 {
241 rtnPath = url.substr( index + searchStr.length );
242 rtnPath = this._assetPath + rtnPath;
243 }
244 return rtnPath;
245 }
231 246
232} 247}
233 248
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)
32 } 32 }
33 33
34 // Load random normal texture 34 // Load random normal texture
35 this.randTexture = createTexture(gl, "assets/images/random_normal.png"); 35 this.randTexture = createTexture(gl, g_Engine._assetPath+"images/random_normal.png");
36 gl.bindTexture(gl.TEXTURE_2D, this.randTexture); 36 gl.bindTexture(gl.TEXTURE_2D, this.randTexture);
37 gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR); 37 gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR);
38 gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.REPEAT); 38 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()
42 if(this.sceneName) 42 if(this.sceneName)
43 { 43 {
44 this.loadScene("assets_web/mesh/" + this.sceneName + ".json", this.sceneName); 44 this.loadScene("assets_web/mesh/" + this.sceneName + ".json", this.sceneName);
45 } 45 }
46 46
47 if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) 47 if (this.hasUserState && this.userRunState && this.userRunState.onLoadState)
48 this.userRunState.onLoadState(); 48 this.userRunState.onLoadState();
49} 49}
50 50
51LoadState.prototype.ReInit = function() 51LoadState.prototype.ReInit = function()
52{ 52{
53 if (this.hasUserState && this.userRunState && this.userRunState.onLoadState) 53 if (this.hasUserState && this.userRunState && this.userRunState.onLoadState)
54 this.userRunState.onLoadState(); 54 this.userRunState.onLoadState();
55} 55}
56 56
57LoadState.prototype.Resize = function() 57LoadState.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) {
191 case "mat2": this.data = [0, 0, 0, 0]; break; 191 case "mat2": this.data = [0, 0, 0, 0]; break;
192 case "float": this.data = [0]; break; 192 case "float": this.data = [0]; break;
193 case "int": this.data = [0]; break; 193 case "int": this.data = [0]; break;
194 case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; 194 case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break;
195 case "texCube": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; 195 case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break;
196 } 196 }
197 } 197 }
198 else { 198 else {
@@ -243,8 +243,8 @@ jshader = function(addr) {
243 case "mat2": this.data = [0, 0, 0, 0]; break; 243 case "mat2": this.data = [0, 0, 0, 0]; break;
244 case "float": this.data = [0]; break; 244 case "float": this.data = [0]; break;
245 case "int": this.data = [0]; break; 245 case "int": this.data = [0]; break;
246 case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; 246 case "tex2d": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break;
247 case "texCube": this.data = [ctx.canvas.renderer.getTextureByName("assets/images/white.png")]; break; 247 case "texCube": this.data = [ctx.canvas.renderer.getTextureByName(g_Engine._assetPath+"images/white.png")]; break;
248 } 248 }
249 } 249 }
250 else { 250 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) {
338 if (tex === undefined) 338 if (tex === undefined)
339 { 339 {
340 // load the texture 340 // load the texture
341 name = g_Engine.remapAssetFolder( name );
341 tex = this.createTexture(name + ext, wrap, mips); 342 tex = this.createTexture(name + ext, wrap, mips);
342 this.textureMap[name] = tex; 343 this.textureMap[name] = tex;
343 tex.lookUpName = name; 344 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)
336 matNode.setTexture = function(texType, texName) 336 matNode.setTexture = function(texType, texName)
337 { 337 {
338 var renderer = g_Engine.getContext().renderer; 338 var renderer = g_Engine.getContext().renderer;
339 this.textureList[texType].handle = renderer.getTextureByName("assets/images/" + texName); 339 this.textureList[texType].handle = renderer.getTextureByName(g_Engine._assetPath+"/images/" + texName);
340 this.textureList[texType].unit = texType; 340 this.textureList[texType].unit = texType;
341 this.textureList[texType].type = UNIFORMTYPE.TEXTURE2D; 341 this.textureList[texType].type = UNIFORMTYPE.TEXTURE2D;
342 342
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)
159 } else 159 } else
160 { 160 {
161 var vshaderRequest = new XMLHttpRequest(); 161 var vshaderRequest = new XMLHttpRequest();
162 vshaderRequest.open("GET", 'assets/shaders/' + strVertShaderName + '.glsl', false); 162 vshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strVertShaderName + '.glsl', false);
163 vshaderRequest.send(null); 163 vshaderRequest.send(null);
164 vShader = vshaderRequest.responseText; 164 vShader = vshaderRequest.responseText;
165 } 165 }
@@ -169,7 +169,7 @@ function createShader(ctx, strVertShaderName, strFragShaderName, attribs)
169 } else 169 } else
170 { 170 {
171 var fshaderRequest = new XMLHttpRequest(); 171 var fshaderRequest = new XMLHttpRequest();
172 fshaderRequest.open("GET", 'assets/shaders/' + strFragShaderName + '.glsl', false); 172 fshaderRequest.open("GET", g_Engine._assetPath+'shaders/' + strFragShaderName + '.glsl', false);
173 fshaderRequest.send(null); 173 fshaderRequest.send(null);
174 fShader = fshaderRequest.responseText; 174 fShader = fshaderRequest.responseText;
175 } 175 }
diff --git a/js/helper-classes/RDGE/src/tools/rdge-compiled.js b/js/helper-classes/RDGE/src/tools/rdge-compiled.js
index a211d17f..d1040d73 100644
--- a/js/helper-classes/RDGE/src/tools/rdge-compiled.js
+++ b/js/helper-classes/RDGE/src/tools/rdge-compiled.js
@@ -54,14 +54,14 @@ this.ctx.clearColor(1,0,0,1);this.clearColor=[1,0,0,1];this.clearFlags=this.ctx.
545123;this.INT=5124;this.UNSIGNED_INT=5125;this.FLOAT=5126;this.VS_ELEMENT_FLOAT4=4;this.VS_ELEMENT_FLOAT3=this.VS_ELEMENT_NORM=this.VS_ELEMENT_POS=3;this.VS_ELEMENT_UV=this.VS_ELEMENT_FLOAT2=2;this.VS_ELEMENT_FLOAT=1;this.MAX_ELEM_TYPES=7;this.BUFFER_STATIC=35040;this.BUFFER_DYNAMIC=35044;this.BUFFER_STREAM=35048;this.MAX_MATERIAL_LIGHTS=4;this.usedTextureUnits=5;this.vpY=this.vpX=0;this.vpWidth=a.width;this.vpHeight=a.height;this.cameraMan=new cameraManager;this.buffers=[];this.cullBackFace=function(){this.ctx.cullFace(this.ctx.Back)}; 545123;this.INT=5124;this.UNSIGNED_INT=5125;this.FLOAT=5126;this.VS_ELEMENT_FLOAT4=4;this.VS_ELEMENT_FLOAT3=this.VS_ELEMENT_NORM=this.VS_ELEMENT_POS=3;this.VS_ELEMENT_UV=this.VS_ELEMENT_FLOAT2=2;this.VS_ELEMENT_FLOAT=1;this.MAX_ELEM_TYPES=7;this.BUFFER_STATIC=35040;this.BUFFER_DYNAMIC=35044;this.BUFFER_STREAM=35048;this.MAX_MATERIAL_LIGHTS=4;this.usedTextureUnits=5;this.vpY=this.vpX=0;this.vpWidth=a.width;this.vpHeight=a.height;this.cameraMan=new cameraManager;this.buffers=[];this.cullBackFace=function(){this.ctx.cullFace(this.ctx.Back)};
55this.cullFrontFace=function(){this.ctx.cullFace(this.ctx.FRONT)};this.disableCulling=function(){this.ctx.disable(this.ctx.CULL_FACE)};this.enableCulling=function(){this.ctx.enable(this.ctx.CULL_FACE)};this.enablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.disablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.enablePointSprites=function(){};this.disablePointSprites=function(){};this.setClearColor=function(a){this.clearColor=a.slice(); 55this.cullFrontFace=function(){this.ctx.cullFace(this.ctx.FRONT)};this.disableCulling=function(){this.ctx.disable(this.ctx.CULL_FACE)};this.enableCulling=function(){this.ctx.enable(this.ctx.CULL_FACE)};this.enablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.disablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.enablePointSprites=function(){};this.disablePointSprites=function(){};this.setClearColor=function(a){this.clearColor=a.slice();
56this.ctx.clearColor(a[0],a[1],a[2],a[3])};this.setClearFlags=function(a){this.clearFlags=a};this._clear=function(){this.ctx.clear(this.clearFlags)};this.clear=function(a){this.ctx.clear(a)};this.flush=function(){this.ctx.flush()};this.setViewPort=function(a,b,h,l){this.vpX=a;this.vpY=b;this.vpWidth=h;this.vpHeight=l;this.ctx.viewport(this.vpX,this.vpY,this.vpWidth,this.vpHeight)};this.cameraManager=function(){return this.cameraMan};this.textureMap=[];this.rttMap=[];this.getTextureByName=function(a, 56this.ctx.clearColor(a[0],a[1],a[2],a[3])};this.setClearFlags=function(a){this.clearFlags=a};this._clear=function(){this.ctx.clear(this.clearFlags)};this.clear=function(a){this.ctx.clear(a)};this.flush=function(){this.ctx.flush()};this.setViewPort=function(a,b,h,l){this.vpX=a;this.vpY=b;this.vpWidth=h;this.vpHeight=l;this.ctx.viewport(this.vpX,this.vpY,this.vpWidth,this.vpHeight)};this.cameraManager=function(){return this.cameraMan};this.textureMap=[];this.rttMap=[];this.getTextureByName=function(a,
57b,h){var l=a.split(".")[1],n=this.textureMap[a];n===void 0?(n=this.createTexture(a+(l?"":".png"),b,h),this.textureMap[a]=n,n.lookUpName=a,n.previouslyReferenced=!1):n.previouslyReferenced=!0;return n};this.unloadedTextureCount=0;_texparams=function(a,b){this.wrap=a;this.mips=b};this.createTexture=function(a,b,h){var l=this.ctx.createTexture();this.unloadedTextureCount++;b===void 0&&(b="CLAMP");h===void 0&&(h=!0);if(l)l.image=new Image,l.image.src=a,l.image.context=g_Engine.getContext(),l.texparams= 57b,h){var l=a.split(".")[1],l=l?"":".png",n=this.textureMap[a];n===void 0?(a=g_Engine.remapAssetFolder(a),n=this.createTexture(a+l,b,h),this.textureMap[a]=n,n.lookUpName=a,n.previouslyReferenced=!1):n.previouslyReferenced=!0;return n};this.unloadedTextureCount=0;_texparams=function(a,b){this.wrap=a;this.mips=b};this.createTexture=function(a,b,h){var l=this.ctx.createTexture();this.unloadedTextureCount++;b===void 0&&(b="CLAMP");h===void 0&&(h=!0);if(l)l.image=new Image,l.image.src=a,l.image.context=
58new _texparams(b,h),l.image.onload=function(){this.context.ctxStateManager.RDGEInitState.loadTexture(l);this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")},l.image.onerror=function(){this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")};return l};this.commitTexture=function(a){this.ctx.bindTexture(this.ctx.TEXTURE_2D, 58g_Engine.getContext(),l.texparams=new _texparams(b,h),l.image.onload=function(){this.context.ctxStateManager.RDGEInitState.loadTexture(l);this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")},l.image.onerror=function(){this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")};
59a);this.ctx.texImage2D(this.ctx.TEXTURE_2D,0,this.ctx.RGBA,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,a.image);a.texparams.mips&&this.ctx.generateMipmap(this.ctx.TEXTURE_2D);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MAG_FILTER,this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MIN_FILTER,a.texparams.mips?this.ctx.LINEAR_MIPMAP_LINEAR:this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_S,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT: 59return l};this.commitTexture=function(a){this.ctx.bindTexture(this.ctx.TEXTURE_2D,a);this.ctx.texImage2D(this.ctx.TEXTURE_2D,0,this.ctx.RGBA,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,a.image);a.texparams.mips&&this.ctx.generateMipmap(this.ctx.TEXTURE_2D);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MAG_FILTER,this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MIN_FILTER,a.texparams.mips?this.ctx.LINEAR_MIPMAP_LINEAR:this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,
60this.ctx.CLAMP_TO_EDGE);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_T,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.bindTexture(this.ctx.TEXTURE_2D,null)};this.verify=function(a){var b=this.ctx.getError();b!=0&&window.console.log("GLError ( "+a+") : "+b)};this.createRenderTargetTexture=function(a,b,h,l){var n=this.ctx,o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o);o.width=b;o.height=h;b=n.createTexture();n.bindTexture(n.TEXTURE_2D,b); 60this.ctx.TEXTURE_WRAP_S,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_T,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.bindTexture(this.ctx.TEXTURE_2D,null)};this.verify=function(a){var b=this.ctx.getError();b!=0&&window.console.log("GLError ( "+a+") : "+b)};this.createRenderTargetTexture=function(a,b,h,l){var n=this.ctx,o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o);o.width=
61try{n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,null)}catch(p){h=new WebctxUnsignedByteArray(o.width*o.height*4),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,h)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,l?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);l&& 61b;o.height=h;b=n.createTexture();n.bindTexture(n.TEXTURE_2D,b);try{n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,null)}catch(p){h=new WebctxUnsignedByteArray(o.width*o.height*4),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,h)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,l?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE);n.texParameteri(n.TEXTURE_2D,
62n.generateMipmap(n.TEXTURE_2D);l=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,l);n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height);n.getError(n.bindFramebuffer(n.FRAMEBUFFER,o));n.getError(n.bindRenderbuffer(n.RENDERBUFFER,l));n.getEr