diff options
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-x | js/lib/geom/circle.js | 8 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 87 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 9 |
3 files changed, 99 insertions, 5 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index dd82a4cc..f94d4e6b 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js | |||
@@ -61,6 +61,8 @@ var Circle = function GLCircle() { | |||
61 | } else { | 61 | } else { |
62 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); | 62 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); |
63 | } | 63 | } |
64 | |||
65 | this.exportMaterials(); | ||
64 | }; | 66 | }; |
65 | 67 | ||
66 | /////////////////////////////////////////////////////////////////////// | 68 | /////////////////////////////////////////////////////////////////////// |
@@ -577,9 +579,10 @@ var Circle = function GLCircle() { | |||
577 | } else { | 579 | } else { |
578 | rtnStr += "flatMaterial"; | 580 | rtnStr += "flatMaterial"; |
579 | } | 581 | } |
580 | |||
581 | rtnStr += "\n"; | 582 | rtnStr += "\n"; |
582 | 583 | ||
584 | rtnStr += this.exportMaterials(); | ||
585 | |||
583 | return rtnStr; | 586 | return rtnStr; |
584 | }; | 587 | }; |
585 | 588 | ||
@@ -609,8 +612,9 @@ var Circle = function GLCircle() { | |||
609 | console.log( "object material not found in library: " + fillMaterialName ); | 612 | console.log( "object material not found in library: " + fillMaterialName ); |
610 | fillMat = MaterialsModel.exportFlatMaterial(); | 613 | fillMat = MaterialsModel.exportFlatMaterial(); |
611 | } | 614 | } |
612 | |||
613 | this._fillMaterial = fillMat; | 615 | this._fillMaterial = fillMat; |
616 | |||
617 | this.importMaterials( importStr ); | ||
614 | }; | 618 | }; |
615 | 619 | ||
616 | this.collidesWithPoint = function( x, y ) { | 620 | this.collidesWithPoint = function( x, y ) { |
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index c5880843..1a197832 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 |
@@ -204,6 +225,72 @@ var GeomObj = function GLGeomObj() { | |||
204 | return fillMaterial; | 225 | return fillMaterial; |
205 | }; | 226 | }; |
206 | 227 | ||
228 | this.exportMaterials = function() | ||
229 | { | ||
230 | var rtnStr = ""; | ||
231 | if (this._materialArray && this._materialNodeArray) | ||
232 | { | ||
233 | var nMats = this._materialArray.length; | ||
234 | rtnStr += "nMaterials: " + nMats + "\n"; | ||
235 | for (var i=0; i<nMats; i++) | ||
236 | { | ||
237 | var matNode = this._materialNodeArray[i]; | ||
238 | rtnStr += "materialNodeName: " + matNode.name + "\n"; | ||
239 | |||
240 | var material = this._materialArray[i]; | ||
241 | rtnStr += material.export(); | ||
242 | } | ||
243 | } | ||
244 | else | ||
245 | rtnStr += "nMaterials: 0\n" ; | ||
246 | |||
247 | return rtnStr; | ||
248 | } | ||
249 | |||
250 | this.importMaterials = function(importStr) | ||
251 | { | ||
252 | var nMaterials = Number( this.getPropertyFromString( "nMaterials: ", importStr ) ); | ||
253 | for (var i=0; i<nMaterials; i++) | ||
254 | { | ||
255 | var mat; | ||
256 | var materialType = this.getPropertyFromString( "material: ", importStr ); | ||
257 | switch (materialType) | ||
258 | { | ||
259 | case "flat": mat = new FlatMaterial(); break; | ||
260 | case "radialGradient": mat = new RadialGradientMaterial(); break; | ||
261 | case "linearGradient": mat = new LinearGradientMaterial(); break; | ||
262 | case "bumpMetal": mat = new BumpMetalMaterial(); break; | ||
263 | case "uber": mat = new UberMaterial(); break; | ||
264 | case "plasma": mat = new PlasmaMaterial(); break; | ||
265 | case "deform": mat = new DeformMaterial(); break; | ||
266 | case "water": mat = new WaterMaterial(); break; | ||
267 | case "tunnel": mat = new TunnelMaterial(); break; | ||
268 | case "reliefTunnel": mat = new ReliefTunnelMaterial(); break; | ||
269 | case "squareTunnel": mat = new SquareTunnelMaterial(); break; | ||
270 | case "twist": mat = new TwiseMaterial(); break; | ||
271 | case "fly": mat = new FlyMaterial(); break; | ||
272 | case "julia": mat = new JuliaMaterial(); break; | ||
273 | case "mandel": mat = new MandelMaterial(); break; | ||
274 | case "star": mat = new StarMaterial(); break; | ||
275 | case "zinvert": mat = new ZInvertMaterial(); break; | ||
276 | case "keleidoscope": mat = new KeleidoscopeMaterial(); break; | ||
277 | case "radialBlur": mat = new RadialBlurMaterial(); break; | ||
278 | case "pulse": mat = new PulseMaterial(); break; | ||
279 | |||
280 | default: | ||
281 | console.log( "material type: " + materialType + " is not supported" ); | ||
282 | break; | ||
283 | } | ||
284 | |||
285 | if (mat) | ||
286 | mat.import( importStr ); | ||
287 | |||
288 | var endIndex = importStr.indexOf( "endMaterial\n" ); | ||
289 | if (endIndex < 0) break; | ||
290 | importStr = importStr.substr( endIndex ); | ||
291 | } | ||
292 | } | ||
293 | |||
207 | this.translate = function(v) { | 294 | this.translate = function(v) { |
208 | var mat = Matrix.Translation( v ); | 295 | var mat = Matrix.Translation( v ); |
209 | //var mat2 = mat.multiply( this._matrix ); | 296 | //var mat2 = mat.multiply( this._matrix ); |
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 81b385b3..370bb257 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -79,6 +79,8 @@ var Rectangle = function GLRectangle() { | |||
79 | } else { | 79 | } else { |
80 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); | 80 | this._fillMaterial = MaterialsModel.exportFlatMaterial(); |
81 | } | 81 | } |
82 | |||
83 | this.exportMaterials(); | ||
82 | }; | 84 | }; |
83 | 85 | ||
84 | /////////////////////////////////////////////////////////////////////// | 86 | /////////////////////////////////////////////////////////////////////// |
@@ -218,7 +220,6 @@ var Rectangle = function GLRectangle() { | |||
218 | } else { | 220 | } else { |
219 | rtnStr += "flatMaterial"; | 221 | rtnStr += "flatMaterial"; |
220 | } | 222 | } |
221 | |||
222 | rtnStr += "\n"; | 223 | rtnStr += "\n"; |
223 | 224 | ||
224 | rtnStr += "fillMat: "; | 225 | rtnStr += "fillMat: "; |
@@ -227,9 +228,10 @@ var Rectangle = function GLRectangle() { | |||
227 | } else { | 228 | } else { |
228 | rtnStr += "flatMaterial"; | 229 | rtnStr += "flatMaterial"; |
229 | } | 230 | } |
230 | |||
231 | rtnStr += "\n"; | 231 | rtnStr += "\n"; |
232 | 232 | ||
233 | rtnStr += this.exportMaterials(); | ||
234 | |||
233 | return rtnStr; | 235 | return rtnStr; |
234 | }; | 236 | }; |
235 | 237 | ||
@@ -264,8 +266,9 @@ var Rectangle = function GLRectangle() { | |||
264 | console.log( "object material not found in library: " + fillMaterialName ); | 266 | console.log( "object material not found in library: " + fillMaterialName ); |
265 | fillMat = MaterialsModel.exportFlatMaterial(); | 267 | fillMat = MaterialsModel.exportFlatMaterial(); |
266 | } | 268 | } |
267 | |||
268 | this._fillMaterial = fillMat; | 269 | this._fillMaterial = fillMat; |
270 | |||
271 | this.importMaterials( importStr ); | ||
269 | }; | 272 | }; |
270 | 273 | ||
271 | this.buildBuffers = function() { | 274 | this.buildBuffers = function() { |