aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/GLWorld.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/GLWorld.js')
-rwxr-xr-xjs/helper-classes/RDGE/GLWorld.js33
1 files changed, 26 insertions, 7 deletions
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js
index 0ab3c242..d9e91404 100755
--- a/js/helper-classes/RDGE/GLWorld.js
+++ b/js/helper-classes/RDGE/GLWorld.js
@@ -13,7 +13,6 @@ var fragmentShaderSource = "";
13 13
14var rdgeStarted = false; 14var rdgeStarted = false;
15 15
16var nodeCounter = 0;
17var worldCounter = 0; 16var worldCounter = 0;
18 17
19 18
@@ -74,6 +73,10 @@ function GLWorld( canvas, use3D )
74 this._worldCount = worldCounter; 73 this._worldCount = worldCounter;
75 worldCounter++; 74 worldCounter++;
76 75
76 // keep a counter for generating node names
77 this._nodeCounter = 0;
78
79
77 /////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////
78 // Property accessors 81 // Property accessors
79 /////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////
@@ -392,6 +395,13 @@ function GLWorld( canvas, use3D )
392 RDGEStart( this._canvas ); 395 RDGEStart( this._canvas );
393 this._canvas.task.stop() 396 this._canvas.task.stop()
394 } 397 }
398
399 this.generateUniqueNodeID = function()
400 {
401 var str = String( this._nodeCounter );
402 this._nodeCounter++;
403 return str;
404 }
395} 405}
396 406
397 407
@@ -418,7 +428,7 @@ GLWorld.prototype.updateObject = function (obj)
418 ctrTrNode = obj.getTransformNode(); 428 ctrTrNode = obj.getTransformNode();
419 if (ctrTrNode == null) 429 if (ctrTrNode == null)
420 { 430 {
421 ctrTrNode = createTransformNode("objRootNode_" + nodeCounter++); 431 ctrTrNode = createTransformNode("objRootNode_" + this._nodeCounter++);
422 this._rootNode.insertAsChild( ctrTrNode ); 432 this._rootNode.insertAsChild( ctrTrNode );
423 obj.setTransformNode( ctrTrNode ); 433 obj.setTransformNode( ctrTrNode );
424 } 434 }
@@ -428,7 +438,7 @@ GLWorld.prototype.updateObject = function (obj)
428 }); 438 });
429 ctrTrNode.meshes = []; 439 ctrTrNode.meshes = [];
430 440
431 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prims[0]); 441 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]);
432 ctrTrNode.attachMaterial(materialNodes[0]); 442 ctrTrNode.attachMaterial(materialNodes[0]);
433 } 443 }
434 444
@@ -451,12 +461,12 @@ GLWorld.prototype.updateObject = function (obj)
451 } 461 }
452 else 462 else
453 { 463 {
454 childTrNode = createTransformNode("objNode_" + nodeCounter++); 464 childTrNode = createTransformNode("objNode_" + this._nodeCounter++);
455 ctrTrNode.insertAsChild(childTrNode); 465 ctrTrNode.insertAsChild(childTrNode);
456 } 466 }
457 467
458 // attach the instanced box goe 468 // attach the instanced box goe
459 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prim); 469 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim);
460 childTrNode.attachMaterial(materialNodes[i]); 470 childTrNode.attachMaterial(materialNodes[i]);
461 } 471 }
462} 472}
@@ -821,6 +831,8 @@ GLWorld.prototype.export = function( exportForPublish )
821 exportStr += "zNear: " + this._zNear + "\n"; 831 exportStr += "zNear: " + this._zNear + "\n";
822 exportStr += "zFar: " + this._zFar + "\n"; 832 exportStr += "zFar: " + this._zFar + "\n";
823 exportStr += "viewDist: " + this._viewDist + "\n"; 833 exportStr += "viewDist: " + this._viewDist + "\n";
834 if (this._useWebGL)
835 exportStr += "webGL: true\n";
824 836
825 // we need 2 export modes: One for save/restore, one for publish. 837 // we need 2 export modes: One for save/restore, one for publish.
826 // hardcoding for now 838 // hardcoding for now
@@ -831,11 +843,16 @@ GLWorld.prototype.export = function( exportForPublish )
831 if (exportForPublish) 843 if (exportForPublish)
832 { 844 {
833 exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; 845 exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n";
846
847 // write out all of the objects
848 exportStr += "tree\n";
849 exportStr += this.exportObjects( this._geomRoot );
850 exportStr += "endtree\n";
834 } 851 }
835 else 852 else
836 { 853 {
837 // output the material library 854 // output the material library
838 exportStr += MaterialsLibrary.export(); 855 //exportStr += MaterialsLibrary.export(); // THIS NEEDS TO BE DONE AT THE DOC LEVEL
839 856
840 // write out all of the objects 857 // write out all of the objects
841 exportStr += "tree\n"; 858 exportStr += "tree\n";
@@ -903,11 +920,13 @@ GLWorld.prototype.import = function( importStr )
903 rdgeStr = rdgeStr.substr( 0, endIndex ); 920 rdgeStr = rdgeStr.substr( 0, endIndex );
904 921
905 this.myScene.importJSON( rdgeStr ); 922 this.myScene.importJSON( rdgeStr );
923
924 this.importObjects( importStr, this._rootNode );
906 } 925 }
907 else 926 else
908 { 927 {
909 // load the material library 928 // load the material library
910 importStr = MaterialsLibrary.import( importStr ); 929 //importStr = MaterialsLibrary.import( importStr );
911 930
912 // import the objects 931 // import the objects
913 this.importObjects( importStr, this._rootNode ); 932 this.importObjects( importStr, this._rootNode );