diff options
author | Valerio Virgillito | 2012-03-13 11:15:34 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-03-13 11:15:34 -0700 |
commit | f6b958360d82854bdaf51848e7fd715d1f633179 (patch) | |
tree | 80f6c08bb730089bdd3f26310df8d2363f9ba863 /js/helper-classes/backup-delete/GLGeomObj.js | |
parent | c24f58c10231c30d3a8a4c9fb9a4f395dd746180 (diff) | |
parent | 4d7b86f55c504ee4e8c2460cf6b60cb9a2cf18f0 (diff) | |
download | ninja-f6b958360d82854bdaf51848e7fd715d1f633179.tar.gz |
Merge pull request #105 from joseeight/FileIO-Build-Candidate
File I/O adding webGL/canvas data functionality
Diffstat (limited to 'js/helper-classes/backup-delete/GLGeomObj.js')
-rwxr-xr-x | js/helper-classes/backup-delete/GLGeomObj.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/js/helper-classes/backup-delete/GLGeomObj.js b/js/helper-classes/backup-delete/GLGeomObj.js index 8946470d..54933590 100755 --- a/js/helper-classes/backup-delete/GLGeomObj.js +++ b/js/helper-classes/backup-delete/GLGeomObj.js | |||
@@ -158,6 +158,52 @@ function GLGeomObj() | |||
158 | return fillMaterial; | 158 | return fillMaterial; |
159 | } | 159 | } |
160 | 160 | ||
161 | this.exportMaterials = function() | ||
162 | { | ||
163 | var rtnStr = ""; | ||
164 | if (this._materialArray && this._materialNodeArray) | ||
165 | { | ||
166 | var nMats = this._materialArray.length; | ||
167 | rtnStr += "nMaterials: " + nMats + "\n"; | ||
168 | for (var i=0; i<nMats; i++) | ||
169 | { | ||
170 | var matNode = this._materialNodeArray[i]; | ||
171 | rtnStr += "materialNodeName: " + matNode.name + "\n"; | ||
172 | |||
173 | var material = this._materialArray[i]; | ||
174 | rtnStr += material.export(); | ||
175 | } | ||
176 | } | ||
177 | else | ||
178 | rtnStr += "nMaterials: 0\n" ; | ||
179 | |||
180 | return rtnStr; | ||
181 | } | ||
182 | |||
183 | this.importMaterials = function(importStr) | ||
184 | { | ||
185 | var nMaterials = Number( this.getPropertyFromString( "nMaterials: ", importStr ) ); | ||
186 | for (var i=0; i<nMaterials; i++) | ||
187 | { | ||
188 | var mat; | ||
189 | var materialType = this.getPropertyFromString( "material: ", importStr ); | ||
190 | switch (materialType) | ||
191 | { | ||
192 | case "flat": mat = new FlatMaterial(); break; | ||
193 | |||
194 | default: | ||
195 | console.log( "material type: " + materialType + " is not supported" ); | ||
196 | break; | ||
197 | } | ||
198 | |||
199 | if (mat) | ||
200 | mat.import( importStr ); | ||
201 | |||
202 | var endIndex = importStr.indexOf( "endMaterial\n" ); | ||
203 | if (endIndex < 0) break; | ||
204 | importStr = importStr.substr( endIndex ); | ||
205 | } | ||
206 | } | ||
161 | 207 | ||
162 | this.translate = function(v) | 208 | this.translate = function(v) |
163 | { | 209 | { |