diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/scenegraphNodes.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | 1141 |
1 files changed, 571 insertions, 570 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js index 7fa4ff27..dc2efd3a 100755 --- a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js +++ b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | |||
@@ -1,570 +1,571 @@ | |||
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 | /* | 34 | |
35 | * Creates a unique node id | 35 | /* |
36 | */ | 36 | * Creates a unique node id |
37 | RDGE.nodeIdGen = {}; | 37 | */ |
38 | 38 | RDGE.nodeIdGen = {}; | |
39 | RDGE.nodeIdGen.counter = 0; | 39 | |
40 | 40 | RDGE.nodeIdGen.counter = 0; | |
41 | RDGE.nodeIdGen.getId = function () { | 41 | |
42 | return "gen_" + RDGE.nodeIdGen.counter++; | 42 | RDGE.nodeIdGen.getId = function () { |
43 | }; | 43 | return "gen_" + RDGE.nodeIdGen.counter++; |
44 | 44 | }; | |
45 | /* | 45 | |
46 | * Constructs a new transform node | 46 | /* |
47 | */ | 47 | * Constructs a new transform node |
48 | RDGE.createTransformNode = function (nodeName) { | 48 | */ |
49 | node = { 'name': nodeName }; | 49 | RDGE.createTransformNode = function (nodeName) { |
50 | 50 | node = { 'name': nodeName }; | |
51 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); | 51 | |
52 | 52 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); | |
53 | return node; | 53 | |
54 | }; | 54 | return node; |
55 | 55 | }; | |
56 | /* | 56 | |
57 | * Constructs a new material node | 57 | /* |
58 | */ | 58 | * Constructs a new material node |
59 | RDGE.createMaterialNode = function (nodeName) { | 59 | */ |
60 | node = { 'name': nodeName }; | 60 | RDGE.createMaterialNode = function (nodeName) { |
61 | 61 | node = { 'name': nodeName }; | |
62 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); | 62 | |
63 | 63 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); | |
64 | return node; | 64 | |
65 | }; | 65 | return node; |
66 | 66 | }; | |
67 | /* | 67 | |
68 | * Constructs a new mesh node | 68 | /* |
69 | */ | 69 | * Constructs a new mesh node |
70 | RDGE.createMeshNode = function (nodeName, primitive) { | 70 | */ |
71 | meshNode = { 'mesh':{}, 'meshNodeTemplate':{} }; | 71 | RDGE.createMeshNode = function (nodeName, primitive) { |
72 | 72 | meshNode = { 'mesh':{}, 'meshNodeTemplate':{} }; | |
73 | var renderer = RDGE.globals.engine.getContext().renderer; | 73 | |
74 | 74 | var renderer = RDGE.globals.engine.getContext().renderer; | |
75 | if (!primitive.built) { | 75 | |
76 | renderer.createPrimitive(primitive); | 76 | if (!primitive.built) { |
77 | } | 77 | renderer.createPrimitive(primitive); |
78 | 78 | } | |
79 | var model = RDGE.globals.meshMan.getModelByName(nodeName); | 79 | |
80 | if (!model) { | 80 | var model = RDGE.globals.meshMan.getModelByName(nodeName); |
81 | meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, primitive, nodeName); | 81 | if (!model) { |
82 | 82 | meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, primitive, nodeName); | |
83 | RDGE.globals.meshMan.modelMap[nodeName] = meshNode.mesh; | 83 | |
84 | return meshNode; // --early out-- | 84 | RDGE.globals.meshMan.modelMap[nodeName] = meshNode.mesh; |
85 | } | 85 | return meshNode; // --early out-- |
86 | else if (!renderer.buffers[model.primitive.buffersID]) { | 86 | } |
87 | renderer.createPrimitive(model.primitive); | 87 | else if (!renderer.buffers[model.primitive.buffersID]) { |
88 | } | 88 | renderer.createPrimitive(model.primitive); |
89 | 89 | } | |
90 | meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, model.primitive, nodeName); | 90 | |
91 | 91 | meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, model.primitive, nodeName); | |
92 | return meshNode; | 92 | |
93 | }; | 93 | return meshNode; |
94 | 94 | }; | |
95 | /* | 95 | |
96 | * Construct a light node | 96 | /* |
97 | */ | 97 | * Construct a light node |
98 | RDGE.createLightNode = function (nodeName) { | 98 | */ |
99 | node = { 'name': nodeName }; | 99 | RDGE.createLightNode = function (nodeName) { |
100 | node.lightNodeTemplate = new RDGE.lightNodeTemplate(node); | 100 | node = { 'name': nodeName }; |
101 | 101 | node.lightNodeTemplate = new RDGE.lightNodeTemplate(node); | |
102 | return node; | 102 | |
103 | }; | 103 | return node; |
104 | 104 | }; | |
105 | /* | 105 | |
106 | * creates a specialized mesh node representing a screen aligned quad with identity transform | 106 | /* |
107 | */ | 107 | * creates a specialized mesh node representing a screen aligned quad with identity transform |
108 | RDGE.createScreenQuadNode = function () { | 108 | */ |
109 | var trNode = RDGE.createTransformNode(); | 109 | RDGE.createScreenQuadNode = function () { |
110 | trNode.attachMeshNode("screenQuad", RDGE.renderUtils.createScreenAlignedQuad()); | 110 | var trNode = RDGE.createTransformNode(); |
111 | return trNode; | 111 | trNode.attachMeshNode("screenQuad", RDGE.renderUtils.createScreenAlignedQuad()); |
112 | }; | 112 | return trNode; |
113 | 113 | }; | |
114 | RDGE.verifyTransformNode = function (node) { | 114 | |
115 | if (node.transformNodeTemplate == undefined) { | 115 | RDGE.verifyTransformNode = function (node) { |
116 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); | 116 | if (node.transformNodeTemplate == undefined) { |
117 | } | 117 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); |
118 | }; | 118 | } |
119 | 119 | }; | |
120 | RDGE.verifyMaterialNode = function (node) { | 120 | |
121 | if (node.materialNodeTemplate == undefined) { | 121 | RDGE.verifyMaterialNode = function (node) { |
122 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); | 122 | if (node.materialNodeTemplate == undefined) { |
123 | } | 123 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); |
124 | }; | 124 | } |
125 | 125 | }; | |
126 | RDGE.verifyLightNode = function (node) { | 126 | |
127 | if (node.lightNodeTemplate == undefined) { | 127 | RDGE.verifyLightNode = function (node) { |
128 | node.lightNodeTemplate = new RDGE.lightNodeTemplate(node); | 128 | if (node.lightNodeTemplate == undefined) { |
129 | } | 129 | node.lightNodeTemplate = new RDGE.lightNodeTemplate(node); |
130 | }; | 130 | } |
131 | 131 | }; | |
132 | /* | 132 | |
133 | * Takes an object and attaches transform node | 133 | /* |
134 | * functions and fields if they are not defined | 134 | * Takes an object and attaches transform node |