aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/GLLine.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/GLLine.js')
-rwxr-xr-xjs/helper-classes/RDGE/GLLine.js507
1 files changed, 0 insertions, 507 deletions
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
deleted file mode 100755
index 65e6ab1c..00000000
--- a/js/helper-classes/RDGE/GLLine.js
+++ /dev/null
@@ -1,507 +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 GLLine
9// GL representation of a line.
10// Derived from class GLGeomObj
11///////////////////////////////////////////////////////////////////////
12function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj)
13{
14 // initialize the inherited members
15 this.inheritedFrom = GLGeomObj;
16 this.inheritedFrom();
17
18 ///////////////////////////////////////////////////////////////////////
19 // Instance variables
20 ///////////////////////////////////////////////////////////////////////
21 this._width = 2.0;
22 this._height = 2.0;
23 this._xOffset = 0;
24 this._yOffset = 0;
25
26 // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side
27 this._xAdj = 0;
28 this._yAdj = 0;
29
30 this._slope = 0;
31
32 this._strokeWidth = 0.25;
33
34 this._strokeStyle = "Solid";
35 this._scaleX = 1.0;
36 this._scaleY = 1.0;
37
38 if (arguments.length > 0)
39 {
40 this._width = width;
41 this._height = height;
42 this._xOffset = xOffset;
43 this._yOffset = yOffset;
44
45 this._xAdj = xAdj;
46 this._yAdj = yAdj;
47
48 this._slope = slope;
49 this._strokeWidth = strokeSize;
50 if (strokeColor) this._strokeColor = strokeColor.slice();
51
52 this._strokeStyle = strokeStyle;
53 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
54 }
55
56 this._strokeVerticesLen = 0;
57
58 this.m_world = world;
59
60 this._materialAmbient = [0.2, 0.2, 0.2, 1.0];
61 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0];
62 this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
63
64 if(strokeMaterial)
65 {
66 this._strokeMaterial = strokeMaterial;
67 }
68
69 ///////////////////////////////////////////////////////////////////////
70 // Property Accessors
71 ///////////////////////////////////////////////////////////////////////
72 this.getStrokeWidth = function() { return this._strokeWidth; }
73 this.setStrokeWidth = function(w) { this._strokeWidth = w; }
74
75 this.getStrokeMaterial = function() { return this._strokeMaterial; }
76 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; }
77
78 this.getStrokeColor = function() { return this._strokeColor; }
79 //this.setStrokeColor = function(c) { this._strokeColor = c; }
80
81 this.getStrokeStyle = function() { return this._strokeStyle; }
82 this.setStrokeStyle = function(s) { this._strokeStyle = s; }
83
84 this.getFillMaterial = function() { return null; }
85
86 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; }
87 this.getStrokeMaterial = function() { return this._strokeMaterial; }
88
89 this.getWidth = function() { return this._width; }
90 this.setWidth = function(w) { this._width = w; }
91
92 this.getHeight = function() { return this._height; }
93 this.setHeight = function(h) { this._height = h; }
94
95 this.getXAdj = function() { return this._xAdj; }
96 this.setXAdj = function(x) { this._xAdj = x; }
97
98 this.getYAdj = function() { return this._yAdj; }
99 this.setYAdj = function(y) { this._yAdj = y; }
100
101 this.getSlope = function() { return this._slope; }
102 this.setSlope = function(m) { this._slope = m; }
103
104 this.geomType = function() { return this.GEOM_TYPE_LINE; }
105
106 ///////////////////////////////////////////////////////////////////////
107 // Methods
108 ///////////////////////////////////////////////////////////////////////
109 this.export = function()
110 {
111 var rtnStr = "type: " + this.geomType() + "\n";
112
113 rtnStr += "xoff: " + this._xOffset + "\n";
114 rtnStr += "yoff: " + this._yOffset + "\n";
115 rtnStr += "width: " + this._width + "\n";
116 rtnStr += "height: " + this._height + "\n";
117 rtnStr += "xAdj: " + this._xAdj + "\n";
118 rtnStr += "yAdj: " + this._yAdj + "\n";
119 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
120 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n";
121 rtnStr += "strokeStyle: " + this._strokeStyle + "\n";
122 rtnStr += "slope: " + String(this._slope) + "\n";
123
124 rtnStr += "strokeMat: ";
125 if (this._strokeMaterial)
126 rtnStr += this._strokeMaterial.getName();
127 else
128 rtnStr += "flatMaterial";
129 rtnStr += "\n";
130
131 return rtnStr;
132 }
133
134 this.import = function( importStr )
135 {
136 this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) );
137 this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) );
138 this._width = Number( this.getPropertyFromString( "width: ", importStr ) );
139 this._height = Number( this.getPropertyFromString( "height: ", importStr ) );
140 this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) );
141 this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) );
142 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) );
143 var slope = this.getPropertyFromString( "slope: ", importStr );
144 if(isNaN(Number(slope)))
145 this._slope = slope;
146 else
147 this._slope = Number(slope);
148
149 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
150 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr );
151 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" );
152
153 var strokeMat = MaterialsLibrary.getMaterial( strokeMaterialName );
154 if (!strokeMat)
155 {
156 console.log( "object material not found in library: " + strokeMaterialName );
157 strokeMat = new FlatMaterial();
158 }
159 this._strokeMaterial = strokeMat;
160
161 }
162
163 ///////////////////////////////////////////////////////////////////////
164 // Methods
165 ///////////////////////////////////////////////////////////////////////
166 this.buildBuffers = function()
167 {
168 // get the world
169 var world = this.getWorld();
170 if (!world) throw( "null world in buildBuffers" );
171 if (!world._useWebGL) return;
172
173 // make sure RDGE has the correct context
174 g_Engine.setContext( world.getCanvas().rdgeid );
175
176 // create the gl buffer
177 var gl = world.getGLContext();
178
179 this._strokeVerticesLen = 0;
180
181 var strokeVertices = [];
182 var strokeTextures = [];
183 var strokeNormals = [];
184 var strokeColors = [];
185
186// var scaleMat = Matrix.I(3);
187// scaleMat.elements[0][0] = this._scaleX;
188// scaleMat.elements[1][1] = this._scaleY;
189
190
191// get the normalized device coordinates (NDC) for
192 // all position and dimensions.
193 var vpw = world.getViewportWidth(), vph = world.getViewportHeight();
194 var xNDC = 2*this._xOffset/vpw, yNDC = 2*this._yOffset/vph,
195 xFillNDC = this._width/vpw, yFillNDC = this._height/vph,
196 xAdjNDC = this._xAdj/vpw, yAdjNDC = this._yAdj/vph,
197 xStrokeNDC = this._strokeWidth/vpw, yStrokeNDC = this._strokeWidth/vph;
198
199 var aspect = world.getAspect();
200 var zn = world.getZNear(), zf = world.getZFar();
201 var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0),
202 b = -t,
203 r = aspect*t,
204 l = -r;
205
206 // calculate the object coordinates from their NDC coordinates
207 var z = -world.getViewDistance();
208
209 // get the position of the origin
210 var x = -z*(r-l)/(2.0*zn)*xNDC,
211 y = -z*(t-b)/(2.0*zn)*yNDC;
212
213 // get the x and y fill
214 var xFill = -z*(r-l)/(2.0*zn)*xFillNDC,
215 yFill = -z*(t-b)/(2.0*zn)*yFillNDC;
216
217 // get the x & y stroke size
218 var xStroke = -z*(r-l)/(2.0*zn)*xStrokeNDC,
219 yStroke = -z*(t-b)/(2.0*zn)*yStrokeNDC;
220
221 // get the x & y adjustments size
222 var xAdj = -z*(r-l)/(2.0*zn)*xAdjNDC*2,
223 yAdj = -z*(t-b)/(2.0*zn)*yAdjNDC*2;
224