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.js416
1 files changed, 208 insertions, 208 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 7f08bd6c..d2f05fad 100755
--- a/js/helper-classes/RDGE/src/core/script/run_state.js
+++ b/js/helper-classes/RDGE/src/core/script/run_state.js
@@ -7,47 +7,47 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7var RDGE = RDGE || {}; 7var RDGE = RDGE || {};
8 8
9RDGE.RunState = function (userRunState, context) { 9RDGE.RunState = function (userRunState, context) {
10 this.name = "RunState"; 10 this.name = "RunState";
11 this.userRunState = userRunState != undefined ? userRunState : new RDGE.core.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
17RDGE.RunState.prototype.Init = function () { 17RDGE.RunState.prototype.Init = function () {
18 this.initialized = true; 18 this.initialized = true;
19 var width = this.renderer.vpWidth; 19 var width = this.renderer.vpWidth;
20 var height = this.renderer.vpHeight; 20 var height = this.renderer.vpHeight;
21 var cam = new RDGE.camera(); 21 var cam = new RDGE.camera();
22 cam.setPerspective(45.0, width / height, 1.0, 100.0); 22 cam.setPerspective(45.0, width / height, 1.0, 100.0);
23 cam.setLookAt([0, 0, 20], [0, 0, 0], RDGE.vec3.up()); 23 cam.setLookAt([0, 0, 20], [0, 0, 0], RDGE.vec3.up());
24 24
25 this.renderer.cameraManager().setActiveCamera(cam); 25 this.renderer.cameraManager().setActiveCamera( cam );
26 26
27 if (this.hasUserState && this.userRunState.init != undefined) { 27 if (this.hasUserState && this.userRunState.init != undefined) {
28 this.userRunState.init(); 28 this.userRunState.init();
29 } 29 }
30 30
31 if (this.hasUserState && this.userRunState && this.userRunState.onRunState) 31 if (this.hasUserState && this.userRunState && this.userRunState.onRunState)
32 this.userRunState.onRunState(); 32 this.userRunState.onRunState();
33
33 34
35 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
34 36
35 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 37// if(theScene=="Robots_rt") {
36 38// g_enableShadowMapping=false;
37 // if(theScene=="Robots_rt") { 39// g_showSSAO=false;
38 // g_enableShadowMapping=false;
39 // g_showSSAO=false;
40 // RDGE.globals.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] };
41 // RDGE.globals.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] };
42 // } 42// }
43 43
44 44
45 // g_hrDepthMapGenShader=createShader(this.renderer.ctx,'depthMap_vshader','depthMap_fshader',["vert","normal"]); 45// g_hrDepthMapGenShader=createShader(this.renderer.ctx,'depthMap_vshader','depthMap_fshader',["vert","normal"]);
46 // 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"]);
47 47
48 // // shadow light 48// // shadow light
49 // g_mainLight=new RDGE.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
50 // g_mainLight.setPerspective(45.0,width/height,1.0,200.0); 50// g_mainLight.setPerspective(45.0,width/height,1.0,200.0);
51 // g_mainLight.setLookAt([-60,17,-15],[-5,-5,15],RDGE.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
52 // g_mainLight.mvMatrix=RDGE.mat4.copy(g_mainLight.view); // hold model view transform 52 // g_mainLight.mvMatrix=RDGE.mat4.copy(g_mainLight.view); // hold model view transform
53 // g_mainLight.invViewMatrix=RDGE.mat4.inverse(g_mainLight.view); 53 // g_mainLight.invViewMatrix=RDGE.mat4.inverse(g_mainLight.view);
@@ -55,49 +55,49 @@ RDGE.RunState.prototype.Init = function () {
55 // g_mainLight.shadowMatrix=RDGE.mat4.identity(); // shadow matrix creates shadow bias 55 // g_mainLight.shadowMatrix=RDGE.mat4.identity(); // shadow matrix creates shadow bias
56 // g_mainLight.shadowMatrix=RDGE.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]);
57 // g_mainLight.shadowMatrix=RDGE.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]);
58 // //g_cameraManager.setActiveCamera( g_mainLight ); 58// //g_cameraManager.setActiveCamera( g_mainLight );
59 // 59//
60 // uniformEnableGlow = this.renderer.ctx.getUniformLocation(RDGE.globals.engine.defaultContext.shaderProg, "u_renderGlow"); 60 // uniformEnableGlow = this.renderer.ctx.getUniformLocation(RDGE.globals.engine.defaultContext.shaderProg, "u_renderGlow");
61 // 61//
62 // depthRTT=createRenderTargetTexture(1024,1024); 62// depthRTT=createRenderTargetTexture(1024,1024);
63 // glowRTT=createRenderTargetTexture(512,512); 63// glowRTT=createRenderTargetTexture(512,512);
64 // blurFX=new RDGE.fx.fxBlur([256,128,64],true); 64 // blurFX=new RDGE.fx.fxBlur([256,128,64],true);
65 // mainRTT=createRenderTargetTexture(1024,1024); 65// mainRTT=createRenderTargetTexture(1024,1024);
66 // ssaoFX=new RDGE.fx.fxSSAO(true); 66 // ssaoFX=new RDGE.fx.fxSSAO(true);
67 // ssaoRTT=createRenderTargetTexture(1024,1024); 67// ssaoRTT=createRenderTargetTexture(1024,1024);
68 // depthRTT=createRenderTargetTexture(1024,1024); 68// depthRTT=createRenderTargetTexture(1024,1024);
69 // hrDepthRTT=createRenderTargetTexture(1024,1024); 69// hrDepthRTT=createRenderTargetTexture(1024,1024);
70 // hrDepthRTTSSAO=createRenderTargetTexture(1024,1024); 70// hrDepthRTTSSAO=createRenderTargetTexture(1024,1024);
71 // mainSceneQuad=new RDGE.ScreenQuad(mainRTT); 71 // mainSceneQuad=new RDGE.ScreenQuad(mainRTT);
72 // mainSceneQuad.initialize(RDGE.renderInitScreenQuad); 72 // mainSceneQuad.initialize(RDGE.renderInitScreenQuad);
73 73
74 // cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png"); 74// cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png");
75 // lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png"); 75// lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png");
76 // black = this.renderer.createTexture("assets/images/black.png"); 76// black = this.renderer.createTexture("assets/images/black.png");
77 77
78 // renderGlow=false; 78// renderGlow=false;
79 79
80 // // depth map and normal proc 80// // depth map and normal proc
81 // renderProcDepth=new GenerateDepthMap(); 81// renderProcDepth=new GenerateDepthMap();
82 // renderProcGlow=new GenerateGlowMap(); 82// renderProcGlow=new GenerateGlowMap();
83 // renderProc=new RDGE.SceneRender(); 83 // renderProc=new RDGE.SceneRender();
84 // renderProcCreateShadowMap=new SceneCreateShadowMap(); 84// renderProcCreateShadowMap=new SceneCreateShadowMap();
85 // renderProcHighResDepth=new GenerateHighResDepthMap(); 85// renderProcHighResDepth=new GenerateHighResDepthMap();
86 86
87 // RDGE.globals.engine.defaultContext.textureList.push({ 'handle': hrDepthRTT,'unit': 7,'type': RDGE.UNIFORMTYPE.TEXTURE2D }); 87 // RDGE.globals.engine.defaultContext.textureList.push({ 'handle': hrDepthRTT,'unit': 7,'type': RDGE.UNIFORMTYPE.TEXTURE2D });
88 // RDGE.globals.engine.defaultContext.uniforms.push({ 'name': "depthMap",'value': [hrDepthRTT] }); 88 // RDGE.globals.engine.defaultContext.uniforms.push({ 'name': "depthMap",'value': [hrDepthRTT] });
89 89
90 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 90 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
91}; 91};
92 92
93RDGE.RunState.prototype.ReInit = function () { 93RDGE.RunState.prototype.ReInit = function () {
94 if (!this.initialized) { 94 if (!this.initialized) {
95 this.Init(); 95 this.Init();
96 } 96 }
97 else { 97 else {
98 if (this.hasUserState && this.userRunState && this.userRunState.onRunState) 98 if (this.hasUserState && this.userRunState && this.userRunState.onRunState)
99 this.userRunState.onRunState(); 99 this.userRunState.onRunState();
100 } 100 }
101}; 101};
102 102
103RDGE.RunState.prototype.Update = function (dt) { 103RDGE.RunState.prototype.Update = function (dt) {
@@ -106,105 +106,105 @@ RDGE.RunState.prototype.Update = function (dt) {
106 106
107RDGE.RunState.prototype.Resize = function () { 107RDGE.RunState.prototype.Resize = function () {
108 if (RDGE.globals.engine.lastWindowWidth == window.innerWidth && RDGE.globals.engine.lastWindowHeight == window.innerHeight) { 108 if (RDGE.globals.engine.lastWindowWidth == window.innerWidth && RDGE.globals.engine.lastWindowHeight == window.innerHeight) {
109 this.userRunState.resize(); 109 this.userRunState.resize();
110 RDGE.globals.engine.lastWindowWidth = window.innerWidth; 110 RDGE.globals.engine.lastWindowWidth = window.innerWidth;
111 RDGE.globals.engine.lastWindowHeight = window.innerHeight; 111 RDGE.globals.engine.lastWindowHeight = window.innerHeight;
112 } 112}
113}; 113};
114 114
115RDGE.RunState.prototype.Draw = function () { 115RDGE.RunState.prototype.Draw = function () {
116 var width = this.renderer.vpWidth; 116 var width = this.renderer.vpWidth;
117 var height = this.renderer.vpHeight; 117 var height = this.renderer.vpHeight;
118 118
119 // this.renderer._clear(); 119// this.renderer._clear();
120 120
121 this.userRunState.draw(); 121 this.userRunState.draw();
122 122
123 // ~~~~ removing post process till multi-context and post process system is in place 123// ~~~~ removing post process till multi-context and post process system is in place
124 // if(this.currentScene==null) 124// if(this.currentScene==null)
125 // return; 125// return;
126 126
127 // this.renderer.setClearColor([1.0,1.0,1.0,1.0]); 127// this.renderer.setClearColor([1.0,1.0,1.0,1.0]);
128 128
129 // // post process will eventually be wrapped in 129// // post process will eventually be wrapped in
130 // this.renderer.ctx.bindFramebuffer(renderer.ctx.FRAMEBUFFER, depthRTT.frameBuffer); 130// this.renderer.ctx.bindFramebuffer(renderer.ctx.FRAMEBUFFER, depthRTT.frameBuffer);
131 // this.renderer.setViewPort(0,0,1024,1024); 131// this.renderer.setViewPort(0,0,1024,1024);
132 // this.renderer.clear(this.renderer.colorBuffer | this.renderer.depthBuffer); 132// this.renderer.clear(this.renderer.colorBuffer | this.renderer.depthBuffer);
133 // this.currentScene.render(renderProcDepth);