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 | 543 |
1 files changed, 272 insertions, 271 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js index 035e30d1..95ee2803 100755 --- a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js +++ b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | |||
@@ -8,46 +8,46 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
8 | var RDGE = RDGE || {}; | 8 | var RDGE = RDGE || {}; |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Creates a unique node id | 11 | * Creates a unique node id |
12 | */ | 12 | */ |
13 | RDGE.nodeIdGen = {}; | 13 | RDGE.nodeIdGen = {}; |
14 | 14 | ||
15 | RDGE.nodeIdGen.counter = 0; | 15 | RDGE.nodeIdGen.counter = 0; |
16 | 16 | ||
17 | RDGE.nodeIdGen.getId = function () { | 17 | RDGE.nodeIdGen.getId = function () { |
18 | return "gen_" + RDGE.nodeIdGen.counter++; | 18 | return "gen_" + RDGE.nodeIdGen.counter++; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Constructs a new transform node | 22 | * Constructs a new transform node |
23 | */ | 23 | */ |
24 | RDGE.createTransformNode = function (nodeName) { | 24 | RDGE.createTransformNode = function (nodeName) { |
25 | node = { 'name': nodeName }; | 25 | node = { 'name': nodeName }; |
26 | 26 | ||
27 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); | 27 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); |
28 | 28 | ||
29 | return node; | 29 | return node; |
30 | }; | 30 | }; |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * Constructs a new material node | 33 | * Constructs a new material node |
34 | */ | 34 | */ |
35 | RDGE.createMaterialNode = function (nodeName) { | 35 | RDGE.createMaterialNode = function (nodeName) { |
36 | node = { 'name': nodeName }; | 36 | node = { 'name': nodeName }; |
37 | 37 | ||
38 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); | 38 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); |
39 | 39 | ||
40 | return node; | 40 | return node; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | /* | 43 | /* |
44 | * Constructs a new mesh node | 44 | * Constructs a new mesh node |
45 | */ | 45 | */ |
46 | RDGE.createMeshNode = function (nodeName, primitive) { | 46 | RDGE.createMeshNode = function (nodeName, primitive) { |
47 | meshNode = { 'mesh': {}, 'meshNodeTemplate': {} }; | 47 | meshNode = { 'mesh':{}, 'meshNodeTemplate':{} }; |
48 | 48 | ||
49 | var renderer = RDGE.globals.engine.getContext().renderer; | 49 | var renderer = RDGE.globals.engine.getContext().renderer; |
50 | 50 | ||
51 | if (!primitive.built) { | 51 | if (!primitive.built) { |
52 | renderer.createPrimitive(primitive); | 52 | renderer.createPrimitive(primitive); |
53 | } | 53 | } |
@@ -60,43 +60,43 @@ RDGE.createMeshNode = function (nodeName, primitive) { | |||
60 | return meshNode; // --early out-- | 60 | return meshNode; // --early out-- |
61 | } | 61 | } |
62 | else if (!renderer.buffers[model.primitive.buffersID]) { | 62 | else if (!renderer.buffers[model.primitive.buffersID]) { |
63 | renderer.createPrimitive(model.primitive); | 63 | renderer.createPrimitive(model.primitive); |
64 | } | 64 | } |
65 | 65 | ||
66 | meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, model.primitive, nodeName); | 66 | meshNode.mesh.meshNodeTemplate = new RDGE.meshNodeTemplate(meshNode.mesh, model.primitive, nodeName); |
67 | 67 | ||
68 | return meshNode; | 68 | return meshNode; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | /* | 71 | /* |
72 | * Construct a light node | 72 | * Construct a light node |
73 | */ | 73 | */ |
74 | RDGE.createLightNode = function (nodeName) { | 74 | RDGE.createLightNode = function (nodeName) { |
75 | node = { 'name': nodeName }; | 75 | node = { 'name': nodeName }; |
76 | node.lightNodeTemplate = new RDGE.lightNodeTemplate(node); | 76 | node.lightNodeTemplate = new RDGE.lightNodeTemplate(node); |
77 | 77 | ||
78 | return node; | 78 | return node; |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * creates a specialized mesh node representing a screen aligned quad with identity transform | 82 | * creates a specialized mesh node representing a screen aligned quad with identity transform |
83 | */ | 83 | */ |
84 | RDGE.createScreenQuadNode = function () { | 84 | RDGE.createScreenQuadNode = function () { |
85 | var trNode = RDGE.createTransformNode(); | 85 | var trNode = RDGE.createTransformNode(); |
86 | trNode.attachMeshNode("screenQuad", RDGE.renderUtils.createScreenAlignedQuad()); | 86 | trNode.attachMeshNode("screenQuad", RDGE.renderUtils.createScreenAlignedQuad()); |
87 | return trNode; | 87 | return trNode; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | RDGE.verifyTransformNode = function (node) { | 90 | RDGE.verifyTransformNode = function (node) { |
91 | if (node.transformNodeTemplate == undefined) { | 91 | if (node.transformNodeTemplate == undefined) { |
92 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); | 92 | node.transformNodeTemplate = new RDGE.transformNodeTemplate(node); |
93 | } | 93 | } |
94 | }; | 94 | }; |
95 | 95 | ||
96 | RDGE.verifyMaterialNode = function (node) { | 96 | RDGE.verifyMaterialNode = function (node) { |
97 | if (node.materialNodeTemplate == undefined) { | 97 | if (node.materialNodeTemplate == undefined) { |
98 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); | 98 | node.materialNodeTemplate = new RDGE.materialNodeTemplate(node); |
99 | } | 99 | } |
100 | }; | 100 | }; |
101 | 101 | ||
102 | RDGE.verifyLightNode = function (node) { | 102 | RDGE.verifyLightNode = function (node) { |
@@ -107,299 +107,300 @@ RDGE.verifyLightNode = function (node) { | |||
107 | 107 | ||
108 | /* | 108 | /* |
109 | * Takes an object and attaches transform node | 109 | * Takes an object and attaches transform node |
110 | * functions and fields if they are not defined | 110 | * functions and fields if they are not defined |
111 | */ | 111 | */ |
112 | RDGE.transformNodeTemplate = function (trNode) { | 112 | RDGE.transformNodeTemplate = function (trNode) { |
113 | // Lots of checking for things that might exist and adding them when they don't | 113 | // Lots of checking for things that might exist and adding them when they don't |
114 | 114 | ||
115 | /* ------------------------------------------- */ | 115 | /* ------------------------------------------- */ |
116 | if (!trNode.children) { | 116 | if (!trNode.children) { |
117 | trNode.children = []; | 117 | trNode.children = []; |
118 | } | 118 | } |
119 | 119 | ||
120 | if (!trNode.local) { | 120 | if (!trNode.local) { |
121 | trNode.local = RDGE.mat4.identity(); | 121 | trNode.local = RDGE.mat4.identity(); |
122 | } | 122 | } |
123 | 123 | ||
124 | if (!trNode.world) { | 124 | if (!trNode.world) { |
125 | trNode.world = RDGE.mat4.identity(); | 125 | trNode.world = RDGE.mat4.identity(); |
126 | } | 126 | } |
127 | 127 | ||
128 | if (!trNode.id) { | 128 | if (!trNode.id) { |
129 | trNode.id = RDGE.nodeIdGen.getId(); | 129 | trNode.id = RDGE.nodeIdGen.getId(); |
130 | } | 130 | } |
131 | 131 | ||
132 | if (!trNode.name) { | 132 | if (!trNode.name) { |
133 | trNode.name = "xfrmNode" + trNode.id; | 133 | trNode.name = "xfrmNode" + trNode.id; |
134 | } | 134 | } |
135 | 135 | ||
136 | if (!trNode.parent) { | 136 | if (!trNode.parent) { |
137 | trNode.parent = null; | 137 | trNode.parent = null; |
138 | } | 138 | } |
139 | 139 | ||
140 | if (!trNode.meshes) { | 140 | if (!trNode.meshes) { |
141 | trNode.meshes = []; | 141 | trNode.meshes = []; |
142 | } | 142 | } |
143 | 143 | ||
144 | if (!trNode.nodeType) { | 144 | if (!trNode.nodeType) { |
145 | trNode.nodeType = RDGE.rdgeConstants.nodeType.TRNODE; | 145 | trNode.nodeType = RDGE.rdgeConstants.nodeType.TRNODE; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* ------------------------------------------- */ | 148 | /* ------------------------------------------- */ |
149 | 149 | ||
150 | // Adding functions to the node none of these exist from export process | 150 | // Adding functions to the node none of these exist from export process |
151 | /* | 151 |