aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/GLBrushStroke.js
diff options
context:
space:
mode:
authorJonathan Duran2012-03-06 11:38:39 -0800
committerJonathan Duran2012-03-06 11:38:39 -0800
commit342fb451bd251358068a0dcb10e9dc218b79a176 (patch)
treeaa0195d581c3934fb6dc09981506b3c070002806 /js/helper-classes/RDGE/GLBrushStroke.js
parent2815adfd7c19b3dff89dc3e1bda9af8d30dca8d6 (diff)
downloadninja-342fb451bd251358068a0dcb10e9dc218b79a176.tar.gz
Squashed commit of the following:
commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito <valerio@motorola.com> Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito <valerio@motorola.com> commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran <jduran@motorola.com> commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman <ericg@motorola.com> Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran <jduran@motorola.com> commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/helper-classes/RDGE/GLBrushStroke.js')
-rwxr-xr-xjs/helper-classes/RDGE/GLBrushStroke.js397
1 files changed, 0 insertions, 397 deletions
diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js
deleted file mode 100755
index 5d773c2d..00000000
--- a/js/helper-classes/RDGE/GLBrushStroke.js
+++ /dev/null
@@ -1,397 +0,0 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7// Todo: This entire class should be converted to a module
8var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
9
10///////////////////////////////////////////////////////////////////////
11// Class GLBrushStroke
12// representation a sequence points (polyline) created by brush tool.
13// Derived from class GLGeomObj
14///////////////////////////////////////////////////////////////////////
15function GLBrushStroke() {
16 ///////////////////////////////////////////////////
17 // Instance variables
18 ///////////////////////////////////////////////////
19 this._Points = [];
20 this._BBoxMin = [0, 0, 0];
21 this._BBoxMax = [0, 0, 0];
22 this._dirty = true;
23
24 //whether or not to use the canvas drawing to stroke/fill
25 this._useCanvasDrawing = true;
26
27 //the X and Y location of this subpath's canvas in stage world space of Ninja
28 this._canvasX = 0;
29 this._canvasY = 0;
30
31 //stroke information
32 this._strokeWidth = 0.0;
33 this._strokeColor = [0.4, 0.4, 0.4, 1.0];
34 this._strokeMaterial;
35 this._strokeStyle = "Solid";
36
37 //the wetness of the brush (currently this is multiplied to the square of the stroke width, but todo should be changed to not depend on stroke width entirely
38 //smaller value means more samples for the path
39 this._WETNESS_FACTOR = 0.25;
40
41 //prevent extremely long paths that can take a long time to render
42 this._MAX_ALLOWED_SAMPLES = 500;
43
44 //drawing context
45 this._world = null;
46
47 //tool that owns this brushstroke
48 this._drawingTool = null;
49 this._planeMat = null;
50 this._planeMatInv = null;
51 this._planeCenter = null;
52
53 // initialize the inherited members
54 this.inheritedFrom = GLGeomObj;
55 this.inheritedFrom();
56
57 /////////////////////////////////////////////////////////
58 // Property Accessors/Setters
59 /////////////////////////////////////////////////////////
60 this.setWorld = function (world) { this._world = world; }
61 this.getWorld = function () { return this._world; }
62 this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; }
63 this.setDrawingTool = function (tool) {this._drawingTool = tool;}
64 this.getDrawingTool = function () {return this._drawingTool;}
65 this.setPlaneMatrix = function(planeMat){this._planeMat = planeMat;}
66 this.setPlaneMatrixInverse = function(planeMatInv){this._planeMatInv = planeMatInv;}
67 this.setPlaneCenter = function(pc){this._planeCenter = pc;}
68
69 this.getCanvasX = function(){return this._canvasX;}
70 this.getCanvasY = function(){return this._canvasY;}
71 this.setCanvasX = function(cx){this._canvasX=cx;}
72 this.setCanvasY = function(cy){this._canvasY=cy;}
73
74
75 this.getNumPoints = function () { return this._Points.length; }
76 this.getPoint = function (index) { return this._Points[index]; }
77 this.addPoint = function (pt)
78 {
79 //add the point only if it is some epsilon away from the previous point
80 var numPoints = this._Points.length;
81 if (numPoints>0) {
82 var threshold = this._WETNESS_FACTOR*this._strokeWidth;
83 var prevPt = this._Points[numPoints-1];
84 var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]];
85 var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]);
86 if (diffPtMag>threshold){
87 this._Points.push(pt);
88 this._dirty=true;
89 }
90 }else{
91 this._Points.push(pt);
92 this._dirty=true;
93 }
94 }
95
96 this.insertPoint = function(pt, index){ this._Points.splice(index, 0, pt); this._dirty=true;}
97 this.isDirty = function(){return this._dirty;}
98 this.makeDirty = function(){this._dirty=true;}
99
100 this.getBBoxMin = function () { return this._BBoxMin; }
101 this.getBBoxMax = function () { return this._BBoxMax; }
102
103 this.getStrokeWidth = function () { return this._strokeWidth; }
104 this.setStrokeWidth = function (w) { this._strokeWidth = w; this._dirty=true;}
105 this.getStrokeMaterial = function () { return this._strokeMaterial; }
106 this.setStrokeMaterial = function (m) { this._strokeMaterial = m; }
107 this.getStrokeColor = function () { return this._strokeColor; }
108 this.setStrokeColor = function (c) { this._strokeColor = c; }
109 this.getStrokeStyle = function () { return this._strokeStyle; }
110 this.setStrokeStyle = function (s) { this._strokeStyle = s; }
111
112 this.setWidth = function () { }//NO-OP for now
113 this.setHeight = function () {}//NO-OP for now
114
115
116 //remove and return anchor at specified index, return null on error
117 this.removePoint = function (index) {
118 var retAnchor = null;
119 if (index < this._Points.length) {
120 retPt = this._Points.splice(index, 1);
121 this._dirty=true;
122 }
123 return retPoint;
124 }
125
126 //remove all the points
127 this.clear = function () { this._Points = []; this._dirty=true;}
128
129 this.translate = function (tx, ty, tz) {
130 for (var i=0;i<this._Points.length;i++){
131 this._Points[i][0]+=tx;
132 this._Points[i][1]+=ty;
133 this._Points[i][2]+=tz;
134 }
135 }
136
137 this.computeMetaGeometry = function(){
138 if (this._dirty){
139 var numPoints = this._Points.length;
140
141 //**** add samples to the path if needed...linear interpolation for now
142 if (numPoints>1) {
143 var threshold = this._WETNESS_FACTOR*this._strokeWidth;
144 var prevPt = this._Points[0];
145 var prevIndex = 0;
146 for (var i=1;i<numPoints;i++){
147 var pt = this._Points[i];
148 var diff = [pt[0]-prevPt[0], pt[1]-prevPt[1]];
149 var distance = Math.sqrt(diff[0]*diff[0]+diff[1]*diff[1]);
150 if (distance>threshold){
151 //insert points along the prev. to current point
152 var numNewPoints = Math.floor(distance/threshold);
153 for (var j=0;j<numNewPoints;j++){
154 var param = (j+1)/(numNewPoints+1);
155 var newpt = [prevPt[0]+ diff[0]*param, prevPt[1]+ diff[1]*param];
156 //insert new point before point i
157 this._Points.splice(i, 0, [newpt[0], newpt[1], 0]);
158 i++;
159 }
160 this._dirty=true;
161 }
162 prevPt=pt;
163 //update numPoints to match the new length
164 numPoints = this._Points.length;
165
166 //end this function if the numPoints has gone above the max. size specified
167 if (numPoints> this._MAX_ALLOWED_SAMPLES){
168 console.log("leaving the resampling because numPoints is greater than limit:"+this._MAX_ALLOWED_SAMPLES);
169 break;
170 }
171 }
172 }
173
174 // *** compute the bounding box *********
175 this._BBoxMin = [Infinity, Infinity, Infinity];
176 this._BBoxMax = [-Infinity, -Infinity, -Infinity];
177 numPoints = this._Points.length;
178 if (numPoints === 0) {
179 this._BBoxMin = [0, 0, 0];
180 this._BBoxMax = [0, 0, 0];
181 } else {
182 for (var i=0;i<numPoints;i++){
183 var pt = this._Points[i];
184 for (var d = 0; d < 3; d++) {
185 if (this._BBoxMin[d] > pt[d]) {
186 this._BBoxMin[d] = pt[d];
187 }
188 if (this._BBoxMax[d] < pt[d]) {
189 this._BBoxMax[d] = pt[d];
190 }
191 }//for every dimension d from 0 to 2
192 }
193 }
194 //increase the bbox given the stroke width
195 for (var d = 0; d < 3; d++) {
196 this._BBoxMin[d]-= this._strokeWidth/2;
197 this._BBoxMax[d]+= this._strokeWidth/2;
198 }//for every dimension d from 0 to 2
199 }
200 this._dirty = false;