aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/scenegraph.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/scenegraph.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/scenegraph.js1754
1 files changed, 805 insertions, 949 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/scenegraph.js b/js/helper-classes/RDGE/src/core/script/scenegraph.js
index 6814dcbf..2f080347 100755
--- a/js/helper-classes/RDGE/src/core/script/scenegraph.js
+++ b/js/helper-classes/RDGE/src/core/script/scenegraph.js
@@ -4,81 +4,67 @@ 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
7var g_drawCount = 0; 7// RDGE namespaces
8g_enableFlyCam = false; 8var RDGE = RDGE || {};
9
10g_sceneStats = {};
11g_sceneStats.nodesVisible = new stat("scenegraph", "nodesVisible", 0, null, false);
12g_sceneStats.nodesCulled = new stat("scenegraph", "nodesCulled", 0, null, false);
13g_sceneStats.nodesVisited = new stat("scenegraph", "nodesVisited", 0, null, false);
14g_sceneStats.reset = function() {
15 g_sceneStats.nodesVisible.value = 0;
16 g_sceneStats.nodesVisited.value = 0;
17 g_sceneStats.nodesCulled.value = 0;
18};
19 9
20// default render proc 10// default render proc
21// render scene nodes 11// render scene nodes
22function DefaultRender() 12RDGE.DefaultRender = function () {
23{ 13 // setup the default shader
24 // setup the default shader 14 this.renderer = RDGE.globals.engine.getContext().renderer;
25 this.renderer = g_Engine.getContext().renderer; 15 //this.shaderProgram = this.renderer.defaultShader;
26 //this.shaderProgram = this.renderer.defaultShader; 16 this.jshaderProgram = new RDGE.jshader();
27 this.jshaderProgram = new jshader(); 17 this.jshaderProgram.def = this.renderer.defaultShaderDefintion;
28 this.jshaderProgram.def = this.renderer.defaultShaderDefintion; 18 this.jshaderProgram.init();
29 this.jshaderProgram.init(); 19};
30}
31
32DefaultRender.prototype.process=function(context,trNode,parent) {
33 20
34} 21RDGE.DefaultRender.prototype.process = function (context, trNode, parent) {
22};
35 23
36function renderObject( trNode, renderCtx, parent) 24function renderObject(trNode, renderCtx, parent) {
37{ 25 this.node = trNode ? trNode : RDGE.createTransformNode();
38 this.node = trNode ? trNode : createTransformNode(); 26 this.context = renderCtx ? renderCtx : new RDGE.RenderContext();
39 this.context = renderCtx ? renderCtx : new RenderContext(); 27 this.parent = parent ? parent : null;
40 this.parent = parent ? parent : null; 28};
41}
42 29
43 30
44// Scene graph contains set of tools for manipulating the graph 31// Scene graph contains set of tools for manipulating the graph
45function SceneGraph(scene) 32RDGE.SceneGraph = function (scene) {
46{ 33 if (scene == undefined || scene == null)
47 if(scene == undefined || scene == null) 34 scene = {};
48 scene = {}; 35
49 36 this.scene = scene;
50 this.scene = scene; 37
51 38 if (this.scene.root != undefined)
52 if(this.scene.root != undefined) 39 this.scene = this.scene.root;
53 this.scene = this.scene.root; 40 else
54 else 41 this.scene = { 'children': [] };
55 this.scene = { 'children':[] }; 42
56 43 this.tick = 0;
57 this.tick = 0; 44 this.lastTick = -1;
58 this.lastTick = -1; 45 this.frustumCulling = true;
59 this.frustumCulling = true; 46
60 47 // the main light for the scene - also casts shadows
61 // the main light for the scene - also casts shadows 48 this.mainLight = new RDGE.shadowLight();
62 this.mainLight = new shadowLight(); 49
63 50 this.bckTypes = RDGE.rdgeConstants.categoryEnumeration;
64 this.bckTypes = rdgeConstants.categoryEnumeration; 51
65 52 this.renderList = new Array(this.bckTypes.MAX_CAT);
66 this.renderList = new Array(this.bckTypes.MAX_CAT); 53 this.renderList[this.bckTypes.BACKGROUND] = []; //BACKGROUND
67 this.renderList[this.bckTypes.BACKGROUND] = []; //BACKGROUND 54 this.renderList[this.bckTypes.OPAQUE] = []; //OPAQUE
68 this.renderList[this.bckTypes.OPAQUE] = []; //OPAQUE 55 this.renderList[this.bckTypes.TRANSPARENT] = []; //TRANSPARENT
69 this.renderList[this.bckTypes.TRANSPARENT] = []; //TRANSPARENT 56 this.renderList[this.bckTypes.ADDITIVE] = []; //ADDITIVE
70 this.renderList[this.bckTypes.ADDITIVE] = []; //ADDITIVE 57 this.renderList[this.bckTypes.TRANSLUCENT] = []; //TRANSLUCENT
71 this.renderList[this.bckTypes.TRANSLUCENT] = []; //TRANSLUCENT 58 this.renderList[this.bckTypes.FOREGROUND] = []; //FOREGROUND
72 this.renderList[this.bckTypes.FOREGROUND] = []; //FOREGROUND 59
73 60 // a list of shadow geometry
74 // a list of shadow geometry 61 this.shadowRenderList = [];
75 this.shadowRenderList = []; 62
76 63 // scene traversal functor for creating a culled list of shadow geometry
77 // scene traversal functor for creating a culled list of shadow geometry 64 this.shadowCuller = null;
78 this.shadowCuller = null; 65
79 66 // define passes to render geometry and handle post-processing
80 // define passes to render geometry and handle post-processing 67 this.defaultPassDef =
81 this.defaultPassDef =
82 { 68 {
83 // a pass can have children that will receive their parents output as input 69 // a pass can have children that will receive their parents output as input
84 70
@@ -102,7 +88,7 @@ function SceneGraph(scene)
102 // 'outputs':[{ 'name':"u_shadowDepthMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], 88 // 'outputs':[{ 'name':"u_shadowDepthMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }],
103 // // custom parameter 89 // // custom parameter
104 // 'name':"shadowDepthMap", 90 // 'name':"shadowDepthMap",
105 // 'shader': rdgeDepthMapShaderDef, 91 // 'shader': RDGE.rdgeDepthMapShaderDef,
106 // 'technique':"shadowDepthMap", 92 // 'technique':"shadowDepthMap",
107 // 'geometrySet':"SHADOW", 93 // 'geometrySet':"SHADOW",
108 // 'children': 94 // 'children':
@@ -111,7 +97,7 @@ function SceneGraph(scene)
111 // { 97 // {
112 // 'outputs':[{ 'name':"u_shadowMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], 98 // 'outputs':[{ 'name':"u_shadowMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }],
113 // 'name':"shadowMap", 99 // 'name':"shadowMap",
114 // 'shader': rdgeShadowMapShader, 100 // 'shader': RDGE.rdgeShadowMapShader,
115 // 'clearColor' : [1.0,1.0,1.0,1.0], 101 // 'clearColor' : [1.0,1.0,1.0,1.0],
116 // 'geometrySet':"SHADOW", 102 // 'geometrySet':"SHADOW",
117 // } 103 // }
@@ -121,7 +107,7 @@ function SceneGraph(scene)
121 // { 107 // {
122 // 'outputs':[{ 'name':"sTexture", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], 108 // 'outputs':[{ 'name':"sTexture", 'type':"target", 'width':1024, 'height':1024, 'mips':false }],
123 // 'name':"glowMap", 109 // 'name':"glowMap",
124 // 'shader': rdgeGlowMapShader, 110 // 'shader': RDGE.rdgeGlowMapShader,
125 // 'clearColor' : [0.0,0.0,0.0,1.0], 111 // 'clearColor' : [0.0,0.0,0.0,1.0],
126 // 'technique':"createGlowMap", 112 // 'technique':"createGlowMap",
127 // 'geometrySet':"ALL", 113 // 'geometrySet':"ALL",
@@ -130,21 +116,21 @@ function SceneGraph(scene)
130 // { // the blur pass at half resolution 116 // { // the blur pass at half resolution
131 // 'name':"blurQuarter", 117 // 'name':"blurQuarter",
132 // 'geometrySet':"SCREEN_QUAD", 118 // 'geometrySet':"SCREEN_QUAD",
133 // 'shader': rdgeGaussianBlurShader, 119 // 'shader': RDGE.rdgeGaussianBlurShader,
134 // 'outputs':[{ 'name':"sTexture", 'type':"target", 'width':256, 'height':256, 'mips':false }], 120 // 'outputs':[{ 'name':"sTexture", 'type':"target", 'width':256, 'height':256, 'mips':false }],
135 // 'children': 121 // 'children':
136 // [ 122 // [
137 // { // the blur pass at half resolution 123 // { // the blur pass at half resolution
138 // 'name':"blurThreeQuarter", 124 // 'name':"blurThreeQuarter",
139 // 'geometrySet':"SCREEN_QUAD", 125 // 'geometrySet':"SCREEN_QUAD",
140 // 'shader': rdgeGaussianBlurShader, 126 // 'shader': RDGE.rdgeGaussianBlurShader,
141 // 'outputs':[{ 'name':"sTexture", 'type':"target", 'width':128, 'height':128, 'mips':false }], 127 // 'outputs':[{ 'name':"sTexture", 'type':"target", 'width':128, 'height':128, 'mips':false }],
142 // 'children': 128 // 'children':
143 // [ 129 // [
144 // { // the blur pass at quarter resolution 130 // { // the blur pass at quarter resolution
145 // 'name':"blurFull", 131 // 'name':"blurFull",
146 // 'geometrySet':"SCREEN_QUAD", 132 // 'geometrySet':"SCREEN_QUAD",
147 // 'shader': rdgeGaussianBlurShader, 133 // 'shader': RDGE.rdgeGaussianBlurShader,
148 // 'outputs':[{ 'name':"u_glowFinal", 'type':"target", 'width':1024, 'height':1024, 'mips':false }] 134 // 'outputs':[{ 'name':"u_glowFinal", 'type':"target", 'width':1024, 'height':1024, 'mips':false }]
149 // } 135 // }
150 // ] 136 // ]
@@ -156,7 +142,7 @@ function SceneGraph(scene)
156 // // depth map in view space 142 // // depth map in view space
157 // { 143 // {
158 // 'name':"depth_map", 144 // 'name':"depth_map",
159 // 'shader': rdgeDepthMapShaderDef, 145