diff options
author | Pushkar Joshi | 2012-03-13 11:36:11 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-03-13 11:36:11 -0700 |
commit | 6023f7c8258e660388ee33730601f1161f9299e9 (patch) | |
tree | 632484428b398f71b8481aa8e30180895ff2483c /js/helper-classes/backup-delete | |
parent | 76f2021618c0a6a99a1b855233e353e84ca99467 (diff) | |
parent | 4ad1650f629e7e345eade52ed6dadc233b27cc45 (diff) | |
download | ninja-6023f7c8258e660388ee33730601f1161f9299e9.tar.gz |
Merge branch 'pentool' into brushtool
Diffstat (limited to 'js/helper-classes/backup-delete')
26 files changed, 233 insertions, 84 deletions
diff --git a/js/helper-classes/backup-delete/GLCircle.js b/js/helper-classes/backup-delete/GLCircle.js index 15ed6b6d..59d0bdaf 100755 --- a/js/helper-classes/backup-delete/GLCircle.js +++ b/js/helper-classes/backup-delete/GLCircle.js | |||
@@ -381,7 +381,6 @@ function GLCircle() | |||
381 | // translate | 381 | // translate |
382 | var xCtr = 0.5*world.getViewportWidth() + this._xOffset, | 382 | var xCtr = 0.5*world.getViewportWidth() + this._xOffset, |
383 | yCtr = 0.5*world.getViewportHeight() + this._yOffset; | 383 | yCtr = 0.5*world.getViewportHeight() + this._yOffset; |
384 | //ctx.setTransform( xScale, 0.0, 0.0, yScale, xCtr, yCtr ); | ||
385 | var mat = Matrix.create( [ | 384 | var mat = Matrix.create( [ |
386 | [ xScale, 0.0, 0.0, xCtr], | 385 | [ xScale, 0.0, 0.0, xCtr], |
387 | [ 0.0, yScale, 0.0, yCtr], | 386 | [ 0.0, yScale, 0.0, yCtr], |
@@ -538,6 +537,8 @@ function GLCircle() | |||
538 | rtnStr += "flatMaterial"; | 537 | rtnStr += "flatMaterial"; |
539 | rtnStr += "\n"; | 538 | rtnStr += "\n"; |
540 | 539 | ||
540 | rtnStr += this.exportMaterials(); | ||
541 | |||
541 | return rtnStr; | 542 | return rtnStr; |
542 | } | 543 | } |
543 | 544 | ||
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 | { |
diff --git a/js/helper-classes/backup-delete/GLRectangle.js b/js/helper-classes/backup-delete/GLRectangle.js index a801d3c4..2caa7080 100755 --- a/js/helper-classes/backup-delete/GLRectangle.js +++ b/js/helper-classes/backup-delete/GLRectangle.js | |||
@@ -166,6 +166,8 @@ function GLRectangle() | |||
166 | rtnStr += "flatMaterial"; | 166 | rtnStr += "flatMaterial"; |
167 | rtnStr += "\n"; | 167 | rtnStr += "\n"; |
168 | 168 | ||
169 | rtnStr += this.exportMaterials(); | ||
170 | |||
169 | return rtnStr; | 171 | return rtnStr; |
170 | } | 172 | } |
171 | 173 | ||
diff --git a/js/helper-classes/backup-delete/GLWorld.js b/js/helper-classes/backup-delete/GLWorld.js index 8017207f..c8bc4c1c 100755 --- a/js/helper-classes/backup-delete/GLWorld.js +++ b/js/helper-classes/backup-delete/GLWorld.js | |||
@@ -13,7 +13,6 @@ var fragmentShaderSource = ""; | |||
13 | 13 | ||
14 | var rdgeStarted = false; | 14 | var rdgeStarted = false; |
15 | 15 | ||
16 | var nodeCounter = 0; | ||
17 | var worldCounter = 0; | 16 | var worldCounter = 0; |
18 | 17 | ||
19 | 18 | ||
@@ -74,6 +73,10 @@ function GLWorld( canvas, use3D ) | |||
74 | this._worldCount = worldCounter; | 73 | this._worldCount = worldCounter; |
75 | worldCounter++; | 74 | worldCounter++; |
76 | 75 | ||
76 | // keep a counter for generating node names | ||
77 | this._nodeCounter = 0; | ||
78 | |||
79 | |||
77 | /////////////////////////////////////////////////////////////////////// | 80 | /////////////////////////////////////////////////////////////////////// |
78 | // Property accessors | 81 | // Property accessors |
79 | /////////////////////////////////////////////////////////////////////// | 82 | /////////////////////////////////////////////////////////////////////// |
@@ -376,10 +379,12 @@ function GLWorld( canvas, use3D ) | |||
376 | return false; | 379 | return false; |
377 | } | 380 | } |
378 | 381 | ||
379 | 382 | this.generateUniqueNodeID = function() | |
380 | // END RDGE | 383 | { |
381 | //////////////////////////////////////////////////////////////////////////////////// | 384 | var str = String( this._nodeCounter ); |
382 | 385 | this._nodeCounter++; | |
386 | return str; | ||
387 | } | ||
383 | 388 | ||
384 | // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state | 389 | // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state |
385 | // in the case of a procedurally built scene an init state is not needed for loading data | 390 | // in the case of a procedurally built scene an init state is not needed for loading data |
@@ -418,7 +423,7 @@ GLWorld.prototype.updateObject = function (obj) | |||
418 | ctrTrNode = obj.getTransformNode(); | 423 | ctrTrNode = obj.getTransformNode(); |
419 | if (ctrTrNode == null) | 424 | if (ctrTrNode == null) |
420 | { | 425 | { |
421 | ctrTrNode = createTransformNode("objRootNode_" + nodeCounter++); | 426 | ctrTrNode = createTransformNode("objRootNode_" + this._nodeCounter++); |
422 | this._rootNode.insertAsChild( ctrTrNode ); | 427 | this._rootNode.insertAsChild( ctrTrNode ); |
423 | obj.setTransformNode( ctrTrNode ); | 428 | obj.setTransformNode( ctrTrNode ); |
424 | } | 429 | } |
@@ -428,7 +433,7 @@ GLWorld.prototype.updateObject = function (obj) | |||
428 | }); | 433 | }); |
429 | ctrTrNode.meshes = []; | 434 | ctrTrNode.meshes = []; |
430 | 435 | ||
431 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prims[0]); | 436 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); |
432 | ctrTrNode.attachMaterial(materialNodes[0]); | 437 | ctrTrNode.attachMaterial(materialNodes[0]); |
433 | } | 438 | } |
434 | 439 | ||
@@ -451,12 +456,12 @@ GLWorld.prototype.updateObject = function (obj) | |||
451 | } | 456 | } |
452 | else | 457 | else |
453 | { | 458 | { |
454 | childTrNode = createTransformNode("objNode_" + nodeCounter++); | 459 | childTrNode = createTransformNode("objNode_" + this._nodeCounter++); |
455 | ctrTrNode.insertAsChild(childTrNode); | 460 | ctrTrNode.insertAsChild(childTrNode); |
456 | } |