From 878743cbbb75f2fc84855ca27779597b67ab1a95 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Mon, 2 Apr 2012 15:25:00 -0700 Subject: render the pen path with local coordinates, but use stage world coordinates to position the canvas on which the path is rendered AND add data-montage- to the ids in the pen and brush reels AND fix a bug with pen stroke transparency not working --- js/helper-classes/3D/view-utils.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index a72b7906..f60b953a 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -242,7 +242,6 @@ exports.ViewUtils = Montage.create(Component, { var worldPt = MathUtils.transformPoint( viewPt, mat ); var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); this.popViewportObj(); - return stageWorldPt; } }, -- cgit v1.2.3 From f492c816575f990429f4540c9a3eb60c28a89623 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Fri, 6 Apr 2012 10:53:27 -0700 Subject: complete version of the code for rendering selected subpath anchor points and path overlay (code needs cleanup)...still buggy if creating new paths --- js/helper-classes/3D/view-utils.js | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index f60b953a..35f4a568 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -787,6 +787,7 @@ exports.ViewUtils = Montage.create(Component, { } }, + /* getStageWorldToGlobalMatrix: { value: function() { var stage = this.application.ninja.currentDocument.documentRoot; @@ -820,6 +821,26 @@ exports.ViewUtils = Montage.create(Component, { return mat; } }, + */ + getStageWorldToGlobalMatrix: + { + value: function() + { + var stage = this.application.ninja.currentDocument.documentRoot; + + this.pushViewportObj( stage ); + // 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]); + this.popViewportObj(); + + // append the localToGlobal matrix of the stage. + var mat = this.getLocalToGlobalMatrix( stage ); + glmat4.multiply( mat, v2s ); + return mat; + } + }, localScreenToLocalWorld: { value: function( objPt, elt ) { @@ -967,6 +988,56 @@ exports.ViewUtils = Montage.create(Component, { } }, + getLocalToStageWorldMatrix: { + value: function( elt, shouldProject, shouldLocalTransform ) { + var mat = Matrix.I(4); + while (elt) + { + this.pushViewportObj( elt ); + var cop = this.getCenterOfProjection(); + var s2v = Matrix.Translation([-cop[0], -cop[1], 0]); + var objMat = this.getMatrixFromElement( elt ); + var projMat; + if(shouldProject) + { + //projMat = Matrix.I(4).multiply( this.getPerspectiveDistFromElement(elt) ); + var pDist = this.getPerspectiveDistFromElement(elt); + var projMat = glmat4.scale(Matrix.I(4), [pDist,pDist,pDist], []); + projMat[11] = -1; + projMat[15] = 1400; + } + var v2s = Matrix.Translation([cop[0], cop[1], 0]); + this.popViewportObj(); + + // multiply all the matrices together + //mat = s2v.multiply( mat ); + glmat4.multiply( s2v, mat, mat ); + if (elt === this._stageElement) break; + //mat = objMat.multiply( mat ); + if (shouldLocalTransform) { + glmat4.multiply( objMat, mat, mat ); + } + if(shouldProject) + { + //mat = projMat.multiply( mat ); + glmat4.multiply( projMat, mat, mat ); + } + //mat = v2s.multiply( mat ); + glmat4.multiply( v2s, mat, mat ); + + // offset to the parent + var offset = this.getElementOffset( elt ); + var offMat = Matrix.Translation([offset[0], offset[1], 0]); + //mat = offMat.multiply( mat ); + glmat4.multiply( offMat, mat, mat ); + + elt = elt.parentElement; + } + + return mat; + } + }, + getUpVectorFromMatrix: { value: function( mat ) { //var inv = mat.inverse(); -- cgit v1.2.3 From dae3041e6b8269da3d593a44c09e2288bb434a02 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Mon, 9 Apr 2012 15:55:10 -0700 Subject: snapping feedback for pen tool, correct for subpaths that may lie on rotated canvas, and with a rotated view --- js/helper-classes/3D/vec-utils.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'js/helper-classes/3D') diff --git a/js/helper-classes/3D/vec-utils.js b/js/helper-classes/3D/vec-utils.js index 4eacd856..0916c840 100755 --- a/js/helper-classes/3D/vec-utils.js +++ b/js/helper-classes/3D/vec-utils.js @@ -113,6 +113,25 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype, } }, + vecDistSq : { + value: function( dimen, a, b ) { + var sum; + + if ((a.length < dimen) || (b.length < dimen)) + { + throw new Error( "dimension error in VecUtils.vecDistSq" ); + } + + var sum = 0.0; + for (var i=0; i