aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/jpass.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/jpass.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/jpass.js771
1 files changed, 355 insertions, 416 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/jpass.js b/js/helper-classes/RDGE/src/core/script/jpass.js
index 326394dc..f3943684 100755
--- a/js/helper-classes/RDGE/src/core/script/jpass.js
+++ b/js/helper-classes/RDGE/src/core/script/jpass.js
@@ -4,34 +4,38 @@ 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
8// RDGE namespaces
9var RDGE = RDGE || {};
10
7/* 11/*
8 * jpass geometry set - determines the category(s) of geometry that a pass will render 12* jpass geometry set - determines the category(s) of geometry that a pass will render
9 * can be OR'ed together 13* can be OR'ed together
10 */ 14*/
11jpassGeoSet = 15RDGE.jpassGeoSet =
12{ 16{
13 'BACKGROUND' :1, 17 'BACKGROUND': 1,
14 'OPAQUE' :2, 18 'OPAQUE': 2,
15 'TRANSPARENT' :4, 19 'TRANSPARENT': 4,
16 'ADDITIVE' :8, 20 'ADDITIVE': 8,
17 'TRANSLUCENT' :16, 21 'TRANSLUCENT': 16,
18 'FOREGROUND' :32, 22 'FOREGROUND': 32,
19 'ALL' :127, 23 'ALL': 127,
20 'SCREEN_QUAD' :128, // a screen aligned quad - for rendering a texture to screen 24 'SCREEN_QUAD': 128, // a screen aligned quad - for rendering a texture to screen
21 'SHADOW' :256, // the opaque geometry from shadow light's point of view 25 'SHADOW': 256, // the opaque geometry from shadow light's point of view
22 'MAXSETS' :9 26 'MAXSETS': 9
23}; 27};
24 28
25 29
26/* 30/*
27 * The abstract base class that defines a jpass 31* The abstract base class that defines a jpass
28 * a jpass represents a single render pass of the scene graph 32* a jpass represents a single render pass of the scene graph
29 */ 33*/
30_jpassBaseClass = function() { 34RDGE._jpassBaseClass = function () {
31 this.context = g_Engine.getContext(); 35 this.context = RDGE.globals.engine.getContext();
32 this.renderer = g_Engine.getContext().renderer; 36 this.renderer = RDGE.globals.engine.getContext().renderer;
33 this.sortCats = rdgeConstants.categoryEnumeration; 37 this.sortCats = RDGE.rdgeConstants.categoryEnumeration;
34 this.bucketCount = rdgeConstants.categoryEnumeration.MAX_CAT; 38 this.bucketCount = RDGE.rdgeConstants.categoryEnumeration.MAX_CAT;
35 39
36 // render order 40 // render order
37 this.renderOrder = []; 41 this.renderOrder = [];
@@ -43,7 +47,7 @@ _jpassBaseClass = function() {
43 this.renderOrder[this.sortCats.FOREGROUND] = 5; 47 this.renderOrder[this.sortCats.FOREGROUND] = 5;
44 48
45 // the name of this pass 49 // the name of this pass
46 this.name = "renderPass_" + nodeIdGen.getId(); 50 this.name = "renderPass_" + RDGE.nodeIdGen.getId();
47 51
48 /* 52 /*
49 * if 0 this pass and children are culled from rendering 53 * if 0 this pass and children are culled from rendering
@@ -53,20 +57,19 @@ _jpassBaseClass = function() {
53 /* 57 /*
54 * called when the pass is hidden - override for customication 58 * called when the pass is hidden - override for customication
55 */ 59 */
56 this.onHide = function() { 60 this.onHide = function () {
57 61 };
58 }
59 62
60 /* 63 /*
61 * Called by the system to hide the pass and its children 64 * Called by the system to hide the pass and its children
62 */ 65 */
63 this.hidePass = function() { 66 this.hidePass = function () {
64 this.onHide(); 67 this.onHide();
65 68
66 for (var i = 0, len = this.children.length; i < len; ++i) { 69 for (var i = 0, len = this.children.length; i < len; ++i) {
67 this.children[i].hidePass(); 70 this.children[i].hidePass();
68 } 71 }
69 } 72 };
70 73
71 /* 74 /*
72 * the default output render targets that this pass will create 75 * the default output render targets that this pass will create
@@ -95,17 +98,12 @@ _jpassBaseClass = function() {
95 /* 98 /*
96 * outputs from the previous pass are set as inputs for this pass 99 * outputs from the previous pass are set as inputs for this pass
97 */ 100 */
98 this.inputs = 101 this.inputs = [];
99 [
100 ];
101 102
102 /* 103 /*
103 * other textures requested for this pass 104 * other textures requested for this pass
104 */ 105 */
105 this.textures = 106 this.textures = [];
106 [
107
108 ];
109 107
110 /* 108 /*
111 * the flags that control how the pass is rendered 109 * the flags that control how the pass is rendered
@@ -143,7 +141,6 @@ _jpassBaseClass = function() {
143 */ 141 */
144 this.geometrySet = "SCREEN_QUAD"; 142 this.geometrySet = "SCREEN_QUAD";
145 143
146
147 /* 144 /*
148 * A camera set here will override any camera active in the scene 145 * A camera set here will override any camera active in the scene
149 */ 146 */
@@ -152,21 +149,20 @@ _jpassBaseClass = function() {
152 /* 149 /*
153 * Initialize the pass 150 * Initialize the pass
154 */ 151 */
155 this.init = function() { 152 this.init = function () {
156 153 };
157 }
158 154
159 /* 155 /*
160 * inserts a node into the child map using the pass name as the key 156 * inserts a node into the child map using the pass name as the key
161 */ 157 */
162 this.insertChildPass = function(jpassObj) { 158 this.insertChildPass = function (jpassObj) {
163 this.children[jpassObj.name] = jpassObj; 159 this.children[jpassObj.name] = jpassObj;
164 } 160 };
165 161
166 /* 162 /*
167 * the scene-graph to process 163 * the scene-graph to process
168 */ 164 */
169 this.process = function() { 165 this.process = function () {
170 // pre-defined local variables to prevent allocation 166 // pre-defined local variables to prevent allocation
171 var context; 167 var context;
172 var shaderProg; 168 var shaderProg;
@@ -182,9 +178,9 @@ _jpassBaseClass = function() {
182 var paramIdx = 0; 178 var paramIdx = 0;
183 var passIdx = 0; 179 var passIdx = 0;
184 180
185 var renderer = g_Engine.getContext().renderer; 181 var renderer = RDGE.globals.engine.getContext().renderer;
186 182
187 //this.renderer = g_Engine.getContext().renderer; 183 //this.renderer = RDGE.globals.engine.getContext().renderer;
188 184
189 // bind output target for rendering 185 // bind output target for rendering
190 this.bindOutput(); 186 this.bindOutput();
@@ -201,10 +197,10 @@ _jpassBaseClass = function() {
201 renderer.projectionMatrix = activeCam.proj; 197 renderer.projectionMatrix = activeCam.proj;
202 198
203 // parameters that can be set once per pass 199 // parameters that can be set once per pass
204 rdgeGlobalParameters.u_inv_viewport_width.set([1.0 / renderer.vpWidth]); 200 RDGE.rdgeGlobalParameters.u_inv_viewport_width.set([1.0 / renderer.vpWidth]);
205 rdgeGlobalParameters.u_inv_viewport_height.set([1.0 / renderer.vpHeight]); 201 RDGE.rdgeGlobalParameters.u_inv_viewport_height.set([1.0 / renderer.vpHeight]);
206 rdgeGlobalParameters.u_farZ.set([activeCam.zFar()]); 202 RDGE.rdgeGlobalParameters.u_farZ.set([activeCam.zFar()]);
207 rdgeGlobalParameters.u_projMatrix.set(renderer.projectionMatrix); 203 RDGE.rdgeGlobalParameters.u_projMatrix.set(renderer.projectionMatrix);
208 204
209 for (var bucketIdx = 0, bckCnt = this.renderList.length; bucketIdx < bckCnt; ++bucketIdx) { 205 for (var bucketIdx = 0, bckCnt = this.renderList.length; bucketIdx < bckCnt; ++bucketIdx) {
210 //var curList = this.renderList[bucketIdx]; 206 //var curList = this.renderList[bucketIdx];
@@ -217,21 +213,21 @@ _jpassBaseClass = function() {
217 context = this.renderList[bucketIdx][nodeIdx].context; 213 context = this.renderList[bucketIdx][nodeIdx].context;
218 shaderProg = this.shader ? this.shader : context.shaderProg; 214 shaderProg = this.shader ? this.shader : context.shaderProg;
219 215
220 renderer.mvMatrix = mat4.mul4x3(node.world, activeCam.view); 216 renderer.mvMatrix = RDGE.mat4.mul4x3(node.world, activeCam.view);
221 renderer.invMvMatrix = mat4.inverse(renderer.mvMatrix); 217 renderer.invMvMatrix = RDGE.mat4.inverse(renderer.mvMatrix);
222 renderer.normalMatrix = mat4.transpose(renderer.invMvMatrix); 218 renderer.normalMatrix = RDGE.mat4.transpose(renderer.invMvMatrix);
223 219
224 rdgeGlobalParameters.u_mvMatrix.set(renderer.mvMatrix); 220 RDGE.rdgeGlobalParameters.u_mvMatrix.set(renderer.mvMatrix);
225 rdgeGlobalParameters.u_normalMatrix.set(renderer.normalMatrix); 221 RDGE.rdgeGlobalParameters.u_normalMatrix.set(renderer.normalMatrix);
226 rdgeGlobalParameters.u_worldMatrix.set(node.world); 222 RDGE.rdgeGlobalParameters.u_worldMatrix.set(node.world);
227 223
228