diff options
author | John Mayhew | 2012-04-02 16:28:39 -0700 |
---|---|---|
committer | John Mayhew | 2012-04-02 16:28:39 -0700 |
commit | b4155fb4c33675a8a7cd37473513718043fdf0ba (patch) | |
tree | 3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/helper-classes/RDGE/src/core | |
parent | 5ba9aeac94c86049423fd5d4b37b277263939c13 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts:
js/helper-classes/RDGE/rdge-compiled.js
js/helper-classes/RDGE/runtime/GLRuntime.js
js/helper-classes/RDGE/src/core/script/MeshManager.js
js/helper-classes/RDGE/src/core/script/engine.js
js/helper-classes/RDGE/src/core/script/fx/ssao.js
js/helper-classes/RDGE/src/core/script/init_state.js
js/helper-classes/RDGE/src/core/script/run_state.js
js/helper-classes/RDGE/src/core/script/scenegraphNodes.js
js/helper-classes/RDGE/src/core/script/utilities.js
js/helper-classes/RDGE/src/tools/compile-rdge-core.bat
js/helper-classes/RDGE/src/tools/compile-rdge-core.sh
js/helper-classes/RDGE/src/tools/rdge-compiled.js
js/lib/drawing/world.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/linear-gradient-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-blur-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
js/preloader/Preloader.js
Diffstat (limited to 'js/helper-classes/RDGE/src/core')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/MeshManager.js | 116 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/engine.js | 290 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/fx/ssao.js | 90 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/init_state.js | 298 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/jshader.js | 8 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/renderer.js | 1 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/run_state.js | 416 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/scenegraphNodes.js | 543 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/utilities.js | 152 |
9 files changed, 970 insertions, 944 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/MeshManager.js b/js/helper-classes/RDGE/src/core/script/MeshManager.js index 2c31781e..4fa3c908 100755 --- a/js/helper-classes/RDGE/src/core/script/MeshManager.js +++ b/js/helper-classes/RDGE/src/core/script/MeshManager.js | |||
@@ -14,31 +14,31 @@ RDGE.Model = function (name, mesh) { | |||
14 | }; | 14 | }; |
15 | 15 | ||
16 | /* | 16 | /* |
17 | * Maintains a list of meshes to allow instancing of data | 17 | * Maintains a list of meshes to allow instancing of data |
18 | */ | 18 | */ |
19 | RDGE.MeshManager = function () { | 19 | RDGE.MeshManager = function () { |
20 | this.contentUrl = "assets_web/mesh/"; | 20 | this.contentUrl = "assets_web/mesh/"; |
21 | this.modelMap = {}; | 21 | this.modelMap = {}; |
22 | this.readyList = []; // meshes that have data ready | 22 | this.readyList = []; // meshes that have data ready |
23 | this.meshesLoading = true; // indicates that no meshes have loaded or that they are still loading | 23 | this.meshesLoading = true; // indicates that no meshes have loaded or that they are still loading |
24 | this.postMeshLoadCallbackList = []; | 24 | this.postMeshLoadCallbackList = []; |
25 | this.tempSphere = null; | 25 | this.tempSphere = null; |
26 | this.requestCounter = 0; | 26 | this.requestCounter = 0; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * Pass the scene meshNode stump, loads temp object while real mesh is downloading | 30 | * Pass the scene meshNode stump, loads temp object while real mesh is downloading |
31 | */ | 31 | */ |
32 | RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) { | 32 | RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) { |
33 | // if it exists already, return the mesh requested | 33 | // if it exists already, return the mesh requested |
34 | if (this.modelMap[meshStump.name] !== undefined) | 34 | if ( this.modelMap[meshStump.name] !== undefined ) |
35 | return this.modelMap[meshStump.name]; | 35 | return this.modelMap[meshStump.name]; |
36 | 36 | ||
37 | meshStump.ready = false; | 37 | meshStump.ready = false; |
38 | meshStump.addr = this.contentUrl + meshStump.name + "_mesh.json"; | 38 | meshStump.addr = this.contentUrl + meshStump.name + "_mesh.json"; |
39 | meshStump.ctxID = RDGE.globals.engine.getContext().renderer.id; | 39 | meshStump.ctxID = RDGE.globals.engine.getContext().renderer.id; |
40 | 40 | ||
41 | // sets a temp mesh up in place of the final mesh to load | 41 | // sets a temp mesh up in place of the final mesh to load |
42 | if (!tempMesh) { | 42 | if (!tempMesh) { |
43 | if (this.tempSphere == null) { | 43 | if (this.tempSphere == null) { |
44 | this.tempSphere = RDGE.renderUtils.makeSphere(RDGE.globals.engine.getContext().renderer.ctx, 25, 5, 5); | 44 | this.tempSphere = RDGE.renderUtils.makeSphere(RDGE.globals.engine.getContext().renderer.ctx, 25, 5, 5); |
@@ -47,9 +47,9 @@ RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) { | |||
47 | tempMesh = this.tempSphere; | 47 | tempMesh = this.tempSphere; |
48 | } | 48 | } |
49 | 49 | ||
50 | // add the temp mesh to the map of loaded meshes | 50 | // add the temp mesh to the map of loaded meshes |
51 | this.modelMap[meshStump.name] = tempMesh; | 51 | this.modelMap[meshStump.name] = tempMesh; |
52 | 52 | ||
53 | // update the request counter - we now have one more mesh to load | 53 | // update the request counter - we now have one more mesh to load |
54 | this.requestCounter++; | 54 | this.requestCounter++; |
55 | 55 | ||
@@ -59,18 +59,18 @@ RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) { | |||
59 | }; | 59 | }; |
60 | 60 | ||
61 | /* | 61 | /* |
62 | * Deletes the passed mesh from the manager as well as all renderers | 62 | * Deletes the passed mesh from the manager as well as all renderers |
63 | */ | 63 | */ |
64 | RDGE.MeshManager.prototype.deleteMesh = function (name) { | 64 | RDGE.MeshManager.prototype.deleteMesh = function (name) { |
65 | var model = this.modelMap[name]; | 65 | var model = this.modelMap[name]; |
66 | 66 | ||
67 | if (model) { | 67 | if (model) { |
68 | RDGE.globals.engine.ctxMan.forEach(function (context) { | 68 | RDGE.globals.engine.ctxMan.forEach(function (context) { |
69 | context.renderer.deletePrimitive(model.primitive); | 69 | context.renderer.deletePrimitive(model.primitive); |
70 | }); | 70 | }); |
71 | 71 | ||
72 | delete this.modelMap[name]; | 72 | delete this.modelMap[name]; |
73 | } | 73 | } |
74 | }; | 74 | }; |
75 | 75 | ||
76 | RDGE.MeshManager.prototype.getModelByName = function (name) { | 76 | RDGE.MeshManager.prototype.getModelByName = function (name) { |
@@ -89,22 +89,22 @@ RDGE.MeshManager.prototype.getModelNames = function () { | |||
89 | 89 | ||
90 | RDGE.MeshManager.prototype.processMeshData = function () { | 90 | RDGE.MeshManager.prototype.processMeshData = function () { |
91 | var renderer = RDGE.globals.engine.getContext().renderer; | 91 | var renderer = RDGE.globals.engine.getContext().renderer; |
92 | 92 | ||
93 | // loop through meshes and load ready data | 93 | // loop through meshes and load ready data |
94 | for (var index in this.readyList) { | 94 | for (var index in this.readyList) { |
95 | // if item is ready load it | 95 | // if item is ready load it |
96 | if (this.readyList[index] && this.readyList[index].ready && renderer.id === this.readyList[index].ctxID) { | 96 | if (this.readyList[index] && this.readyList[index].ready && renderer.id === this.readyList[index].ctxID) { |
97 | 97 | ||
98 | 98 | ||
99 | // pop the item | 99 | // pop the item |
100 | var model = this.readyList[index]; | 100 | var model = this.readyList[index]; |
101 | this.readyList.splice(index, 1); | 101 | this.readyList.splice(index, 1); |
102 | 102 | ||
103 | var primset = new RDGE.rdgePrimitiveDefinition(); | 103 | var primset = new RDGE.rdgePrimitiveDefinition(); |
104 | 104 | ||
105 | primset.vertexDefinition = | 105 | primset.vertexDefinition = |
106 | { | 106 | { |
107 | // this shows two ways to map this data to an attribute | 107 | // this shows two ways to map this data to an attribute |
108 | "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, | 108 | "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, |
109 | "a_pos": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, | 109 | "a_pos": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, |
110 | "normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, | 110 | "normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, |
@@ -115,44 +115,44 @@ RDGE.MeshManager.prototype.processMeshData = function () { | |||
115 | "a_texcoords": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, | 115 | "a_texcoords": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, |
116 | "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC } | 116 | "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC } |
117 | }; | 117 | }; |
118 | 118 | ||
119 | primset.bufferStreams = | 119 | primset.bufferStreams = |
120 | [ | 120 | [ |
121 | model.root.data.coords, | 121 | model.root.data.coords, |
122 | model.root.data.normals, | 122 | model.root.data.normals, |
123 | model.root.data.uvs | 123 | model.root.data.uvs |
124 | ]; | 124 | ]; |
125 | 125 | ||
126 | primset.streamUsage = | 126 | primset.streamUsage = |
127 | [ | 127 | [ |
128 | RDGE.rdgeConstants.BUFFER_STATIC, | 128 | RDGE.rdgeConstants.BUFFER_STATIC, |
129 | RDGE.rdgeConstants.BUFFER_STATIC, | 129 | RDGE.rdgeConstants.BUFFER_STATIC, |
130 | RDGE.rdgeConstants.BUFFER_STATIC | 130 | RDGE.rdgeConstants.BUFFER_STATIC |
131 | ]; | 131 | ]; |
132 | 132 | ||
133 | primset.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM; | 133 | primset.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM; |
134 | 134 | ||
135 | primset.indexBuffer = model.root.data.indices; | 135 | primset.indexBuffer = model.root.data.indices; |
136 | 136 | ||
137 | renderer.createPrimitive(primset); | 137 | renderer.createPrimitive( primset ); |
138 | 138 | ||
139 | model.root.primitive = primset; | 139 | model.root.primitive = primset; |
140 | 140 | ||
141 | // generate a bounding box for this mesh | 141 | // generate a bounding box for this mesh |
142 | model.root.bbox = new RDGE.box(); | 142 | model.root.bbox = new RDGE.box(); |
143 | 143 | ||
144 | var numCoords = model.root.data.coords.length; var idx = 0; | 144 | var numCoords = model.root.data.coords.length; var idx = 0; |
145 | while (idx < numCoords - 2) { | 145 | while (idx < numCoords - 2) { |
146 | var thisCoord = [model.root.data.coords[idx + 0], model.root.data.coords[idx + 1], model.root.data.coords[idx + 2]]; | 146 | var thisCoord = [model.root.data.coords[idx+0], model.root.data.coords[idx+1], model.root.data.coords[idx+2]]; |
147 | model.root.bbox.addVec3(thisCoord); | 147 | model.root.bbox.addVec3(thisCoord); |
148 |