From fdeed8051c3af538d28ca3bc599121cea483c22c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 22 Mar 2012 15:47:56 -0700 Subject: Squashed commit of the following GL integration Signed-off-by: Valerio Virgillito --- js/lib/rdge/materials/bump-metal-material.js | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'js/lib/rdge/materials/bump-metal-material.js') diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index fa6f5300..2ef83227 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js @@ -152,6 +152,46 @@ var BumpMetalMaterial = function BumpMetalMaterial() { } }; + this.exportJSON = function() + { + var jObj = + { + 'material' : this.getShaderName(), + 'name' : this.getName(), + 'lightDiff' : this.getLightDiff(), + 'diffuseTexture' : this.getDiffuseTexture(), + 'specularTexture' : this.getSpecularTexture(), + 'normalMap' : this.getNormalTexture() + }; + + return jObj; + }; + + this.importJSON = function( jObj ) + { + if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); + this.setName( jObj.name ); + + try + { + var lightDiff = jObj.lightDiff, + dt = jObj.diffuseTexture, + st = jObj.specularTexture, + nt = jObj.normalMap; + + this.setProperty( "lightDiff", lightDiff); + this.setProperty( "diffuseTexture", dt ); + this.setProperty( "specularTexture", st ); + this.setProperty( "normalMap", nt ); + } + catch (e) + { + throw new Error( "could not import BumpMetal material: " + jObj ); + } + + return; + }; + this.export = function() { // every material needs the base type and instance name -- cgit v1.2.3