From 3a8875c288049b466bfeb8b7f0510fd8cbfb970d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 7 Feb 2012 13:30:08 -0800 Subject: Supporting switching materials in the PI. Also, moved makeFillMaterial and makeStrokeMaterial functions into GLGeomObj so shapes other than GLRectangle can use these routines. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/RDGE/GLGeomObj.js | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'js/helper-classes/RDGE/GLGeomObj.js') diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js index 72019703..62fbf562 100644 --- a/js/helper-classes/RDGE/GLGeomObj.js +++ b/js/helper-classes/RDGE/GLGeomObj.js @@ -37,6 +37,10 @@ function GLGeomObj() this.m_world = null; + // stroke and fill colors + this._strokeColor; + this._fillColor; + // stroke and fill materials this._fillMaterial; this._strokeMaterial; @@ -104,6 +108,53 @@ function GLGeomObj() this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } this.setStrokeColor = function(c) { this.setMaterialColor(c, "stroke"); } + this.makeStrokeMaterial = function() + { + var strokeMaterial; + if (this.getStrokeMaterial()) + strokeMaterial = this.getStrokeMaterial().dup(); + else + strokeMaterial = new FlatMaterial(); + + if (strokeMaterial) + { + strokeMaterial.init( this.getWorld() ); + if(this._strokeColor) + { + strokeMaterial.setProperty("color", this._strokeColor); + } + } + + this._materialArray.push( strokeMaterial ); + this._materialTypeArray.push( "stroke" ); + + return strokeMaterial; + } + + this.makeFillMaterial = function() + { + var fillMaterial; + if (this.getFillMaterial()) + fillMaterial = this.getFillMaterial().dup(); + else + fillMaterial = new FlatMaterial(); + + if (fillMaterial) + { + fillMaterial.init( this.getWorld() ); + //if(!this.getFillMaterial() && this._fillColor) + if (this._fillColor) + { + fillMaterial.setProperty("color", this._fillColor); + } + } + + this._materialArray.push( fillMaterial ); + this._materialTypeArray.push( "fill" ); + + return fillMaterial; + } + this.translate = function(v) { -- cgit v1.2.3