diff options
author | Jose Antonio Marquez | 2012-06-22 16:21:20 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-06-22 16:21:20 -0700 |
commit | d94c2ebbcd44e7970102d6dc58a9f316692f9767 (patch) | |
tree | 22985c8362329c2a3b9aeb2be49c1b84817ce7d6 /js/helper-classes/3D/draw-utils.js | |
parent | 8d0c07b6734d874b481bb4866466de8f863a67a7 (diff) | |
parent | f5b8f2cc5f2b7e9cff892d7487ce56019bf66d4c (diff) | |
download | ninja-d94c2ebbcd44e7970102d6dc58a9f316692f9767.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/helper-classes/3D/draw-utils.js')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 8ddd0d52..bd47ffc3 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -630,6 +630,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
630 | value: function () | 630 | value: function () |
631 | { | 631 | { |
632 | this.application.ninja.stage.clearGridCanvas(); | 632 | this.application.ninja.stage.clearGridCanvas(); |
633 | this.drawStageOutline(); | ||
633 | if (!this.isDrawingGrid()) return; | 634 | if (!this.isDrawingGrid()) return; |
634 | 635 | ||
635 | var saveContext = this.getDrawingSurfaceElement(); | 636 | var saveContext = this.getDrawingSurfaceElement(); |
@@ -701,21 +702,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
701 | this._lineColor = saveColor; | 702 | this._lineColor = saveColor; |
702 | this._drawingContext.lineWidth = saveLineWidth; | 703 | this._drawingContext.lineWidth = saveLineWidth; |
703 | 704 | ||
704 | if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { | ||
705 | // draw an outline around the body | ||
706 | var stagePt = MathUtils.getPointOnPlane([0,0,1,0]); | ||
707 | var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt); | ||
708 | // glmat4.multiply( tMat, stageMat, stageMat); | ||
709 | pt0 = [0, 0, 0]; | ||
710 | pt1 = [0, height, 0]; | ||
711 | delta = [width, 0, 0]; | ||
712 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
713 | pt0 = [0, 0, 0]; | ||
714 | pt1 = [width, 0, 0]; | ||
715 | delta = [0, height, 0]; | ||
716 | this.drawGridLines(pt0, pt1, delta, stageMat, 2); | ||
717 | } | ||
718 | |||
719 | // draw the lines | 705 | // draw the lines |
720 | this.redrawGridLines(); | 706 | this.redrawGridLines(); |
721 | 707 | ||
@@ -738,15 +724,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
738 | var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); | 724 | var sourceSpaceMat = this.viewUtils.getLocalToGlobalMatrix( this._sourceSpaceElt ); |
739 | for (var i = 0; i < nLines; i++) { | 725 | for (var i = 0; i < nLines; i++) { |
740 | // transform the points from working plane space to world space | 726 | // transform the points from working plane space to world space |
741 | //var t0 = mat.multiply(p0), | ||
742 | // t1 = mat.multiply(p1); | ||
743 | var t0 = glmat4.multiplyVec3( mat, p0, [] ), | 727 | var t0 = glmat4.multiplyVec3( mat, p0, [] ), |
744 | t1 = glmat4.multiplyVec3( mat, p1, [] ); | 728 | t1 = glmat4.multiplyVec3( mat, p1, [] ); |
745 | 729 | ||
746 | // transform from world space to global screen space | 730 | // transform from world space to global screen space |
747 | if (this._sourceSpaceElt) { | 731 | if (this._sourceSpaceElt) { |
748 | // t0 = this.viewUtils.localToGlobal(t0, this._sourceSpaceElt); | ||
749 | // t1 = this.viewUtils.localToGlobal(t1, this._sourceSpaceElt); | ||
750 | t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); | 732 | t0 = this.viewUtils.localToGlobal2(t0, sourceSpaceMat); |
751 | t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); | 733 | t1 = this.viewUtils.localToGlobal2(t1, sourceSpaceMat); |
752 | } | 734 | } |
@@ -764,9 +746,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
764 | line.setVisibility(vis); | 746 | line.setVisibility(vis); |
765 | 747 | ||
766 | // increment the points to the next position | 748 | // increment the points to the next position |
767 | // p0 = p0.add(d); p0[3] = 1.0; | ||
768 | p0 = vecUtils.vecAdd(4, p0, d); p0[3] = 1.0; | 749 | p0 = vecUtils.vecAdd(4, p0, d); p0[3] = 1.0; |
769 | // p1 = p1.add(d); p1[3] = 1.0; | ||
770 | p1 = vecUtils.vecAdd(4, p1, d); p1[3] = 1.0; | 750 | p1 = vecUtils.vecAdd(4, p1, d); p1[3] = 1.0; |
771 | } | 751 | } |
772 | } | 752 | } |
@@ -819,25 +799,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
819 | // draw the lines | 799 | // draw the lines |
820 | var line, | 800 | var line, |
821 | nLines = this._gridLineArray.length; | 801 | nLines = this._gridLineArray.length; |
822 | if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { | ||
823 | nLines = this._gridLineArray.length-4; | ||
824 | } | ||
825 | 802 | ||
826 | for (var i = 0; i < nLines; i++) { | 803 | for (var i = 0; i < nLines; i++) { |
827 | line = this._gridLineArray[i]; | 804 | line = this._gridLineArray[i]; |
828 | this.drawIntersectedLine(line, this._drawingContext); | 805 | this.drawIntersectedLine(line, this._drawingContext); |
829 | } | 806 | } |
830 | 807 | ||
831 | if(this.application.ninja.currentDocument.model.documentRoot.id !== "UserContent") { | ||
832 | this._lineColor = "red"; | ||
833 | i = nLines; | ||
834 | nLines += 4; | ||
835 | for (; i < nLines; i++) { | ||
836 | line = this._gridLineArray[i]; | ||
837 | this.drawIntersectedLine(line, this._drawingContext); | ||
838 | } | ||
839 | } | ||
840 | |||
841 | this.popState(); | 808 | this.popState(); |
842 | } | 809 | } |
843 | }, | 810 | }, |
@@ -1213,6 +1180,43 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
1213 | } | 1180 | } |
1214 | }, | 1181 | }, |
1215 | 1182 | ||
1183 | drawStageOutline : { | ||
1184 | value: function() { | ||
1185 | var context = this.application.ninja.stage.gridContext; | ||
1186 | var stage = this.application.ninja.stage; | ||
1187 | var stageRoot = this.application.ninja.currentDocument.model.documentRoot; | ||
1188 | var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot); | ||
1189 | |||
1190 | var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1); | ||
1191 | if(!l) return; | ||
1192 | var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); | ||
1193 | if(!r) return; | ||
1194 | |||
1195 | var t = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, 0, 0], [stage.canvas.width, 0, 0], 0.1); | ||
1196 | if(!t) return; | ||
1197 | var b = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[1], [0, stage.canvas.height, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); | ||
1198 | if(!b) return; | ||
1199 | |||
1200 | context.save(); | ||
1201 | context.strokeStyle = "#333"; | ||
1202 | context.lineWidth = 0.5; | ||
1203 | |||
1204 | context.beginPath(); | ||
1205 | |||
1206 | context.moveTo(l[0], l[1]); | ||
1207 | context.lineTo(r[0], r[1]); | ||
1208 | |||
1209 | context.moveTo(t[0], t[1]); | ||
1210 | context.lineTo(b[0], b[1]); | ||
1211 | |||
1212 | context.closePath(); | ||
1213 | context.stroke(); | ||
1214 | |||
1215 | context.fillText("(0, 0)", bounds3D[0][0] + 4, bounds3D[0][1] - 6); | ||
1216 | context.restore(); | ||
1217 | } | ||
1218 | }, | ||
1219 | |||
1216 | draw3DCompass : { | 1220 | draw3DCompass : { |
1217 | value: function() { | 1221 | value: function() { |
1218 | // set the element to be the viewport object - temporarily | 1222 | // set the element to be the viewport object - temporarily |