From c534f70e9af920d252d0d94151c9d6f884283b81 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 1 May 2012 07:01:44 -0700 Subject: Get working plane grid to draw for new stage web template workflow. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'js/helper-classes/3D/draw-utils.js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 7bd77c3a..f7b02485 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -583,17 +583,24 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // get a point that lies on the plane var ptOnPlane = MathUtils.getPointOnPlane(this._workingPlane); + // define the grid parameters + var width, + height, + nLines = 10; + + if(this.application.ninja.documentController.webTemplate) { + width = this.application.ninja.currentDocument.documentRoot.scrollWidth; + height = this.application.ninja.currentDocument.documentRoot.scrollHeight; + } else { + width = this.snapManager.getStageWidth(); + height = this.snapManager.getStageHeight(); + } // get a matrix from working plane space to the world var mat = this.getPlaneToWorldMatrix(zAxis, ptOnPlane); - var tMat = Matrix.Translation( [0.5*this.snapManager.getStageWidth(), 0.5*this.snapManager.getStageHeight(),0] ); + var tMat = Matrix.Translation( [0.5*width, 0.5*height, 0] ); //mat = tMat.multiply(mat); glmat4.multiply( tMat, mat, mat); - // define the grid parameters - var width = this.snapManager.getStageWidth(), - height = this.snapManager.getStageHeight(); - var nLines = 10; - // the positioning of the grid may depend on the view direction. var stage = this.snapManager.getStage(); var viewMat = this.viewUtils.getMatrixFromElement(stage); @@ -662,6 +669,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { var offset = this.viewUtils.getElementOffset(this._sourceSpaceElt); offset[2] = 0; this.viewUtils.setViewportObj(this._sourceSpaceElt); + var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); for (var i = 0; i < nLines; i++) { // transform the points from working plane space to world space //var t0 = mat.multiply(p0), @@ -671,8 +679,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // transform from world space to global screen space if (this._sourceSpaceElt) { - t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); - t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); +// t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); +// t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); + t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); + t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); } // create a line from the endpoints -- cgit v1.2.3 From 84eec0ae4352c9f6e5986529cc70eed726d97a88 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 1 May 2012 09:29:49 -0700 Subject: webTemplate var gets reset to false, so must check for new stage template differently. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/helper-classes/3D/draw-utils.js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index f7b02485..81a740e0 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -588,7 +588,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { height, nLines = 10; - if(this.application.ninja.documentController.webTemplate) { +// if(this.application.ninja.documentController.webTemplate) { + if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { width = this.application.ninja.currentDocument.documentRoot.scrollWidth; height = this.application.ninja.currentDocument.documentRoot.scrollHeight; } else { -- cgit v1.2.3 From 0f16c5ea0d08a740f553284c436bb3e589fb1357 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 1 May 2012 16:49:29 -0700 Subject: Draw a red outline around the stage for reference when rotating stage. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'js/helper-classes/3D/draw-utils.js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 81a740e0..88830964 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -651,6 +651,21 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this._lineColor = saveColor; this._drawingContext.lineWidth = saveLineWidth; + if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { + // draw an outline around the body + var stagePt = MathUtils.getPointOnPlane([0,0,1,0]); + var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt); + // glmat4.multiply( tMat, stageMat, stageMat); + pt0 = [0, 0, 0]; + pt1 = [0, height, 0]; + delta = [width, 0, 0]; + this.drawGridLines(pt0, pt1, delta, stageMat, 2); + pt0 = [0, 0, 0]; + pt1 = [width, 0, 0]; + delta = [0, height, 0]; + this.drawGridLines(pt0, pt1, delta, stageMat, 2); + } + // draw the lines this.redrawGridLines(); @@ -752,12 +767,27 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this._drawingContext.lineWidth = 0.25; // draw the lines - var nLines = this._gridLineArray.length; + var line, + nLines = this._gridLineArray.length; + if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { + nLines = this._gridLineArray.length-4; + } + for (var i = 0; i < nLines; i++) { - var line = this._gridLineArray[i]; + line = this._gridLineArray[i]; this.drawIntersectedLine(line, this._drawingContext); } + if(this.application.ninja.currentDocument.documentRoot.id !== "UserContent") { + this._lineColor = "red"; + i = nLines; + nLines += 4; + for (; i < nLines; i++) { + line = this._gridLineArray[i]; + this.drawIntersectedLine(line, this._drawingContext); + } + } + this.popState(); } }, -- cgit v1.2.3