diff options
author | hwc487 | 2012-02-08 14:48:16 -0800 |
---|---|---|
committer | hwc487 | 2012-02-08 14:48:16 -0800 |
commit | 43e713a85785cd170bf0f5312d149d93235dadf2 (patch) | |
tree | 2142672a6cefe6ae531b84f3e23920f36157d394 /js/helper-classes/RDGE/Materials/FlatMaterial.js | |
parent | 468d324f8e9a5f018bc7609b58254ae468075ce9 (diff) | |
parent | 72805efb66c372bec2df8a2686dfd56c9ed26622 (diff) | |
download | ninja-43e713a85785cd170bf0f5312d149d93235dadf2.tar.gz |
Merge branch 'ToolFixes' of github.com:mqg734/ninja-internal into working
Conflicts:
js/helper-classes/RDGE/Materials/FlatMaterial.js
Diffstat (limited to 'js/helper-classes/RDGE/Materials/FlatMaterial.js')
-rw-r--r-- | js/helper-classes/RDGE/Materials/FlatMaterial.js | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js index de039231..a250dc0a 100644 --- a/js/helper-classes/RDGE/Materials/FlatMaterial.js +++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js | |||
@@ -75,11 +75,12 @@ function FlatMaterial() | |||
75 | 75 | ||
76 | this.setProperty = function( prop, value ) | 76 | this.setProperty = function( prop, value ) |
77 | { | 77 | { |
78 | // make sure we have legitimate imput | 78 | // make sure we have legitimate input |
79 | if (this.validateProperty( prop, value )) | 79 | if (this.validateProperty( prop, value )) |
80 | { | 80 | { |
81 | this._color = value.slice(0); | 81 | this._propValues[prop] = value; |
82 | this._shader.colorMe[prop].set(value); | 82 | if (this._shader && this._shader.colorMe) |
83 | this._shader.colorMe[prop].set(value); | ||
83 | } | 84 | } |
84 | } | 85 | } |
85 | /////////////////////////////////////////////////////////////////////// | 86 | /////////////////////////////////////////////////////////////////////// |
@@ -88,7 +89,7 @@ function FlatMaterial() | |||
88 | { | 89 | { |
89 | // this function should be overridden by subclasses | 90 | // this function should be overridden by subclasses |
90 | var exportStr = "material: " + this.getShaderName() + "\n"; | 91 | var exportStr = "material: " + this.getShaderName() + "\n"; |
91 | exportStr = "name: " + this.getName() + "\n"; | 92 | exportStr += "name: " + this.getName() + "\n"; |
92 | 93 | ||
93 | if (this._shader) | 94 | if (this._shader) |
94 | exportStr += "color: " + String(this._shader.colorMe.color) + "\n"; | 95 | exportStr += "color: " + String(this._shader.colorMe.color) + "\n"; |
@@ -99,19 +100,32 @@ function FlatMaterial() | |||
99 | return exportStr; | 100 | return exportStr; |
100 | } | 101 | } |
101 | 102 | ||
102 | this.import = function( importStr ) | 103 | this.import = function( importStr ) |
103 | { | 104 | { |
104 | var pu = new ParseUtils( importStr ); | 105 | var pu = new ParseUtils( importStr ); |
105 | var material = pu.nextValue( "material: " ); | 106 | var material = pu.nextValue( "material: " ); |
106 | if (material != this.getShaderName()) throw new Error( "ill-formed material" ); | 107 | if (material != this.getShaderName()) throw new Error( "ill-formed material" ); |
107 | this.setName( pu.nextValue( "material: ") ); | 108 | this.setName( pu.nextValue( "name: ") ); |
108 | var color = pu.nextValue( "color: " ); | 109 | |
109 | 110 | var rtnStr; | |
110 | var endKey = "endMaterial\n"; | 111 | try |
111 | var index = importStr.indexOf( endKey ) + endKey.len; | 112 | { |
112 | var rtnStr = importStr.substr( index ); | 113 | var color = eval( "[" + pu.nextValue( "color: " ) + "]" ); |
113 | return rtnStr; | 114 | |
114 | } | 115 | this.setProperty( "color", color); |
116 | |||
117 | var endKey = "endMaterial\n"; | ||
118 | var index = importStr.indexOf( endKey ); | ||
119 | index += endKey.length; | ||
120 | rtnStr = importStr.substr( index ); | ||
121 | } | ||
122 | catch (e) | ||
123 | { | ||
124 | throw new Error( "could not import material: " + importStr ); | ||
125 | } | ||
126 | |||
127 | return rtnStr; | ||
128 | } | ||
115 | 129 | ||
116 | this.update = function( time ) | 130 | this.update = function( time ) |
117 | { | 131 | { |