From 191cb96b3b4e1e5aa805211e5ab8dbd6aa075881 Mon Sep 17 00:00:00 2001
From: Nivesh Rajbhandari
Date: Thu, 9 Feb 2012 10:09:13 -0800
Subject: Merging WebGL changes that allow users to modify different shape
 instances. Also, merging in changes that improve rendering performance by not
 updating static materials.

Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
---
 js/helper-classes/RDGE/GLMaterial.js | 40 ++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

(limited to 'js/helper-classes/RDGE/GLMaterial.js')

diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js
index e1a68abd..642fab05 100644
--- a/js/helper-classes/RDGE/GLMaterial.js
+++ b/js/helper-classes/RDGE/GLMaterial.js
@@ -31,6 +31,11 @@ function GLMaterial( world )
 
 	this._texture;
 
+	// vertex deformation variables
+	this._hasVertexDeformation = false;
+	this._vertexDeformationRange = [0, 0, 1, 1];	// (xMin, yMin, xMax, yMax)
+	this._vertexDeformationTolerance = 0.1;
+
 	// RDGE variables
 	this._shader;
 	this._materialNode;
@@ -62,6 +67,16 @@ function GLMaterial( world )
 	this.getShader			= function()			{  return this._shader;				}
 	this.getMaterialNode	= function()			{  return this._materialNode;		}
 
+	// a material can be animated or not. default is not.  
+	// Any material needing continuous rendering should override this method
+	this.isAnimated			= function()			{  return false;					}
+
+	// the vertex shader can apply deformations requiring refinement in
+	// certain areas.
+	this.hasVertexDeformation			= function()	{  return this._hasVertexDeformation;			}
+	this.getVertexDeformationRange		= function()	{  return this._vertexDeformationRange.slice();	}	
+	this.getVertexDeformationTolerance	= function()	{  return this._vertexDeformationTolerance;		}
+
 
     ///////////////////////////////////////////////////////////////////////
     // Common Material Methods
@@ -174,6 +189,31 @@ function GLMaterial( world )
 		// animated materials should implement the update method
 	}
 
+	this.registerTexture = function( texture )
+	{
+		// the world needs to know about the texture map
+		var world = this.getWorld();
+		if (!world)
+			console.log( "**** world not defined for registering texture map: " + texture.lookUpName );
+		else
+			world.textureToLoad( texture );
+	}
+
+	this.loadTexture = function( texMapName, wrap, mips )
+	{
+		var tex;
+		var world = this.getWorld();
+		if (!world)
+			console.log( "world not defined for material with texture map" );
+		else
+		{
+			var renderer = world.getRenderer();
+			tex = renderer.getTextureByName(texMapName, wrap, mips );
+			this.registerTexture( tex );
+		}
+		return tex;
+	}
+
 	this.export = function()
 	{
 		// this function should be overridden by subclasses
-- 
cgit v1.2.3