diff options
author | John Mayhew | 2012-07-09 17:28:24 -0700 |
---|---|---|
committer | John Mayhew | 2012-07-09 17:28:24 -0700 |
commit | 770bcb52422742ff741a88a75ecefbeb90bc9247 (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/helper-classes/RDGE/src/core/script/scenegraph.js | |
parent | 8c5ecaf90062f9e030386f338bdc19fd62b826c8 (diff) | |
parent | 2b2b5fbb4b6a786daa4e9d4ee9eba9ac78924842 (diff) | |
download | ninja-770bcb52422742ff741a88a75ecefbeb90bc9247.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Conflicts:
manifest.json
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/scenegraph.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/scenegraph.js | 2007 |
1 files changed, 1004 insertions, 1003 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/scenegraph.js b/js/helper-classes/RDGE/src/core/script/scenegraph.js index 44f1212f..580f9c84 100755 --- a/js/helper-classes/RDGE/src/core/script/scenegraph.js +++ b/js/helper-classes/RDGE/src/core/script/scenegraph.js | |||
@@ -1,1003 +1,1004 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | 4 | |
5 | 5 | Redistribution and use in source and binary forms, with or without | |
6 | Redistribution and use in source and binary forms, with or without | 6 | modification, are permitted provided that the following conditions are met: |
7 | modification, are permitted provided that the following conditions are met: | 7 | |
8 | 8 | * Redistributions of source code must retain the above copyright notice, | |
9 | - Redistributions of source code must retain the above copyright notice, | 9 | this list of conditions and the following disclaimer. |
10 | this list of conditions and the following disclaimer. | 10 | |
11 | - Redistributions in binary form must reproduce the above copyright | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
12 | notice, this list of conditions and the following disclaimer in the | 12 | this list of conditions and the following disclaimer in the documentation |
13 | documentation and/or other materials provided with the distribution. | 13 | and/or other materials provided with the distribution. |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 14 | |
15 | may be used to endorse or promote products derived from this software | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | without specific prior written permission. | 16 | contributors may be used to endorse or promote products derived from this |
17 | 17 | software without specific prior written permission. | |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 18 | |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 26 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | POSSIBILITY OF SUCH DAMAGE. | 28 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | </copyright> */ | 29 | POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | </copyright> */ | |
31 | // RDGE namespaces | 31 | |
32 | var RDGE = RDGE || {}; | 32 | // RDGE namespaces |
33 | 33 | var RDGE = RDGE || {}; | |
34 | // default render proc | 34 | |
35 | // render scene nodes | 35 | // default render proc |
36 | RDGE.DefaultRender = function () { | 36 | // render scene nodes |
37 | // setup the default shader | 37 | RDGE.DefaultRender = function () { |
38 | this.renderer = RDGE.globals.engine.getContext().renderer; | 38 | // setup the default shader |
39 | //this.shaderProgram = this.renderer.defaultShader; | 39 | this.renderer = RDGE.globals.engine.getContext().renderer; |
40 | this.jshaderProgram = new RDGE.jshader(); | 40 | //this.shaderProgram = this.renderer.defaultShader; |
41 | this.jshaderProgram.def = this.renderer.defaultShaderDefintion; | 41 | this.jshaderProgram = new RDGE.jshader(); |
42 | this.jshaderProgram.init(); | 42 | this.jshaderProgram.def = this.renderer.defaultShaderDefintion; |
43 | }; | 43 | this.jshaderProgram.init(); |
44 | 44 | }; | |
45 | RDGE.DefaultRender.prototype.process = function (context, trNode, parent) { | 45 | |
46 | }; | 46 | RDGE.DefaultRender.prototype.process = function (context, trNode, parent) { |
47 | 47 | }; | |
48 | function renderObject(trNode, renderCtx, parent) { | 48 | |
49 | this.node = trNode ? trNode : RDGE.createTransformNode(); | 49 | function renderObject(trNode, renderCtx, parent) { |
50 | this.context = renderCtx ? renderCtx : new RDGE.RenderContext(); | 50 | this.node = trNode ? trNode : RDGE.createTransformNode(); |
51 | this.parent = parent ? parent : null; | 51 | this.context = renderCtx ? renderCtx : new RDGE.RenderContext(); |
52 | }; | 52 | this.parent = parent ? parent : null; |
53 | 53 | }; | |
54 | 54 | ||
55 | // Scene graph contains set of tools for manipulating the graph | 55 | |
56 | RDGE.SceneGraph = function (scene) { | 56 | // Scene graph contains set of tools for manipulating the graph |
57 | if (scene == undefined || scene == null) | 57 | RDGE.SceneGraph = function (scene) { |
58 | scene = {}; | 58 | if (scene == undefined || scene == null) |
59 | 59 | scene = {}; | |
60 | this.scene = scene; | 60 | |
61 | 61 | this.scene = scene; | |
62 | if (this.scene.root != undefined) | 62 | |
63 | this.scene = this.scene.root; | 63 | if (this.scene.root != undefined) |
64 | else | 64 | this.scene = this.scene.root; |
65 | this.scene = { 'children': [] }; | 65 | else |
66 | 66 | this.scene = { 'children': [] }; | |
67 | this.tick = 0; | 67 | |
68 | this.lastTick = -1; | 68 | this.tick = 0; |
69 | this.frustumCulling = true; | 69 | this.lastTick = -1; |
70 | 70 | this.frustumCulling = true; | |
71 | // the main light for the scene - also casts shadows | 71 | |
72 | this.mainLight = new RDGE.shadowLight(); | 72 | // the main light for the scene - also casts shadows |
73 | 73 | this.mainLight = new RDGE.shadowLight(); | |
74 | this.bckTypes = RDGE.rdgeConstants.categoryEnumeration; | 74 | |
75 | 75 | this.bckTypes = RDGE.rdgeConstants.categoryEnumeration; | |
76 | this.renderList = new Array(this.bckTypes.MAX_CAT); | 76 | |
77 | this.renderList[this.bckTypes.BACKGROUND] = []; //BACKGROUND | 77 | this.renderList = new Array(this.bckTypes.MAX_CAT); |
78 | this.renderList[this.bckTypes.OPAQUE] = []; //OPAQUE | 78 | this.renderList[this.bckTypes.BACKGROUND] = []; //BACKGROUND |
79 | this.renderList[this.bckTypes.TRANSPARENT] = []; //TRANSPARENT | 79 | this.renderList[this.bckTypes.OPAQUE] = []; //OPAQUE |
80 | this.renderList[this.bckTypes.ADDITIVE] = []; //ADDITIVE | 80 | this.renderList[this.bckTypes.TRANSPARENT] = []; //TRANSPARENT |
81 | this.renderList[this.bckTypes.TRANSLUCENT] = []; //TRANSLUCENT | 81 | this.renderList[this.bckTypes.ADDITIVE] = []; //ADDITIVE |
82 | this.renderList[this.bckTypes.FOREGROUND] = []; //FOREGROUND | 82 | this.renderList[this.bckTypes.TRANSLUCENT] = []; //TRANSLUCENT |
83 | 83 | this.renderList[this.bckTypes.FOREGROUND] = []; //FOREGROUND | |
84 | // a list of shadow geometry | 84 | |
85 | this.shadowRenderList = []; | 85 | // a list of shadow geometry |
86 | 86 | this.shadowRenderList = []; | |
87 | // scene traversal functor for creating a culled list of shadow geometry | 87 | |
88 | this.shadowCuller = null; | 88 | // scene traversal functor for creating a culled list of shadow geometry |
89 | 89 | this.shadowCuller = null; | |
90 | // define passes to render geometry and handle post-processing | 90 | |
91 | this.defaultPassDef = | 91 | // define passes to render geometry and handle post-processing |
92 | { | 92 | this.defaultPassDef = |
93 | // a pass can have children that will receive their parents output as input | 93 | { |
94 | 94 | // a pass can have children that will receive their parents output as input | |
95 | // this pass renders the depth map to an off-screen target - from the shadow lights view | 95 | |
96 | // you can specify what your output should be | 96 | // this pass renders the depth map to an off-screen target - from the shadow lights view |
97 | // @param name - this tells jshader's of child passes (which receive the parents output as input) | 97 | // you can specify what your output should be |
98 | // what the sampler2d uniform name will be for this output texture | 98 | // @param name - this tells jshader's of child passes (which receive the parents output as input) |
99 | // @param type - the type of output could be tex2d or target | 99 | // what the sampler2d uniform name will be for this output texture |
100 | // @param width - optional width of the render target | 100 | // @param type - the type of output could be tex2d or target |
101 | // @param height - optional height of the render target | 101 | // @param width - optional width of the render target |
102 | // @param mips - optional flag indicating whether the render target will support mip-mapping | 102 | // @param height - optional height of the render target |
103 | 103 | // @param mips - optional flag indicating whether the render target will support mip-mapping | |
104 | // the geometry pass | 104 | |
105 | 'name': "geoPass", | 105 | // the geometry pass |
106 | 'geometrySet': "ALL" | 106 | 'name': "geoPass", |
107 | // 'outputs':[{ 'name':"u_mainRT", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], | 107 | 'geometrySet': "ALL" |
108 | // 'children': | 108 | // 'outputs':[{ 'name':"u_mainRT", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], |
109 | // [ | 109 | // 'children': |
110 | // // shadow pass | 110 | // [ |
111 | // { | 111 | // // shadow pass |
112 | // 'outputs':[{ 'name':"u_shadowDepthMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], | 112 | // { |
113 | // // custom parameter | 113 | // 'outputs':[{ 'name':"u_shadowDepthMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], |
114 | // 'name':"shadowDepthMap", | 114 | // // custom parameter |
115 | // 'shader': RDGE.rdgeDepthMapShaderDef, | 115 | // 'name':"shadowDepthMap", |
116 | // 'technique':"shadowDepthMap", | 116 | // 'shader': RDGE.rdgeDepthMapShaderDef, |
117 | // 'geometrySet':"SHADOW", | 117 | // 'technique':"shadowDepthMap", |
118 | // 'children': | 118 | // 'geometrySet':"SHADOW", |
119 | // [ | 119 | // 'children': |
120 | // // create shadow rt | 120 | // [ |
121 | // { | 121 | // // create shadow rt |
122 | // 'outputs':[{ 'name':"u_shadowMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], | 122 | // { |
123 | // 'name':"shadowMap", | 123 | // 'outputs':[{ 'name':"u_shadowMap", 'type':"target", 'width':1024, 'height':1024, 'mips':false }], |
124 | // 'shader': RDGE.rdgeShadowMapShader, | 124 | // 'name':"shadowMap", |
125 | // 'clearColor' : [1.0,1.0,1.0,1.0], | 125 |