aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/GLGeomObj.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/GLGeomObj.js')
-rwxr-xr-xjs/helper-classes/RDGE/GLGeomObj.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js
index c1ee01ba..955f0f39 100755
--- a/js/helper-classes/RDGE/GLGeomObj.js
+++ b/js/helper-classes/RDGE/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 {