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/bump-metal-material.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (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 99a80da2..ea3322cf 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js @@ -20,6 +20,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() { this._shaderName = "bumpMetal"; + this._defaultLightDiff = [0.3, 0.3, 0.3, 1.0]; this._defaultDiffuseTexture = "assets/images/metal.png"; this._defaultSpecularTexture = "assets/images/silver.png"; this._defaultNormalTexture = "assets/images/normalMap.png"; @@ -43,7 +44,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() { this._propTypes = ["color", "file", "file", "file" ]; this._propValues = []; - this._propValues[ this._propNames[0] ] = [0.3, 0.3, 0.3, 1.0]; + this._propValues[ this._propNames[0] ] = this._defaultLightDiff; this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); @@ -72,8 +73,19 @@ var BumpMetalMaterial = function BumpMetalMaterial() { this.setShaderValues(); this.update(0); }; + + this.resetToDefault = function() + { + this._propValues[ this._propNames[0] ] = this._defaultLightDiff; + this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); + this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); + this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); + for (var i=0; i<4; i++) + this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] ); + }; }; + /////////////////////////////////////////////////////////////////////////////////////// // RDGE shader -- cgit v1.2.3 From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/lib/rdge/materials/bump-metal-material.js | 154 +++++++++++++-------------- 1 file changed, 77 insertions(+), 77 deletions(-) (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 3db3df1d..bcc092f9 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js @@ -40,62 +40,62 @@ var BumpMetalMaterial = function BumpMetalMaterial() { /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// - this._name = "Bump Metal"; - this._shaderName = "bumpMetal"; + this._name = "Bump Metal"; + this._shaderName = "bumpMetal"; this._defaultDiffuseTexture = "assets/images/metal.png"; this._defaultSpecularTexture = "assets/images/silver.png"; - this._defaultNormalTexture = "assets/images/normalMap.png"; + this._defaultNormalTexture = "assets/images/normalMap.png"; // array textures indexed by shader uniform name this._glTextures = []; - this._speed = 1.0; + this._speed = 1.0; /////////////////////////////////////////////////////////////////////// // Property Accessors /////////////////////////////////////////////////////////////////////// - this.isAnimated = function() { return true; }; - this.getShaderDef = function() { return bumpMetalMaterialDef; }; + this.isAnimated = function() { return true; }; + this.getShaderDef = function() { return bumpMetalMaterialDef; }; /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// - this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ]; - this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ]; - this._propTypes = ["color", "file", "file", "file" ]; - this._propValues = []; + this._propNames = ["u_light0Diff", "u_colMap", "u_normalMap", "u_glowMap" ]; + this._propLabels = ["Diffuse Color", "Diffuse Map", "Bump Map", "Specular Map" ]; + this._propTypes = ["color", "file", "file", "file" ]; + this._propValues = []; - this._propValues[ this._propNames[0] ] = [0.3, 0.3, 0.3, 1.0]; - this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); - this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); - this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); + this._propValues[ this._propNames[0] ] = [0.3, 0.3, 0.3, 1.0]; + this._propValues[ this._propNames[1] ] = this._defaultDiffuseTexture.slice(0); + this._propValues[ this._propNames[2] ] = this._defaultNormalTexture.slice(0); + this._propValues[ this._propNames[3] ] = this._defaultSpecularTexture.slice(0); /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// - this.init = function( world ) - { - // save the world - if (world) { - this.setWorld( world ); + this.init = function( world ) + { + // save the world + if (world) { + this.setWorld( world ); } - // set up the shader - this._shader = new RDGE.jshader(); - this._shader.def = bumpMetalMaterialDef; - this._shader.init(); + // set up the shader + this._shader = new RDGE.jshader(); + this._shader.def = bumpMetalMaterialDef; + this._shader.init(); - // set up the material node - this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); - this._materialNode.setShader(this._shader); + // set up the material node + this._materialNode = RDGE.createMaterialNode( this.getShaderName() + "_" + world.generateUniqueNodeID() ); + this._materialNode.setShader(this._shader); - this.setShaderValues(); - this.update(0); - }; + this.setShaderValues(); + this.update(0); + }; }; /////////////////////////////////////////////////////////////////////////////////////// @@ -104,28 +104,28 @@ var BumpMetalMaterial = function BumpMetalMaterial() { // shader spec (can also be loaded from a .JSON file, or constructed at runtime) var bumpMetalMaterialDef = bumpMetalShaderDef = { - 'shaders': - { - // this shader is being referenced by file - 'defaultVShader':"assets/shaders/test_vshader.glsl", - 'defaultFShader':"assets/shaders/test_fshader.glsl", + 'shaders': + { + // this shader is being referenced by file + 'defaultVShader':"assets/shaders/test_vshader.glsl", + 'defaultFShader':"assets/shaders/test_fshader.glsl", - // this shader is inline - 'dirLightVShader': "\ - uniform mat4 u_mvMatrix;\ - uniform mat4 u_normalMatrix;\ - uniform mat4 u_projMatrix;\ - uniform mat4 u_worldMatrix;\ - attribute vec3 a_pos;\ - attribute vec3 a_nrm;\ - varying vec3 vNormal;\ - varying vec3 vPos;\ - void main() {\ - vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\ - gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\ - vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\ - }", - 'dirLightFShader': "\ + // this shader is inline + 'dirLightVShader': "\ + uniform mat4 u_mvMatrix;\ + uniform mat4 u_normalMatrix;\ + uniform mat4 u_projMatrix;\ + uniform mat4 u_worldMatrix;\ + attribute vec3 a_pos;\ + attribute vec3 a_nrm;\ + varying vec3 vNormal;\ + varying vec3 vPos;\ + void main() {\ + vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\ + gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\ + vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\ + }", + 'dirLightFShader': "\ precision highp float;\ uniform vec4 u_light1Diff;\ uniform vec3 u_light1Pos;\ @@ -142,29 +142,29 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = float alpha2 = max(0.0, 1.0 - ( (light2.x*light2.x)/range + (light2.y*light2.y)/range + (light2.z*light2.z)/range));\ gl_FragColor = vec4((u_light2Diff*alpha2 + u_light1Diff*alpha1).rgb, 1.0);\ }" - }, - 'techniques': - { - 'default': - [ - { - 'vshader' : 'defaultVShader', - 'fshader' : 'defaultFShader', - // attributes - 'attributes' : - { - 'vert' : { 'type' : 'vec3' }, - 'normal' : { 'type' : 'vec3' }, - 'texcoord' : { 'type' : 'vec2' } - }, - // parameters - 'params' : - { - 'u_light0Diff' : { 'type' : 'vec4' }, - 'u_colMap': { 'type' : 'tex2d' }, - 'u_normalMap': { 'type' : 'tex2d' }, - 'u_glowMap': { 'type' : 'tex2d' } - }, + }, + 'techniques': + { + 'default': + [ + { + 'vshader' : 'defaultVShader', + 'fshader' : 'defaultFShader', + // attributes + 'attributes' : + { + 'vert' : { 'type' : 'vec3' }, + 'normal' : { 'type' : 'vec3' }, + 'texcoord' : { 'type' : 'vec2' } + }, + // parameters + 'params' : + { + 'u_light0Diff' : { 'type' : 'vec4' }, + 'u_colMap': { 'type' : 'tex2d' }, + 'u_normalMap': { 'type' : 'tex2d' }, + 'u_glowMap': { 'type' : 'tex2d' } + }, // render states 'states' : @@ -172,7 +172,7 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = 'depthEnable' : true, 'offset':[1.0, 0.1] } - }, + }, { // light pass 'vshader' : 'dirLightVShader', 'fshader' : 'dirLightFShader', @@ -195,9 +195,9 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = "srcBlend" : "SRC_ALPHA", "dstBlend" : "DST_ALPHA" } - } // light pass - ] - } // techniques + } // light pass + ] + } // techniques }; BumpMetalMaterial.prototype = new Material(); -- 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/bump-metal-material.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (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 bcc092f9..fa830d3d 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js @@ -100,7 +100,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() { /////////////////////////////////////////////////////////////////////////////////////// // RDGE shader - + // shader spec (can also be loaded from a .JSON file, or constructed at runtime) var bumpMetalMaterialDef = bumpMetalShaderDef = { @@ -109,7 +109,7 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = // this shader is being referenced by file 'defaultVShader':"assets/shaders/test_vshader.glsl", 'defaultFShader':"assets/shaders/test_fshader.glsl", - + // this shader is inline 'dirLightVShader': "\ uniform mat4 u_mvMatrix;\ @@ -124,7 +124,7 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = vNormal.xyz = (u_normalMatrix*vec4(a_nrm, 0.0)).xyz;\ gl_Position = u_projMatrix * u_mvMatrix * vec4(a_pos,1.0);\ vPos = (u_worldMatrix * vec4(a_pos,1.0)).xyz;\ - }", + }", 'dirLightFShader': "\ precision highp float;\ uniform vec4 u_light1Diff;\ @@ -144,7 +144,7 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = }" }, 'techniques': - { + { 'default': [ { @@ -158,7 +158,7 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = 'texcoord' : { 'type' : 'vec2' } }, // parameters - 'params' : + 'params' : { 'u_light0Diff' : { 'type' : 'vec4' }, 'u_colMap': { 'type' : 'tex2d' }, @@ -167,7 +167,7 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = }, // render states - 'states' : + 'states' : { 'depthEnable' : true, 'offset':[1.0, 0.1] @@ -183,12 +183,12 @@ var bumpMetalMaterialDef = bumpMetalShaderDef = 'a_nrm' : { 'type' : 'vec3' } }, // parameters - 'params' : + 'params' : { }, // render states - 'states' : + 'states' : { 'depthEnable' : true, "blendEnable" : true, -- 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/bump-metal-material.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (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 044dc59b..02540033 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-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 -- cgit v1.2.3