diff options
author | hwc487 | 2012-04-19 13:01:43 -0700 |
---|---|---|
committer | hwc487 | 2012-04-19 13:01:43 -0700 |
commit | e6a20fe64574763483dc602bd759278ccf5e5e68 (patch) | |
tree | 69defe7200206f0257fe90697136fadef59d521e /js/lib/rdge/texture.js | |
parent | ae7eb87564632ce7c676bd728b8ff2710ff0bb83 (diff) | |
parent | 9284c19f076dec3b47ece7dc7bcd22d74e4246c3 (diff) | |
download | ninja-e6a20fe64574763483dc602bd759278ccf5e5e68.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts:
js/lib/drawing/world.js
js/lib/geom/geom-obj.js
js/lib/rdge/materials/cloud-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
Diffstat (limited to 'js/lib/rdge/texture.js')
-rw-r--r-- | js/lib/rdge/texture.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js index e0bf3364..bcbcb4bc 100644 --- a/js/lib/rdge/texture.js +++ b/js/lib/rdge/texture.js | |||
@@ -112,6 +112,7 @@ function Texture( dstWorld, texMapName, wrap, mips ) | |||
112 | switch (type) | 112 | switch (type) |
113 | { | 113 | { |
114 | case notifier.OBJECT_DELETE: | 114 | case notifier.OBJECT_DELETE: |
115 | texture.rebuildSrcLocally(); | ||
115 | break; | 116 | break; |
116 | 117 | ||
117 | case notifier.OBJECT_REINSTANTIATE: | 118 | case notifier.OBJECT_REINSTANTIATE: |
@@ -134,6 +135,30 @@ function Texture( dstWorld, texMapName, wrap, mips ) | |||
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
138 | this.rebuildSrcLocally = function() | ||
139 | { | ||
140 | var srcWorld = this._srcWorld; | ||
141 | if (srcWorld) | ||
142 | { | ||
143 | // get the data from the old world | ||
144 | var jStr = srcWorld.exportJSON(); | ||
145 | var jObj = JSON.parse( jStr ); | ||
146 | var oldCanvas = srcWorld.getCanvas(); | ||
147 | |||
148 | // create a new canvas | ||
149 | this._srcCanvas = NJUtils.makeNJElement("canvas", canvasID, "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); | ||
150 | srcCanvas = this._srcCanvas; | ||
151 | srcCanvas.width = oldCanvas.width; | ||
152 | srcCanvas.height = oldCanvas.height; | ||
153 | |||
154 | // rebuild the world | ||
155 | this._srcWorld = new GLWorld( this._srcCanvas, true, true ); | ||
156 | this._srcWorld.importSJON( jObj ); | ||
157 | |||
158 | this._isLocal = true; | ||
159 | } | ||
160 | } | ||
161 | |||
137 | this.loadFromFile = function() | 162 | this.loadFromFile = function() |
138 | { | 163 | { |
139 | var tex = this._texture; | 164 | var tex = this._texture; |
@@ -197,6 +222,12 @@ function Texture( dstWorld, texMapName, wrap, mips ) | |||
197 | } | 222 | } |
198 | var srcCanvas = this._srcCanvas; | 223 | var srcCanvas = this._srcCanvas; |
199 | 224 | ||
225 | if (this._isLocal) | ||
226 | { | ||
227 | this._srcWorld.update(); | ||
228 | this._srcWorld.draw(); | ||
229 | } | ||
230 | |||
200 | var world = this.getDstWorld(); | 231 | var world = this.getDstWorld(); |
201 | if (!world) | 232 | if (!world) |
202 | { | 233 | { |
@@ -233,9 +264,19 @@ function Texture( dstWorld, texMapName, wrap, mips ) | |||
233 | 264 | ||
234 | // copy the source canvas to the context to be used in the texture | 265 | // copy the source canvas to the context to be used in the texture |
235 | renderCtx.drawImage(srcCanvas, 0, 0, width, height); | 266 | renderCtx.drawImage(srcCanvas, 0, 0, width, height); |
267 | /* | ||
268 | renderCtx.fillStyle = "#00000a"; | ||
269 | renderCtx.fillRect(0, 0, width, height ); | ||
270 | var imageData = renderCtx.getImageData(0,0,width, height); | ||
271 | for (var i=3; i<imageData.data.length; i+=4) | ||
272 | { | ||
273 | imageData.data[i] = 128; | ||
274 | } | ||
275 | */ | ||
236 | 276 | ||
237 | ///////////////// | 277 | ///////////////// |
238 | tex.image = renderCanvas; | 278 | tex.image = renderCanvas; |
279 | |||
239 | renderer.commitTexture( tex ); | 280 | renderer.commitTexture( tex ); |
240 | 281 | ||
241 | return tex; | 282 | return tex; |