diff options
author | Nivesh Rajbhandari | 2012-03-13 13:05:16 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-13 13:05:16 -0700 |
commit | e19376c54eedd1f1c457ba405b2f110be376a559 (patch) | |
tree | d48c090f71ed2cd6bd6ce38ff68c36ab69299985 /js/lib/geom/geom-obj.js | |
parent | 970c2e63aa8ec3f70df2bf073cedb9e3b7617755 (diff) | |
parent | f56b8cf4d3316d250c0f0045fb78f0dbd5c56e94 (diff) | |
download | ninja-e19376c54eedd1f1c457ba405b2f110be376a559.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-x | js/lib/geom/geom-obj.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index fb1cb246..f285f24a 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -5,6 +5,27 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | 7 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; |
8 | var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial; | ||
9 | var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial; | ||
10 | var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial; | ||
11 | var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial; | ||
12 | var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial; | ||
13 | var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial; | ||
14 | var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial; | ||
15 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; | ||
16 | var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial; | ||
17 | var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial; | ||
18 | var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; | ||
19 | var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; | ||
20 | var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; | ||
21 | var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; | ||
22 | var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; | ||
23 | var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; | ||
24 | var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial; | ||
25 | var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial; | ||
26 | var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial; | ||
27 | var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial; | ||
28 | |||
8 | /////////////////////////////////////////////////////////////////////// | 29 | /////////////////////////////////////////////////////////////////////// |
9 | // Class GLGeomObj | 30 | // Class GLGeomObj |
10 | // Super class for all geometry classes | 31 | // Super class for all geometry classes |
@@ -244,6 +265,72 @@ var GeomObj = function GLGeomObj() { | |||
244 | return fillMaterial; | 265 | return fillMaterial; |
245 | }; | 266 | }; |
246 | 267 | ||
268 | this.exportMaterials = function() | ||
269 | { | ||
270 | var rtnStr = ""; | ||
271 | if (this._materialArray && this._materialNodeArray) | ||
272 | { | ||
273 | var nMats = this._materialArray.length; | ||
274 | rtnStr += "nMaterials: " + nMats + "\n"; | ||
275 | for (var i=0; i<nMats; i++) | ||
276 | { | ||
277 | var matNode = this._materialNodeArray[i]; | ||
278 | rtnStr += "materialNodeName: " + matNode.name + "\n"; | ||
279 | |||
280 | var material = this._materialArray[i]; | ||
281 | rtnStr += material.export(); | ||
282 | } | ||
283 | } | ||
284 | else | ||
285 | rtnStr += "nMaterials: 0\n" ; | ||
286 | |||
287 | return rtnStr; | ||
288 | } | ||
289 | |||
290 | this.importMaterials = function(importStr) | ||
291 | { | ||
292 | var nMaterials = Number( this.getPropertyFromString( "nMaterials: ", importStr ) ); | ||
293 | for (var i=0; i<nMaterials; i++) | ||
294 | { | ||
295 | var mat; | ||
296 | var materialType = this.getPropertyFromString( "material: ", importStr ); | ||
297 | switch (materialType) | ||
298 | { | ||
299 | case "flat": mat = new FlatMaterial(); break; | ||
300 | case "radialGradient": mat = new RadialGradientMaterial(); break; | ||
301 | case "linearGradient": mat = new LinearGradientMaterial(); break; | ||
302 | case "bumpMetal": mat = new BumpMetalMaterial(); break; | ||
303 | case "uber": mat = new UberMaterial(); break; | ||
304 | case "plasma": mat = new PlasmaMaterial(); break; | ||
305 | case "deform": mat = new DeformMaterial(); break; | ||
306 | case "water": mat = new WaterMaterial(); break; | ||
307 | case "tunnel": mat = new TunnelMaterial(); break; | ||
308 | case "reliefTunnel": mat = new ReliefTunnelMaterial(); break; | ||
309 | case "squareTunnel": mat = new SquareTunnelMaterial(); break; | ||
310 | case "twist": mat = new TwiseMaterial(); break; | ||
311 | case "fly": mat = new FlyMaterial(); break; | ||
312 | case "julia": mat = new JuliaMaterial(); break; | ||
313 | case "mandel": mat = new MandelMaterial(); break; | ||
314 | case "star": mat = new StarMaterial(); break; | ||
315 | case "zinvert": mat = new ZInvertMaterial(); break; | ||
316 | case "keleidoscope": mat = new KeleidoscopeMaterial(); break; | ||
317 | case "radialBlur": mat = new RadialBlurMaterial(); break; | ||
318 | case "pulse": mat = new PulseMaterial(); break; | ||
319 | |||
320 | default: | ||
321 | console.log( "material type: " + materialType + " is not supported" ); | ||
322 | break; | ||
323 | } | ||
324 | |||
325 | if (mat) | ||
326 | mat.import( importStr ); | ||
327 | |||
328 | var endIndex = importStr.indexOf( "endMaterial\n" ); | ||
329 | if (endIndex < 0) break; | ||
330 | importStr = importStr.substr( endIndex ); | ||
331 | } | ||
332 | } | ||
333 | |||
247 | this.translate = function(v) { | 334 | this.translate = function(v) { |
248 | var mat = Matrix.Translation( v ); | 335 | var mat = Matrix.Translation( v ); |
249 | //var mat2 = mat.multiply( this._matrix ); | 336 | //var mat2 = mat.multiply( this._matrix ); |