aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/GLPath.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/GLPath.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/GLPath.js')
-rwxr-xr-xjs/helper-classes/RDGE/GLPath.js232
1 files changed, 0 insertions, 232 deletions
diff --git a/js/helper-classes/RDGE/GLPath.js b/js/helper-classes/RDGE/GLPath.js
deleted file mode 100755
index c711888b..00000000
--- a/js/helper-classes/RDGE/GLPath.js
+++ /dev/null
@@ -1,232 +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///////////////////////////////////////////////////////////////////////
8// Class GLPath
9// GL representation of a path.
10// Derived from class GLGeomObj
11// The position and dimensions of the stroke, fill, and inner Radius should be in pixels
12///////////////////////////////////////////////////////////////////////
13function GLPath()
14{
15
16 // initialize the inherited members
17 this.inheritedFrom = GLGeomObj;
18 this.inheritedFrom();
19
20 this.init = function( world, dataArray, typeArray, strokeWidth, strokeColor, strokeMaterial )
21 {
22 ///////////////////////////////////////////////////////////////////////
23 // Instance variables
24 ///////////////////////////////////////////////////////////////////////
25
26
27 // stroke
28 this._strokeWidth = 0.25;
29 this._strokeColor = strokeColor;
30 this._strokeMaterial = strokeMaterial;
31
32 // data
33 this._dataArray = dataArray.slice(0);
34 this._typeArray = typeArray.slice(0);
35
36 this._world = world;
37 }
38
39 ///////////////////////////////////////////////////////////////////////
40 // Property Accessors
41 ///////////////////////////////////////////////////////////////////////
42 this.getStrokeWidth = function() { return this._strokeWidth; }
43 this.setStrokeWidth = function(w) { this._strokeWidth = w; }
44
45 this.getStrokeMaterial = function() { return this._strokeMaterial; }
46 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; }
47
48 this.getWorld = function() { return this._world; }
49 this.setWorld = function(w) { this._world = w; }
50
51 this.geomType = function() { return this.GEOM_TYPE_PATH; }
52
53 ///////////////////////////////////////////////////////////////////////
54 // Methods
55 ///////////////////////////////////////////////////////////////////////
56
57 ///////////////////////////////////////////////////////////////////////
58 // update the "color of the material
59 this.getStrokeColor = function()
60 {
61 return this._strokeColor;
62 }
63
64// this.setStrokeColor = function(c)
65// {
66// this._strokeColor = c;
67// }
68 ///////////////////////////////////////////////////////////////////////
69
70 this.buildBuffers = function()
71 {
72 // currently no GL representation
73 }
74
75 this.render = function()
76 {
77 // get the world
78 var world = this.getWorld();
79 if (!world) throw( "null world in buildBuffers" );
80
81 // get the context
82 var ctx = world.get2DContext();
83 if (!ctx) return;
84
85 // create the matrix
86 var lineWidth = this._strokeWidth;
87
88 // set up the stroke style
89 ctx.beginPath();
90 ctx.lineWidth = lineWidth;
91 ctx.strokeStyle = "#0000ff";
92 if (this._strokeColor)
93 ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor );
94
95 // declarations
96 var pt, p0, p1, p2;
97
98 // draw the stroke
99 var index = 0;
100 var dataIndex = 0;
101 var n = this._typeArray.length;
102 while (index < n)
103 {
104 var type = this._typeArray[index];
105 index++;
106
107 switch (type)
108 {
109 case 0: // moveTo
110 pt = this._dataArray[dataIndex];
111 dataIndex++;
112 ctx.moveTo( pt[0], pt[1] );
113 break;
114
115 case 1: // line
116 pt = this._dataArray[dataIndex];
117 dataIndex++;
118 ctx.lineTo( pt[0], pt[1] );
119 break;
120
121 case 2: // quadratic Bezier
122 p0 = this._dataArray[dataIndex]; dataIndex++;
123 p1 = this._dataArray[dataIndex]; dataIndex++;
124 ctx.quadraticCurveTo( p0[0], p0[1], p1[0], p1[1] );
125 break;
126
127 case 3: // cubic Bezier
128 p0 = this._dataArray[dataIndex]; dataIndex++;
129 p1 = this._dataArray[dataIndex]; dataIndex++;
130 p2 = this._dataArray[dataIndex]; dataIndex++;
131 ctx.bezierCurveTo( p0[0], p0[1], p1[0], p1[1], p2[0], p2[1] );
132 break;
133
134 default:
135 console.log( "unsupported path type: " + type );
136 break;
137 }
138 }
139
140 // render the stroke
141 ctx.stroke();
142 }
143
144 this.export = function()
145 {
146 var rtnStr = "type: " + this.geomType() + "\n";
147
148 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
149
150 rtnStr += "strokeMat: ";
151 if (this._strokeMaterial)
152 rtnStr += this._strokeMaterial.getName();
153 else
154 rtnStr += "flatMaterial";
155 rtnStr += "\n";
156
157 return rtnStr;
158 }
159
160 this.import = function( importStr )
161 {
162 this._strokeWidth = this.getPropertyFromString( "strokeWidth: ", importStr );
163 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
164
165 var strokeMat = MaterialsLibrary.getMaterial( strokeMaterialName );
166 if (!strokeMat)
167 {
168 console.log( "object material not found in library: " + strokeMaterialName );
169 strokeMat = new FlatMaterial();
170 }
171 this._strokeMaterial = strokeMat;
172 }
173
174 this.collidesWithPoint = function( x, y )
175 {
176 return false;
177 }
178
179 this.containsPoint = function( pt, dir )
180 {
181 return false;
182 }
183
184 this.getNearPoint = function( pt, dir )
185 {
186 var world = this.getWorld();
187 if (!world) throw( "null world in getNearPoint" );
188
189 // get a point on the plane of the circle
190 // the point is in NDC, as is the input parameters
191 var mat = this.getMatrix();
192 var plane = [0,0,1,0];
193 plane = MathUtils.transformPlane( plane, mat );
194 var projPt = MathUtils.vecIntersectPlane ( pt, dir, plane );
195
196 // transform the projected point back to the XY plane
197 //var invMat = mat.inverse();
198 var invMat = glmat4.inverse( mat, [] );
199 var planePt = MathUtils.transformPoint( projPt, invMat );
200
201 // get the normalized device coordinates (NDC) for
202 // the position and radii.
203 var vpw = world.getViewportWidth(), vph = world.getViewportHeight();
204 var xNDC = 2*this._xOffset/vpw, yNDC = 2*this._yOffset/vph;
205 var projMat = world.makePerspectiveMatrix();
206 var z = -world.getViewDistance();
207 var planePtNDC = planePt.slice(0);
208 planePtND