aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorhwc4872012-03-06 14:44:30 -0800
committerhwc4872012-03-06 14:44:30 -0800
commit1207735f05f202b5bdc5f70c73445f8e0934a227 (patch)
tree44e69b843b5333b9372645f000fa9aa078b78ec7 /js/helper-classes
parent3fcb463816a399b5474114725322653a20a22e9a (diff)
downloadninja-1207735f05f202b5bdc5f70c73445f8e0934a227.tar.gz
IO
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/RDGE/Materials/UberMaterial.js37
1 files changed, 36 insertions, 1 deletions
diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js
index 570d3326..1652b4c9 100755
--- a/js/helper-classes/RDGE/Materials/UberMaterial.js
+++ b/js/helper-classes/RDGE/Materials/UberMaterial.js
@@ -430,11 +430,22 @@ function UberMaterial()
430 this._materialNode.setShader(this._shader); 430 this._materialNode.setShader(this._shader);
431 }; 431 };
432 432
433 this.import = function( importStr )
434 {
435 // limit the key searches to this material
436 var endKey = "endMaterial\n";
437 var index = importStr.indexOf( endKey );
438 index += endKey.length;
439 importStr = importStr.substr( index );
440 }
441
433 this.export = function() 442 this.export = function()
434 { 443 {
435 // every material needs the base type and instance name 444 // every material needs the base type and instance name
436 var exportStr = "material: " + this.getShaderName() + "\n"; 445 var exportStr = "material: " + this.getShaderName() + "\n";
437 exportStr += "name: " + this.getName() + "\n"; 446 exportStr += "name: " + this.getName() + "\n";
447
448 var caps = this._ubershaderCaps;
438 449
439 // export the material properties 450 // export the material properties
440 if (typeof caps.material != 'undefined') 451 if (typeof caps.material != 'undefined')
@@ -452,8 +463,32 @@ function UberMaterial()
452 var t; 463 var t;
453 for (var i=0; i<this._MAX_LIGHTS; i++) 464 for (var i=0; i<this._MAX_LIGHTS; i++)
454 { 465 {
455 if (typeof light != 'undefined') 466 var light = caps.lighting["light" + i];
467 if( typeof light != "undefined")
456 { 468 {
469 exportStr += "light" + i + ': ' + light.type + "\n";
470
471 if (light.type === 'directional')
472 {
473 exportStr += 'light' + i + 'Dir: ' + light['direction'] + '\n';
474 }
475 else if (light.type === 'spot')
476 {
477 exportStr += 'light' + i + 'Pos: ' + light['position'] + '\n';
478
479 var deg2Rad = Math.PI / 180;
480 exportStr += 'light' + i + 'Spot: ' + [ Math.cos( ( light['spotInnerCutoff'] || 45.0 ) * deg2Rad ),
481 Math.cos( ( light['spotOuterCutoff'] || 90.0 ) * deg2Rad )] + '\n';
482 }
483 else // light.type === 'point'
484 {
485 technique['u_light'+i+'Pos'].set(light['position'] || [ 0, 0, 0 ]);
486 technique['u_light'+i+'Atten'].set(light['attenuation'] || [ 1,0,0 ]);
487 }
488 exportStr += 'light' + i + 'Color: ' + light['diffuseColor'] || [ 1,1,1,1 ] + '\n';
489 exportStr += 'light' + i + 'SpecularColor: ' + light['specularColor'] || [ 1, 1, 1, 1 ] + '\n';
490
491 exportStr += "endlight\n";
457 } 492 }
458 } 493 }
459 } 494 }