aboutsummaryrefslogtreecommitdiff
path: root/js/tools/Rotate3DToolBase.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-04-18 13:42:18 -0700
committerNivesh Rajbhandari2012-04-18 13:42:18 -0700
commit7b3ef287f248c07602aefa3ba2cc907e0d16493a (patch)
treefb098120c06002204b1c6edbfea1a0f4aeb45ac0 /js/tools/Rotate3DToolBase.js
parentfb20a74856a8c272d09d106765eb2e44c883f0c3 (diff)
downloadninja-7b3ef287f248c07602aefa3ba2cc907e0d16493a.tar.gz
Fixing some more merge issues.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/tools/Rotate3DToolBase.js')
-rwxr-xr-xjs/tools/Rotate3DToolBase.js31
1 files changed, 19 insertions, 12 deletions
diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js
index 6bd92353..04bdc946 100755
--- a/js/tools/Rotate3DToolBase.js
+++ b/js/tools/Rotate3DToolBase.js
@@ -80,6 +80,11 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
80 pt0 = data.pt0, 80 pt0 = data.pt0,
81 pt1 = data.pt1; 81 pt1 = data.pt1;
82 82
83 var selectedElements = this.application.ninja.selectedElements;
84 if(this.rotateStage) {
85 selectedElements = [this.application.ninja.currentDocument.documentRoot];
86 }
87
83 if(this._handleMode !== null) 88 if(this._handleMode !== null)
84 { 89 {
85 if(this._activateOriginHandle) 90 if(this._activateOriginHandle)
@@ -94,12 +99,13 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
94 var swOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2swMat ); 99 var swOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2swMat );
95 //console.log( "modifyElements, _origin: " + this._origin + ", in stageWorld: " + swOrigin ); 100 //console.log( "modifyElements, _origin: " + this._origin + ", in stageWorld: " + swOrigin );
96 101
97 var len = this._targets.length; 102 var len = selectedElements.length;
98 if(len === 1) 103 if(len === 1)
99 { 104 {
100 var g2lMat = this._targets[0].g2l; 105 var elt = selectedElements[0];
106 var g2lMat = elt.elementModel.getProperty("g2l");
101 var localOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2lMat ); 107 var localOrigin = MathUtils.transformAndDivideHomogeneousPoint( this._origin, g2lMat );
102 var elt = this._targets[0].elt; 108
103 viewUtils.pushViewportObj( elt ); 109 viewUtils.pushViewportObj( elt );
104 var viewOrigin = viewUtils.screenToView( localOrigin[0], localOrigin[1], localOrigin[2] ); 110 var viewOrigin = viewUtils.screenToView( localOrigin[0], localOrigin[1], localOrigin[2] );
105 viewUtils.popViewportObj(); 111 viewUtils.popViewportObj();
@@ -178,7 +184,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
178 184
179 if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1 || this.rotateStage) ) 185 if(this._inLocalMode && (this.application.ninja.selectedElements.length === 1 || this.rotateStage) )
180 { 186 {
181 console.log( "modifyElements: rotateLocally " ); 187// console.log( "modifyElements: rotateLocally " );
182 this._rotateLocally(mat); 188 this._rotateLocally(mat);
183 } 189 }
184 else 190 else
@@ -245,7 +251,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
245 var transformCtr = this._startOriginArray[i].slice(0); 251 var transformCtr = this._startOriginArray[i].slice(0);
246 transformCtr = MathUtils.transformPoint(transformCtr, curMat); 252 transformCtr = MathUtils.transformPoint(transformCtr, curMat);
247 253
248 console.log( "modifyElements: rotateGlobally, ctr: " + transformCtr ); 254// console.log( "modifyElements: rotateGlobally, ctr: " + transformCtr );
249 255
250 tMat[12] = transformCtr[0]; 256 tMat[12] = transformCtr[0];
251 tMat[13] = transformCtr[1]; 257 tMat[13] = transformCtr[1];
@@ -366,15 +372,15 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
366 self = this; 372 self = this;
367 373
368 this.application.ninja.selectedElements.forEach(function(element) { 374 this.application.ninja.selectedElements.forEach(function(element) {
369 var curMat = viewUtils.getMatrixFromElement(elt); 375 var curMat = viewUtils.getMatrixFromElement(element);
370 var curMatInv = glmat4.inverse(curMat, []); 376 var curMatInv = glmat4.inverse(curMat, []);
371 377
372 viewUtils.pushViewportObj( elt ); 378 viewUtils.pushViewportObj( element );
373 var eltCtr = viewUtils.getCenterOfProjection(); 379 var eltCtr = viewUtils.getCenterOfProjection();
374 viewUtils.popViewportObj(); 380 viewUtils.popViewportObj();
375 381
376 // cache the local to global and global to local matrices 382 // cache the local to global and global to local matrices
377 var l2gMat = viewUtils.getLocalToGlobalMatrix( elt ); 383 var l2gMat = viewUtils.getLocalToGlobalMatrix( element );
378 var g2lMat = glmat4.inverse( l2gMat, [] ); 384 var g2lMat = glmat4.inverse( l2gMat, [] );
379 eltCtr = MathUtils.transformAndDivideHomogeneousPoint( eltCtr, l2gMat ); 385 eltCtr = MathUtils.transformAndDivideHomogeneousPoint( eltCtr, l2gMat );
380 386
@@ -416,11 +422,11 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
416 for (i = 0; i < len; i++) 422 for (i = 0; i < len; i++)
417 { 423 {
418 // get the next element and localToGlobal matrix 424 // get the next element and localToGlobal matrix
419 elt = this.application.ninja.selectedElements[i]; 425 var elt = this.application.ninja.selectedElements[i];
420 var l2g = elt.elementModel.getProperty("l2g"); 426 var l2g = elt.elementModel.getProperty("l2g");
421 427
422 // get the element bounds in 'plane' space 428 // get the element bounds in 'plane' space
423 bounds = viewUtils.getElementViewBounds3D( elt ); 429 var bounds = viewUtils.getElementViewBounds3D( elt );
424 for (j=0; j<4; j++) 430 for (j=0; j<4; j++)
425 { 431 {
426 var localPt = bounds[j]; 432 var localPt = bounds[j];
@@ -440,7 +446,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
440 } 446 }
441 var stageWorldCtr = [ 0.5*(minPt[0] + maxPt[0]), 0.5*(minPt[1] + maxPt[1]), 0.5*(minPt[2] + maxPt[2]) ]; 447 var stageWorldCtr = [ 0.5*(minPt[0] + maxPt[0]), 0.5*(minPt[1] + maxPt[1]), 0.5*(minPt[2] + maxPt[2]) ];
442 var globalCtr = MathUtils.transformAndDivideHomogeneousPoint( stageWorldCtr, viewUtils.getStageWorldToGlobalMatrix() ); 448 var globalCtr = MathUtils.transformAndDivideHomogeneousPoint( stageWorldCtr, viewUtils.getStageWorldToGlobalMatrix() );
443 console.log( "resetting _origin to: " + this._origin ); 449// console.log( "resetting _origin to: " + this._origin );
444 450
445 return globalCtr; 451 return globalCtr;
446 } 452 }
@@ -498,7 +504,8 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, {
498 // Update transform ctr for all elements if transform origin was modified 504 // Update transform ctr for all elements if transform origin was modified
499 if (!this._origin) this._origin = this.calculateMultiSelOrigin(); 505 if (!this._origin) this._origin = this.calculateMultiSelOrigin();
500 var globalCtr = this._origin; 506 var globalCtr = this._origin;
501 for (i=0; i<len; i++) 507 var len = this.application.ninja.selectedElements.length;
508 for (var i=0; i<len; i++)
502 { 509 {
503 // get the next element and localToGlobal matrix 510 // get the next element and localToGlobal matrix
504 elt = this.application.ninja.selectedElements[i]; 511 elt = this.application.ninja.selectedElements[i];