aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/GLLine.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE/GLLine.js')
-rw-r--r--js/helper-classes/RDGE/GLLine.js99
1 files changed, 81 insertions, 18 deletions
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index bd3cbc26..5ec51230 100644
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -28,6 +28,8 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
28 this._strokeWidth = 0.25; 28 this._strokeWidth = 0.25;
29 29
30 this._strokeStyle = "Solid"; 30 this._strokeStyle = "Solid";
31 this._scaleX = 1.0;
32 this._scaleY = 1.0;
31 33
32 if (arguments.length > 0) 34 if (arguments.length > 0)
33 { 35 {
@@ -44,13 +46,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
44 this._strokeColor = strokeColor; 46 this._strokeColor = strokeColor;
45 47
46 this._strokeStyle = strokeStyle; 48 this._strokeStyle = strokeStyle;
49 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
47 } 50 }
48 51
49 this._scaleX = 1.0;
50 this._scaleY = 1.0;
51
52 this._scaleX = (world._viewportWidth)/(world._viewportHeight);
53
54 this._strokeVerticesLen = 0; 52 this._strokeVerticesLen = 0;
55 53
56 this.m_world = world; 54 this.m_world = world;
@@ -77,11 +75,16 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
77 this.getStrokeMaterial = function() { return this._strokeMaterial; } 75 this.getStrokeMaterial = function() { return this._strokeMaterial; }
78 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } 76 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; }
79 77
80 this.getStrokeColor = function() { return this._strokeColor; } 78 this.getStrokeColor = function() { return this._strokeColor; }
81 //this.setStrokeColor = function(c) { this._strokeColor = c; } 79 //this.setStrokeColor = function(c) { this._strokeColor = c; }
82 80
83 this.getStrokeStyle = function() { return this._strokeStyle; } 81 this.getStrokeStyle = function() { return this._strokeStyle; }
84 this.setStrokeStyle = function(s) { this._strokeStyle = s; } 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; }
85 88
86 this.getWidth = function() { return this._width; } 89 this.getWidth = function() { return this._width; }
87 this.setWidth = function(w) { this._width = w; } 90 this.setWidth = function(w) { this._width = w; }
@@ -99,7 +102,64 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
99 this.setSlope = function(m) { this._slope = m; } 102 this.setSlope = function(m) { this._slope = m; }
100 103
101 this.geomType = function() { return this.GEOM_TYPE_LINE; } 104 this.geomType = function() { return this.GEOM_TYPE_LINE; }
102 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
103 /////////////////////////////////////////////////////////////////////// 163 ///////////////////////////////////////////////////////////////////////
104 // Methods 164 // Methods
105 /////////////////////////////////////////////////////////////////////// 165 ///////////////////////////////////////////////////////////////////////
@@ -109,6 +169,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
109 var world = this.getWorld(); 169 var world = this.getWorld();
110 if (!world) throw( "null world in buildBuffers" ); 170 if (!world) throw( "null world in buildBuffers" );
111 if (!world._useWebGL) return; 171 if (!world._useWebGL) return;
172
173 // make sure RDGE has the correct context
174 g_Engine.setContext( world.getCanvas().uuid );
112 175
113 // create the gl buffer 176 // create the gl buffer
114 var gl = world.getGLContext(); 177 var gl = world.getGLContext();
@@ -184,9 +247,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
184 xFill+x, yFill+y, 0.0, 247 xFill+x, yFill+y, 0.0,
185 -xFill+x, -yFill+y, 0.0, 248 -xFill+x, -yFill+y, 0.0,
186 249
187 xFill+x, yFill+y, 0.0, 250 xFill+x, -yFill+y, 0.0,
188 -xFill+x, -yFill+y, 0.0, 251 -xFill+x, -yFill+y, 0.0,
189 xFill+x, -yFill+y, 0.0 252 xFill+x, yFill+y, 0.0
190 ]; 253 ];
191 } 254 }
192 else if(this._slope === "horizontal") 255 else if(this._slope === "horizontal")
@@ -199,10 +262,10 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
199 xFill+x, yFill+y, 0.0, 262 xFill+x, yFill+y, 0.0,
200 -xFill+x, -yFill+y, 0.0, 263 -xFill+x, -yFill+y, 0.0,
201 264
202 xFill+x, yFill+y, 0.0, 265 xFill+x, -yFill+y, 0.0,
203 -xFill+x, -yFill+y, 0.0, 266 -xFill+x, -yFill+y, 0.0,
204 xFill+x, -yFill+y, 0.0 267 xFill+x, yFill+y, 0.0
205 ]; 268 ];
206 } 269 }
207 else if(this._slope > 0) 270 else if(this._slope > 0)
208 { 271 {
@@ -212,9 +275,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
212 -xFill+2*xAdj+x, yFill+y, 0.0, 275 -xFill+2*xAdj+x, yFill+y, 0.0,
213 xFill-2*xAdj+x, -yFill+y, 0.0, 276 xFill-2*xAdj+x, -yFill+y, 0.0,
214 277
215 -xFill+2*xAdj+x, yFill+y, 0.0, 278 xFill+x, -yFill+2*yAdj+y, 0.0,
216 xFill-2*xAdj+x, -yFill+y, 0.0, 279 xFill-2*xAdj+x, -yFill+y, 0.0,
217 xFill+x, -yFill+2*yAdj+y, 0.0 280 -xFill+2*xAdj+x, yFill+y, 0.0
218 ]; 281 ];
219 } 282 }
220 else 283 else
@@ -225,9 +288,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
225 -xFill+2*xAdj+x, -yFill+y, 0.0, 288 -xFill+2*xAdj+x, -yFill+y, 0.0,
226 xFill-2*xAdj+x, yFill+y, 0.0, 289 xFill-2*xAdj+x, yFill+y, 0.0,
227 290
228 -xFill+2*xAdj+x, -yFill+y, 0.0, 291 xFill+x, yFill-2*yAdj+y, 0.0,
229 xFill-2*xAdj+x, yFill+y, 0.0, 292 xFill-2*xAdj+x, yFill+y, 0.0,
230 xFill+x, yFill-2*yAdj+y, 0.0 293 -xFill+2*xAdj+x, -yFill+y, 0.0
231 ]; 294 ];
232 } 295 }
233 } 296 }