aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/flat-material.js
diff options
context:
space:
mode:
authorJonathan Duran2012-03-14 08:59:17 -0700
committerJonathan Duran2012-03-14 08:59:17 -0700
commite065244ac75d1d0f25fd5c75cb58e714a13fe16b (patch)
tree6b49a85a45fdd41b81be5603fbbc2e0d197eb187 /js/lib/rdge/materials/flat-material.js
parente8f207dc50ad942ee8c1c1db6b146c0110ce3216 (diff)
downloadninja-e065244ac75d1d0f25fd5c75cb58e714a13fe16b.tar.gz
Squashed commit of the following:
merge master into timeline Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/lib/rdge/materials/flat-material.js')
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js41
1 files changed, 23 insertions, 18 deletions
diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js
index be8bf2b8..97e4f646 100755
--- a/js/lib/rdge/materials/flat-material.js
+++ b/js/lib/rdge/materials/flat-material.js
@@ -36,19 +36,27 @@ var FlatMaterial = function FlatMaterial() {
36 // duplcate method requirde 36 // duplcate method requirde
37 this.dup = function() { return new FlatMaterial(); } ; 37 this.dup = function() { return new FlatMaterial(); } ;
38 38
39 this.init = function() 39 this.init = function( world )
40 { 40 {
41 // set up the shader 41 // save the world
42 this._shader = new jshader(); 42 if (world)
43 this._shader.def = flatShaderDef; 43 {
44 this._shader.init(); 44 this.setWorld( world );
45 45
46 // set the defaults 46 // set up the shader
47 this._shader.colorMe.color.set( this.getColor() ); 47 this._shader = new jshader();
48 48 this._shader.def = flatShaderDef;
49 // set up the material node 49 this._shader.init();
50 this._materialNode = createMaterialNode("flatMaterial"); 50
51 this._materialNode.setShader(this._shader); 51 // set the defaults
52 this._shader.colorMe.color.set( this.getColor() );
53
54 // set up the material node
55 this._materialNode = createMaterialNode("flatMaterial_" + world.generateUniqueNodeID() );
56 this._materialNode.setShader(this._shader);
57 }
58 else
59 throw new Error( "GLWorld not supplied to material initialization" );
52 }; 60 };
53 61
54 62
@@ -73,15 +81,12 @@ var FlatMaterial = function FlatMaterial() {
73 }; 81 };
74 /////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////
75 83
76 this.export = function() { 84 this.export = function()
85 {
77 // this function should be overridden by subclasses 86 // this function should be overridden by subclasses
78 var exportStr = "material: " + this.getShaderName() + "\n"; 87 var exportStr = "material: " + this.getShaderName() + "\n";
79 exportStr += "name: " + this.getName() + "\n"; 88 exportStr += "name: " + this.getName() + "\n";
80 89 exportStr += "color: " + String(this._propValues["color"]) + "\n";
81 if (this._shader)
82 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
83 else
84 exportStr += "color: " + this.getColor() + "\n";
85 exportStr += "endMaterial\n"; 90 exportStr += "endMaterial\n";
86 91
87 return exportStr; 92 return exportStr;