From 182f05f2f7a8f43f1589c9b8c15bf00d6e983676 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 6 Mar 2012 11:41:09 -0800 Subject: File IO --- js/helper-classes/RDGE/Materials/UberMaterial.js | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'js/helper-classes/RDGE/Materials') diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js index 825f88ca..570d3326 100755 --- a/js/helper-classes/RDGE/Materials/UberMaterial.js +++ b/js/helper-classes/RDGE/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' }; @@ -428,6 +430,40 @@ function UberMaterial() this._materialNode.setShader(this._shader); }; + this.export = function() + { + // every material needs the base type and instance name + var exportStr = "material: " + this.getShaderName() + "\n"; + exportStr += "name: " + this.getName() + "\n"; + + // 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