From 2d68f944e93b201deb46015392e706b7a24201c9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 8 Feb 2012 14:24:48 -0800 Subject: Fixed several typos in Materials import/export code to support toggling between 2d and 3d shape modes. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/Materials/UberMaterial.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/helper-classes/RDGE/Materials/UberMaterial.js') diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js index a8254465..f3acdaa6 100644 --- a/js/helper-classes/RDGE/Materials/UberMaterial.js +++ b/js/helper-classes/RDGE/Materials/UberMaterial.js @@ -45,9 +45,9 @@ function UberMaterial() /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// - this._propNames = ["ambientColor", "diffuseColor", "specularColor", "specularPower" , "diffuseMap", "normalMap", "specularMap", "environmentMap", "environmentAmount", "dummy" ]; - this._propLabels = ["Ambient Color", "Diffuse Color", "Specular Color", "Specular Power", "Texture Map", "Bump Map", "Specular Map", "Environment Map", "Environment Map Amount", "Dummy" ]; - this._propTypes = ["color", "color", "color", "float", "file", "file", "file", "file", "float", "checkbox"]; + this._propNames = ["ambientColor", "diffuseColor", "specularColor", "specularPower" , "diffuseMap", "normalMap", "specularMap", "environmentMap", "environmentAmount" ]; + this._propLabels = ["Ambient Color", "Diffuse Color", "Specular Color", "Specular Power", "Texture Map", "Bump Map", "Specular Map", "Environment Map", "Environment Map Amount" ]; + this._propTypes = ["color", "color", "color", "float", "file", "file", "file", "file", "float" ]; this._propValues = []; this._propValues[ this._propNames[0] ] = this._ambientColor.slice(0); -- cgit v1.2.3 From 805059d68087530721212a650412aefb85e98d1f Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 10:26:57 -0800 Subject: Removed unused materials. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/Materials/UberMaterial.js | 37 +++++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'js/helper-classes/RDGE/Materials/UberMaterial.js') diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js index f3acdaa6..8385f2d6 100644 --- a/js/helper-classes/RDGE/Materials/UberMaterial.js +++ b/js/helper-classes/RDGE/Materials/UberMaterial.js @@ -151,10 +151,10 @@ function UberMaterial() { // ubershader material properties. 'material' : { - 'ambientColor' : this._ambientColor, // material ambient color - 'diffuseColor' : this._diffuseColor, // material diffuse color - 'specularColor' : this._specularColor, // material specular color - 'specularPower' : this._specularPower, // material specular power (shininess) + 'ambientColor' : this._ambientColor, // material ambient color + 'diffuseColor' : this._diffuseColor, // material diffuse color + 'specularColor' : this._specularColor, // material specular color + 'specularPower' : this._specularPower // material specular power (shininess) }, // ubershader supports up to four lights. @@ -162,7 +162,7 @@ function UberMaterial() 'light0' : this._lights[0], 'light1' : this._lights[1], 'light2' : this._lights[2], - 'light3' : this._lights[3], + 'light3' : this._lights[3] }, // uvTransform can be used to scale or offset the texture coordinates. @@ -178,7 +178,7 @@ function UberMaterial() 'specularMap' : this._specularMapOb, // optional environment map - 'environmentMap' : this._environmentMapOb, + 'environmentMap' : this._environmentMapOb }; this.updateAmbientColor = function() @@ -270,6 +270,7 @@ function UberMaterial() if (renderer && technique) { var tex = renderer.getTextureByName(value, caps.environmentMap.wrap); + this.registerTexture( tex ); technique.s_environmentMap.set( tex ); } } @@ -307,6 +308,7 @@ function UberMaterial() if (renderer && technique) { var tex = renderer.getTextureByName(value, caps.diffuseMap.wrap); + this.registerTexture( tex ); technique.s_diffuseMap.set( tex ); } } @@ -344,6 +346,7 @@ function UberMaterial() if (renderer && technique) { var tex = renderer.getTextureByName(value, caps.specularMap.wrap); + this.registerTexture( tex ); technique.s_specularMap.set( tex ); } } @@ -381,6 +384,7 @@ function UberMaterial() if (renderer && technique) { var tex = renderer.getTextureByName(value, caps.normalMap.wrap); + this.registerTexture( tex ); technique.s_normalMap.set( tex ); } } @@ -411,8 +415,11 @@ function UberMaterial() return newMat; } - this.init = function() + this.init = function( world ) { + // save the world + if (world) this.setWorld( world ); + // set up the shader this._shader = this.buildUberShader( this._ubershaderCaps ); @@ -579,16 +586,24 @@ function UberMaterial() renderer = g_Engine.getContext().renderer; if(this._useDiffuseMap) { - technique.s_diffuseMap.set(renderer.getTextureByName(caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips)); + var tex = renderer.getTextureByName(caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips); + this.registerTexture( tex ); + technique.s_diffuseMap.set( tex ); } if(this._useNormalMap) { - technique.s_normalMap.set(renderer.getTextureByName(caps.normalMap.texture, caps.normalMap.wrap, caps.normalMap.mips)); + var tex = renderer.getTextureByName(caps.normalMap.texture, caps.normalMap.wrap, caps.normalMap.mips); + this.registerTexture( tex ); + technique.s_normalMap.set( tex ); } if(this._useSpecularMap) { - technique.s_specMap.set(renderer.getTextureByName(caps.specularMap.texture, caps.specularMap.wrap)); + var tex = renderer.getTextureByName(caps.specularMap.texture, caps.specularMap.wrap); + this.registerTexture( tex ); + technique.s_specMap.set( tex ); } if(this._useEnvironmentMap) { - technique.s_envMap.set(renderer.getTextureByName(caps.environmentMap.texture, caps.environmentMap.wrap)); + var tex = renderer.getTextureByName(caps.environmentMap.texture, caps.environmentMap.wrap); + this.registerTexture( tex ); + technique.s_envMap.set( tex ); technique.u_envReflection.set([ caps.environmentMap.envReflection || 1.0 ] ); } -- cgit v1.2.3 From 3ba2be686e1981c8af3054ead1c7bb59af8b5d66 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 9 Feb 2012 14:18:20 -0800 Subject: Updated linear and radial gradient materials import/export routines. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/Materials/UberMaterial.js | 44 ++++++++++++------------ 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'js/helper-classes/RDGE/Materials/UberMaterial.js') diff --git a/js/helper-classes/RDGE/Materials/UberMaterial.js b/js/helper-classes/RDGE/Materials/UberMaterial.js index 8385f2d6..c7855c95 100644 --- a/js/helper-classes/RDGE/Materials/UberMaterial.js +++ b/js/helper-classes/RDGE/Materials/UberMaterial.js @@ -21,7 +21,7 @@ function UberMaterial() /////////////////////////////////////////////////////////////////////// this._name = "UberMaterial"; this._shaderName = "uber"; - this.getShaderName = function() { return this._shaderName; } + this.getShaderName = function() { return this._shaderName; }; // set some default values this._ambientColor = [ 0.0, 0.0, 0.0, 1.0 ]; @@ -99,7 +99,7 @@ function UberMaterial() break; } } - } + }; /////////////////////////////////////////////////////////////////////// // define the 4 lights @@ -190,7 +190,7 @@ function UberMaterial() var technique = material.shaderProgram.defaultTechnique; technique.u_ambientColor.set(this._ambientColor); } - } + }; this.updateDiffuseColor = function() { @@ -202,7 +202,7 @@ function UberMaterial() var technique = material.shaderProgram.defaultTechnique; technique.u_diffuseColor.set(this._diffuseColor); } - } + }; this.updateSpecularColor = function( value ) { @@ -214,7 +214,7 @@ function UberMaterial() var technique = material.shaderProgram.defaultTechnique; technique.u_specularColor.set(this._specularColor); } - } + }; this.updateSpecularPower = function( value) { @@ -226,7 +226,7 @@ function UberMaterial() var technique = material.shaderProgram.defaultTechnique; technique.u_specularPower.set([this._specularPower]); } - } + }; this.updateEnvironmentAmount = function(value) { @@ -238,7 +238,7 @@ function UberMaterial() var technique = material.shaderProgram.defaultTechnique; technique.u_envReflection.set([this._environmentMapOb.envReflection]); } - } + }; this.updateEnvironmentMap = function() { @@ -276,7 +276,7 @@ function UberMaterial() } } } - } + }; this.updateDiffuseMap = function(value) { @@ -314,7 +314,7 @@ function UberMaterial() } } } - } + }; this.updateSpecularMap = function() { @@ -352,7 +352,7 @@ function UberMaterial() } } } - } + }; this.updateNormalMap = function(value) { @@ -390,7 +390,7 @@ function UberMaterial() } } } - } + }; // duplcate method requirde this.dup = function() @@ -413,7 +413,7 @@ function UberMaterial() newMat.setProperty( propNames[i], propValues[i] ); return newMat; - } + }; this.init = function( world ) { @@ -426,7 +426,7 @@ function UberMaterial() // set up the material node this._materialNode = createMaterialNode("uberMaterial"); this._materialNode.setShader(this._shader); - } + }; this.buildUberShader = function(caps) { @@ -446,7 +446,7 @@ function UberMaterial() { preproc += '#define LIGHTING\n'; preproc += '#define SPECULAR\n'; - for(i = 0; i < 4; ++i) { + for(var i = 0; i < 4; ++i) { var light = caps.lighting['light' + i]; var t; if (typeof light != 'undefined') { @@ -507,7 +507,7 @@ function UberMaterial() var fshader = preproc + uberFShader; // build output jshader - uberJShader = new jshader(); + var uberJShader = new jshader(); uberJShader.def = { 'shaders': { 'defaultVShader': vshader, @@ -520,18 +520,18 @@ function UberMaterial() 'attributes' : { 'a_pos' : { 'type' : 'vec3' }, 'a_normal' : { 'type' : 'vec3' }, - 'a_texcoord' : { 'type' : 'vec2' }, + 'a_texcoord' : { 'type' : 'vec2' } }, 'params' : paramBlock, 'states' : { 'depthEnable' : true, 'blendEnable' : false, 'culling' : true, - 'cullFace' : "FRONT", - }, + 'cullFace' : "FRONT" + } }] } - } + }; // initialize the jshader try { @@ -584,7 +584,7 @@ function UberMaterial() } technique.u_uvMatrix.set(caps.uvTransform || mat4.identity()); - renderer = g_Engine.getContext().renderer; + var renderer = g_Engine.getContext().renderer; if(this._useDiffuseMap) { var tex = renderer.getTextureByName(caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips); this.registerTexture( tex ); @@ -608,7 +608,7 @@ function UberMaterial() } return uberJShader; - } + }; this.rebuildShader = function() { @@ -667,7 +667,7 @@ function UberMaterial() var material = this._materialNode; if (material) material.setShader( buildUbershader(this._ubershaderCaps) ); - } + }; } -- cgit v1.2.3