aboutsummaryrefslogtreecommitdiff
path: root/js/tools
diff options
context:
space:
mode:
authorJohn Mayhew2012-04-02 16:28:39 -0700
committerJohn Mayhew2012-04-02 16:28:39 -0700
commitb4155fb4c33675a8a7cd37473513718043fdf0ba (patch)
tree3d8c802473f2395d53d599ec9d8b70b60a4db50c /js/tools
parent5ba9aeac94c86049423fd5d4b37b277263939c13 (diff)
parentc6de22bf42be90b403491b5f87b1818d9020310c (diff)
downloadninja-b4155fb4c33675a8a7cd37473513718043fdf0ba.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts: js/helper-classes/RDGE/rdge-compiled.js js/helper-classes/RDGE/runtime/GLRuntime.js js/helper-classes/RDGE/src/core/script/MeshManager.js js/helper-classes/RDGE/src/core/script/engine.js js/helper-classes/RDGE/src/core/script/fx/ssao.js js/helper-classes/RDGE/src/core/script/init_state.js js/helper-classes/RDGE/src/core/script/run_state.js js/helper-classes/RDGE/src/core/script/scenegraphNodes.js js/helper-classes/RDGE/src/core/script/utilities.js js/helper-classes/RDGE/src/tools/compile-rdge-core.bat js/helper-classes/RDGE/src/tools/compile-rdge-core.sh js/helper-classes/RDGE/src/tools/rdge-compiled.js js/lib/drawing/world.js js/lib/rdge/materials/bump-metal-material.js js/lib/rdge/materials/deform-material.js js/lib/rdge/materials/flat-material.js js/lib/rdge/materials/fly-material.js js/lib/rdge/materials/julia-material.js js/lib/rdge/materials/keleidoscope-material.js js/lib/rdge/materials/linear-gradient-material.js js/lib/rdge/materials/mandel-material.js js/lib/rdge/materials/plasma-material.js js/lib/rdge/materials/pulse-material.js js/lib/rdge/materials/radial-blur-material.js js/lib/rdge/materials/radial-gradient-material.js js/lib/rdge/materials/relief-tunnel-material.js js/lib/rdge/materials/square-tunnel-material.js js/lib/rdge/materials/star-material.js js/lib/rdge/materials/taper-material.js js/lib/rdge/materials/tunnel-material.js js/lib/rdge/materials/twist-material.js js/lib/rdge/materials/twist-vert-material.js js/lib/rdge/materials/uber-material.js js/lib/rdge/materials/water-material.js js/lib/rdge/materials/z-invert-material.js js/preloader/Preloader.js
Diffstat (limited to 'js/tools')
-rw-r--r--js/tools/BrushTool.js207
-rwxr-xr-xjs/tools/EyedropperTool.js151
-rwxr-xr-xjs/tools/PenTool.js39
-rwxr-xr-xjs/tools/SelectionTool.js33
-rwxr-xr-xjs/tools/TextTool.js5
-rwxr-xr-xjs/tools/Translate3DToolBase.js112
-rwxr-xr-xjs/tools/TranslateObject3DTool.js42
-rwxr-xr-xjs/tools/drawing-tool.js2
-rwxr-xr-xjs/tools/modifier-tool-base.js37
9 files changed, 486 insertions, 142 deletions
diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js
index 752aa2a3..f7f0e4bf 100644
--- a/js/tools/BrushTool.js
+++ b/js/tools/BrushTool.js
@@ -5,6 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var ShapeTool = require("js/tools/ShapeTool").ShapeTool; 7var ShapeTool = require("js/tools/ShapeTool").ShapeTool;
8var ShapesController = require("js/controllers/elements/shapes-controller").ShapesController;
8var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; 9var DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase;
9var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; 10var defaultEventManager = require("montage/core/event/event-manager").defaultEventManager;
10var Montage = require("montage/core/core").Montage; 11var Montage = require("montage/core/core").Montage;
@@ -15,6 +16,9 @@ var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager;
15 16
16var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; 17var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke;
17 18
19//whether or not we want the mouse move to be handled all the time (not just while drawing) inside the brush tool
20var g_DoBrushToolMouseMove = true;
21
18exports.BrushTool = Montage.create(ShapeTool, { 22exports.BrushTool = Montage.create(ShapeTool, {
19 hasReel: { value: false }, 23 hasReel: { value: false },
20 _toolID: { value: "brushTool" }, 24 _toolID: { value: "brushTool" },
@@ -35,6 +39,7 @@ exports.BrushTool = Montage.create(ShapeTool, {
35 //view options 39 //view options
36 _brushStrokeCanvas: {value: null, writable: true}, 40 _brushStrokeCanvas: {value: null, writable: true},
37 _brushStrokePlaneMat: {value: null, writable: true}, 41 _brushStrokePlaneMat: {value: null, writable: true},
42 _draggingPlane: {value: null, writable: true},
38 43
39 //the current brush stroke 44 //the current brush stroke
40 _selectedBrushStroke: {value: null, writable: true}, 45 _selectedBrushStroke: {value: null, writable: true},
@@ -60,23 +65,61 @@ exports.BrushTool = Montage.create(ShapeTool, {
60 } 65 }
61 66
62 this.startDraw(event); 67 this.startDraw(event);
63 if (this._brushStrokePlaneMat === null) { 68 this._brushStrokePlaneMat = this.mouseDownHitRec.getPlaneMatrix();
64 this._brushStrokePlaneMat = this.mouseDownHitRec.getPlaneMatrix(); 69
65 }
66 //start a new brush stroke 70 //start a new brush stroke
67 if (this._selectedBrushStroke === null){ 71 if (this._selectedBrushStroke === null){
68 this._selectedBrushStroke = new BrushStroke(); 72 this._selectedBrushStroke = new BrushStroke();
69 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ 73 if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){
70 this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); 74 this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor);
71 } 75 }
76 if (this.application.ninja.colorController.colorToolbar.fill.webGlColor){
77 this._selectedBrushStroke.setSecondStrokeColor(this.application.ninja.colorController.colorToolbar.fill.webGlColor);
78 }
79
72 //add this point to the brush stroke in case the user does a mouse up before doing a mouse move 80 //add this point to the brush stroke in case the user does a mouse up before doing a mouse move
73 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); 81 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY);
74 this._selectedBrushStroke.addPoint(currMousePos); 82 this._selectedBrushStroke.addPoint(currMousePos);
75 83
76 //TODO get these values from the options 84 var strokeSize = 1;
77 this._selectedBrushStroke.setStrokeWidth(20); 85 if (this.options.strokeSize) {
86 strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units);
87 }
88 this._selectedBrushStroke.setStrokeWidth(strokeSize);
89
90 var strokeHardness = 100;
91 if (this.options.strokeHardness){
92 strokeHardness = this.options.strokeHardness.value;
93 }
94 this._selectedBrushStroke.setStrokeHardness(strokeHardness);
95
96 var doSmoothing = false;
97 if (this.options.doSmoothing){
98 doSmoothing = this.options.doSmoothing;
99 }
100 this._selectedBrushStroke.setDoSmoothing(doSmoothing);
101 if (doSmoothing){
102 this._selectedBrushStroke.setSmoothingAmount(this.options.smoothingAmount.value);
103 }
104
105 var useCalligraphic = false;
106 if (this.options.useCalligraphic){
107 useCalligraphic = this.options.useCalligraphic;
108 }
109 if (useCalligraphic) {
110 this._selectedBrushStroke.setStrokeUseCalligraphic(true);
111 var strokeAngle = 0;
112 if (this.options.strokeAngle){
113 strokeAngle= this.options.strokeAngle.value;
114 }
115 this._selectedBrushStroke.setStrokeAngle(Math.PI * strokeAngle/180);
116 } else {
117 this._selectedBrushStroke.setStrokeUseCalligraphic(false);
118 }
119
78 } 120 }
79 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove(); 121 if (!g_DoBrushToolMouseMove)
122 NJevent("enableStageMove");//stageManagerModule.stageManager.enableMouseMove();
80 } //value: function (event) { 123 } //value: function (event) {
81 }, //HandleLeftButtonDown 124 }, //HandleLeftButtonDown
82 125
@@ -91,7 +134,9 @@ exports.BrushTool = Montage.create(ShapeTool, {
91 snapManager.enableSnapAlign(false); 134 snapManager.enableSnapAlign(false);
92 135
93 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y)); 136 var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(x,y));
137 //todo fix this function to allow us to get the correct location (in 3D) for the mouse position
94 var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false)); 138 var unsnappedpos = DrawingToolBase.getHitRecPos(snapManager.snap(point.x, point.y, false));
139 this._draggingPlane = snapManager.getDragPlane();
95 140
96 snapManager.enableElementSnap(elemSnap); 141 snapManager.enableElementSnap(elemSnap);
97 snapManager.enableGridSnap(gridSnap); 142 snapManager.enableGridSnap(gridSnap);
@@ -112,13 +157,15 @@ exports.BrushTool = Montage.create(ShapeTool, {
112 return; 157 return;
113 } 158 }
114 159
160 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY);
115 if (this._isDrawing) { 161 if (this._isDrawing) {
116 var currMousePos = this._getUnsnappedPosition(event.pageX, event.pageY); 162 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<1000){
117 if (this._selectedBrushStroke && this._selectedBrushStroke.getNumPoints()<100){
118 this._selectedBrushStroke.addPoint(currMousePos); 163 this._selectedBrushStroke.addPoint(currMousePos);
119 } 164 }
120 this.ShowCurrentBrushStrokeOnStage(); 165 this.ShowCurrentBrushStrokeOnStage();
121 } //if (this._isDrawing) { 166 } else {
167 this.ShowCurrentBrushIconOnStage(currMousePos);
168 }
122 169
123 //this.drawLastSnap(); //TODO.. is this line necessary if we're not snapping? // Required cleanup for both Draw/Feedbacks 170 //this.drawLastSnap(); //TODO.. is this line necessary if we're not snapping? // Required cleanup for both Draw/Feedbacks
124 171
@@ -129,27 +176,69 @@ exports.BrushTool = Montage.create(ShapeTool, {
129 176
130 HandleLeftButtonUp: { 177 HandleLeftButtonUp: {
131 value: function (event) { 178 value: function (event) {
132 /*var drawData = this.getDrawingData();
133 if (drawData) {
134 if (this._brushStrokePlaneMat === null) {
135 this._brushStrokePlaneMat = drawData.planeMat;
136 }
137 }
138 if (this._isDrawing) {
139 this.doDraw(event);
140 }*/
141 this.endDraw(event); 179 this.endDraw(event);
142 180
143 this._isDrawing = false; 181 this._isDrawing = false;
144 this._hasDraw = false; 182 this._hasDraw = false;
145 183
146 184 //finish giving enough info. to the brush stroke
185 this._selectedBrushStroke.setPlaneMatrix(this._brushStrokePlaneMat);
186 this._selectedBrushStroke.setPlaneMatrixInverse(glmat4.inverse(this._brushStrokePlaneMat,[]));
187 this._selectedBrushStroke.setDragPlane(this._draggingPlane);
188
147 //display the previously drawn stroke in a separate canvas 189 //display the previously drawn stroke in a separate canvas
148 this.RenderCurrentBrushStroke(); 190 this.RenderCurrentBrushStroke();
149 191
150 this._selectedBrushStroke = null; 192 this._selectedBrushStroke = null;
151 this._brushStrokeCanvas = null; 193 this._brushStrokeCanvas = null;
152 NJevent("disableStageMove"); 194 if (!g_DoBrushToolMouseMove)
195 NJevent("disableStageMove");
196 }
197 },
198
199 ShowCurrentBrushIconOnStage:{
200 value: function(currMousePos) {
201 //clear the canvas before we draw anything else
202 this.application.ninja.stage.clearDrawingCanvas();
203 //display the brush icon of proper size (query the options bar)
204 var strokeSize = 1;
205 if (this.options.strokeSize) {
206 strokeSize = ShapesController.GetValueInPixels(this.options.strokeSize.value, this.options.strokeSize.units);
207 }
208 var useCalligraphic = false;
209 if (this.options.useCalligraphic){
210 useCalligraphic = this.options.useCalligraphic;
211 }
212 var ctx = this.application.ninja.stage.drawingContext;//stageManagerModule.stageManager.drawingContext;
213 if (ctx === null)
214 throw ("null drawing context in Brushtool::ShowCurrentBrushStrokeOnStage");
215 ctx.save();
216
217 var horizontalOffset = this.application.ninja.stage.userContentLeft;
218 var verticalOffset = this.application.ninja.stage.userContentTop;
219 var halfStrokeWidth = 0.5*strokeSize;
220 ctx.beginPath();
221 if (!useCalligraphic) {
2