From e065244ac75d1d0f25fd5c75cb58e714a13fe16b Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Wed, 14 Mar 2012 08:59:17 -0700 Subject: Squashed commit of the following: merge master into timeline Signed-off-by: Jonathan Duran --- .../backup-delete/Materials/UberMaterial.js | 73 +++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) (limited to 'js/helper-classes/backup-delete/Materials/UberMaterial.js') diff --git a/js/helper-classes/backup-delete/Materials/UberMaterial.js b/js/helper-classes/backup-delete/Materials/UberMaterial.js index c7855c95..1652b4c9 100755 --- a/js/helper-classes/backup-delete/Materials/UberMaterial.js +++ b/js/helper-classes/backup-delete/Materials/UberMaterial.js @@ -30,6 +30,8 @@ function UberMaterial() this._specularPower = 32.0; this._environmentAmount = 0.2; // 0 .. 1 + this._MAX_LIGHTS = 4; + // set the default maps this._diffuseMapOb = { 'texture' : 'assets/images/rocky-diffuse.jpg', 'wrap' : 'REPEAT' }; this._normalMapOb = { 'texture' : 'assets/images/rocky-normal.jpg', 'wrap' : 'REPEAT' }; @@ -424,10 +426,79 @@ function UberMaterial() this._shader = this.buildUberShader( this._ubershaderCaps ); // set up the material node - this._materialNode = createMaterialNode("uberMaterial"); + this._materialNode = createMaterialNode("uberMaterial_" + world.generateUniqueNodeID()); this._materialNode.setShader(this._shader); }; + this.import = function( importStr ) + { + // limit the key searches to this material + var endKey = "endMaterial\n"; + var index = importStr.indexOf( endKey ); + index += endKey.length; + importStr = importStr.substr( index ); + } + + this.export = function() + { + // every material needs the base type and instance name + var exportStr = "material: " + this.getShaderName() + "\n"; + exportStr += "name: " + this.getName() + "\n"; + + var caps = this._ubershaderCaps; + + // export the material properties + if (typeof caps.material != 'undefined') + { + exportStr += "material: true\n"; + exportStr += "ambientColor: " + caps.material.ambientColor + "\n"; + exportStr += "diffuseColor: " + caps.material.diffuseColor + "\n"; + exportStr += "specularColor: " + caps.material.specularColor + "\n"; + exportStr += "specularPower: " + caps.material.specularPower + "\n"; + } + + if (typeof caps.lighting != 'undefined') + { + var light = caps.lighting['light' + i]; + var t; + for (var i=0; i