diff options
Diffstat (limited to 'js/helper-classes/backup-delete/GLRectangle.js')
-rwxr-xr-x | js/helper-classes/backup-delete/GLRectangle.js | 1236 |
1 files changed, 1236 insertions, 0 deletions
diff --git a/js/helper-classes/backup-delete/GLRectangle.js b/js/helper-classes/backup-delete/GLRectangle.js new file mode 100755 index 00000000..a801d3c4 --- /dev/null +++ b/js/helper-classes/backup-delete/GLRectangle.js | |||
@@ -0,0 +1,1236 @@ | |||
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 GLRectangle | ||
9 | // GL representation of a rectangle. | ||
10 | // Derived from class GLGeomObj | ||
11 | /////////////////////////////////////////////////////////////////////// | ||
12 | function GLRectangle() | ||
13 | { | ||
14 | // CONSTANTS | ||
15 | this.N_TRIANGLES = 15; | ||
16 | |||
17 | // initialize the inherited members | ||
18 | this.inheritedFrom = GLGeomObj; | ||
19 | this.inheritedFrom(); | ||
20 | |||
21 | /////////////////////////////////////////////////////////////////////// | ||
22 | // Instance variables | ||
23 | /////////////////////////////////////////////////////////////////////// | ||
24 | this._width = 2.0; | ||
25 | this._height = 2.0; | ||
26 | this._xOffset = 0; | ||
27 | this._yOffset = 0; | ||
28 | |||
29 | this._tlRadius = 0; | ||
30 | this._trRadius = 0; | ||
31 | this._blRadius = 0; | ||
32 | this._brRadius = 0; | ||
33 | |||
34 | this._strokeWidth = 0.25; | ||
35 | |||
36 | this._strokeStyle = "Solid"; | ||
37 | this.init = function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, | ||
38 | tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle) | ||
39 | { | ||
40 | |||
41 | |||
42 | this.m_world = world; | ||
43 | |||
44 | if (arguments.length > 0) | ||
45 | { | ||
46 | this._width = width; | ||
47 | this._height = height; | ||
48 | this._xOffset = xOffset; | ||
49 | this._yOffset = yOffset; | ||
50 | |||
51 | this._strokeWidth = strokeSize; | ||
52 | this._strokeColor = strokeColor; | ||
53 | this._fillColor = fillColor; | ||
54 | |||
55 | this.setTLRadius(tlRadius); | ||
56 | this.setTRRadius(trRadius); | ||
57 | this.setBLRadius(blRadius); | ||
58 | this.setBRRadius(brRadius); | ||
59 | |||
60 | this._strokeStyle = strokeStyle; | ||
61 | } | ||
62 | |||
63 | // the overall radius includes the fill and the stroke. separate the two based onthe stroke width | ||
64 | // this._fillRad = this._radius - this._strokeWidth; | ||
65 | // var err = 0.05; | ||
66 | var err = 0; | ||
67 | this._fillWidth = this._width - this._strokeWidth + err; | ||
68 | this._fillHeight = this._height - this._strokeWidth + err; | ||
69 | |||
70 | this._materialAmbient = [0.2, 0.2, 0.2, 1.0]; | ||
71 | this._materialDiffuse = [0.4, 0.4, 0.4, 1.0]; | ||
72 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; | ||
73 | |||
74 | if(strokeMaterial) | ||
75 | this._strokeMaterial = strokeMaterial; | ||
76 | else | ||
77 | this._strokeMaterial = new FlatMaterial(); | ||
78 | |||
79 | if(fillMaterial) | ||
80 | this._fillMaterial = fillMaterial; | ||
81 | else | ||
82 | this._fillMaterial = new FlatMaterial(); | ||
83 | } | ||
84 | |||
85 | /////////////////////////////////////////////////////////////////////// | ||
86 | // Property Accessors | ||
87 | /////////////////////////////////////////////////////////////////////// | ||
88 | this.getStrokeWidth = function() { return this._strokeWidth; } | ||
89 | this.setStrokeWidth = function(w) { this._strokeWidth = w; } | ||
90 | |||
91 | this.getStrokeMaterial = function() { return this._strokeMaterial; } | ||
92 | this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } | ||
93 | |||
94 | this.getFillMaterial = function() { return this._fillMaterial; } | ||
95 | this.setFillMaterial = function(m) { this._fillMaterial = m; } | ||
96 | |||
97 | this.getStrokeColor = function() { return this._strokeColor; } | ||
98 | //this.setStrokeColor = function(c) { this._strokeColor = c; } | ||
99 | |||
100 | this.getFillColor = function() { return this._fillColor; } | ||
101 | //this.setFillColor = function(c) { this._fillColor = c.slice(0); } | ||
102 | |||
103 | this.getTLRadius = function() { return this._tlRadius; } | ||
104 | this.setTLRadius = function(r) { this._tlRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2); } | ||
105 | |||
106 | this.getTRRadius = function() { return this._trRadius; } | ||
107 | this.setTRRadius = function(r) { this._trRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2); } | ||
108 | |||
109 | this.getBLRadius = function() { return this._blRadius; } | ||
110 | this.setBLRadius = function(r) { this._blRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2); } | ||
111 | |||
112 | this.getBRRadius = function() { return this._brRadius; } | ||
113 | this.setBRRadius = function(r) { this._brRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2); } | ||
114 | |||
115 | this.getStrokeStyle = function() { return this._strokeStyle; } | ||
116 | this.setStrokeStyle = function(s) { this._strokeStyle = s; } | ||
117 | |||
118 | this.getWidth = function() { return this._width; } | ||
119 | this.setWidth = function(w) { this._width = w; } | ||
120 | |||
121 | this.getHeight = function() { return this._height; } | ||
122 | this.setHeight = function(h) { this._height = h; } | ||
123 | |||
124 | this.geomType = function() { return this.GEOM_TYPE_RECTANGLE; } | ||
125 | |||
126 | |||
127 | /////////////////////////////////////////////////////////////////////// | ||
128 | // Methods | ||
129 | /////////////////////////////////////////////////////////////////////// | ||
130 | this.export = function() | ||
131 | { | ||
132 | var rtnStr = "type: " + this.geomType() + "\n"; | ||
133 | |||
134 | ///////////////////////////////////////////////////////////////////////// | ||
135 | // | ||
136 | // world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, | ||
137 | // tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle | ||
138 | // | ||
139 | ///////////////////////////////////////////////////////////////////////////// | ||
140 | |||
141 | rtnStr += "xoff: " + this._xOffset + "\n"; | ||
142 | rtnStr += "yoff: " + this._yOffset + "\n"; | ||
143 | rtnStr += "width: " + this._width + "\n"; | ||
144 | rtnStr += "height: " + this._height + "\n"; | ||
145 | rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; | ||
146 | rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; | ||
147 | rtnStr += "fillColor: " + String(this._fillColor) + "\n"; | ||
148 | rtnStr += "tlRadius: " + this._tlRadius + "\n"; | ||
149 | rtnStr += "trRadius: " + this._trRadius + "\n"; | ||
150 | rtnStr += "blRadius: " + this._blRadius + "\n"; | ||
151 | rtnStr += "brRadius: " + this._brRadius + "\n"; | ||
152 | rtnStr += "innerRadius: " + this._innerRadius + "\n"; | ||
153 | rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; | ||
154 | |||
155 | rtnStr += "strokeMat: "; | ||
156 | if (this._strokeMaterial) | ||
157 | rtnStr += this._strokeMaterial.getName(); | ||
158 | else | ||
159 | rtnStr += "flatMaterial"; | ||
160 | rtnStr += "\n"; | ||
161 | |||
162 | rtnStr += "fillMat: "; | ||
163 | if (this._fillMaterial) | ||
164 | rtnStr += this._fillMaterial.getName(); | ||
165 | else | ||
166 | rtnStr += "flatMaterial"; | ||
167 | rtnStr += "\n"; | ||
168 | |||
169 | return rtnStr; | ||
170 | } | ||
171 | |||
172 | this.import = function( importStr ) | ||
173 | { | ||
174 | this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) ); | ||
175 | this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); | ||
176 | this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); | ||
177 | this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); | ||
178 | this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); | ||
179 | this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) ); | ||
180 | this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) ); | ||
181 | var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); | ||
182 | var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr ); | ||
183 | this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); | ||
184 | this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); | ||
185 | this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); | ||
186 | this._tlRadius = Number( this.getPropertyFromString( "tlRadius: ", importStr ) ); | ||
187 | this._trRadius = Number( this.getPropertyFromString( "trRadius: ", importStr ) ); | ||
188 | this._blRadius = Number( this.getPropertyFromString( "blRadius: ", importStr ) ); | ||
189 | this._brRadius = Number( this.getPropertyFromString( "brRadius: ", importStr ) ); | ||
190 | |||
191 | var strokeMat = MaterialsLibrary.getMaterial( strokeMaterialName ); | ||
192 | if (!strokeMat) | ||
193 | { | ||
194 | console.log( "object material not found in library: " + strokeMaterialName ); | ||
195 | strokeMat = new FlatMaterial(); | ||
196 | } | ||
197 | this._strokeMaterial = strokeMat; | ||
198 | |||
199 | var fillMat = MaterialsLibrary.getMaterial( fillMaterialName ); | ||
200 | if (!fillMat) | ||
201 | { | ||
202 | console.log( "object material not found in library: " + fillMaterialName ); | ||
203 | fillMat = new FlatMaterial(); | ||
204 | } | ||
205 | this._fillMaterial = fillMat; | ||
206 | } | ||
207 | |||
208 | this.buildBuffers = function() | ||
209 | { | ||