diff options
Diffstat (limited to 'js/lib/rdge/materials/twist-vert-material.js')
-rw-r--r-- | js/lib/rdge/materials/twist-vert-material.js | 53 |
1 files changed, 9 insertions, 44 deletions
diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js index 802690a2..f093fbca 100644 --- a/js/lib/rdge/materials/twist-vert-material.js +++ b/js/lib/rdge/materials/twist-vert-material.js | |||
@@ -4,15 +4,17 @@ | |||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; | 7 | var Material = require("js/lib/rdge/materials/material").Material; |
8 | var Texture = require("js/lib/rdge/texture").Texture; | ||
9 | |||
8 | /////////////////////////////////////////////////////////////////////// | 10 | /////////////////////////////////////////////////////////////////////// |
9 | // Class GLMaterial | 11 | // Class GLMaterial |
10 | // RDGE representation of a material. | 12 | // RDGE representation of a material. |
11 | /////////////////////////////////////////////////////////////////////// | 13 | /////////////////////////////////////////////////////////////////////// |
12 | function TwistVertMaterial() | 14 | var TwistVertMaterial = function TwistVertMaterial() |
13 | { | 15 | { |
14 | // initialize the inherited members | 16 | // initialize the inherited members |
15 | this.inheritedFrom = GLMaterial; | 17 | this.inheritedFrom = Material; |
16 | this.inheritedFrom(); | 18 | this.inheritedFrom(); |
17 | 19 | ||
18 | /////////////////////////////////////////////////////////////////////// | 20 | /////////////////////////////////////////////////////////////////////// |
@@ -131,47 +133,6 @@ function TwistVertMaterial() | |||
131 | } | 133 | } |
132 | } | 134 | } |
133 | 135 | ||
134 | this.export = function() | ||
135 | { | ||
136 | // this function should be overridden by subclasses | ||
137 | var exportStr = "material: " + this.getShaderName() + "\n"; | ||
138 | exportStr += "name: " + this.getName() + "\n"; | ||
139 | |||
140 | if (this._shader) | ||
141 | exportStr += "color: " + String(this._shader.twistMe.color) + "\n"; | ||
142 | else | ||
143 | exportStr += "color: " + this.getColor() + "\n"; | ||
144 | exportStr += "endMaterial\n"; | ||
145 | |||
146 | return exportStr; | ||
147 | } | ||
148 | |||
149 | this.import = function( importStr ) | ||
150 | { | ||
151 | var pu = new MaterialParser( importStr ); | ||
152 | var material = pu.nextValue( "material: " ); | ||
153 | if (material != this.getShaderName()) throw new Error( "ill-formed material" ); | ||
154 | this.setName( pu.nextValue( "name: ") ); | ||
155 | |||
156 | var rtnStr; | ||
157 | try | ||
158 | { | ||
159 | var color = eval( "[" + pu.nextValue( "color: " ) + "]" ); | ||
160 | |||
161 | this.setProperty( "color", color); | ||
162 | |||
163 | var endKey = "endMaterial\n"; | ||
164 | var index = importStr.indexOf( endKey ); | ||
165 | index += endKey.length; | ||
166 | rtnStr = importStr.substr( index ); | ||
167 | } | ||
168 | catch (e) | ||
169 | { | ||
170 | throw new Error( "could not import material: " + importStr ); | ||
171 | } | ||
172 | |||
173 | return rtnStr; | ||
174 | } | ||
175 | 136 | ||
176 | this.update = function( time ) | 137 | this.update = function( time ) |
177 | { | 138 | { |
@@ -277,3 +238,7 @@ twistVertShaderDef = | |||
277 | } | 238 | } |
278 | }; | 239 | }; |
279 | 240 | ||
241 | if (typeof exports === "object") { | ||
242 | exports.TwistVertMaterial = TwistVertMaterial; | ||
243 | } | ||
244 | |||