From 2f66a9ab38f761b7796800bb37f8146f140db40b Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 26 Mar 2012 11:31:23 -0700 Subject: WebGL & Canvas as data for texture maps. --- js/lib/rdge/materials/material.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'js/lib/rdge/materials/material.js') diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index c1d13b15..157fa7db 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js @@ -252,6 +252,29 @@ var Material = function GLMaterial( world ) { return tex; }; + this.findWorld = function( id, elt ) + { + if (elt.id && elt.id === id) + { + if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) + { + var world = elt.elementModel.shapeModel.GLWorld; + return world; + } + } + + if (elt.children) + { + var nKids = elt.children.length; + for (var i=0; i= 3)); break; + case "angle": case "float": rtnVal = (valType == "number"); break; -- cgit v1.2.3 From f0bbd7688bcf2c6b8f749c7c6061ac09640ab08c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 4 Jun 2012 11:35:17 -0700 Subject: Avoid throwing shader errors in the console for 'color' property at a base class level. --- js/lib/rdge/materials/material.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib/rdge/materials/material.js') diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index b9de9988..856513e2 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js @@ -210,7 +210,7 @@ var Material = function GLMaterial( world ) { console.log( "setting invalid material property: " + prop + ", value: " + value ); } - if (!rtnVal) { + if (!rtnVal && (prop != 'color')) { console.log( "invalid material property: " + prop + " : " + value ); } -- cgit v1.2.3 From 6c994c4b90023cecf4fd0caafb404b859fe28f54 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 6 Jun 2012 16:34:41 -0700 Subject: material cleanup and rearchitecture --- js/lib/rdge/materials/material.js | 219 ++++++++++++++++++++++++++++++-------- 1 file changed, 176 insertions(+), 43 deletions(-) (limited to 'js/lib/rdge/materials/material.js') diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 856513e2..d2586b58 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js @@ -4,6 +4,9 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ +var Texture = require("js/lib/rdge/texture").Texture; + + /////////////////////////////////////////////////////////////////////// // Class GLMaterial // GL representation of a material. @@ -15,19 +18,16 @@ var Material = function GLMaterial( world ) { this._name = "GLMaterial"; this._shaderName = "undefined"; + this._time = 0.0; + this._dTime = 0.01; + // keep a reference to the owning GLWorld this._world = null; if(world) { this._world = world; } - this._shininess = 60; - - this._ambient = [0.0, 0.0, 0.0, 1.0]; - this._diffuse = [0.0, 0.0, 0.0, 1.0]; - this._specular = [0.0, 0.0, 0.0, 1.0]; - - this._texture = null; + this._glTextures = []; // indexed by uniform name // vertex deformation variables this._hasVertexDeformation = false; @@ -46,13 +46,6 @@ var Material = function GLMaterial( world ) { /////////////////////////////////////////////////////////////////////// // Property Accessors /////////////////////////////////////////////////////////////////////// - this.getShininess = function() { - return this._shininess; - }; - - this.setShininess = function(s) { - this._shininess = s; - }; this.setName = function(n) { this._name = n; @@ -78,30 +71,6 @@ var Material = function GLMaterial( world ) { return this._world; }; - this.setAmbient = function(r, g, b, a) { - this._ambient = [r, g, b, a]; - }; - - this.getAmbient = function() { - return [this._ambient[0], this._ambient[1], this._ambient[2], this._ambient[3]]; - }; - - this.setDiffuse = function(r, g, b, a) { - this._diffuse = [r, g, b, a]; - }; - - this.getDiffuse = function() { - return [this._diffuse[0], this._diffuse[1], this._diffuse[2], this._diffuse[3]]; - }; - - this.setSpecular = function(r, g, b, a) { - this._specular = [r, g, b, a]; - }; - - this.getSpecular = function() { - return [this._specular[0], this._specular[1], this._specular[2], this._specular[3]]; - }; - this.getShader = function() { return this._shader; }; @@ -116,6 +85,10 @@ var Material = function GLMaterial( world ) { return false; }; + this.getTechniqueName = function() { + return 'default' + }; + // the vertex shader can apply deformations requiring refinement in // certain areas. this.hasVertexDeformation = function() { @@ -166,6 +139,43 @@ var Material = function GLMaterial( world ) { } }; + this.hasProperty = function( prop ) + { + var propNames = [], dummy = []; + this.getAllProperties( propNames, dummy, dummy, dummy ) + for (var i=0; i