diff options
author | Kris Kowal | 2012-07-06 11:52:06 -0700 |
---|---|---|
committer | Kris Kowal | 2012-07-06 15:01:48 -0700 |
commit | 648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch) | |
tree | 8f0f55557bd0c47a84e49c1977c950645d284607 /js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | |
parent | aedd14b18695d031f695d27dfbd94df5614495bb (diff) | |
download | ninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz |
Expand tabs
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/scenegraphNodes.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | 462 |
1 files changed, 231 insertions, 231 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..5a1e025b 100755 --- a/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js +++ b/js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | |||
@@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. | |||
32 | var RDGE = RDGE || {}; | 32 | var RDGE = RDGE || {}; |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Creates a unique node id | 35 | * Creates a unique node id |
36 | */ | 36 | */ |
37 | RDGE.nodeIdGen = {}; | 37 | RDGE.nodeIdGen = {}; |
38 | 38 | ||
@@ -43,35 +43,35 @@ RDGE.nodeIdGen.getId = function () { | |||
43 | }; | 43 | }; |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Constructs a new transform node | 46 | * Constructs a new transform node |
47 | */ | 47 | */ |
48 | RDGE.createTransformNode = function (nodeName) { | 48 | RDGE.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 | ||
56 | /* | 56 | /* |
57 | * Constructs a new material node | 57 | * Constructs a new material node |
58 | */ | 58 | */ |
59 | RDGE.createMaterialNode = function (nodeName) { | 59 | RDGE.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 | ||
67 | /* | 67 | /* |
68 | * Constructs a new mesh node | 68 | * Constructs a new mesh node |
69 | */ | 69 | */ |
70 | RDGE.createMeshNode = function (nodeName, primitive) { | 70 | RDGE.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 | } |
@@ -84,31 +84,31 @@ RDGE.createMeshNode = function (nodeName, primitive) { | |||
84 | return meshNode; // --early out-- | 84 | return meshNode; // --early out-- |
85 | } | 85 | } |
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 | ||
95 | /* | 95 | /* |
96 | * Construct a light node | 96 | * Construct a light node |
97 | */ | 97 | */ |
98 | RDGE.createLightNode = function (nodeName) { | 98 | RDGE.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 | ||
105 | /* | 105 | /* |
106 | * creates a specialized mesh node representing a screen aligned quad with identity transform | 106 | * creates a specialized mesh node representing a screen aligned quad with identity transform |
107 | */ | 107 | */ |
108 | RDGE.createScreenQuadNode = function () { | 108 | RDGE.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 | ||
114 | RDGE.verifyTransformNode = function (node) { | 114 | RDGE.verifyTransformNode = function (node) { |
@@ -130,301 +130,301 @@ RDGE.verifyLightNode = function (node) { | |||
130 | }; | 130 | }; |
131 | 131 | ||
132 | /* | 132 | /* |
133 | * Takes an object and attaches transform node | 133 | * Takes an object and attaches transform node |
134 | * functions and fields if they are not defined | 134 | * functions and fields if they are not defined |
135 | */ | 135 | */ |
136 | RDGE.transformNodeTemplate = function (trNode) { | 136 | RDGE.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 |
187 | */ |