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