aboutsummaryrefslogtreecommitdiff
path: root/js/models
diff options
context:
space:
mode:
authorJohn Mayhew2012-04-02 16:28:39 -0700
committerJohn Mayhew2012-04-02 16:28:39 -0700
commitb4155fb4c33675a8a7cd37473513718043fdf0ba (patch)
tree3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/models
parent5ba9aeac94c86049423fd5d4b37b277263939c13 (diff)
parentc6de22bf42be90b403491b5f87b1818d9020310c (diff)
downloadninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts: js/helper-classes/RDGE/rdge-compiled.js js/helper-classes/RDGE/runtime/GLRuntime.js js/helper-classes/RDGE/src/core/script/MeshManager.js js/helper-classes/RDGE/src/core/script/engine.js js/helper-classes/RDGE/src/core/script/fx/ssao.js js/helper-classes/RDGE/src/core/script/init_state.js js/helper-classes/RDGE/src/core/script/run_state.js js/helper-classes/RDGE/src/core/script/scenegraphNodes.js js/helper-classes/RDGE/src/core/script/utilities.js js/helper-classes/RDGE/src/tools/compile-rdge-core.bat js/helper-classes/RDGE/src/tools/compile-rdge-core.sh js/helper-classes/RDGE/src/tools/rdge-compiled.js js/lib/drawing/world.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/deform-material.js js/lib/rdge/materials/flat-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/linear-gradient-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-blur-material.js js/lib/rdge/materials/radial-gradient-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 js/preloader/Preloader.js
Diffstat (limited to 'js/models')
-rwxr-xr-xjs/models/color-model.js3
-rwxr-xr-xjs/models/materials-model.js91
-rwxr-xr-xjs/models/shape-model.js3
3 files changed, 72 insertions, 25 deletions
diff --git a/js/models/color-model.js b/js/models/color-model.js
index 2c86422f..4189fbef 100755
--- a/js/models/color-model.js
+++ b/js/models/color-model.js
@@ -574,6 +574,9 @@ exports.ColorModel = Montage.create(Component, {
574 temp = this.hslToRgb(color.h/360, color.s/100, color.l/100); 574 temp = this.hslToRgb(color.h/360, color.s/100, color.l/100);
575 } else if (color.r !== undefined) { 575 } else if (color.r !== undefined) {
576 temp = color; 576 temp = color;
577 } else if (color.gradientMode) {
578 // TODO - Need to handle gradients at some point
579 return null;
577 } 580 }
578 temp.a = color.a; 581 temp.a = color.a;
579 } 582 }
diff --git a/js/models/materials-model.js b/js/models/materials-model.js
index d8fb4016..44364aa2 100755
--- a/js/models/materials-model.js
+++ b/js/models/materials-model.js
@@ -17,6 +17,7 @@ var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-mate
17var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial; 17var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial;
18var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial; 18var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial;
19var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial; 19var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial;
20var RaidersMaterial = require("js/lib/rdge/materials/radial-blur-material").RaidersMaterial;
20var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial; 21var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial;
21var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; 22var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial;
22var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial; 23var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial;
@@ -24,6 +25,7 @@ var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material
24var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; 25var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial;
25var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; 26var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial;
26var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; 27var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial;
28var ParisMaterial = require("js/lib/rdge/materials/water-material").ParisMaterial;
27var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; 29var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial;
28var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; 30var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial;
29var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; 31var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial;
@@ -48,6 +50,7 @@ exports.MaterialsModel = Montage.create(Component, {
48 this.addMaterial(new BumpMetalMaterial()); 50 this.addMaterial(new BumpMetalMaterial());
49 this.addMaterial(new UberMaterial()); 51 this.addMaterial(new UberMaterial());
50 this.addMaterial(new RadialBlurMaterial()); 52 this.addMaterial(new RadialBlurMaterial());
53 this.addMaterial(new RaidersMaterial());
51 this.addMaterial(new PlasmaMaterial()); 54 this.addMaterial(new PlasmaMaterial());
52 this.addMaterial(new PulseMaterial()); 55 this.addMaterial(new PulseMaterial());
53 this.addMaterial(new TunnelMaterial()); 56 this.addMaterial(new TunnelMaterial());
@@ -55,6 +58,7 @@ exports.MaterialsModel = Montage.create(Component, {
55 this.addMaterial(new SquareTunnelMaterial()); 58 this.addMaterial(new SquareTunnelMaterial());
56 this.addMaterial(new FlyMaterial()); 59 this.addMaterial(new FlyMaterial());
57 this.addMaterial(new WaterMaterial()); 60 this.addMaterial(new WaterMaterial());
61 this.addMaterial(new ParisMaterial());
58 this.addMaterial(new ZInvertMaterial()); 62 this.addMaterial(new ZInvertMaterial());
59 this.addMaterial(new DeformMaterial()); 63 this.addMaterial(new DeformMaterial());
60 this.addMaterial(new StarMaterial()); 64 this.addMaterial(new StarMaterial());
@@ -112,10 +116,34 @@ exports.MaterialsModel = Montage.create(Component, {
112 value: function (materialName) { 116 value: function (materialName) {
113 var index = this.getIndexOfMaterial(materialName); 117 var index = this.getIndexOfMaterial(materialName);
114 if(index !== -1) { 118 if(index !== -1) {
115 return this._materials[index]; 119 return this._materials[index].dup();
116 } 120 }
117 } 121 }
118 }, 122 },
123
124 getMaterialByShader:
125 {
126 value: function( shaderName )
127 {
128 var index = this.getIndexOfMaterialByShader( shaderName );
129 if (index >= 0)
130 return this._materials[index].dup();
131 }
132 },
133
134 getIndexOfMaterialByShader: {
135 value: function (shaderName) {
136 var len = this._materials.length;
137 for(var i=0; i<len; i++) {
138 var material = this._materials[i];
139 if(material.getShaderName() === shaderName) {
140 return i;
141 }
142 }
143
144 return -1;
145 }
146 },
119 147
120 getIndexOfMaterial: { 148 getIndexOfMaterial: {
121 value: function (materialName) { 149 value: function (materialName) {
@@ -143,37 +171,54 @@ exports.MaterialsModel = Montage.create(Component, {
143 } 171 }
144 }, 172 },
145 173
146 exportMaterials: { 174 getDefaultMaterialName: {
147 value: function() { 175 value: function() {
176 return "FlatMaterial";
177 }
178 },
148 179
149 var exportStr = "MaterialLibrary: \n"; 180 exportMaterials: {
150 181 value: function()
182 {
183 var matArray = [];
151 var nMats = this._materials.length; 184 var nMats = this._materials.length;
152
153 for (var i=0; i<nMats; i++) { 185 for (var i=0; i<nMats; i++) {
154 var material = this._materials[i]; 186 var material = this._materials[i];
155 exportStr += material.export(); 187 var matObj = material.exportJSON();
188 matArray.push( matObj );
156 } 189 }
157 190
158 exportStr += "endMatLib\n"; 191 var jObj =
159 return exportStr; 192 {
193 'materialLibrary': 1.0,
194 'materials': matArray
195 };
196
197 // prepend an identifiable string to aid parsing when the
198 // material model is loaded.
199 var jStr = "materialLibrary;" + JSON.stringify( jObj );
200
201 return jStr;
160 } 202 }
161 }, 203 },
162 204
163 importMaterials: { 205 importMaterials: {
164 value: function( importStr ) { 206 value: function( jObj )
207 {
208 // make sure we have some materials to import before doing anything
209 var matArray = jObj.materials;
210 if (!matArray) return;
211
165 // we replace allmaterials, so remove anything 212 // we replace allmaterials, so remove anything
166 // that is currently there. 213 // that is currently there.
167 this.clearAllMaterials(); 214 this.clearAllMaterials();
168 215
169 var pu = new MaterialParser( importStr ); 216 var nMats = matArray.length;
170 217 for (var i=0; i<nMats; i++)
171 var type = pu.nextValue( "material: ", "\n", false ); 218 {
172 219 var mat = null;
173 while (type) { 220 var jMatObj = matArray[i];
174 221 var type = jMatObj.material;
175 var mat = null;
176
177 switch (type) 222 switch (type)
178 { 223 {
179 case "flat": mat = new FlatMaterial(); break; 224 case "flat": mat = new FlatMaterial(); break;
@@ -192,6 +237,8 @@ exports.MaterialsModel = Montage.create(Component, {
192 case "squareTunnel": mat = new SquareTunnelMaterial(); break; 237 case "squareTunnel": mat = new SquareTunnelMaterial(); break;
193 case "fly": mat = new FlyMaterial(); break; 238 case "fly": mat = new FlyMaterial(); break;
194 case "water": mat = new WaterMaterial(); break; 239 case "water": mat = new WaterMaterial(); break;
240 case "paris": mat = new ParisMaterial(); break;
241 case "raiders": mat = new RaidersMaterial(); break;
195 case "zinvert": mat = new ZInvertMaterial(); break; 242 case "zinvert": mat = new ZInvertMaterial(); break;
196 case "deform": mat = new DeformMaterial(); break; 243 case "deform": mat = new DeformMaterial(); break;
197 case "star": mat = new StarMaterial(); break; 244 case "star": mat = new StarMaterial(); break;
@@ -203,20 +250,16 @@ exports.MaterialsModel = Montage.create(Component, {
203 250
204 default: 251 default:
205 throw new Error( "Unrecognized material type: " + type ); 252 throw new Error( "Unrecognized material type: " + type );
206 pu.advancePastToken( "endMaterial\n" );
207 break; 253 break;
208 } 254 }
209 255
210 if (mat) { 256 if (mat) {
211 importStr = mat.import( importStr ); 257 importStr = mat.importJSON( jMatObj );
212 pu._strBuffer = importStr;
213 this.addMaterial( mat ); 258 this.addMaterial( mat );
214 } 259 }
215
216 type = pu.nextValue( "material: ", "\n", false );
217 } 260 }
218 261
219 return pu._strBuffer;