diff options
Diffstat (limited to 'js/helper-classes/RDGE/GLCircle.js')
-rwxr-xr-x | js/helper-classes/RDGE/GLCircle.js | 711 |
1 files changed, 0 insertions, 711 deletions
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js deleted file mode 100755 index 59d0bdaf..00000000 --- a/js/helper-classes/RDGE/GLCircle.js +++ /dev/null | |||
@@ -1,711 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No 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 GLCircle | ||
9 | // GL representation of a circle. | ||
10 | // Derived from class GLGeomObj | ||
11 | // The position and dimensions of the stroke, fill, and inner Radius should be in pixels | ||
12 | /////////////////////////////////////////////////////////////////////// | ||
13 | function GLCircle() | ||
14 | { | ||
15 | |||
16 | // initialize the inherited members | ||
17 | this.inheritedFrom = GLGeomObj; | ||
18 | this.inheritedFrom(); | ||
19 | |||
20 | this.init = function( world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) | ||
21 | { | ||
22 | /////////////////////////////////////////////////////////////////////// | ||
23 | // Instance variables | ||
24 | /////////////////////////////////////////////////////////////////////// | ||
25 | this._width = 2.0; | ||
26 | this._height = 2.0; | ||
27 | this._xOffset = 0; | ||
28 | this._yOffset = 0; | ||
29 | |||
30 | this._radius = 2.0; | ||
31 | this._strokeWidth = 0.25; | ||
32 | this._innerRadius = 0; | ||
33 | |||
34 | this._ovalHeight = this._ovalHeight = 2.0*this.radius; | ||
35 | |||
36 | this._strokeStyle = "Solid"; | ||
37 | |||
38 | this._aspectRatio = 1.0; | ||
39 | |||
40 | |||
41 | if (arguments.length > 0) | ||
42 | { | ||
43 | this._width = width; | ||
44 | this._height = height; | ||
45 | this._xOffset = xOffset; | ||
46 | this._yOffset = yOffset; | ||
47 | |||
48 | this._strokeWidth = strokeSize; | ||
49 | this._innerRadius = innerRadius; | ||
50 | if (strokeColor) this._strokeColor = strokeColor; | ||
51 | if (fillColor) this._fillColor = fillColor; | ||
52 | |||
53 | this._strokeStyle = strokeStyle; | ||
54 | } | ||
55 | |||
56 | this.m_world = world; | ||
57 | |||
58 | |||
59 | if(strokeMaterial) | ||
60 | this._strokeMaterial = strokeMaterial; | ||
61 | else | ||
62 | this._strokeMaterial = new FlatMaterial(); | ||
63 | |||
64 | if(fillMaterial) | ||
65 | this._fillMaterial = fillMaterial; | ||
66 | else | ||
67 | this._fillMaterial = new FlatMaterial(); | ||
68 | } | ||
69 | |||
70 | /////////////////////////////////////////////////////////////////////// | ||
71 | // Property Accessors | ||
72 | /////////////////////////////////////////////////////////////////////// | ||
73 | this.getStrokeWidth = function() { return this._strokeWidth; } | ||
74 | this.setStrokeWidth = function(w) { this._strokeWidth = w; } | ||
75 | |||
76 | this.getStrokeMaterial = function() { return this._strokeMaterial; } | ||
77 | this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } | ||
78 | |||
79 | this.getFillMaterial = function() { return this._fillMaterial; } | ||
80 | this.setFillMaterial = function(m) { this._fillMaterial = m; } | ||
81 | |||
82 | this.getRadius = function() { return this._radius; } | ||
83 | this.setRadius = function(r) { this._radius = r; } | ||
84 | |||
85 | this.getWorld = function() { return this._world; } | ||
86 | this.setWorld = function(w) { this._world = w; } | ||
87 | |||
88 | this.getInnerRadius = function() { return this._innerRadius; } | ||
89 | this.setInnerRadius = function(r) { this._innerRadius = r; } | ||
90 | |||
91 | this.getStrokeStyle = function() { return this._strokeStyle; } | ||
92 | this.setStrokeStyle = function(s) { this._strokeStyle = s; } | ||
93 | |||
94 | this.getWidth = function() { return this._width; } | ||
95 | this.setWidth = function(w) { this._width = w; } | ||
96 | |||
97 | this.getHeight = function() { return this._height; } | ||
98 | this.setHeight = function(h) { this._height = h; } | ||
99 | |||
100 | this.geomType = function() { return this.GEOM_TYPE_CIRCLE; } | ||
101 | |||
102 | /////////////////////////////////////////////////////////////////////// | ||
103 | // Methods | ||
104 | /////////////////////////////////////////////////////////////////////// | ||
105 | |||
106 | /////////////////////////////////////////////////////////////////////// | ||
107 | // update the "color of the material | ||
108 | this.getFillColor = function() | ||
109 | { | ||
110 | return this._fillColor; | ||
111 | } | ||
112 | |||
113 | // this.setFillColor = function(c) | ||
114 | // { | ||
115 | // this._fillColor = c; | ||
116 | // } | ||
117 | |||
118 | this.getStrokeColor = function() | ||
119 | { | ||
120 | return this._strokeColor; | ||
121 | } | ||
122 | |||
123 | // this.setStrokeColor = function(c) | ||
124 | // { | ||
125 | // this._strokeColor = c; | ||
126 | // } | ||
127 | /////////////////////////////////////////////////////////////////////// | ||
128 | |||
129 | this.buildBuffers = function() | ||
130 | { | ||
131 | // get the world | ||
132 | var world = this.getWorld(); | ||
133 | if (!world) throw( "null world in buildBuffers" ); | ||
134 | |||
135 | if (!world._useWebGL) return; | ||
136 | |||
137 | // make sure RDGE has the correct context | ||
138 | g_Engine.setContext( world.getCanvas().rdgeid ); | ||
139 | |||
140 | // create the gl buffer | ||
141 | var gl = world.getGLContext(); | ||
142 | |||
143 | // determine the number of triangles to generate | ||
144 | var nTriangles = 60; // yes, we will do better than this | ||
145 | |||
146 | // get the normalized device coordinates (NDC) for | ||
147 | // all position and dimensions. | ||
148 | var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); | ||
149 | var xNDC = 2*this._xOffset/vpw, yNDC = 2*this._yOffset/vph, | ||
150 | xRadNDC = this._width/vpw, yRadNDC = this._height/vph, | ||
151 | xStrokeNDC = 2*this._strokeWidth/vpw, yStrokeNDC = 2*this._strokeWidth/vph, | ||
152 | xInnRadNDC = this._innerRadius*xRadNDC, yInnRadNDC = this._innerRadius*yRadNDC; | ||
153 | |||
154 | var aspect = world.getAspect(); | ||
155 | var zn = world.getZNear(), zf = world.getZFar(); | ||
156 | var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0), | ||
157 | b = -t, | ||
158 | r = aspect*t, | ||
159 | l = -r; | ||
160 | |||
161 | // calculate the object coordinates from their NDC coordinates | ||
162 | var z = -world.getViewDistance(); | ||
163 | |||
164 | // get the position of the origin | ||
165 | var x = -z*(r-l)/(2.0*zn)*xNDC, | ||
166 | y = -z*(t-b)/(2.0*zn)*yNDC; | ||
167 | |||
168 | // get the x and y radii | ||
169 | var xRad = -z*(r-l)/(2.0*zn)*xRadNDC, | ||
170 | yRad = -z*(t-b)/(2.0*zn)*yRadNDC; | ||
171 | |||
172 | // save the overall dimensions to be used in the uv calculations | ||
173 | this._ovalWidth = xRad; this._ovalHeight = yRad; | ||
174 | |||
175 | // get the x & y stroke size | ||
176 | var xStroke = -z*(r-l)/(2.0*zn)*xStrokeNDC, | ||
177 | yStroke = -z*(t-b)/(2.0*zn)*yStrokeNDC; | ||
178 | |||
179 | // get the inner radius | ||
180 | var xInnRad = -z*(r-l)/(2.0*zn)*xInnRadNDC, | ||
181 | yInnRad = -z*(t-b)/(2.0*zn)*yInnRadNDC; | ||
182 | |||
183 | // get a matrix to rotate a point around the circle | ||
184 | var angle = 2.0*Math.PI/Number(nTriangles); | ||
185 | var mat = Matrix.RotationZ( angle ); | ||
186 | var reverseRotMat = Matrix.RotationZ( -angle ); | ||
187 | |||
188 | // calculate matrices to scale the circle and stroke to fit the bounds of the ellipse | ||
189 | var strokeScaleMat = Matrix.I(4); | ||
190 | strokeScaleMat[0] = xRad; | ||
191 | strokeScaleMat[5] = yRad; | ||
192 | |||
193 | var fillScaleMat = Matrix.I(4); | ||
194 | fillScaleMat[0] = xRad - xStroke; | ||
195 | fillScaleMat[5] = yRad - yStroke; | ||
196 | |||
197 | var innerRadiusScaleMat = Matrix.I(4); | ||
198 | innerRadiusScaleMat[0] = xInnRad; | ||
199 | innerRadiusScaleMat[5] = yInnRad; | ||
200 | |||
201 | var innerStrokeScaleMat = Matrix.I(4); | ||
202 | innerStrokeScaleMat[0] = xInnRad - xStroke; | ||
203 | innerStrokeScaleMat[5] = yInnRad - yStroke; | ||
204 | |||
205 | var fillPrim, strokePrim0, strokePrim1; | ||
206 | var fillMaterial, strokeMaterial0, strokeMaterial2; | ||
207 | |||
208 | this._primArray = []; | ||
209 | this._materialArray = []; | ||
210 | this._materialTypeArray = []; | ||
211 | this._materialNodeArray = []; | ||
212 | |||
213 | ///////////////////////////////////////////////////////////// | ||
214 | // Strokes | ||
215 | if(this._strokeWidth > 0) | ||
216 | { | ||
217 | var numStrokes = 1; | ||
218 | if(this._innerRadius !== 0) | ||
219 | strokePrim0 = this.generateOvalRing(x, y, reverseRotMat, innerStrokeScaleMat, innerRadiusScaleMat, nTriangles); | ||
220 | |||
221 | strokePrim1 = this.generateOvalRing(x, y, reverseRotMat, fillScaleMat, strokeScaleMat, nTriangles); | ||
222 | } | ||
223 | |||
224 | ///////////////////////////////////////////////////////////// | ||
225 | // Fill | ||
226 | if(this._innerRadius === 0) | ||