aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/geom-obj.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-xjs/lib/geom/geom-obj.js87
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
7var MaterialsModel = require("js/models/materials-model").MaterialsModel; 7var MaterialsModel = require("js/models/materials-model").MaterialsModel;
8var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial;
9var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial;
10var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial;
11var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial;
12var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial;
13var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial;
14var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial;
15var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
16var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial;
17var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial;
18var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
19var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
20var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
21var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
22var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
23var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
24var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial;
25var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial;
26var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial;
27var 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 );