From 182f05f2f7a8f43f1589c9b8c15bf00d6e983676 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 6 Mar 2012 11:41:09 -0800 Subject: File IO --- js/document/html-document.js | 2 +- js/helper-classes/3D/math-utils.js | 5 +++- js/helper-classes/RDGE/Materials/UberMaterial.js | 36 +++++++++++++++++++++++ js/helper-classes/RDGE/runtime/RuntimeMaterial.js | 1 - 4 files changed, 41 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index f1b99866..1f335f79 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -185,7 +185,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { var elt = this.documentRoot; if (elt) { - var loadForRuntime = true; + var loadForRuntime = false; if (loadForRuntime) { //console.log( "load canvas data: " , value ); diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 37044763..f084cf9f 100755 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js @@ -709,7 +709,10 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { // the area of the polygon is the length of the normal var area = VecUtils.vecMag(3, normal ); if (this.fpSign(area) != 0) - vec3.scale(normal, 1.0/area); + { + //vec3.scale(normal, 1.0/area); + normal = VecUtils.vecNormalize(3, normal, 1.0); + } return normal; } 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