From 22cbc9644b79df60b3f6336f9563debd47fb3ea1 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 28 Jun 2012 11:44:15 -0700 Subject: Added capability to split a mesh into multiiple parts to avoid buffer overflow situations. --- js/lib/rdge/materials/uber-material.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (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 347e45d3..97adf310 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js @@ -62,6 +62,23 @@ var UberMaterial = function UberMaterial() { this._propValues[this._propNames[7]] = this._environmentMapOb['texture']; this._propValues[this._propNames[8]] = this._environmentMapOb['envReflection']; + this.resetToDefault = function() + { + this._propValues[this._propNames[0]] = this._ambientColor.slice(0); + this._propValues[this._propNames[1]] = this._diffuseColor.slice(0); + this._propValues[this._propNames[2]] = this._specularColor.slice(0); + this._propValues[this._propNames[3]] = this._specularPower; + this._propValues[this._propNames[4]] = this._diffuseMapOb['texture']; + this._propValues[this._propNames[5]] = this._normalMapOb['texture']; + this._propValues[this._propNames[6]] = this._specularMapOb['texture']; + this._propValues[this._propNames[7]] = this._environmentMapOb['texture']; + this._propValues[this._propNames[8]] = this._environmentMapOb['envReflection']; + + var nProps = this._propNames.length; + for (var i=0; i 0) { this._ubershaderCaps.lighting = - { - 'light0': this._lights[0], - 'light1': this._lights[1], - 'light2': this._lights[2], - 'light3': this._lights[3] - } + { + 'light0': this._lights[0], + 'light1': this._lights[1], + 'light2': this._lights[2], + 'light3': this._lights[3] + } } } @@ -534,20 +534,20 @@ var UberMaterial = function UberMaterial() { // every material needs the base type and instance name var caps = this._ubershaderCaps; var jObj = - { - 'material': this.getShaderName(), - 'name': this.getName() - }; + { + 'material': this.getShaderName(), + 'name': this.getName() + }; // export the material properties if (typeof caps.material != 'undefined') { jObj.materialProps = - { - 'ambientColor': this._ambientColor, - 'diffuseColor': this._diffuseColor, - 'specularColor': this._specularColor, - 'specularPower': this._specularPower - }; + { + 'ambientColor': this._ambientColor, + 'diffuseColor': this._diffuseColor, + 'specularColor': this._specularColor, + 'specularPower': this._specularPower + }; } @@ -568,7 +568,7 @@ var UberMaterial = function UberMaterial() { lightObj['light' + i + 'SpotInnerCutoff'] = light['spotInnerCutoff']; lightObj['light' + i + 'SpotOuterCutoff'] = light['spotOuterCutoff']; } - else // light.type === 'point' + else // light.type === 'point' { lightObj['light' + i + 'Pos'] = (light['position'] || [0, 0, 0]); lightObj['light' + i + 'Attenuation'] = (light['attenuation'] || [1, 0, 0]); @@ -742,7 +742,7 @@ var UberMaterial = function UberMaterial() { technique['u_light' + i + 'Pos'].set(light['position'] || [0, 0, 0]); var deg2Rad = Math.PI / 180; technique['u_light' + i + 'Spot'].set([Math.cos((light['spotInnerCutoff'] || 45.0) * deg2Rad), - Math.cos((light['spotOuterCutoff'] || 90.0) * deg2Rad)]); + Math.cos((light['spotOuterCutoff'] || 90.0) * deg2Rad)]); technique['u_light' + i + 'Atten'].set(light['attenuation'] || [1, 0, 0]); } else { technique['u_light' + i + 'Pos'].set(light['position'] || [0, 0, 0]); @@ -757,9 +757,9 @@ var UberMaterial = function UberMaterial() { var renderer = RDGE.globals.engine.getContext().renderer; if (this._useDiffuseMap) { - this._diffuseTexture = new Texture( this.getWorld(), caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips ); + this._diffuseTexture = new Texture( this.getWorld(), caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips ); var tex = this._diffuseTexture.getTexture(); - technique.s_diffuseMap.set( tex ); + technique.s_diffuseMap.set( tex ); } if (this._useNormalMap) { -- cgit v1.2.3 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- js/lib/rdge/materials/uber-material.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 8bd44e60..34aa06bf 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js @@ -146,9 +146,9 @@ var UberMaterial = function UberMaterial() { 'spotOuterCutoff': 15.0, // fragments outside the outer cutoff 'cone' are unlit. 'position': [8.0, 2.0, 8.0], // light position; ignored for directional lights 'direction': [-1.0, -1.0, -1.0], // light direction; ignored for point lights - 'attenuation': [1.0, 0.025, 0.00125], // light attenuation; constant, linear, quadratic + 'attenuation': [1.0, 0.025, 0.00125], // light attenuation; constant, linear, quadratic 'diffuseColor': [1.0, 0.5, 0.5, 1.0], // diffuse light color - 'specularColor': [1.0, 1.0, 1.0, 1.0] // specular light color + 'specularColor': [1.0, 1.0, 1.0, 1.0] // specular light color }, { 'type': 'point', @@ -184,7 +184,7 @@ var UberMaterial = function UberMaterial() { this._ubershaderCaps = { - // ubershader material properties. + // ubershader material properties. 'material': { 'ambientColor': this._ambientColor, // material ambient color 'diffuseColor': this._diffuseColor, // material diffuse color @@ -192,7 +192,7 @@ var UberMaterial = function UberMaterial() { 'specularPower': this._specularPower // material specular power (shininess) }, - // ubershader supports up to four lights. + // ubershader supports up to four lights. 'lighting': { 'light0': this._lights[0], 'light1': this._lights[1], @@ -386,7 +386,7 @@ var UberMaterial = function UberMaterial() { // get the current values; var propNames = [], propValues = [], propTypes = [], propLabels = []; this.getAllProperties(propNames, propValues, propTypes, propLabels); - + // allocate a new material var newMat = new UberMaterial(); newMat._useDiffuseMap = this._useDiffuseMap; @@ -434,7 +434,7 @@ var UberMaterial = function UberMaterial() { } } } - + this.isAnimated = function() { var anim = (this._diffuseTexture && this._diffuseTexture.isAnimated()); @@ -687,7 +687,7 @@ var UberMaterial = function UberMaterial() { var vshader = preproc + uberVShader; var fshader = preproc + uberFShader; - // build output jshader + // build output jshader var uberJShader = new RDGE.jshader(); uberJShader.def = { 'shaders': { -- cgit v1.2.3 From fdbec324dad4ab33d97282ab021d2c1661bc097c Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 9 Jul 2012 16:27:52 -0700 Subject: BSD License --- js/lib/rdge/materials/uber-material.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 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 7c7dced4..3cf950f5 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js @@ -1,24 +1,25 @@ /* -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -97,7 +98,7 @@ var UberMaterial = function UberMaterial() { this._propValues[this._propNames[6]] = this._specularMapOb['texture']; this._propValues[this._propNames[7]] = this._environmentMapOb['texture']; this._propValues[this._propNames[8]] = this._environmentMapOb['envReflection']; - + var nProps = this._propNames.length; for (var i=0; i