diff options
author | Eric Guzman | 2012-03-17 00:05:14 -0700 |
---|---|---|
committer | Eric Guzman | 2012-03-17 00:05:14 -0700 |
commit | a3192d8bc0f8c0698265817c14dcd2284fd89d7d (patch) | |
tree | 497ac55f550ed52f9d73b464aafb2aa6cb5f5038 /js/lib/rdge/materials/flat-material.js | |
parent | a6a6f9bcc5ff92f5bb5e9275336dfaec2d8e8f4c (diff) | |
parent | 954f5a13e371febcb1c0fb8015c577ee51c23130 (diff) | |
download | ninja-a3192d8bc0f8c0698265817c14dcd2284fd89d7d.tar.gz |
Merge branch 'refs/heads/master' into AddAnimationsLibrary
Conflicts:
js/panels/presets/default-transition-presets.js
Diffstat (limited to 'js/lib/rdge/materials/flat-material.js')
-rwxr-xr-x | js/lib/rdge/materials/flat-material.js | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js index be8bf2b8..fff0e68e 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; |
@@ -97,13 +102,7 @@ var FlatMaterial = function FlatMaterial() { | |||
97 | try | 102 | try |
98 | { | 103 | { |
99 | var color = eval( "[" + pu.nextValue( "color: " ) + "]" ); | 104 | var color = eval( "[" + pu.nextValue( "color: " ) + "]" ); |
100 | |||
101 | this.setProperty( "color", color); | 105 | this.setProperty( "color", color); |
102 | |||
103 | var endKey = "endMaterial\n"; | ||
104 | var index = importStr.indexOf( endKey ); | ||
105 | index += endKey.length; | ||
106 | rtnStr = importStr.substr( index ); | ||
107 | } | 106 | } |
108 | catch (e) | 107 | catch (e) |
109 | { | 108 | { |