diff options
author | hwc487 | 2012-03-29 07:27:49 -0700 |
---|---|---|
committer | hwc487 | 2012-03-29 07:27:49 -0700 |
commit | 2ab7fbef0df37f0c2bb6a4447f03993b9d50b5d0 (patch) | |
tree | a66f2eea7d70fa20ca78a7f997ca8e7c1ad67cc6 /js | |
parent | 0a0aa4662ffa687dd049cc5a24e701cedf87253a (diff) | |
download | ninja-2ab7fbef0df37f0c2bb6a4447f03993b9d50b5d0.tar.gz |
linked textures
Diffstat (limited to 'js')
-rwxr-xr-x | js/lib/drawing/world.js | 72 | ||||
-rw-r--r-- | js/lib/rdge/texture.js | 8 |
2 files changed, 16 insertions, 64 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index f077a5e2..a489110f 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -364,6 +364,15 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { | |||
364 | return str; | 364 | return str; |
365 | }; | 365 | }; |
366 | 366 | ||
367 | this.addListener = function( obj, callbackFunc, calleeData ) | ||
368 | { | ||
369 | this._notifier.addListener( obj, callbackFunc, calleeData ); | ||
370 | } | ||
371 | |||
372 | this.removeListener = function( obj ) | ||
373 | { | ||
374 | this._notifier.removeListener( obj ); | ||
375 | } | ||
367 | 376 | ||
368 | // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state | 377 | // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state |
369 | // in the case of a procedurally built scene an init state is not needed for loading data | 378 | // in the case of a procedurally built scene an init state is not needed for loading data |
@@ -818,70 +827,7 @@ World.prototype.exportObjectsJSON = function( obj, parentObj ) | |||
818 | this.exportObjectsJSON( obj.getNext(), parentObj ); | 827 | this.exportObjectsJSON( obj.getNext(), parentObj ); |
819 | } | 828 | } |
820 | 829 | ||
821 | /* | ||
822 | World.prototype.export = function() | ||
823 | { | ||
824 | var exportStr = "GLWorld 1.0\n"; | ||
825 | var id = this.getCanvas().getAttribute( "data-RDGE-id" ); | ||
826 | exportStr += "id: " + id + "\n"; | ||
827 | //exportStr += "id: " + this._canvas.rdgeid + "\n"; | ||
828 | exportStr += "fov: " + this._fov + "\n"; | ||
829 | exportStr += "zNear: " + this._zNear + "\n"; | ||
830 | exportStr += "zFar: " + this._zFar + "\n"; | ||
831 | exportStr += "viewDist: " + this._viewDist + "\n"; | ||
832 | if (this._useWebGL) | ||
833 | exportStr += "webGL: true\n"; | ||
834 | |||
835 | // we need 2 export modes: One for save/restore, one for publish. | ||
836 | // hardcoding for now | ||
837 | //var exportForPublish = false; | ||
838 | //if (!exportForPublish) exportForPublish = false; | ||
839 | var exportForPublish = true; | ||
840 | exportStr += "publish: " + exportForPublish + "\n"; | ||
841 | |||
842 | if (exportForPublish && this._useWebGL) | ||
843 | { | ||
844 | exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; | ||
845 | |||
846 | // write out all of the objects | ||
847 | exportStr += "tree\n"; | ||
848 | exportStr += this.exportObjects( this._geomRoot ); | ||
849 | exportStr += "endtree\n"; | ||
850 | } | ||
851 | else | ||
852 | { | ||
853 | // output the material library | ||
854 | //exportStr += MaterialsLibrary.export(); // THIS NEEDS TO BE DONE AT THE DOC LEVEL | ||
855 | |||
856 | // write out all of the objects | ||
857 | exportStr += "tree\n"; | ||
858 | exportStr += this.exportObjects( this._geomRoot ); | ||
859 | exportStr += "endtree\n"; | ||
860 | } | ||
861 | |||
862 | return exportStr; | ||
863 | }; | ||
864 | |||
865 | World.prototype.exportObjects = function( obj ) { | ||
866 | if (!obj) return; | ||
867 | |||
868 | var rtnStr = "OBJECT\n"; | ||
869 | rtnStr += obj.export(); | ||
870 | 830 | ||
871 | if (obj.getChild()) { | ||
872 | rtnStr += this.exportObjects( obj.getChild () ); | ||
873 | } | ||
874 | |||
875 | // the end object goes outside the children | ||
876 | rtnStr += "ENDOBJECT\n"; | ||
877 | |||
878 | if (obj.getNext()) { | ||
879 | rtnStr += this.exportObjects( obj.getNext() ); | ||
880 | } | ||
881 | |||
882 | return rtnStr; | ||
883 | }; | ||
884 | */ | ||
885 | 831 | ||
886 | World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { | 832 | World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { |
887 | //if (trNode == null) trNode = this._ctrNode; | 833 | //if (trNode == null) trNode = this._ctrNode; |
diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js index 41c9a54a..d67c65d2 100644 --- a/js/lib/rdge/texture.js +++ b/js/lib/rdge/texture.js | |||
@@ -68,6 +68,9 @@ function Texture( dstWorld, texMapName, wrap, mips ) | |||
68 | { | 68 | { |
69 | this._srcWorld = srcCanvas.elementModel.shapeModel.GLWorld; | 69 | this._srcWorld = srcCanvas.elementModel.shapeModel.GLWorld; |
70 | 70 | ||
71 | // add a notifier to the world | ||
72 | this._srcWorld.addListener( this, this.worldCallback, { myObj: 'anything' } ); | ||
73 | |||
71 | // check if the source is animated | 74 | // check if the source is animated |
72 | if (srcCanvas.elementModel && srcCanvas.elementModel.shapeModel && srcCanvas.elementModel.shapeModel.GLWorld) | 75 | if (srcCanvas.elementModel && srcCanvas.elementModel.shapeModel && srcCanvas.elementModel.shapeModel.GLWorld) |
73 | this._isAnimated = this._srcWorld._hasAnimatedMaterials; | 76 | this._isAnimated = this._srcWorld._hasAnimatedMaterials; |
@@ -79,8 +82,11 @@ function Texture( dstWorld, texMapName, wrap, mips ) | |||
79 | { | 82 | { |
80 | this.loadFromFile(); | 83 | this.loadFromFile(); |
81 | } | 84 | } |
85 | } | ||
82 | 86 | ||
83 | 87 | this.worldCallback = function( type, callbackObj, calleeData, callerData ) | |
88 | { | ||
89 | console.log( "texture callback, type: " + type ); | ||
84 | } | 90 | } |
85 | 91 | ||
86 | this.loadFromFile = function() | 92 | this.loadFromFile = function() |