/*
This file contains proprietary software owned by Motorola Mobility, Inc.
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
*/
///////////////////////////////////////////////////////////////////////
// MaterialsLibrary module -- Contains an array of GLMaterials.
///////////////////////////////////////////////////////////////////////
var Montage = require("montage/core/core").Montage,
Component = require("montage/ui/component").Component,
AppModel = require("js/models/app-model").AppModel;
var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial;
var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial;
var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial;
var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial;
var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial;
var CloudMaterial = require("js/lib/rdge/materials/cloud-material").CloudMaterial;
var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial;
var RaidersMaterial = require("js/lib/rdge/materials/radial-blur-material").RaidersMaterial;
var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial;
var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial;
var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial;
var FlagMaterial = require("js/lib/rdge/materials/flag-material").FlagMaterial;
var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
var ParisMaterial = require("js/lib/rdge/materials/water-material").ParisMaterial;
var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial;
var TwistVertMaterial = require("js/lib/rdge/materials/twist-vert-material").TwistVertMaterial;
var TaperMaterial = require("js/lib/rdge/materials/taper-material").TaperMaterial;
var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial;
var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial;
var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial;
exports.MaterialsModel = Montage.create(Component, {
hasTemplate: {
value: false
},
deserializedFromTemplate: {
value: function() {
// Load all the materials
this.addMaterial(new FlatMaterial());
this.addMaterial(new LinearGradientMaterial());
this.addMaterial(new RadialGradientMaterial());
this.addMaterial(new BumpMetalMaterial());
this.addMaterial(new UberMaterial());
this.addMaterial(new CloudMaterial());
this.addMaterial(new RadialBlurMaterial());
this.addMaterial(new RaidersMaterial());
this.addMaterial(new PlasmaMaterial());
this.addMaterial(new PulseMaterial());
this.addMaterial(new TunnelMaterial());
this.addMaterial(new ReliefTunnelMaterial());
this.addMaterial(new FlagMaterial());
this.addMaterial(new SquareTunnelMaterial());
this.addMaterial(new FlyMaterial());
this.addMaterial(new WaterMaterial());
this.addMaterial(new ParisMaterial());
this.addMaterial(new ZInvertMaterial());
this.addMaterial(new DeformMaterial());
this.addMaterial(new StarMaterial());
this.addMaterial(new TwistMaterial());
this.addMaterial(new TwistVertMaterial());
this.addMaterial(new TaperMaterial());
this.addMaterial(new JuliaMaterial());
this.addMaterial(new KeleidoscopeMaterial());
this.addMaterial(new MandelMaterial());
}
},
_materials : {
value: AppModel.materials
},
materials : {
get: function() {
return this._materials;
}
},
addMaterial: {
value: function (material) {
this._materials.push(material);
}
},
addMaterialAt: {
value: function (material, index) {
this._materials.splice(index, 0, material);
}
},
removeMaterialAt: {
value: function (index) {
return this._materials.splice(index, 1);
}
},
removeMaterial: {
value: function (materialName) {
var index = this.getIndexOfMaterial(materialName);
if(index !== -1) {
return this.removeMaterialAt(index);
}
}
},
getMaterialAt: {
value: function (index) {
return this._materials[index];
}
},
getMaterial: {
value: function (materialName) {
var index = this.getIndexOfMaterial(materialName);
if(index !== -1) {
return this._materials[index];
}
}
},
getMaterialByShader:
{
value: function( shaderName )
{
var index = this.getIndexOfMaterialByShader( shaderName );
if (index >= 0)
return this._materials[index];
}
},
getIndexOfMaterialByShader: {
value: function (shaderName) {
var len = this._materials.length;
for(var i=0; i