From 8423cceac4f45f3d08d92ae969d17d488674717f Mon Sep 17 00:00:00 2001
From: hwc487
Date: Mon, 2 Apr 2012 16:28:09 -0700
Subject: Translate 3D fix for multi-selection Z translation
---
js/tools/Translate3DToolBase.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 18e2b610..bd2b3af1 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -147,8 +147,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
_translateGlobally: {
value: function (transMat) {
- //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
//console.log( "_translateGlobally, transMat: " + transMat );
+ //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
var len = this._targets.length,
i = 0,
item,
@@ -160,6 +160,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
if (this._mode === 1)
{
+ if (len > 1) curMat = this._targets[0].mat.slice();
var curInv = glmat4.inverse( curMat, [] );
transMat = glmat4.multiply( nMat, curInv, [] );
}
--
cgit v1.2.3
From b6fa38e2680ccce73f4a195f9adffa552f1d237c Mon Sep 17 00:00:00 2001
From: hwc487
Date: Wed, 4 Apr 2012 12:37:43 -0700
Subject: turned off translation handles during a multi-object drag.
---
js/tools/Translate3DToolBase.js | 175 ++++++++++++++++++++--------------------
js/tools/modifier-tool-base.js | 13 ++-
2 files changed, 100 insertions(+), 88 deletions(-)
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index bd2b3af1..32132c9a 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -73,13 +73,13 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
var transMat = Matrix.Translation( delta );
- //console.log( "Translate: " + delta );
if(this._inLocalMode && (this._targets.length === 1) )
{
this._translateLocally(transMat);
}
else
{
+ console.log( "modifyElements delta: " + delta );
this._translateGlobally(transMat);
}
}
@@ -147,23 +147,23 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
_translateGlobally: {
value: function (transMat) {
- //console.log( "_translateGlobally, transMat: " + transMat );
- //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
+ //console.log( "_translateGlobally, transMat: " + transMat );
+ //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
var len = this._targets.length,
i = 0,
item,
elt,
curMat = viewUtils.getMatrixFromElement( this._target ),
- matInv = glmat4.inverse(this._startMat, []),
- nMat = glmat4.multiply(transMat, this._startMat, [] ),
- qMat = glmat4.multiply(matInv, nMat, []);
-
- if (this._mode === 1)
- {
- if (len > 1) curMat = this._targets[0].mat.slice();
- var curInv = glmat4.inverse( curMat, [] );
- transMat = glmat4.multiply( nMat, curInv, [] );
- }
+ matInv = glmat4.inverse(this._startMat, []),
+ nMat = glmat4.multiply(transMat, this._startMat, [] ),
+ qMat = glmat4.multiply(matInv, nMat, []);
+
+ if (this._mode === 1)
+ {
+ if (len > 1) curMat = this._targets[0].mat.slice();
+ var curInv = glmat4.inverse( curMat, [] );
+ transMat = glmat4.multiply( nMat, curInv, [] );
+ }
var shouldUpdateStartMat = true;
@@ -185,27 +185,27 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
// glmat4.multiply(curMat, qMat, curMat);
//
// viewUtils.setMatrixForElement( elt, curMat, true);
- curMat[12] += transMat[12];
- curMat[13] += transMat[13];
- curMat[14] += transMat[14];
- viewUtils.setMatrixForElement( elt, curMat, true);
+ curMat[12] += transMat[12];
+ curMat[13] += transMat[13];
+ curMat[14] += transMat[14];
+ viewUtils.setMatrixForElement( elt, curMat, true);
if(shouldUpdateStartMat)
{
- //console.log( "\t\tshouldUpdateStartMat" );
+ //console.log( "\t\tshouldUpdateStartMat" );
this._targets[i].mat = curMat;
}
}
}
},
- _updateTargets: {
+ _updateTargets: {
value: function(addToUndoStack)
- {
- console.log( "_updateTargets" );
- var newStyles = [],
- previousStyles = [],
- len = this.application.ninja.selectedElements.length;
+ {
+ //console.log( "_updateTargets" );
+ var newStyles = [],
+ previousStyles = [],
+ len = this.application.ninja.selectedElements.length;
this._targets = [];
for(var i = 0; i < len; i++)
{
@@ -215,47 +215,47 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
var curMatInv = glmat4.inverse(curMat, []);
this._targets.push({elt:elt, mat:curMat, matInv:curMatInv});
- if(addToUndoStack)
- {
- var previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(this._undoArray[i].mat.slice(0), 5)};
+ if(addToUndoStack)
+ {
+ var previousStyleStr = {dist:this._undoArray[i].dist, mat:MathUtils.scientificToDecimal(this._undoArray[i].mat.slice(0), 5)};
- var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)};
+ var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), mat:MathUtils.scientificToDecimal(curMat, 5)};
- previousStyles.push(previousStyleStr);
- newStyles.push(newStyleStr);
- }
+ previousStyles.push(previousStyleStr);
+ newStyles.push(newStyleStr);
+ }
}
if(addToUndoStack)
{
- ElementsMediator.set3DProperties(this.application.ninja.selectedElements,
- newStyles,
- "Change",
- "translateTool",
- previousStyles
- );
- if(this._origin && this._delta)
- {
- if(this._handleMode !== null)
- {
- this._origin[this._handleMode] += this._delta;
- }
- else
- {
- this._origin[0] += this._delta[0];
- this._origin[1] += this._delta[1];
- }
- }
- this._delta = null;
- }
- // Save previous value for undo/redo
- this._undoArray = [];
- for(i = 0, len = this._targets.length; i < len; i++)
- {
- var elt = this._targets[i].elt;
- var _mat = viewUtils.getMatrixFromElement(elt);
- var _dist = viewUtils.getPerspectiveDistFromElement(elt);
- this._undoArray.push({mat:_mat, dist:_dist});
- }
+ ElementsMediator.set3DProperties(this.application.ninja.selectedElements,
+ newStyles,
+ "Change",
+ "translateTool",
+ previousStyles
+ );
+ if(this._origin && this._delta)
+ {
+ if(this._handleMode !== null)
+ {
+ this._origin[this._handleMode] += this._delta;
+ }
+ else
+ {
+ this._origin[0] += this._delta[0];
+ this._origin[1] += this._delta[1];
+ }
+ }
+ this._delta = null;
+ }
+ // Save previous value for undo/redo
+ this._undoArray = [];
+ for(i = 0, len = this._targets.length; i < len; i++)
+ {
+ var elt = this._targets[i].elt;
+ var _mat = viewUtils.getMatrixFromElement(elt);
+ var _dist = viewUtils.getPerspectiveDistFromElement(elt);
+ this._undoArray.push({mat:_mat, dist:_dist});
+ }
}
},
@@ -305,27 +305,27 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
}
else
{
- if(this._origin)
- {
- if(this._delta)
- {
- if(this._handleMode !== null)
- {
+ if(this._origin)
+ {
+ if(this._delta)
+ {
+ if(this._handleMode !== null)
+ {
// this._origin[this._handleMode] = this._delta;
- }
- else
- {
- this._origin[0] += this._delta[0];
- this._origin[1] += this._delta[1];
- }
- }
- }
- else
- {
- this._origin = drawUtils._selectionCtr.slice(0);
- this._origin[0] += this.application.ninja.stage.userContentLeft;
- this._origin[1] += this.application.ninja.stage.userContentTop;
- }
+ }
+ else
+ {
+ this._origin[0] += this._delta[0];
+ this._origin[1] += this._delta[1];
+ }
+ }
+ }
+ else
+ {
+ this._origin = drawUtils._selectionCtr.slice(0);
+ this._origin[0] += this.application.ninja.stage.userContentLeft;
+ this._origin[1] += this.application.ninja.stage.userContentTop;
+ }
}
}
}
@@ -364,10 +364,13 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
}
// Draw tool handles
-
- this._updateHandlesOrigin();
+
+ this._updateHandlesOrigin();
var base = this._origin.slice(0);
+// if (this.isDrawing)
+// console.log( "handle origin: " + base );
+
var len = this.application.ninja.selectedElements.length;
var lMode = this._inLocalMode;
if(len === 1)
@@ -397,10 +400,10 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
this._handles[1]._strokeStyle = 'rgba(0, 255, 0, 0.2)';
break;
}
- if( delta && (len > 1) )
- {
- base[this._handleMode] += ~~delta;
- }
+ if( delta && (len > 1) )
+ {
+ base[this._handleMode] += ~~delta;
+ }
}
this._handles[0].draw(base, item, lMode);
this._handles[1].draw(base, item, lMode);
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 07b28747..e684f58a 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -852,8 +852,10 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
}
}
- this.DrawHandles(this._delta);
- if(this._canSnap)
+ if (!this._isDrawing || (this.application.ninja.selectedElements.length == 1))
+ this.DrawHandles(this._delta);
+
+ if(this._canSnap)
{
snapManager.drawLastHit();
}
@@ -892,6 +894,13 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
this._delta = null;
}
this.endDraw(event);
+
+ this.application.ninja.stage.draw();
+ if (this._targets && (this._targets.length > 1))
+ {
+ this._origin = null;
+ this._updateHandlesOrigin();
+ }
this.DrawHandles();
}
},
--
cgit v1.2.3
From 16f62ca09cc428043e8fef8bdeea11a989e62bc0 Mon Sep 17 00:00:00 2001
From: hwc487
Date: Wed, 4 Apr 2012 16:29:16 -0700
Subject: Cap fix for vecUtils.
---
js/tools/TranslateObject3DTool.js | 3 ++-
js/tools/modifier-tool-base.js | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js
index 7163f005..867bec7f 100755
--- a/js/tools/TranslateObject3DTool.js
+++ b/js/tools/TranslateObject3DTool.js
@@ -7,6 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
var Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase,
drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils,
viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils,
+ vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils,
snapManager = require("js/helper-classes/3D/snap-manager").SnapManager;
exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
@@ -128,7 +129,7 @@ exports.TranslateObject3DTool = Object.create(Translate3DToolBase, {
// only do quadrant snapping if the 4 corners of the element are in the drag plane
- var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0);
+ var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0);
this._shouldUseQuadPt = (sign == 0);
var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane );
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index e684f58a..b6589cba 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -177,7 +177,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
}
// only do quadrant snapping if the 4 corners of the element are in the drag plane
- var sign = MathUtils.fpSign( VecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0);
+ var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0);
this._shouldUseQuadPt = (sign == 0)
var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane );
--
cgit v1.2.3
From 96bfeee2e6b735b87e8482d6e2cf24d5224c6417 Mon Sep 17 00:00:00 2001
From: hwc487
Date: Thu, 5 Apr 2012 17:03:14 -0700
Subject: translate3DObject tool fixes.
---
js/helper-classes/3D/hit-record.js | 46 +++++++++++++++++++++++++++++++++++-
js/helper-classes/3D/snap-manager.js | 1 +
js/helper-classes/3D/view-utils.js | 45 ++++++++++++++++++-----------------
js/tools/Translate3DToolBase.js | 7 +++---
js/tools/modifier-tool-base.js | 2 ++
5 files changed, 75 insertions(+), 26 deletions(-)
diff --git a/js/helper-classes/3D/hit-record.js b/js/helper-classes/3D/hit-record.js
index 2c60adc6..96f87c24 100755
--- a/js/helper-classes/3D/hit-record.js
+++ b/js/helper-classes/3D/hit-record.js
@@ -284,6 +284,50 @@ var HitRecord = exports.HitRecord = Object.create(Object.prototype,
return str;
}
- }
+ },
+
+ test:
+ {
+ value: function()
+ {
+ var elt = this.getElement();
+ var stage = viewUtils.getStage();
+ if (elt === stage) return;
+
+ var localPt = this.calculateElementPreTransformScreenPoint();
+ var stageWorldPt = this.calculateStageWorldPoint();
+ var globalPt = this.getScreenPoint();
+ var err = false;
+
+ var test1 = viewUtils.localToGlobal( localPt, elt );
+ var dist = vecUtils.vecDist(3, test1, globalPt);
+ if (MathUtils.fpSign(dist) != 0)
+ {
+ err = true;
+ console.log( "**** transform error 1 ***** " + dist + ", localPt: " + localPt );
+ }
+
+ var stageWorldToGlobal = viewUtils.getStageWorldToGlobalMatrix();
+ var test2 = MathUtils.transformAndDivideHomogeneousPoint( stageWorldPt, stageWorldToGlobal );
+ dist = vecUtils.vecDist(3, test2, globalPt);
+ if (MathUtils.fpSign(dist) != 0)
+ {
+ err = true;
+ console.log( "**** transform error 2 ***** " + dist + ", localPt: " + localPt );
+ }
+
+ var localToGlobal = viewUtils.getLocalToGlobalMatrix( elt );
+ var globalToLocal = glmat4.inverse( localToGlobal, [] );
+ var test3 = MathUtils.transformAndDivideHomogeneousPoint( globalPt, globalToLocal );
+ dist = vecUtils.vecDist(3, test3, localPt);
+ if (MathUtils.fpSign( vecUtils.vecDist(3, test3, localPt)) != 0)
+ {
+ err = true;
+ console.log( "**** transform error 3 ***** " + dist + ", localPt: " + localPt );
+ }
+
+ if (!err) console.log( "no hitRecord error" );
+ }
+ }
});
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 9f6b9ed1..8eafa7e9 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -300,6 +300,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
this.deactivateDragPlane();
this.setLastHit( rtnHit );
+ //rtnHit.test(); // DEBUG CODE. REMOVE THIS
return rtnHit;
}
},
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index a72b7906..392de0be 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -112,6 +112,13 @@ exports.ViewUtils = Montage.create(Component, {
var mat = this.getMatrixFromElement(elt);
var plane = [mat[8], mat[9], mat[10], mat[11]];
+ var stage = this.application.ninja.currentDocument.documentRoot;
+ if (elt === stage)
+ {
+ xVec = [1,0,0];
+ yVec = [0,1,0];
+ }
+
// The translation value is a point on the plane
this.pushViewportObj( elt );
var ptOnPlane = this.getCenterOfProjection();
@@ -137,6 +144,12 @@ exports.ViewUtils = Montage.create(Component, {
var stageMat = this.getMatrixFromElement(stage);
var stagePlane = [stageMat[8], stageMat[9], stageMat[10], stageMat[11]];
+ if (elt === stage)
+ {
+ xVec = [1,0,0];
+ yVec = [0,1,0];
+ }
+
var xDot = Math.abs(vecUtils.vecDot(3, xVec, stagePlane));
var yDot = Math.abs(vecUtils.vecDot(3, yVec, stagePlane));
@@ -788,35 +801,23 @@ exports.ViewUtils = Montage.create(Component, {
}
},
- getStageWorldToGlobalMatrix: {
- value: function() {
+ getStageWorldToGlobalMatrix:
+ {
+ value: function()
+ {
var stage = this.application.ninja.currentDocument.documentRoot;
this.pushViewportObj( stage );
-
- // get the matrix to the parent
- var mat = Matrix.I(4);
- //var projMat = Matrix.I(4).multiply( this.getPerspectiveDistFromElement(stage) );
- var p = this.getPerspectiveDistFromElement(stage);
- var projMat = glmat4.scale( Matrix.I(4), [p,p,p], [] );
- projMat[11] = -1;
+
+ // put the point into screen space of the stage - requires
+ // a translation to the top/left only
var cop = this.getCenterOfProjection();
var v2s = Matrix.Translation([cop[0], cop[1], 0]);
- //mat = v2s.multiply( projMat );
- mat = glmat4.multiply( v2s, projMat, [] );
-
- // offset to the parent
- var offset = this.getElementOffset( stage );
- var offMat = Matrix.Translation([offset[0], offset[1], 0]);
- //mat = offMat.multiply( mat );
- glmat4.multiply( offMat, mat, mat );
-
this.popViewportObj();
- // var mat2 = this.getLocalToGlobalMatrix( stage.parentElement );
- var mat2 = this.getLocalToGlobalMatrix( this._rootElement );
- //var mat = mat2.multiply( mat );
- glmat4.multiply( mat2, mat, mat );
+ // append the localToGlobal matrix of the stage.
+ var mat = this.getLocalToGlobalMatrix( stage );
+ glmat4.multiply( mat, v2s );
return mat;
}
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js
index 4799b840..2276178c 100755
--- a/js/tools/Translate3DToolBase.js
+++ b/js/tools/Translate3DToolBase.js
@@ -71,6 +71,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
this._delta = delta.slice(0);
}
+ //console.log( "modifyElements delta: " + delta );
var transMat = Matrix.Translation( delta );
if(this._inLocalMode && (this._targets.length === 1) )
@@ -79,7 +80,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
}
else
{
- console.log( "modifyElements delta: " + delta );
this._translateGlobally(transMat);
}
}
@@ -148,7 +148,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
_translateGlobally: {
value: function (transMat) {
//console.log( "_translateGlobally, transMat: " + transMat );
- //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat );
+ //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat[12] + ", " + transMat[13] + ", " + transMat[14] );
var len = this._targets.length,
i = 0,
item,
@@ -167,7 +167,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase,
var shouldUpdateStartMat = true;
- if(this._clickedOnStage)
+ //if (this._clickedOnStage)
+ if(this._clickedOnStage || ((this._handleMode === 2) && (this._targets.length > 1)))
{
shouldUpdateStartMat = false;
}
diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js
index 2c9b484e..f9fd001c 100755
--- a/js/tools/modifier-tool-base.js
+++ b/js/tools/modifier-tool-base.js
@@ -405,6 +405,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
var index = this._snapIndex;
var pt0;
var useViewPoint = (this._inLocalMode && (this._targets.length === 1));
+ //console.log( "useViewPoint: " + useViewPoint );
if (this._useQuadPt)
{
pt0 = this.GetQuadrantPoint(useViewPoint);
@@ -427,6 +428,7 @@ exports.ModifierToolBase = Montage.create(DrawingTool, {
pt1 = MathUtils.transformPoint( pt1, this._startMat );
}
+ //console.log( "getMousePoints, useViewPoint: " + useViewPoint + ", " + pt0 + " => " + pt1 );
return {pt0:pt0, pt1:pt1};
}
else
--
cgit v1.2.3
From 4900f2e6e346df18b1b5a2ac89da5019644ac98a Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Mon, 9 Apr 2012 16:47:35 -0700
Subject: adding a history panel
Signed-off-by: Valerio Virgillito
diff --git a/js/panels/history-panel/history-item.reel/history-item.css b/js/panels/history-panel/history-item.reel/history-item.css new file mode 100644 index 00000000..e69de29b diff --git a/js/panels/history-panel/history-item.reel/history-item.html b/js/panels/history-panel/history-item.reel/history-item.html new file mode 100644 index 00000000..2db27846 --- /dev/null +++ b/js/panels/history-panel/history-item.reel/history-item.html @@ -0,0 +1,29 @@ + + + +
+ + + + + + +
+