diff options
author | hwc487 | 2012-02-22 15:22:13 -0800 |
---|---|---|
committer | hwc487 | 2012-02-22 15:22:13 -0800 |
commit | 2bb869eb1c0b71e379f159eb0f95dfa168496d8d (patch) | |
tree | a87c5bed45925b20ce0394d6ff22280e9afaf02c /js/helper-classes/RDGE | |
parent | f5a9123ba661fe83442a873a05bc6a86edc396f8 (diff) | |
download | ninja-2bb869eb1c0b71e379f159eb0f95dfa168496d8d.tar.gz |
Runtime classes
Diffstat (limited to 'js/helper-classes/RDGE')
-rwxr-xr-x | js/helper-classes/RDGE/GLCircle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLLine.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLRectangle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLWorld.js | 29 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/CanvasLoader.js | 72 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/GLRuntime.js | 159 |
6 files changed, 246 insertions, 20 deletions
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index 5b32547e..712544c0 100755 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -135,7 +135,7 @@ function GLCircle() | |||
135 | if (!world._useWebGL) return; | 135 | if (!world._useWebGL) return; |
136 | 136 | ||
137 | // make sure RDGE has the correct context | 137 | // make sure RDGE has the correct context |
138 | g_Engine.setContext( world.getCanvas().uuid ); | 138 | g_Engine.setContext( world.getCanvas().rdgeid ); |
139 | 139 | ||
140 | // create the gl buffer | 140 | // create the gl buffer |
141 | var gl = world.getGLContext(); | 141 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index 0d815145..f715a43c 100755 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js | |||
@@ -171,7 +171,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro | |||
171 | if (!world._useWebGL) return; | 171 | if (!world._useWebGL) return; |
172 | 172 | ||
173 | // make sure RDGE has the correct context | 173 | // make sure RDGE has the correct context |
174 | g_Engine.setContext( world.getCanvas().uuid ); | 174 | g_Engine.setContext( world.getCanvas().rdgeid ); |
175 | 175 | ||
176 | // create the gl buffer | 176 | // create the gl buffer |
177 | var gl = world.getGLContext(); | 177 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 5b6ff94f..3c1cb7dc 100755 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -214,7 +214,7 @@ function GLRectangle() | |||
214 | if (!world._useWebGL) return; | 214 | if (!world._useWebGL) return; |
215 | 215 | ||
216 | // make sure RDGE has the correct context | 216 | // make sure RDGE has the correct context |
217 | g_Engine.setContext( world.getCanvas().uuid ); | 217 | g_Engine.setContext( world.getCanvas().rdgeid ); |
218 | 218 | ||
219 | // create the gl buffer | 219 | // create the gl buffer |
220 | var gl = world.getGLContext(); | 220 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index 1edd5cff..0addcadc 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -136,13 +136,6 @@ function GLWorld( canvas, use3D ) | |||
136 | var camMat = Matrix.I(4); | 136 | var camMat = Matrix.I(4); |
137 | camMat[14] = this.getViewDistance(); | 137 | camMat[14] = this.getViewDistance(); |
138 | this.setCameraMat( camMat ); | 138 | this.setCameraMat( camMat ); |
139 | |||
140 | ////////////////////////////////////////// | ||
141 | // test call to SVG importer | ||
142 | // console.log( "***** SVG TEST *****" ); | ||
143 | // var svgImporter = new SVGParse( this ); | ||
144 | // svgImporter.importSVG(); | ||
145 | ////////////////////////////////////////// | ||
146 | 139 | ||
147 | // post-load processing of the scene | 140 | // post-load processing of the scene |
148 | this.init = function() | 141 | this.init = function() |
@@ -198,7 +191,9 @@ function GLWorld( canvas, use3D ) | |||
198 | this.myScene.addNode(lightTr); | 191 | this.myScene.addNode(lightTr); |
199 | 192 | ||
200 | // Add the scene to the engine - necessary if you want the engine to draw for you | 193 | // Add the scene to the engine - necessary if you want the engine to draw for you |
201 | g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); | 194 | //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); |
195 | var name = this._canvas.getAttribute( "data-RDGE-id" ); | ||
196 | g_Engine.AddScene("myScene" + name, this.myScene); | ||
202 | } | 197 | } |
203 | 198 | ||
204 | // main code for handling user interaction and updating the scene | 199 | // main code for handling user interaction and updating the scene |
@@ -227,11 +222,11 @@ function GLWorld( canvas, use3D ) | |||
227 | } | 222 | } |
228 | 223 | ||
229 | // defining the draw function to control how the scene is rendered | 224 | // defining the draw function to control how the scene is rendered |
230 | this.draw = function() | 225 | this.draw = function() |
231 | { | 226 | { |
232 | if (this._useWebGL) | 227 | if (this._useWebGL) |
233 | { | 228 | { |
234 | g_Engine.setContext( this._canvas.uuid ); | 229 | g_Engine.setContext( this._canvas.rdgeid ); |
235 | var ctx = g_Engine.getContext(); | 230 | var ctx = g_Engine.getContext(); |
236 | var renderer = ctx.renderer; | 231 | var renderer = ctx.renderer; |
237 | if (renderer.unloadedTextureCount <= 0) | 232 | if (renderer.unloadedTextureCount <= 0) |
@@ -391,12 +386,10 @@ function GLWorld( canvas, use3D ) | |||
391 | if (this._useWebGL) | 386 | if (this._useWebGL) |
392 | { | 387 | { |
393 | rdgeStarted = true; | 388 | rdgeStarted = true; |
394 | this._canvas.rdgeid = this._canvas.uuid; | 389 | var id = this._canvas.getAttribute( "data-RDGE-id" ); |
390 | this._canvas.rdgeid = id; | ||
395 | g_Engine.registerCanvas(this._canvas, this); | 391 | g_Engine.registerCanvas(this._canvas, this); |
396 | RDGEStart( this._canvas ); | 392 | RDGEStart( this._canvas ); |
397 | |||
398 | //this._canvas.fpsTracker = new fpsTracker( '0' ); | ||
399 | //this._canvas.task = new RDGETask(this._canvas, false); | ||
400 | this._canvas.task.stop() | 393 | this._canvas.task.stop() |
401 | } | 394 | } |
402 | } | 395 | } |
@@ -765,7 +758,7 @@ GLWorld.prototype.render = function() | |||
765 | else | 758 | else |
766 | { | 759 | { |
767 | // console.log( "GLWorld.render, " + this._worldCount ); | 760 | // console.log( "GLWorld.render, " + this._worldCount ); |
768 | g_Engine.setContext( this._canvas.uuid ); | 761 | g_Engine.setContext( this._canvas.rdgeId ); |
769 | //this.draw(); | 762 | //this.draw(); |
770 | this.restartRenderLoop(); | 763 | this.restartRenderLoop(); |
771 | } | 764 | } |
@@ -821,7 +814,9 @@ GLWorld.prototype.getShapeFromPoint = function( offsetX, offsetY ) | |||
821 | GLWorld.prototype.export = function() | 814 | GLWorld.prototype.export = function() |
822 | { | 815 | { |
823 | var exportStr = "GLWorld 1.0\n"; | 816 | var exportStr = "GLWorld 1.0\n"; |
824 | exportStr += "id: " + this._canvas.rdgeid + "\n"; | 817 | var id = this.getCanvas().getAttribute( "data-RDGE-id" ); |
818 | exportStr += "id: " + id + "\n"; | ||
819 | //exportStr += "id: " + this._canvas.rdgeid + "\n"; | ||
825 | exportStr += "fov: " + this._fov + "\n"; | 820 | exportStr += "fov: " + this._fov + "\n"; |
826 | exportStr += "zNear: " + this._zNear + "\n"; | 821 | exportStr += "zNear: " + this._zNear + "\n"; |
827 | exportStr += "zFar: " + this._zFar + "\n"; | 822 | exportStr += "zFar: " + this._zFar + "\n"; |
@@ -829,7 +824,7 @@ GLWorld.prototype.export = function() | |||
829 | 824 | ||
830 | // we need 2 export modes: One for save/restore, one for publish. | 825 | // we need 2 export modes: One for save/restore, one for publish. |
831 | // hardcoding for now | 826 | // hardcoding for now |
832 | var exportForPublish = false; | 827 | var exportForPublish = true; |
833 | exportStr += "publish: " + exportForPublish + "\n"; | 828 | exportStr += "publish: " + exportForPublish + "\n"; |
834 | 829 | ||
835 | if (exportForPublish) | 830 | if (exportForPublish) |
diff --git a/js/helper-classes/RDGE/runtime/CanvasLoader.js b/js/helper-classes/RDGE/runtime/CanvasLoader.js new file mode 100644 index 00000000..12a985d3 --- /dev/null +++ b/js/helper-classes/RDGE/runtime/CanvasLoader.js | |||
@@ -0,0 +1,72 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | |||
8 | |||
9 | /////////////////////////////////////////////////////////////////////// | ||
10 | // Class ShapeRuntime | ||
11 | // Manages runtime shape display | ||
12 | /////////////////////////////////////////////////////////////////////// | ||
13 | function CanvasLoader( root, valueArray, loadForAuthoring ) | ||
14 | { | ||
15 | var value = valueArray; | ||
16 | var nWorlds = value.length; | ||
17 | for (var i=0; i<nWorlds; i++) | ||
18 | { | ||
19 | var importStr = value[i]; | ||
20 | var startIndex = importStr.indexOf( "id: " ); | ||
21 | if (startIndex >= 0) | ||
22 | { | ||
23 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
24 | if (endIndex > 0) | ||
25 | { | ||
26 | var id = importStr.substring( startIndex+4, endIndex ); | ||
27 | var canvas = this.findCanvasWithID( id, root ); | ||
28 | if (canvas) | ||
29 | { | ||
30 | if (loadForAuthoring) | ||
31 | { | ||
32 | if (!canvas.elementModel) | ||
33 | { | ||
34 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
35 | } | ||
36 | |||
37 | if (canvas.elementModel) | ||
38 | { | ||
39 | if (canvas.elementModel.shapeModel.GLWorld) | ||
40 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
41 | |||
42 | var world = new GLWorld( canvas ); | ||
43 | canvas.elementModel.shapeModel.GLWorld = world; | ||
44 | world.import( importStr ); | ||
45 | } | ||
46 | } | ||
47 | else | ||
48 | { | ||
49 | var rt = new GLRuntime( canvas, importStr ); | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | this.findCanvasWithID = function( id, elt ) | ||
57 | { | ||
58 | var cid = elt.getAttribute( "data-RDGE-id" ); | ||
59 | if (cid == id) return elt; | ||
60 | |||
61 | if (elt.children) | ||
62 | { | ||
63 | var nKids = elt.children.length; | ||
64 | for (var i=0; i<nKids; i++) | ||
65 | { | ||
66 | var child = elt.children[i]; | ||
67 | this.findCanvasWithID( id, child ); | ||
68 | }< |