diff options
author | Jose Antonio Marquez | 2012-03-09 10:13:59 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-09 10:13:59 -0800 |
commit | d549383abf18a0dc54a990983fb4296602b66120 (patch) | |
tree | ac107d3823abb846c1afae3d03abce0f6aae2c98 /js/lib/rdge/runtime | |
parent | 3bcdfaa322ac53609b66ecedbace1872048fd310 (diff) | |
parent | 7b6e8194b91168abdeb94702eb350d14f147858b (diff) | |
download | ninja-d549383abf18a0dc54a990983fb4296602b66120.tar.gz |
Merge branch 'refs/heads/integration' into FileIO-Integration
Conflicts:
js/document/html-document.js
Diffstat (limited to 'js/lib/rdge/runtime')
-rw-r--r-- | js/lib/rdge/runtime/CanvasDataManager.js | 83 | ||||
-rw-r--r-- | js/lib/rdge/runtime/CanvasRuntime.js | 1338 | ||||
-rw-r--r-- | js/lib/rdge/runtime/GLRuntime.js | 357 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeGeomObj.js | 633 | ||||
-rw-r--r-- | js/lib/rdge/runtime/RuntimeMaterial.js | 351 |
5 files changed, 1338 insertions, 1424 deletions
diff --git a/js/lib/rdge/runtime/CanvasDataManager.js b/js/lib/rdge/runtime/CanvasDataManager.js deleted file mode 100644 index 8afc9de0..00000000 --- a/js/lib/rdge/runtime/CanvasDataManager.js +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
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 | var GeomObj = require("js/lib/geom/geom-obj").GeomObj; | ||
9 | var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive; | ||
10 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | ||
11 | var GLRuntime = require("js/lib/rdge/runtime/GLRuntime").GLRuntime; | ||
12 | |||
13 | /////////////////////////////////////////////////////////////////////// | ||
14 | // Class ShapeRuntime | ||
15 | // Manages runtime shape display | ||
16 | /////////////////////////////////////////////////////////////////////// | ||
17 | var CanvasDataManager = function CanvasDataManager() | ||
18 | { | ||
19 | this.loadGLData = function(root, valueArray ) | ||
20 | { | ||
21 | var value = valueArray; | ||
22 | var nWorlds = value.length; | ||
23 | for (var i=0; i<nWorlds; i++) | ||
24 | { | ||
25 | var importStr = value[i]; | ||
26 | var startIndex = importStr.indexOf( "id: " ); | ||
27 | if (startIndex >= 0) | ||
28 | { | ||
29 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
30 | if (endIndex > 0) | ||
31 | { | ||
32 | var id = importStr.substring( startIndex+4, endIndex ); | ||
33 | var canvas = this.findCanvasWithID( id, root ); | ||
34 | if (canvas) | ||
35 | { | ||
36 | var rt = new GLRuntime( canvas, importStr ); | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | } | ||
41 | } | ||
42 | |||
43 | this.collectGLData = function( elt, dataArray ) | ||
44 | { | ||
45 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | ||
46 | { | ||
47 | var data = elt.elementModel.shapeModel.GLWorld.export( true ); | ||
48 | dataArray.push( data ); | ||
49 | } | ||
50 | |||
51 | if (elt.children) | ||
52 | { | ||
53 | var nKids = elt.children.length; | ||
54 | for (var i=0; i<nKids; i++) | ||
55 | { | ||
56 | var child = elt.children[i]; | ||
57 | this.collectGLData( child, dataArray ); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | this.findCanvasWithID = function( id, elt ) | ||
63 | { | ||
64 | var cid = elt.getAttribute( "data-RDGE-id" ); | ||
65 | if (cid == id) return elt; | ||
66 | |||
67 | if (elt.children) | ||
68 | { | ||
69 | var nKids = elt.children.length; | ||
70 | for (var i=0; i<nKids; i++) | ||
71 | { | ||
72 | var child = elt.children[i]; | ||
73 | var foundElt = this.findCanvasWithID( id, child ); | ||
74 | if (foundElt) return foundElt; | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | |||
80 | |||
81 | if (typeof exports === "object") { | ||
82 | exports.CanvasDataManager = CanvasDataManager; | ||
83 | } | ||
diff --git a/js/lib/rdge/runtime/CanvasRuntime.js b/js/lib/rdge/runtime/CanvasRuntime.js new file mode 100644 index 00000000..d16613ca --- /dev/null +++ b/js/lib/rdge/runtime/CanvasRuntime.js | |||
@@ -0,0 +1,1338 @@ | |||
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 | // Class ShapeRuntime | ||
10 | // Manages runtime shape display | ||
11 | /////////////////////////////////////////////////////////////////////// | ||
12 | function CanvasDataManager() | ||
13 | { | ||
14 | this.loadGLData = function(root, valueArray ) | ||
15 | { | ||
16 | var value = valueArray; | ||
17 | var nWorlds = value.length; | ||
18 | for (var i=0; i<nWorlds; i++) | ||
19 | { | ||
20 | var importStr = value[i]; | ||
21 | var startIndex = importStr.indexOf( "id: " ); | ||
22 | if (startIndex >= 0) | ||
23 | { | ||
24 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
25 | if (endIndex > 0) | ||
26 | { | ||
27 | var id = importStr.substring( startIndex+4, endIndex ); | ||
28 | var canvas = this.findCanvasWithID( id, root ); | ||
29 | if (canvas) | ||
30 | { | ||
31 | var rt = new GLRuntime( canvas, importStr ); | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | |||
38 | this.collectGLData = function( elt, dataArray ) | ||
39 | { | ||
40 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | ||
41 | { | ||
42 | var data = elt.elementModel.shapeModel.GLWorld.export( true ); | ||
43 | dataArray.push( data ); | ||
44 | } | ||
45 | |||
46 | if (elt.children) | ||
47 | { | ||
48 | var nKids = elt.children.length; | ||
49 | for (var i=0; i<nKids; i++) | ||
50 | { | ||
51 | var child = elt.children[i]; | ||
52 | this.collectGLData( child, dataArray ); | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | |||
57 | this.findCanvasWithID = function( id, elt ) | ||
58 | { | ||
59 | var cid = elt.getAttribute( "data-RDGE-id" ); | ||
60 | if (cid == id) return elt; | ||
61 | |||
62 | if (elt.children) | ||
63 | { | ||
64 | var nKids = elt.children.length; | ||
65 | for (var i=0; i<nKids; i++) | ||
66 | { | ||
67 | var child = elt.children[i]; | ||
68 | var foundElt = this.findCanvasWithID( id, child ); | ||
69 | if (foundElt) return foundElt; | ||
70 | } | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | /////////////////////////////////////////////////////////////////////// | ||
76 | // Class GLRuntime | ||
77 | // Manages runtime fora WebGL canvas | ||
78 | /////////////////////////////////////////////////////////////////////// | ||
79 | function GLRuntime( canvas, importStr ) | ||
80 | { | ||
81 | /////////////////////////////////////////////////////////////////////// | ||
82 | // Instance variables | ||
83 | /////////////////////////////////////////////////////////////////////// | ||
84 | this._canvas = canvas; | ||
85 | this._context = null; | ||
86 | this._importStr = importStr; | ||
87 | |||
88 | this.renderer = null; | ||
89 | this.myScene = null; | ||
90 | this.light = null; | ||
91 | this.light2 = null; | ||
92 | this._rootNode = null; | ||
93 | |||
94 | this._firstRender = true; | ||
95 | this._initialized = false; | ||
96 | |||
97 | this._useWebGL = false; | ||
98 | |||
99 | // view parameters | ||
100 | this._fov = 45.0; | ||
101 | this._zNear = 0.1; | ||
102 | this._zFar = 100.0; | ||
103 | this._viewDist = 5.0; | ||
104 | |||
105 | this._aspect = canvas.width/canvas.height; | ||
106 | |||
107 | this._geomRoot; | ||
108 | |||
109 | // all "live" materials | ||
110 | this._materials = []; | ||
111 | |||
112 | /////////////////////////////////////////////////////////////////////// | ||
113 | // accessors | ||
114 | /////////////////////////////////////////////////////////////////////// | ||
115 | this.getZNear = function() { return this._zNear; } | ||
116 | this.getZFar = function() { return this._zFar; } | ||
117 | this.getFOV = function() { return this._fov; } | ||
118 | this.getAspect = function() { return this._aspect; } | ||
119 | this.getViewDistance = function() { return this._viewDist; } | ||
120 | |||
121 | this.get2DContext = function() { return this._context; } | ||
122 | |||
123 | this.getViewportWidth = function() { return this._canvas.width; } | ||
124 | this.getViewportHeight = function() { return this._canvas.height; } | ||
125 | |||
126 | /////////////////////////////////////////////////////////////////////// | ||
127 | // accessors | ||
128 | /////////////////////////////////////////////////////////////////////// | ||
129 | this.loadScene = function() | ||
130 | { | ||
131 |