aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/scenegraphNodes.js')
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/scenegraphNodes.js192
1 files changed, 96 insertions, 96 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
index 5a1e025b..c86dd1e9 100755
--- a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
+++ b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
@@ -35,9 +35,9 @@ var RDGE = RDGE || {};
35 * Creates a unique node id 35 * Creates a unique node id
36 */ 36 */
37RDGE.nodeIdGen = {}; 37RDGE.nodeIdGen = {};
38 38
39RDGE.nodeIdGen.counter = 0; 39RDGE.nodeIdGen.counter = 0;
40 40
41RDGE.nodeIdGen.getId = function () { 41RDGE.nodeIdGen.getId = function () {
42 return "gen_" + RDGE.nodeIdGen.counter++; 42 return "gen_" + RDGE.nodeIdGen.counter++;
43}; 43};
@@ -47,9 +47,9 @@ RDGE.nodeIdGen.getId = function () {
47 */ 47 */
48RDGE.createTransformNode = function (nodeName) { 48RDGE.createTransformNode = function (nodeName) {
49 node = { 'name': nodeName }; 49 node = { 'name': nodeName };
50 50
51 node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); 51 node.transformNodeTemplate = new RDGE.transformNodeTemplate(node);
52 52
53 return node; 53 return node;
54}; 54};
55 55
@@ -58,9 +58,9 @@ RDGE.createTransformNode = function (nodeName) {
58 */ 58 */
59RDGE.createMaterialNode = function (nodeName) { 59RDGE.createMaterialNode = function (nodeName) {
60 node = { 'name': nodeName }; 60 node = { 'name': nodeName };
61 61
62 node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); 62 node.materialNodeTemplate = new RDGE.materialNodeTemplate(node);
63 63
64 return node; 64 return node;
65}; 65};
66 66
@@ -69,9 +69,9 @@ RDGE.createMaterialNode = function (nodeName) {
69 */ 69 */
70RDGE.createMeshNode = function (nodeName, primitive) { 70RDGE.createMeshNode = function (nodeName, primitive) {
71 meshNode = { 'mesh':{}, 'meshNodeTemplate':{} }; 71 meshNode = { 'mesh':{}, 'meshNodeTemplate':{} };
72 72
73 var renderer = RDGE.globals.engine.getContext().renderer; 73 var renderer = RDGE.globals.engine.getContext().renderer;
74 74
75 if (!primitive.built) { 75 if (!primitive.built) {
76 renderer.createPrimitive(primitive); 76 renderer.createPrimitive(primitive);
77 } 77 }
@@ -86,9 +86,9 @@ RDGE.createMeshNode = function (nodeName, primitive) {
86 else if (!renderer.buffers[model.primitive.buffersID]) { 86 else if (!renderer.buffers[model.primitive.buffersID]) {
87 renderer.createPrimitive(model.primitive); 87 renderer.createPrimitive(model.primitive);
88 } 88 }
89 89
90 meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, model.primitive, nodeName); 90 meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, model.primitive, nodeName);
91 91
92 return meshNode; 92 return meshNode;
93}; 93};
94 94
@@ -98,7 +98,7 @@ RDGE.createMeshNode = function (nodeName, primitive) {
98RDGE.createLightNode = function (nodeName) { 98RDGE.createLightNode = function (nodeName) {
99 node = { 'name': nodeName }; 99 node = { 'name': nodeName };
100 node.lightNodeTemplate = new RDGE.lightNodeTemplate(node); 100 node.lightNodeTemplate = new RDGE.lightNodeTemplate(node);
101 101
102 return node; 102 return node;
103}; 103};
104 104
@@ -108,7 +108,7 @@ RDGE.createLightNode = function (nodeName) {
108RDGE.createScreenQuadNode = function () { 108RDGE.createScreenQuadNode = function () {
109 var trNode = RDGE.createTransformNode(); 109 var trNode = RDGE.createTransformNode();
110 trNode.attachMeshNode("screenQuad", RDGE.renderUtils.createScreenAlignedQuad()); 110 trNode.attachMeshNode("screenQuad", RDGE.renderUtils.createScreenAlignedQuad());
111 return trNode; 111 return trNode;
112}; 112};
113 113
114RDGE.verifyTransformNode = function (node) { 114RDGE.verifyTransformNode = function (node) {
@@ -135,52 +135,52 @@ RDGE.verifyLightNode = function (node) {
135 */ 135 */
136RDGE.transformNodeTemplate = function (trNode) { 136RDGE.transformNodeTemplate = function (trNode) {
137 // Lots of checking for things that might exist and adding them when they don't 137 // Lots of checking for things that might exist and adding them when they don't
138 138
139 /* ------------------------------------------- */ 139 /* ------------------------------------------- */
140 if (!trNode.children) { 140 if (!trNode.children) {
141 trNode.children = []; 141 trNode.children = [];
142 } 142 }
143 143
144 if (!trNode.local) { 144 if (!trNode.local) {
145 trNode.local = RDGE.mat4.identity(); 145 trNode.local = RDGE.mat4.identity();
146 } 146 }
147 147
148 if (!trNode.world) { 148 if (!trNode.world) {
149 trNode.world = RDGE.mat4.identity(); 149 trNode.world = RDGE.mat4.identity();
150 } 150 }
151 151
152 if (!trNode.id) { 152 if (!trNode.id) {
153 trNode.id = RDGE.nodeIdGen.getId(); 153 trNode.id = RDGE.nodeIdGen.getId();
154 } 154 }
155 155
156 if (!trNode.name) { 156 if (!trNode.name) {
157 trNode.name = "xfrmNode" + trNode.id; 157 trNode.name = "xfrmNode" + trNode.id;
158 } 158 }
159 159
160 if (!trNode.parent) { 160 if (!trNode.parent) {
161 trNode.parent = null; 161 trNode.parent = null;
162 } 162 }
163 163
164 if (!trNode.meshes) { 164 if (!trNode.meshes) {
165 trNode.meshes = []; 165 trNode.meshes = [];
166 } 166 }
167 167
168 if (!trNode.nodeType) { 168 if (!trNode.nodeType) {
169 trNode.nodeType = RDGE.rdgeConstants.nodeType.TRNODE; 169 trNode.nodeType = RDGE.rdgeConstants.nodeType.TRNODE;
170 } 170 }
171 171
172 /* ------------------------------------------- */ 172 /* ------------------------------------------- */
173 173
174 // Adding functions to the node none of these exist from export process 174 // Adding functions to the node none of these exist from export process
175 /* 175 /*
176 * Attaches a material to a node 176 * Attaches a material to a node
177 */ 177 */
178 trNode.attachMaterial = function (matNode) { 178 trNode.attachMaterial = function (matNode) {
179 RDGE.verifyMaterialNode(matNode); 179 RDGE.verifyMaterialNode(matNode);
180 180
181 this.materialNode = matNode; 181 this.materialNode = matNode;
182 }; 182 };
183 183
184 /* 184 /*
185 * @param node - the node to attach, can optionally be a node name paired with a primitive that will be built into a meshNode 185 * @param node - the node to attach, can optionally be a node name paired with a primitive that will be built into a meshNode
186 * @param primitive - an optional parameter that must be supplied if the node is a name and not an object 186 * @param primitive - an optional parameter that must be supplied if the node is a name and not an object
@@ -192,32 +192,32 @@ RDGE.transformNodeTemplate = function (trNode) {
192 if (trNode.materialNode == undefined) { 192 if (trNode.materialNode == undefined) {
193 trNode.materialNode = RDGE.createMaterialNode(trNode.name + "|defMaterial"); 193 trNode.materialNode = RDGE.createMaterialNode(trNode.name + "|defMaterial");
194 } 194 }
195 195
196 trNode.meshes.push( {'mesh':{'name':node.mesh.attribs.name, 'id':node.mesh.attribs.id}}); 196 trNode.meshes.push( {'mesh':{'name':node.mesh.attribs.name, 'id':node.mesh.attribs.id}});
197 }; 197 };
198 198
199 /* 199 /*
200 * Inserts a node as a child of this node 200 * Inserts a node as a child of this node
201 */ 201 */
202 trNode.insertAsChild = function (transNode) { 202 trNode.insertAsChild = function (transNode) {
203 if(this == transNode) 203 if(this == transNode)
204 return; 204 return;
205 205
206 RDGE.verifyTransformNode(transNode); 206 RDGE.verifyTransformNode(transNode);
207 207
208 transNode.parent = this; 208 transNode.parent = this;
209 this.children.push({transformNode:transNode}); 209 this.children.push({transformNode:transNode});
210 }; 210 };
211 211
212 /* 212 /*
213 * Inserts a node as the parent of this node 213 * Inserts a node as the parent of this node
214 */ 214 */
215 trNode.insertAsParent = function (transNode) { 215 trNode.