aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/run_state.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/run_state.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/run_state.js753
1 files changed, 377 insertions, 376 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/run_state.js b/js/helper-classes/RDGE/src/core/script/run_state.js
index 2bccea6a..82cf975e 100755
--- a/js/helper-classes/RDGE/src/core/script/run_state.js
+++ b/js/helper-classes/RDGE/src/core/script/run_state.js
@@ -1,24 +1,25 @@
1/* <copyright> 1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc 2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved. 3All Rights Reserved.
4BSD License.
5 4
6Redistribution and use in source and binary forms, with or without 5Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met: 6modification, are permitted provided that the following conditions are met:
8 7
9 - Redistributions of source code must retain the above copyright notice, 8* Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer. 9 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright 10
12 notice, this list of conditions and the following disclaimer in the 11* Redistributions in binary form must reproduce the above copyright notice,
13 documentation and/or other materials provided with the distribution. 12 this list of conditions and the following disclaimer in the documentation
14 - Neither the name of Motorola Mobility nor the names of its contributors 13 and/or other materials provided with the distribution.
15 may be used to endorse or promote products derived from this software 14
16 without specific prior written permission. 15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
17 18
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -26,368 +27,368 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 29POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 30</copyright> */
30 31
31var RDGE = RDGE || {}; 32var RDGE = RDGE || {};
32 33
33RDGE.RunState = function (userRunState, context) { 34RDGE.RunState = function (userRunState, context) {
34 this.name = "RunState"; 35 this.name = "RunState";
35 this.userRunState = userRunState != undefined ? userRunState : new RDGE.core.RDGEState; 36 this.userRunState = userRunState != undefined ? userRunState : new RDGE.core.RDGEState;
36 this.hasUserState = userRunState != undefined ? true : false; 37 this.hasUserState = userRunState != undefined ? true : false;
37 this.renderer = context.renderer; 38 this.renderer = context.renderer;
38 this.initialized = false; 39 this.initialized = false;
39}; 40};
40 41
41RDGE.RunState.prototype.Init = function () { 42RDGE.RunState.prototype.Init = function () {
42 this.initialized = true; 43 this.initialized = true;
43 var width = this.renderer.vpWidth; 44 var width = this.renderer.vpWidth;
44 var height = this.renderer.vpHeight; 45 var height = this.renderer.vpHeight;
45 var cam = new RDGE.camera(); 46 var cam = new RDGE.camera();
46 cam.setPerspective(45.0, width / height, 1.0, 100.0); 47 cam.setPerspective(45.0, width / height, 1.0, 100.0);
47 cam.setLookAt([0, 0, 20], [0, 0, 0], RDGE.vec3.up()); 48 cam.setLookAt([0, 0, 20], [0, 0, 0], RDGE.vec3.up());
48 49
49 this.renderer.cameraManager().setActiveCamera( cam ); 50 this.renderer.cameraManager().setActiveCamera( cam );
50 51
51 if (this.hasUserState && this.userRunState.init != undefined) { 52 if (this.hasUserState && this.userRunState.init != undefined) {
52 this.userRunState.init(); 53 this.userRunState.init();
53 } 54 }
54 55
55 if (this.hasUserState && this.userRunState && this.userRunState.onRunState) 56 if (this.hasUserState && this.userRunState && this.userRunState.onRunState)
56 this.userRunState.onRunState(); 57 this.userRunState.onRunState();
57 58
58 59
59 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 60 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60 61
61// if(theScene=="Robots_rt") { 62// if(theScene=="Robots_rt") {
62// g_enableShadowMapping=false; 63// g_enableShadowMapping=false;
63// g_showSSAO=false; 64// g_showSSAO=false;
64 // RDGE.globals.engine.defaultContext.uniforms[1]={ 'name': "u_lightAmb",'value': [0.5,0.5,0.5,1.0] }; 65 // RDGE.globals.engine.defaultContext.uniforms[1]={ 'name': "u_lightAmb",'value': [0.5,0.5,0.5,1.0] };
65 // RDGE.globals.engine.defaultContext.uniforms[7]={ 'name': "u_matAmbient",'value': [0.8,0.8,0.8,1] }; 66 // RDGE.globals.engine.defaultContext.uniforms[7]={ 'name': "u_matAmbient",'value': [0.8,0.8,0.8,1] };
66// } 67// }
67 68
68 69
69// g_hrDepthMapGenShader=createShader(this.renderer.ctx,'depthMap_vshader','depthMap_fshader',["vert","normal"]); 70// g_hrDepthMapGenShader=createShader(this.renderer.ctx,'depthMap_vshader','depthMap_fshader',["vert","normal"]);
70// g_depthMapGenShader=createShader(this.renderer.ctx,'norm_depth_vshader','norm_depth_fshader',["vert","normal"]); 71// g_depthMapGenShader=createShader(this.renderer.ctx,'norm_depth_vshader','norm_depth_fshader',["vert","normal"]);
71 72
72// // shadow light 73// // shadow light
73 // g_mainLight=new RDGE.camera(); // camera to represent our light's point of view 74 // g_mainLight=new RDGE.camera(); // camera to represent our light's point of view
74// g_mainLight.setPerspective(45.0,width/height,1.0,200.0); 75// g_mainLight.setPerspective(45.0,width/height,1.0,200.0);
75 // g_mainLight.setLookAt([-60,17,-15],[-5,-5,15],RDGE.vec3.up()); // lights position and point of view 76 // g_mainLight.setLookAt([-60,17,-15],[-5,-5,15],RDGE.vec3.up()); // lights position and point of view
76 // g_mainLight.mvMatrix=RDGE.mat4.copy(g_mainLight.view); // hold model view transform 77 // g_mainLight.mvMatrix=RDGE.mat4.copy(g_mainLight.view); // hold model view transform
77 // g_mainLight.invViewMatrix=RDGE.mat4.inverse(g_mainLight.view); 78 // g_mainLight.invViewMatrix=RDGE.mat4.inverse(g_mainLight.view);
78 // g_mainLight.mvpMatrix=RDGE.mat4.identity(); 79 // g_mainLight.mvpMatrix=RDGE.mat4.identity();
79 // g_mainLight.shadowMatrix=RDGE.mat4.identity(); // shadow matrix creates shadow bias 80 // g_mainLight.shadowMatrix=RDGE.mat4.identity(); // shadow matrix creates shadow bias
80 // g_mainLight.shadowMatrix=RDGE.mat4.scale(g_mainLight.shadowMatrix,[0.5,0.5,0.5]); 81 // g_mainLight.shadowMatrix=RDGE.mat4.scale(g_mainLight.shadowMatrix,[0.5,0.5,0.5]);
81 // g_mainLight.shadowMatrix=RDGE.mat4.translate(g_mainLight.shadowMatrix,[0.5,0.5,0.5]); 82 // g_mainLight.shadowMatrix=RDGE.mat4.translate(g_mainLight.shadowMatrix,[0.5,0.5,0.5]);
82// //g_cameraManager.setActiveCamera( g_mainLight ); 83// //g_cameraManager.setActiveCamera( g_mainLight );
83// 84//
84 // uniformEnableGlow = this.renderer.ctx.getUniformLocation(RDGE.globals.engine.defaultContext.shaderProg, "u_renderGlow"); 85 // uniformEnableGlow = this.renderer.ctx.getUniformLocation(RDGE.globals.engine.defaultContext.shaderProg, "u_renderGlow");
85// 86//
86// depthRTT=createRenderTargetTexture(1024,1024); 87// depthRTT=createRenderTargetTexture(1024,1024);
87// glowRTT=createRenderTargetTexture(512,512); 88// glowRTT=createRenderTargetTexture(512,512);
88 // blurFX=new RDGE.fx.fxBlur([256,128,64],true); 89 // blurFX=new RDGE.fx.fxBlur([256,128,64],true);
89// mainRTT=createRenderTargetTexture(1024,1024); 90// mainRTT=createRenderTargetTexture(1024,1024);
90 // ssaoFX=new RDGE.fx.fxSSAO(true); 91 // ssaoFX=new RDGE.fx.fxSSAO(true);
91// ssaoRTT=createRenderTargetTexture(1024,1024); 92// ssaoRTT=createRenderTargetTexture(1024,1024);
92// depthRTT=createRenderTargetTexture(1024,1024); 93// depthRTT=createRenderTargetTexture(1024,1024);
93// hrDepthRTT=createRenderTargetTexture(1024,1024); 94// hrDepthRTT=createRenderTargetTexture(1024,1024);
94// hrDepthRTTSSAO=createRenderTargetTexture(1024,1024); 95// hrDepthRTTSSAO=createRenderTargetTexture(1024,1024);
95 // mainSceneQuad=new RDGE.ScreenQuad(mainRTT); 96 // mainSceneQuad=new RDGE.ScreenQuad(mainRTT);
96 // mainSceneQuad.initialize(RDGE.renderInitScreenQuad); 97 // mainSceneQuad.initialize(RDGE.renderInitScreenQuad);
97 98
98// cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png"); 99// cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png");
99// lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png"); 100// lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png");
100// black = this.renderer.createTexture("assets/images/black.png"); 101// black = this.renderer.createTexture("assets/images/black.png");
101 102
102// renderGlow=false; 103// renderGlow=false;
103 104
104// // depth map and normal proc 105// // depth map and normal proc
105// renderProcDepth=new GenerateDepthMap(); 106// renderProcDepth=new GenerateDepthMap();
106// renderProcGlow=new GenerateGlowMap(); 107// renderProcGlow=new GenerateGlowMap();
107 // renderProc=new RDGE.SceneRender(); 108 // renderProc=new RDGE.SceneRender();
108// renderProcCreateShadowMap=new SceneCreateShadowMap(); 109// renderProcCreateShadowMap=new SceneCreateShadowMap();
109// renderProcHighResDepth=new GenerateHighResDepthMap(); 110// renderProcHighResDepth=new GenerateHighResDepthMap();
110 111
111 // RDGE.globals.engine.defaultContext.textureList.push({ 'handle': hrDepthRTT,'unit': 7,'type': RDGE.UNIFORMTYPE.TEXTURE2D }); 112 // RDGE.globals.engine.defaultContext.textureList.push({ 'handle': hrDepthRTT,'unit': 7,'type': RDGE.UNIFORMTYPE.TEXTURE2D });
112 // RDGE.globals.engine.defaultContext.uniforms.push({ 'name': "depthMap",'value': [hrDepthRTT] }); 113 // RDGE.globals.engine.defaultContext.uniforms.push({ 'name': "depthMap",'value': [hrDepthRTT] });
113 114
114 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 115 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115}; 116};
116 117
117RDGE.RunState.prototype.ReInit = function () { 118RDGE.RunState.prototype.ReInit = function () {
118 if (!this.initialized) { 119 if (!this.initialized) {
119 this.Init(); 120 this.Init();
120 } 121 }