diff options
-rwxr-xr-x | js/helper-classes/RDGE/GLWorld.js | 5 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/PulseMaterial.js | 3 | ||||
-rw-r--r-- | js/helper-classes/RDGE/Materials/WaterMaterial.js | 2 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/GLRuntime.js | 54 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/RuntimeGeomObj.js | 27 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/RuntimeMaterial.js | 74 |
6 files changed, 153 insertions, 12 deletions
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index d9e91404..3a779b92 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -840,7 +840,7 @@ GLWorld.prototype.export = function( exportForPublish ) | |||
840 | if (!exportForPublish) exportForPublish = false; | 840 | if (!exportForPublish) exportForPublish = false; |
841 | exportStr += "publish: " + exportForPublish + "\n"; | 841 | exportStr += "publish: " + exportForPublish + "\n"; |
842 | 842 | ||
843 | if (exportForPublish) | 843 | if (exportForPublish && this._useWebGL) |
844 | { | 844 | { |
845 | exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; | 845 | exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; |
846 | 846 | ||
@@ -930,6 +930,9 @@ GLWorld.prototype.import = function( importStr ) | |||
930 | 930 | ||
931 | // import the objects | 931 | // import the objects |
932 | this.importObjects( importStr, this._rootNode ); | 932 | this.importObjects( importStr, this._rootNode ); |
933 | |||
934 | // render using canvas 2D | ||
935 | this.render(); | ||
933 | } | 936 | } |
934 | } | 937 | } |
935 | 938 | ||
diff --git a/js/helper-classes/RDGE/Materials/PulseMaterial.js b/js/helper-classes/RDGE/Materials/PulseMaterial.js index 28f2a430..b0fbd998 100644 --- a/js/helper-classes/RDGE/Materials/PulseMaterial.js +++ b/js/helper-classes/RDGE/Materials/PulseMaterial.js | |||
@@ -185,6 +185,9 @@ function PulseMaterial() | |||
185 | // every material needs the base type and instance name | 185 | // every material needs the base type and instance name |
186 | var exportStr = "material: " + this.getShaderName() + "\n"; | 186 | var exportStr = "material: " + this.getShaderName() + "\n"; |
187 | exportStr += "name: " + this.getName() + "\n"; | 187 | exportStr += "name: " + this.getName() + "\n"; |
188 | |||
189 | var texMapName = this._propValues[this._propNames[0]]; | ||
190 | exportStr += "texture: " + texMapName; | ||
188 | 191 | ||
189 | // every material needs to terminate like this | 192 | // every material needs to terminate like this |
190 | exportStr += "endMaterial\n"; | 193 | exportStr += "endMaterial\n"; |
diff --git a/js/helper-classes/RDGE/Materials/WaterMaterial.js b/js/helper-classes/RDGE/Materials/WaterMaterial.js index 9ece3b45..49761c58 100644 --- a/js/helper-classes/RDGE/Materials/WaterMaterial.js +++ b/js/helper-classes/RDGE/Materials/WaterMaterial.js | |||
@@ -22,7 +22,7 @@ function WaterMaterial() | |||
22 | this._name = "WaterMaterial"; | 22 | this._name = "WaterMaterial"; |
23 | this._shaderName = "water"; | 23 | this._shaderName = "water"; |
24 | 24 | ||
25 | this._texMap = 'assets/images/rocky-normal.jpg'; | 25 | this._texMap = 'assets/images/rocky-normal.jpg\n'; |
26 | 26 | ||
27 | this._time = 0.0; | 27 | this._time = 0.0; |
28 | this._dTime = 0.01; | 28 | this._dTime = 0.01; |
diff --git a/js/helper-classes/RDGE/runtime/GLRuntime.js b/js/helper-classes/RDGE/runtime/GLRuntime.js index d86506ad..e0fff4a8 100644 --- a/js/helper-classes/RDGE/runtime/GLRuntime.js +++ b/js/helper-classes/RDGE/runtime/GLRuntime.js | |||
@@ -16,6 +16,7 @@ function GLRuntime( canvas, importStr ) | |||
16 | // Instance variables | 16 | // Instance variables |
17 | /////////////////////////////////////////////////////////////////////// | 17 | /////////////////////////////////////////////////////////////////////// |
18 | this._canvas = canvas; | 18 | this._canvas = canvas; |
19 | this._context = null; | ||
19 | this._importStr = importStr; | 20 | this._importStr = importStr; |
20 | 21 | ||
21 | this.renderer = null; | 22 | this.renderer = null; |
@@ -27,6 +28,8 @@ function GLRuntime( canvas, importStr ) | |||
27 | this._firstRender = true; | 28 | this._firstRender = true; |
28 | this._initialized = false; | 29 | this._initialized = false; |
29 | 30 | ||
31 | this._useWebGL = false; | ||
32 | |||
30 | // view parameters | 33 | // view parameters |
31 | this._fov = 45.0; | 34 | this._fov = 45.0; |
32 | this._zNear = 0.1; | 35 | this._zNear = 0.1; |
@@ -49,6 +52,14 @@ function GLRuntime( canvas, importStr ) | |||
49 | this.getAspect = function() { return this._aspect; } | 52 | this.getAspect = function() { return this._aspect; } |
50 | this.getViewDistance = function() { return this._viewDist; } | 53 | this.getViewDistance = function() { return this._viewDist; } |
51 | 54 | ||
55 | this.get2DContext = function() { return this._context; } | ||
56 | |||
57 | this.getViewportWidth = function() { return this._canvas.width; } | ||
58 | this.getViewportHeight = function() { return this._canvas.height; } | ||
59 | |||
60 | /////////////////////////////////////////////////////////////////////// | ||
61 | // accessors | ||
62 | /////////////////////////////////////////////////////////////////////// | ||
52 | this.loadScene = function() | 63 | this.loadScene = function() |
53 | { | 64 | { |
54 | // parse the data | 65 | // parse the data |
@@ -56,6 +67,8 @@ function GLRuntime( canvas, importStr ) | |||
56 | var index = importStr.indexOf( "scenedata: " ); | 67 | var index = importStr.indexOf( "scenedata: " ); |
57 | if (index >= 0) | 68 | if (index >= 0) |
58 | { | 69 | { |
70 | this._useWebGL = true; | ||
71 | |||
59 | var rdgeStr = importStr.substr( index+11 ); | 72 | var rdgeStr = importStr.substr( index+11 ); |
60 | var endIndex = rdgeStr.indexOf( "endscene\n" ); | 73 | var endIndex = rdgeStr.indexOf( "endscene\n" ); |
61 | if (endIndex < 0) throw new Error( "ill-formed WebGL data" ); | 74 | if (endIndex < 0) throw new Error( "ill-formed WebGL data" ); |
@@ -67,6 +80,12 @@ function GLRuntime( canvas, importStr ) | |||
67 | this.linkMaterials( this._geomRoot ); | 80 | this.linkMaterials( this._geomRoot ); |
68 | this.initMaterials(); | 81 | this.initMaterials(); |
69 | } | 82 | } |
83 | else | ||
84 | { | ||
85 | this._context = this._canvas.getContext( "2d" ); | ||
86 | this.importObjects( importStr ); | ||
87 | this.render(); | ||
88 | } | ||
70 | } | 89 | } |
71 | 90 | ||
72 | this.init = function() | 91 | this.init = function() |
@@ -230,6 +249,7 @@ function GLRuntime( canvas, importStr ) | |||
230 | this.addObject = function( obj, parent ) | 249 | this.addObject = function( obj, parent ) |
231 | { | 250 | { |
232 | if (!obj) return; | 251 | if (!obj) return; |
252 | obj.setWorld( this ); | ||
233 | 253 | ||
234 | if (parent == null) | 254 | if (parent == null) |
235 | this._geomRoot = obj; | 255 | this._geomRoot = obj; |
@@ -290,11 +310,35 @@ function GLRuntime( canvas, importStr ) | |||
290 | } | 310 | } |
291 | } | 311 | } |
292 | 312 | ||
293 | // start RDGE | 313 | this.render = function( obj ) |
294 | var id = canvas.getAttribute( "data-RDGE-id" ); | 314 | { |
295 | canvas.rdgeid = id; | 315 | if (!obj) obj = this._geomRoot; |
296 | g_Engine.registerCanvas(canvas, this); | 316 | obj.render(); |
297 | RDGEStart( canvas ); | 317 | |
318 | if (obj.children) | ||
319 | { | ||
320 | var nKids = obj.children.length; | ||
321 | for (var i=0; i<nKids; i++) | ||
322 | { | ||
323 | var child = obj.children[i]; | ||
324 | if (child) | ||
325 | this.render( child ); | ||
326 | } | ||
327 | } | ||
328 | } | ||
329 | |||
330 | // start RDGE or load Canvas 2D objects | ||
331 | if (this._useWebGL) | ||
332 | { | ||
333 | var id = canvas.getAttribute( "data-RDGE-id" ); | ||
334 | canvas.rdgeid = id; | ||
335 | g_Engine.registerCanvas(canvas, this); | ||
336 | RDGEStart( canvas ); | ||
337 | } | ||
338 | else | ||
339 | { | ||
340 | this.loadScene(); | ||
341 | } | ||
298 | } | 342 | } |
299 | 343 | ||
300 | 344 | ||
diff --git a/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js b/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js index da941b56..2539abc1 100644 --- a/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js +++ b/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js | |||
@@ -37,7 +37,10 @@ function RuntimeGeomObj() | |||
37 | // Property accessors | 37 | // Property accessors |
38 | /////////////////////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////////////////////// |
39 | 39 | ||
40 | this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; } | 40 | this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; } |
41 | |||
42 | this.setWorld = function(w) { this._world = w; } | ||
43 | this.getWorld = function() { return this._world; } | ||
41 | 44 | ||
42 | /////////////////////////////////////////////////////////////////////// | 45 | /////////////////////////////////////////////////////////////////////// |
43 | // Methods | 46 | // Methods |
@@ -76,8 +79,22 @@ function RuntimeGeomObj() | |||
76 | var materialType = getPropertyFromString( "material: ", importStr ); | 79 | var materialType = getPropertyFromString( "material: ", importStr ); |
77 | switch (materialType) | 80 | switch (materialType) |
78 | { | 81 | { |
79 | case "flat": mat = new RuntimeFlatMaterial(); break; | 82 | case "flat": mat = new RuntimeFlatMaterial(); break; |
80 | case "pulse": mat = new RuntimePulseMaterial(); break; | 83 | |
84 | case "radialGradient": | ||
85 | case "linearGradient": mat = new RuntimeLinearGradientMaterial(); break; | ||
86 | |||
87 | case "water": | ||
88 | case "tunnel": | ||
89 | case "reliefTunnel": | ||
90 | case "squareTunnel": | ||
91 | case "twist": | ||
92 | case "fly": | ||
93 | case "julia": | ||
94 | case "mandel": | ||
95 | case "star": | ||
96 | case "zinvert": | ||
97 | case "pulse": mat = new RuntimePulseMaterial(); break; | ||
81 |