aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/backup-delete/GLPath.js
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/helper-classes/backup-delete/GLPath.js
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/helper-classes/backup-delete/GLPath.js')
-rwxr-xr-xjs/helper-classes/backup-delete/GLPath.js232
1 files changed, 0 insertions, 232 deletions
diff --git a/js/helper-classes/backup-delete/GLPath.js b/js/helper-classes/backup-delete/GLPath.js
deleted file mode 100755
index c711888b..00000000
--- a/js/helper-classes/backup-delete/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 planePtNDC[2] = z;
209 planePtNDC = MathUtils.transformHomogeneousPoint( planePtNDC, projMat );
210 planePtNDC = MathUtils.applyHomogeneousCoordinate( planePtNDC );