aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/radial-blur-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/radial-blur-material.js')
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js82
1 files changed, 79 insertions, 3 deletions
diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js
index 3adb6bb5..8a624556 100644
--- a/js/lib/rdge/materials/radial-blur-material.js
+++ b/js/lib/rdge/materials/radial-blur-material.js
@@ -94,7 +94,7 @@ var RadialBlurMaterial = function RadialBlurMaterial() {
94 this._shader.init(); 94 this._shader.init();
95 95
96 // set up the material node 96 // set up the material node
97 this._materialNode = RDGE.createMaterialNode("radialBlurMaterial"); 97 this._materialNode = RDGE.createMaterialNode("radialBlurMaterial" + "_" + world.generateUniqueNodeID());
98 this._materialNode.setShader(this._shader); 98 this._materialNode.setShader(this._shader);
99 99
100 this._time = 0; 100 this._time = 0;
@@ -157,11 +157,50 @@ var RadialBlurMaterial = function RadialBlurMaterial() {
157 } 157 }
158 }; 158 };
159 159
160 this.exportJSON = function()
161 {
162 var jObj =
163 {
164 'material' : this.getShaderName(),
165 'name' : this.getName(),
166 'color' : this._propValues["color"],
167 'texture' : this._propValues[this._propNames[0]]
168 };
169
170 return jObj;
171 };
172
173 this.importJSON = function( jObj )
174 {
175 if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
176 this.setName( jObj.name );
177
178 var rtnStr;
179 try
180 {
181 this._propValues[this._propNames[0]] = jObj.texture;
182 this.updateTexture();
183 }
184 catch (e)
185 {
186 throw new Error( "could not import material: " + importStr );
187 }
188
189 return rtnStr;
190 };
191
160 this.export = function() { 192 this.export = function() {
161 // every material needs the base type and instance name 193 // every material needs the base type and instance name
162 var exportStr = "material: " + this.getShaderName() + "\n"; 194 var exportStr = "material: " + this.getShaderName() + "\n";
163 exportStr += "name: " + this.getName() + "\n"; 195 exportStr += "name: " + this.getName() + "\n";
164 196
197 var world = this.getWorld();
198 if (!world)
199 throw new Error( "no world in material.export, " + this.getName() );
200
201 var texMapName = this._propValues[this._propNames[0]];
202 exportStr += "texture: " + texMapName + "\n";
203
165 // every material needs to terminate like this 204 // every material needs to terminate like this
166 exportStr += "endMaterial\n"; 205 exportStr += "endMaterial\n";
167 206
@@ -235,10 +274,47 @@ var radialBlurMaterialDef =
235 } 274 }
236}; 275};
237 276
277
278var RaidersMaterial = function RaidersMaterial()
279{
280 // initialize the inherited members
281 this.inheritedFrom = RadialBlurMaterial;
282 this.inheritedFrom();
283
284 this._name = "RaidersMaterial";
285 this._shaderName = "raiders";
286
287 this._texMap = 'assets/images/raiders.png';
288 this._propValues[ this._propNames[0] ] = this._texMap.slice(0);
289
290
291 // duplcate method requirde
292 this.dup = function( world ) {
293 // allocate a new uber material
294 var newMat = new RaidersMaterial();
295
296 // copy over the current values;
297 var propNames = [], propValues = [], propTypes = [], propLabels = [];
298 this.getAllProperties( propNames, propValues, propTypes, propLabels);
299 var n = propNames.length;
300 for (var i=0; i<n; i++)
301 newMat.setProperty( propNames[i], propValues[i] );
302
303 return newMat;
304 };
305}
306
307RaidersMaterial.prototype = new Material();
308
309if (typeof exports === "object")
310{
311 exports.RaidersMaterial = RaidersMaterial;
312}
313
314
238RadialBlurMaterial.prototype = new Material(); 315RadialBlurMaterial.prototype = new Material();
239 316
240if (typeof exports === "object") { 317if (typeof exports === "object")
241 exports.RadialBlurMaterial = RadialBlurMaterial; 318 exports.RadialBlurMaterial = RadialBlurMaterial;
242}
243 319
244 320