diff options
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-x | js/helper-classes/3D/math-utils.js | 5 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/Materials/UberMaterial.js | 36 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/RuntimeMaterial.js | 1 |
3 files changed, 40 insertions, 2 deletions
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, { | |||
709 | // the area of the polygon is the length of the normal | 709 | // the area of the polygon is the length of the normal |
710 | var area = VecUtils.vecMag(3, normal ); | 710 | var area = VecUtils.vecMag(3, normal ); |
711 | if (this.fpSign(area) != 0) | 711 | if (this.fpSign(area) != 0) |
712 | vec3.scale(normal, 1.0/area); | 712 | { |
713 | //vec3.scale(normal, 1.0/area); | ||
714 | normal = VecUtils.vecNormalize(3, normal, 1.0); | ||
715 | } | ||
713 | 716 | ||
714 | return normal; | 717 | return normal; |
715 | } | 718 | } |
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() | |||
30 | this._specularPower = 32.0; | 30 | this._specularPower = 32.0; |
31 | this._environmentAmount = 0.2; // 0 .. 1 | 31 | this._environmentAmount = 0.2; // 0 .. 1 |
32 | 32 | ||
33 | this._MAX_LIGHTS = 4; | ||
34 | |||
33 | // set the default maps | 35 | // set the default maps |
34 | this._diffuseMapOb = { 'texture' : 'assets/images/rocky-diffuse.jpg', 'wrap' : 'REPEAT' }; | 36 | this._diffuseMapOb = { 'texture' : 'assets/images/rocky-diffuse.jpg', 'wrap' : 'REPEAT' }; |
35 | this._normalMapOb = { 'texture' : 'assets/images/rocky-normal.jpg', 'wrap' : 'REPEAT' }; | 37 | this._normalMapOb = { 'texture' : 'assets/images/rocky-normal.jpg', 'wrap' : 'REPEAT' }; |
@@ -428,6 +430,40 @@ function UberMaterial() | |||
428 | this._materialNode.setShader(this._shader); | 430 | this._materialNode.setShader(this._shader); |
429 | }; | 431 | }; |
430 | 432 | ||
433 | this.export = function() | ||
434 | { | ||
435 | // every material needs the base type and instance name | ||
436 | var exportStr = "material: " + this.getShaderName() + "\n"; | ||
437 | exportStr += "name: " + this.getName() + "\n"; | ||
438 | |||
439 | // export the material properties | ||
440 | if (typeof caps.material != 'undefined') | ||
441 | { | ||
442 | exportStr += "material: true\n"; | ||
443 | exportStr += "ambientColor: " + caps.material.ambientColor + "\n"; | ||
444 | exportStr += "diffuseColor: " + caps.material.diffuseColor + "\n"; | ||
445 | exportStr += "specularColor: " + caps.material.specularColor + "\n"; | ||
446 | exportStr += "specularPower: " + caps.material.specularPower + "\n"; | ||
447 | } | ||
448 | |||
449 | if (typeof caps.lighting != 'undefined') | ||
450 | { | ||
451 | var light = caps.lighting['light' + i]; | ||
452 | var t; | ||
453 | for (var i=0; i<this._MAX_LIGHTS; i++) | ||
454 | { | ||
455 | if (typeof light != 'undefined') | ||
456 | { | ||
457 | } | ||
458 | } | ||
459 | } | ||
460 | |||
461 | // every material needs to terminate like this | ||
462 | exportStr += "endMaterial\n"; | ||
463 | |||
464 | return exportStr; | ||
465 | } | ||
466 | |||
431 | this.buildUberShader = function(caps) | 467 | this.buildUberShader = function(caps) |
432 | { | 468 | { |
433 | var preproc = ""; | 469 | var preproc = ""; |
diff --git a/js/helper-classes/RDGE/runtime/RuntimeMaterial.js b/js/helper-classes/RDGE/runtime/RuntimeMaterial.js index 0f10cfbe..6c57d102 100644 --- a/js/helper-classes/RDGE/runtime/RuntimeMaterial.js +++ b/js/helper-classes/RDGE/runtime/RuntimeMaterial.js | |||
@@ -44,7 +44,6 @@ function RuntimeMaterial( world ) | |||
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | |||
48 | function RuntimeFlatMaterial() | 47 | function RuntimeFlatMaterial() |
49 | { | 48 | { |
50 | // inherit the members of RuntimeMaterial | 49 | // inherit the members of RuntimeMaterial |