aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/run_state.js
diff options
context:
space:
mode:
authorKris Kowal2012-07-06 12:34:53 -0700
committerKris Kowal2012-07-06 15:01:48 -0700
commit3644cb6def4f681c99959e5729e78ea353441fad (patch)
treef8a886f4829e507cc4956db37cff2580cae6003d /js/helper-classes/RDGE/src/core/script/run_state.js
parent04343eda8c2f870b0da55cfdc8003c99fe1cc4de (diff)
downloadninja-3644cb6def4f681c99959e5729e78ea353441fad.tar.gz
Normalize to unix line terminators
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/run_state.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/run_state.js718
1 files changed, 359 insertions, 359 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 1c6a6a8c..bb86f72e 100755
--- a/js/helper-classes/RDGE/src/core/script/run_state.js
+++ b/js/helper-classes/RDGE/src/core/script/run_state.js
@@ -26,368 +26,368 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE. 28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */ 29</copyright> */
30 30
31var RDGE = RDGE || {}; 31var RDGE = RDGE || {};
32 32
33RDGE.RunState = function (userRunState, context) { 33RDGE.RunState = function (userRunState, context) {
34 this.name = "RunState"; 34 this.name = "RunState";
35 this.userRunState = userRunState != undefined ? userRunState : new RDGE.core.RDGEState; 35 this.userRunState = userRunState != undefined ? userRunState : new RDGE.core.RDGEState;
36 this.hasUserState = userRunState != undefined ? true : false; 36 this.hasUserState = userRunState != undefined ? true : false;
37 this.renderer = context.renderer; 37 this.renderer = context.renderer;
38 this.initialized = false; 38 this.initialized = false;
39}; 39};
40 40
41RDGE.RunState.prototype.Init = function () { 41RDGE.RunState.prototype.Init = function () {
42 this.initialized = true; 42 this.initialized = true;
43 var width = this.renderer.vpWidth; 43 var width = this.renderer.vpWidth;
44 var height = this.renderer.vpHeight; 44 var height = this.renderer.vpHeight;
45 var cam = new RDGE.camera(); 45 var cam = new RDGE.camera();
46 cam.setPerspective(45.0, width / height, 1.0, 100.0); 46 cam.setPerspective(45.0, width / height, 1.0, 100.0);
47 cam.setLookAt([0, 0, 20], [0, 0, 0], RDGE.vec3.up()); 47 cam.setLookAt([0, 0, 20], [0, 0, 0], RDGE.vec3.up());
48 48
49 this.renderer.cameraManager().setActiveCamera( cam ); 49 this.renderer.cameraManager().setActiveCamera( cam );
50 50
51 if (this.hasUserState && this.userRunState.init != undefined) { 51 if (this.hasUserState && this.userRunState.init != undefined) {
52 this.userRunState.init(); 52 this.userRunState.init();
53 } 53 }
54 54
55 if (this.hasUserState && this.userRunState && this.userRunState.onRunState) 55 if (this.hasUserState && this.userRunState && this.userRunState.onRunState)
56 this.userRunState.onRunState(); 56 this.userRunState.onRunState();
57 57
58 58
59 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60 60
61// if(theScene=="Robots_rt") { 61// if(theScene=="Robots_rt") {
62// g_enableShadowMapping=false; 62// g_enableShadowMapping=false;
63// g_showSSAO=false; 63// g_showSSAO=false;
64 // RDGE.globals.engine.defaultContext.uniforms[1]={ 'name': "u_lightAmb",'value': [0.5,0.5,0.5,1.0] }; 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[7]={ 'name': "u_matAmbient",'value': [0.8,0.8,0.8,1] }; 65 // RDGE.globals.engine.defaultContext.uniforms[7]={ 'name': "u_matAmbient",'value': [0.8,0.8,0.8,1] };
66// } 66// }
67 67
68 68
69// g_hrDepthMapGenShader=createShader(this.renderer.ctx,'depthMap_vshader','depthMap_fshader',["vert","normal"]); 69// 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"]); 70// g_depthMapGenShader=createShader(this.renderer.ctx,'norm_depth_vshader','norm_depth_fshader',["vert","normal"]);
71 71
72// // shadow light 72// // shadow light
73 // g_mainLight=new RDGE.camera(); // camera to represent our light's point of view 73 // 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); 74// 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 75 // 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 76 // g_mainLight.mvMatrix=RDGE.mat4.copy(g_mainLight.view); // hold model view transform
77 // g_mainLight.invViewMatrix=RDGE.mat4.inverse(g_mainLight.view); 77 // g_mainLight.invViewMatrix=RDGE.mat4.inverse(g_mainLight.view);
78 // g_mainLight.mvpMatrix=RDGE.mat4.identity(); 78 // g_mainLight.mvpMatrix=RDGE.mat4.identity();
79 // g_mainLight.shadowMatrix=RDGE.mat4.identity(); // shadow matrix creates shadow bias 79 // 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]); 80 // 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]); 81 // g_mainLight.shadowMatrix=RDGE.mat4.translate(g_mainLight.shadowMatrix,[0.5,0.5,0.5]);
82// //g_cameraManager.setActiveCamera( g_mainLight ); 82// //g_cameraManager.setActiveCamera( g_mainLight );
83// 83//
84 // uniformEnableGlow = this.renderer.ctx.getUniformLocation(RDGE.globals.engine.defaultContext.shaderProg, "u_renderGlow"); 84 // uniformEnableGlow = this.renderer.ctx.getUniformLocation(RDGE.globals.engine.defaultContext.shaderProg, "u_renderGlow");
85// 85//
86// depthRTT=createRenderTargetTexture(1024,1024); 86// depthRTT=createRenderTargetTexture(1024,1024);
87// glowRTT=createRenderTargetTexture(512,512); 87// glowRTT=createRenderTargetTexture(512,512);
88 // blurFX=new RDGE.fx.fxBlur([256,128,64],true); 88 // blurFX=new RDGE.fx.fxBlur([256,128,64],true);
89// mainRTT=createRenderTargetTexture(1024,1024); 89// mainRTT=createRenderTargetTexture(1024,1024);
90 // ssaoFX=new RDGE.fx.fxSSAO(true); 90 // ssaoFX=new RDGE.fx.fxSSAO(true);
91// ssaoRTT=createRenderTargetTexture(1024,1024); 91// ssaoRTT=createRenderTargetTexture(1024,1024);
92// depthRTT=createRenderTargetTexture(1024,1024); 92// depthRTT=createRenderTargetTexture(1024,1024);
93// hrDepthRTT=createRenderTargetTexture(1024,1024); 93// hrDepthRTT=createRenderTargetTexture(1024,1024);
94// hrDepthRTTSSAO=createRenderTargetTexture(1024,1024); 94// hrDepthRTTSSAO=createRenderTargetTexture(1024,1024);
95 // mainSceneQuad=new RDGE.ScreenQuad(mainRTT); 95 // mainSceneQuad=new RDGE.ScreenQuad(mainRTT);
96 // mainSceneQuad.initialize(RDGE.renderInitScreenQuad); 96 // mainSceneQuad.initialize(RDGE.renderInitScreenQuad);
97 97
98// cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png"); 98// cubelight_Glow = this.renderer.createTexture("assets/images/cubelight_Glow.png");
99// lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png"); 99// lightRack_Glow = this.renderer.createTexture("assets/images/lightRack_Glow.png");
100// black = this.renderer.createTexture("assets/images/black.png"); 100// black = this.renderer.createTexture("assets/images/black.png");
101 101
102// renderGlow=false; 102// renderGlow=false;
103 103
104// // depth map and normal proc 104// // depth map and normal proc
105// renderProcDepth=new GenerateDepthMap(); 105// renderProcDepth=new GenerateDepthMap();
106// renderProcGlow=new GenerateGlowMap(); 106// renderProcGlow=new GenerateGlowMap();
107 // renderProc=new RDGE.SceneRender(); 107 // renderProc=new RDGE.SceneRender();
108// renderProcCreateShadowMap=new SceneCreateShadowMap(); 108// renderProcCreateShadowMap=new SceneCreateShadowMap();
109// renderProcHighResDepth=new GenerateHighResDepthMap(); 109// renderProcHighResDepth=new GenerateHighResDepthMap();
110 110
111 // RDGE.globals.engine.defaultContext.textureList.push({ 'handle': hrDepthRTT,'unit': 7,'type': RDGE.UNIFORMTYPE.TEXTURE2D }); 111 // 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] }); 112 // RDGE.globals.engine.defaultContext.uniforms.push({ 'name': "depthMap",'value': [hrDepthRTT] });
113 113
114 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 114 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
115}; 115};
116 116
117RDGE.RunState.prototype.ReInit = function () { 117RDGE.RunState.prototype.ReInit = function () {
118 if (!this.initialized) { 118 if (!this.initialized) {
119 this.Init(); 119 this.Init();
120 } 120 }
121 else { 121 else {
122 if (this.hasUserState && this.userRunState && this.userRunState.onRunState) 122 if (this.hasUserState && this.userRunState && this.userRunState.onRunState)
123 this.userRunState.onRunState(); 123 this.userRunState.onRunState();
124 } 124 }
125}; 125};
126 126
127RDGE.RunState.prototype.Update = function (dt) { 127RDGE.RunState.prototype.Update = function (dt) {
128 this.userRunState.update(dt); 128 this.userRunState.update(dt);
129}; 129};
130 130
131RDGE.RunState.prototype.Resize = function () { 131RDGE.RunState.prototype.Resize = function () {
132 if (RDGE.globals.engine.lastWindowWidth == window.innerWidth && RDGE.globals.engine.lastWindowHeight == window.innerHeight) { 132 if (RDGE.globals.engine.lastWindowWidth == window.innerWidth && RDGE.globals.engine.lastWindowHeight == window.innerHeight) {
133 this.userRunState.resize(); 133 this.userRunState.resize();
134 RDGE.globals.engine.lastWindowWidth = window.innerWidth; 134 RDGE.globals.engine.lastWindowWidth = window.innerWidth;
135 RDGE.globals.engine.lastWindowHeight = window.innerHeight; 135 RDGE.globals.engine.lastWindowHeight = window.innerHeight;
136} 136}
137}; 137};
138 138
139RDGE.RunState.prototype.Draw = function () { 139RDGE.RunState.prototype.Draw = function () {
140 var width = this.renderer.vpWidth; 140 var width = this.renderer.vpWidth;
141 var height = this.renderer.vpHeight; 141 var height = this.renderer.vpHeight;
142 142
143// this.renderer._clear(); 143// this.renderer._clear();
144 144
145 this.userRunState.draw(); 145 this.userRunState.draw();