From 7b6e8194b91168abdeb94702eb350d14f147858b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 8 Mar 2012 17:29:18 -0800 Subject: Canvas IO --- js/lib/rdge/materials/uber-material.js | 46 +++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'js/lib/rdge/materials/uber-material.js') diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js index 0964c9c4..d120ffa1 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js @@ -33,6 +33,8 @@ var UberMaterial = function UberMaterial() { this._useEnvironmentMap = true; this._useLights = [true, true, true, true]; + this._MAX_LIGHTS = 4; + /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// @@ -374,6 +376,18 @@ var UberMaterial = function UberMaterial() { var index = importStr.indexOf( endKey ); index += endKey.length; importStr = importStr.substr( index ); + var pu = new MaterialParser( importStr ); + + var matProps = pu.nextValue( "materialProps: " ); + if (matProps) + { + var ambientColor = Number( pu.nextValue( "ambientColor: " )); this.setProperty( "ambientColor", ambientColor ); + var diffuseColor = Number( pu.nextValue( "diffuseColor: " )); this.setProperty( "diffuseColor", diffuseColor ); + var specularColor = Number( pu.nextValue( "specularColor: " )); this.setProperty( "specularColor", specularColor ); + var specularPower = Number( pu.nextValue( "specularPower: " )); this.setProperty( "specularPower", specularPower ); + } + + var lightProps = pu.nextValue( "theLights" ); } this.export = function() @@ -387,7 +401,7 @@ var UberMaterial = function UberMaterial() { // export the material properties if (typeof caps.material != 'undefined') { - exportStr += "material: true\n"; + exportStr += "materialProps: true\n"; exportStr += "ambientColor: " + caps.material.ambientColor + "\n"; exportStr += "diffuseColor: " + caps.material.diffuseColor + "\n"; exportStr += "specularColor: " + caps.material.specularColor + "\n"; @@ -396,8 +410,9 @@ var UberMaterial = function UberMaterial() { if (typeof caps.lighting != 'undefined') { + exportStr += "lightProps: true\n"; + var light = caps.lighting['light' + i]; - var t; for (var i=0; i