diff options
author | Eric Guzman | 2012-04-05 18:42:40 -0700 |
---|---|---|
committer | Eric Guzman | 2012-04-05 18:42:40 -0700 |
commit | 8ff9dde2053e41d85bb27d9c91808a30e551a138 (patch) | |
tree | 8eec67d632d82d3052ed470096eda13fd50a55c8 /js/helper-classes/RDGE/src/core/script/run_state.js | |
parent | 4631d54ffb4942378835689e9f5d70ed95610822 (diff) | |
parent | 7656b6eac7aec59697c6cddbe2a507fe9e4aa187 (diff) | |
download | ninja-8ff9dde2053e41d85bb27d9c91808a30e551a138.tar.gz |
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/run_state.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/run_state.js | 275 |
1 files changed, 90 insertions, 185 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 a5981caa..d2f05fad 100755 --- a/js/helper-classes/RDGE/src/core/script/run_state.js +++ b/js/helper-classes/RDGE/src/core/script/run_state.js | |||
@@ -4,43 +4,41 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var RDGE = RDGE || {}; | ||
7 | 8 | ||
8 | function RunState(userRunState, context) | 9 | RDGE.RunState = function (userRunState, context) { |
9 | { | ||
10 | this.name = "RunState"; | 10 | this.name = "RunState"; |
11 | this.userRunState = userRunState != undefined ? userRunState : new RDGEState; | 11 | this.userRunState = userRunState != undefined ? userRunState : new RDGE.core.RDGEState; |
12 | this.hasUserState = userRunState != undefined ? true : false; | 12 | this.hasUserState = userRunState != undefined ? true : false; |
13 | this.renderer = context.renderer; | 13 | this.renderer = context.renderer; |
14 | this.initialized = false; | 14 | this.initialized = false; |
15 | } | 15 | }; |
16 | 16 | ||
17 | RunState.prototype.Init = function() | 17 | RDGE.RunState.prototype.Init = function () { |
18 | { | ||
19 | this.initialized = true; | 18 | this.initialized = true; |
20 | var width = this.renderer.vpWidth; | 19 | var width = this.renderer.vpWidth; |
21 | var height = this.renderer.vpHeight; | 20 | var height = this.renderer.vpHeight; |
22 | var cam = new camera(); | 21 | var cam = new RDGE.camera(); |
23 | cam.setPerspective(45.0, width / height, 1.0, 100.0); | 22 | cam.setPerspective(45.0, width / height, 1.0, 100.0); |
24 | cam.setLookAt([0, 0, 20], [0, 0, 0], vec3.up()); | 23 | cam.setLookAt([0, 0, 20], [0, 0, 0], RDGE.vec3.up()); |
25 | 24 | ||
26 | this.renderer.cameraManager().setActiveCamera( cam ); | 25 | this.renderer.cameraManager().setActiveCamera( cam ); |
27 | 26 | ||
28 | if(this.hasUserState && this.userRunState.init != undefined) | 27 | if (this.hasUserState && this.userRunState.init != undefined) { |
29 | { | ||
30 | this.userRunState.init(); | 28 | this.userRunState.init(); |
31 | } | 29 | } |
32 | 30 | ||
33 | if (this.hasUserState && this.userRunState && this.userRunState.onRunState) | 31 | if (this.hasUserState && this.userRunState && this.userRunState.onRunState) |
34 | this.userRunState.onRunState(); | 32 | this.userRunState.onRunState(); |
35 | 33 | ||
36 | 34 | ||
37 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 35 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
38 | 36 | ||
39 | // if(theScene=="Robots_rt") { | 37 | // if(theScene=="Robots_rt") { |
40 | // g_enableShadowMapping=false; | 38 | // g_enableShadowMapping=false; |
41 | // g_showSSAO=false; | 39 | // g_showSSAO=false; |
42 | // g_Engine.defaultContext.uniforms[1]={ 'name': "u_lightAmb",'value': [0.5,0.5,0.5,1.0] }; | 40 | // RDGE.globals.engine.defaultContext.uniforms[1]={ 'name': "u_lightAmb",'value': [0.5,0.5,0.5,1.0] }; |
43 | // g_Engine.defaultContext.uniforms[7]={ 'name': "u_matAmbient",'value': [0.8,0.8,0.8,1] }; | 41 | // RDGE.globals.engine.defaultContext.uniforms[7]={ 'name': "u_matAmbient",'value': [0.8,0.8,0.8,1] }; |
44 | // } | 42 | // } |
45 | 43 | ||
46 | 44 | ||
@@ -48,30 +46,30 @@ RunState.prototype.Init = function() | |||
48 | // g_depthMapGenShader=createShader(this.renderer.ctx,'norm_depth_vshader','norm_depth_fshader',["vert","normal"]); | 46 | // g_depthMapGenShader=createShader(this.renderer.ctx,'norm_depth_vshader','norm_depth_fshader',["vert","normal"]); |
49 | 47 | ||
50 | // // shadow light | 48 | // // shadow light |
51 | // g_mainLight=new camera(); // camera to represent our light's point of view | 49 | // g_mainLight=new RDGE.camera(); // camera to represent our light's point of view |
52 | // g_mainLight.setPerspective(45.0,width/height,1.0,200.0); | 50 | // g_mainLight.setPerspective(45.0,width/height,1.0,200.0); |
53 | // g_mainLight.setLookAt([-60,17,-15],[-5,-5,15],vec3.up()); // lights position and point of view | 51 | // g_mainLight.setLookAt([-60,17,-15],[-5,-5,15],RDGE.vec3.up()); // lights position and point of view |
54 | // g_mainLight.mvMatrix=mat4.copy(g_mainLight.view); // hold model view transform | 52 | // g_mainLight.mvMatrix=RDGE.mat4.copy(g_mainLight.view); // hold model view transform |
55 | // g_mainLight.invViewMatrix=mat4.inverse(g_mainLight.view); | 53 | // g_mainLight.invViewMatrix=RDGE.mat4.inverse(g_mainLight.view); |
56 | // g_mainLight.mvpMatrix=mat4.identity(); | 54 | // g_mainLight.mvpMatrix=RDGE.mat4.identity(); |
57 | // g_mainLight.shadowMatrix=mat4.identity(); // shadow matrix creates shadow bias | 55 | // g_mainLight.shadowMatrix=RDGE.mat4.identity(); // shadow matrix creates shadow bias |
58 | // g_mainLight.shadowMatrix=mat4.scale(g_mainLight.shadowMatrix,[0.5,0.5,0.5]); | 56 | // g_mainLight.shadowMatrix=RDGE.mat4.scale(g_mainLight.shadowMatrix,[0.5,0.5,0.5]); |
59 | // g_mainLight.shadowMatrix=mat4.translate(g_mainLight.shadowMatrix,[0.5,0.5,0.5]); | 57 | // g_mainLight.shadowMatrix=RDGE.mat4.translate(g_mainLight.shadowMatrix,[0.5,0.5,0.5]); |
60 | // //g_cameraManager.setActiveCamera( g_mainLight ); | 58 | // //g_cameraManager.setActiveCamera( g_mainLight ); |
61 | // | 59 | // |
62 | // uniformEnableGlow = this.renderer.ctx.getUniformLocation(g_Engine.defaultContext.shaderProg, "u_renderGlow"); | 60 | // uniformEnableGlow = this.renderer.ctx.getUniformLocation(RDGE.globals.engine.defaultContext.shaderProg, "u_renderGlow"); |
63 | // | 61 | // |
64 | // depthRTT=createRenderTargetTexture(1024,1024); | 62 | // depthRTT=createRenderTargetTexture(1024,1024); |
65 | // glowRTT=createRenderTargetTexture(512,512); | 63 | // glowRTT=createRenderTargetTexture(512,512); |
66 | // blurFX=new fxBlur([256,128,64],true); | 64 | // blurFX=new RDGE.fx.fxBlur([256,128,64],true); |
67 | // mainRTT=createRenderTargetTexture(1024,1024); | 65 | // mainRTT=createRenderTargetTexture(1024,1024); |
68 | // ssaoFX=new fxSSAO(true); | 66 | // ssaoFX=new RDGE.fx.fxSSAO(true); |
69 | // ssaoRTT=createRenderTargetTexture(1024,1024); | 67 | // ssaoRTT=createRenderTargetTexture(1024,1024); |
70 | // depthRTT=createRenderTargetTexture(1024,1024); | 68 | // depthRTT=createRenderTargetTexture(1024,1024); |
71 | // hrDepthRTT=createRenderTargetTexture(1024,1024); | 69 | // hrDepthRTT=createRenderTargetTexture(1024,1024); |
72 | // hrDepthRTTSSAO=createRenderTargetTexture(1024,1024); | 70 | // hrDepthRTTSSAO=createRenderTargetTexture(1024,1024); |
73 | // mainSceneQuad=new ScreenQuad(mainRTT); | 71 | // mainSceneQuad=new RDGE.ScreenQuad(mainRTT); |
74 | // mainSceneQuad.initialize(renderInitScreenQuad); | 72 | // mainSceneQuad.initialize(RDGE.renderInitScreenQuad); |
75 | 73 | ||
76 | // cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png"); | 74 | // cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png"); |
77 | // lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png"); | 75 | // lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png"); |
@@ -82,46 +80,39 @@ RunState.prototype.Init = function() | |||
82 | // // depth map and normal proc | 80 | // // depth map and normal proc |
83 | // renderProcDepth=new GenerateDepthMap(); | 81 | // renderProcDepth=new GenerateDepthMap(); |
84 | // renderProcGlow=new GenerateGlowMap(); | 82 | // renderProcGlow=new GenerateGlowMap(); |
85 | // renderProc=new SceneRender(); | 83 | // renderProc=new RDGE.SceneRender(); |
86 | // renderProcCreateShadowMap=new SceneCreateShadowMap(); | 84 | // renderProcCreateShadowMap=new SceneCreateShadowMap(); |
87 | // renderProcHighResDepth=new GenerateHighResDepthMap(); | 85 | // renderProcHighResDepth=new GenerateHighResDepthMap(); |
88 | 86 | ||
89 | // g_Engine.defaultContext.textureList.push({ 'handle': hrDepthRTT,'unit': 7,'type': UNIFORMTYPE.TEXTURE2D }); | 87 | // RDGE.globals.engine.defaultContext.textureList.push({ 'handle': hrDepthRTT,'unit': 7,'type': RDGE.UNIFORMTYPE.TEXTURE2D }); |
90 | // g_Engine.defaultContext.uniforms.push({ 'name': "depthMap",'value': [hrDepthRTT] }); | 88 | // RDGE.globals.engine.defaultContext.uniforms.push({ 'name': "depthMap",'value': [hrDepthRTT] }); |
91 | 89 | ||
92 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | 90 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
93 | } | 91 | }; |
94 | 92 | ||
95 | RunState.prototype.ReInit = function() | 93 | RDGE.RunState.prototype.ReInit = function () { |
96 | { | 94 | if (!this.initialized) { |
97 | if(!this.initialized) | ||
98 | { | ||
99 | this.Init(); | 95 | this.Init(); |
96 | } | ||
97 | else { | ||
98 | if (this.hasUserState && this.userRunState && this.userRunState.onRunState) | ||
99 | this.userRunState.onRunState(); | ||
100 | } | 100 | } |
101 | else | 101 | }; |
102 | { | ||
103 | if (this.hasUserState && this.userRunState && this.userRunState.onRunState) | ||
104 | this.userRunState.onRunState(); | ||
105 | } | ||
106 | } | ||
107 | 102 | ||
108 | RunState.prototype.Update = function(dt) | 103 | RDGE.RunState.prototype.Update = function (dt) { |
109 | { | ||
110 | this.userRunState.update(dt); | 104 | this.userRunState.update(dt); |
111 | } | 105 | }; |
112 | 106 | ||
113 | RunState.prototype.Resize = function() | 107 | RDGE.RunState.prototype.Resize = function () { |
114 | { | 108 | if (RDGE.globals.engine.lastWindowWidth == window.innerWidth && RDGE.globals.engine.lastWindowHeight == window.innerHeight) { |
115 | if(g_Engine.lastWindowWidth == window.innerWidth && g_Engine.lastWindowHeight == window.innerHeight) | ||
116 | { | ||
117 | this.userRunState.resize(); | 109 | this.userRunState.resize(); |
118 | g_Engine.lastWindowWidth = window.innerWidth; | 110 | RDGE.globals.engine.lastWindowWidth = window.innerWidth; |
119 | g_Engine.lastWindowHeight = window.innerHeight; | 111 | RDGE.globals.engine.lastWindowHeight = window.innerHeight; |
120 | } | ||
121 | } | 112 | } |
113 | }; | ||
122 | 114 | ||
123 | RunState.prototype.Draw = function () | 115 | RDGE.RunState.prototype.Draw = function () { |
124 | { | ||
125 | var width = this.renderer.vpWidth; | 116 | var width = this.renderer.vpWidth; |
126 | var height = this.renderer.vpHeight; | 117 | var height = this.renderer.vpHeight; |
127 | 118 | ||
@@ -194,117 +185,38 @@ RunState.prototype.Draw = function () | |||
194 | // this.renderer.clear( this.renderer.colorBuffer | this.renderer.depthBuffer ); | 185 | // this.renderer.clear( this.renderer.colorBuffer | this.renderer.depthBuffer ); |
195 | 186 | ||
196 | // mainSceneQuad.texture=g_showSSAO?ssaoRTT:mainRTT; | 187 | // mainSceneQuad.texture=g_showSSAO?ssaoRTT:mainRTT; |
197 | // renderProcScreenQuad(mainSceneQuad); | 188 | // RDGE.renderProcScreenQuad(mainSceneQuad); |