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.js594
1 files changed, 307 insertions, 287 deletions
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index 5ec51230..0d815145 100755
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -11,74 +11,74 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
11/////////////////////////////////////////////////////////////////////// 11///////////////////////////////////////////////////////////////////////
12function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj) 12function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj)
13{ 13{
14 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
15 // Instance variables 15 // Instance variables
16 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
17 this._width = 2.0; 17 this._width = 2.0;
18 this._height = 2.0; 18 this._height = 2.0;
19 this._xOffset = 0; 19 this._xOffset = 0;
20 this._yOffset = 0; 20 this._yOffset = 0;
21 21
22 // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side 22 // If line doesn't fit in canvas world, we had to grow the canvas by this much on either side
23 this._xAdj = 0; 23 this._xAdj = 0;
24 this._yAdj = 0; 24 this._yAdj = 0;
25 25
26 this._slope = 0; 26 this._slope = 0;
27 27
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; 31 this._scaleX = 1.0;
32 this._scaleY = 1.0; 32 this._scaleY = 1.0;
33 33
34 if (arguments.length > 0) 34 if (arguments.length > 0)
35 { 35 {
36 this._width = width; 36 this._width = width;
37 this._height = height; 37 this._height = height;
38 this._xOffset = xOffset; 38 this._xOffset = xOffset;
39 this._yOffset = yOffset; 39 this._yOffset = yOffset;
40 40
41 this._xAdj = xAdj; 41 this._xAdj = xAdj;
42 this._yAdj = yAdj; 42 this._yAdj = yAdj;
43 43
44 this._slope = slope; 44 this._slope = slope;
45 this._strokeWidth = strokeSize; 45 this._strokeWidth = strokeSize;
46 this._strokeColor = strokeColor; 46 this._strokeColor = strokeColor;
47 47
48 this._strokeStyle = strokeStyle; 48 this._strokeStyle = strokeStyle;
49 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); 49 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
50 } 50 }
51 51
52 this._strokeVerticesLen = 0; 52 this._strokeVerticesLen = 0;
53 53
54 this.m_world = world; 54 this.m_world = world;
55 55
56 this._materialAmbient = [0.2, 0.2, 0.2, 1.0]; 56 this._materialAmbient = [0.2, 0.2, 0.2, 1.0];
57 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0]; 57 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0];
58 this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; 58 this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
59 59
60 // initialize the inherited members 60 // initialize the inherited members
61 this.inheritedFrom = GLGeomObj; 61 this.inheritedFrom = GLGeomObj;
62 this.inheritedFrom(); 62 this.inheritedFrom();
63 63
64 if(strokeMaterial) 64 if(strokeMaterial)
65 { 65 {
66 this._strokeMaterial = strokeMaterial; 66 this._strokeMaterial = strokeMaterial;
67 } 67 }
68 68
69 /////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////
70 // Property Accessors 70 // Property Accessors
71 /////////////////////////////////////////////////////////////////////// 71 ///////////////////////////////////////////////////////////////////////
72 this.getStrokeWidth = function() { return this._strokeWidth; } 72 this.getStrokeWidth = function() { return this._strokeWidth; }
73 this.setStrokeWidth = function(w) { this._strokeWidth = w; } 73 this.setStrokeWidth = function(w) { this._strokeWidth = w; }
74 74
75 this.getStrokeMaterial = function() { return this._strokeMaterial; } 75 this.getStrokeMaterial = function() { return this._strokeMaterial; }
76 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } 76 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; }
77 77
78 this.getStrokeColor = function() { return this._strokeColor; } 78 this.getStrokeColor = function() { return this._strokeColor; }
79 //this.setStrokeColor = function(c) { this._strokeColor = c; } 79 //this.setStrokeColor = function(c) { this._strokeColor = c; }
80 80
81 this.getStrokeStyle = function() { return this._strokeStyle; } 81 this.getStrokeStyle = function() { return this._strokeStyle; }
82 this.setStrokeStyle = function(s) { this._strokeStyle = s; } 82 this.setStrokeStyle = function(s) { this._strokeStyle = s; }
83 83
84 this.getFillMaterial = function() { return null; } 84 this.getFillMaterial = function() { return null; }
@@ -86,24 +86,24 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
86 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } 86 this.setStrokeMaterial = function(m) { this._strokeMaterial = m; }
87 this.getStrokeMaterial = function() { return this._strokeMaterial; } 87 this.getStrokeMaterial = function() { return this._strokeMaterial; }
88 88
89 this.getWidth = function() { return this._width; } 89 this.getWidth = function() { return this._width; }
90 this.setWidth = function(w) { this._width = w; } 90 this.setWidth = function(w) { this._width = w; }
91 91
92 this.getHeight = function() { return this._height; } 92 this.getHeight = function() { return this._height; }
93 this.setHeight = function(h) { this._height = h; } 93 this.setHeight = function(h) { this._height = h; }
94 94
95 this.getXAdj = function() { return this._xAdj; } 95 this.getXAdj = function() { return this._xAdj; }
96 this.setXAdj = function(x) { this._xAdj = x; } 96 this.setXAdj = function(x) { this._xAdj = x; }
97 97
98 this.getYAdj = function() { return this._yAdj; } 98 this.getYAdj = function() { return this._yAdj; }
99 this.setYAdj = function(y) { this._yAdj = y; } 99 this.setYAdj = function(y) { this._yAdj = y; }
100 100
101 this.getSlope = function() { return this._slope; } 101 this.getSlope = function() { return this._slope; }
102 this.setSlope = function(m) { this._slope = m; } 102 this.setSlope = function(m) { this._slope = m; }
103 103
104 this.geomType = function() { return this.GEOM_TYPE_LINE; } 104 this.geomType = function() { return this.GEOM_TYPE_LINE; }
105 105
106 /////////////////////////////////////////////////////////////////////// 106 ///////////////////////////////////////////////////////////////////////
107 // Methods 107 // Methods
108 /////////////////////////////////////////////////////////////////////// 108 ///////////////////////////////////////////////////////////////////////
109 this.export = function() 109 this.export = function()
@@ -137,14 +137,14 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
137 this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); 137 this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) );
138 this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); 138 this._width = Number( this.getPropertyFromString( "width: ", importStr ) );
139 this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); 139 this._height = Number( this.getPropertyFromString( "height: ", importStr ) );
140 this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) ); 140 this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) );
141 this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) ); 141 this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) );
142 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); 142 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) );
143 var slope = this.getPropertyFromString( "slope: ", importStr ); 143 var slope = this.getPropertyFromString( "slope: ", importStr );
144 if(isNaN(Number(slope))) 144 if(isNaN(Number(slope)))
145 this._slope = slope; 145 this._slope = slope;
146 else 146 else
147 this._slope = Number(slope); 147 this._slope = Number(slope);
148 148
149 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); 149 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
150 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); 150 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr );
@@ -160,28 +160,28 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
160 160
161 } 161 }
162 162
163 /////////////////////////////////////////////////////////////////////// 163 ///////////////////////////////////////////////////////////////////////
164 // Methods 164 // Methods
165 /////////////////////////////////////////////////////////////////////// 165 ///////////////////////////////////////////////////////////////////////
166 this.buildBuffers = function() 166 this.buildBuffers = function()
167 { 167 {
168 // get the world 168 // get the world
169 var world = this.getWorld(); 169 var world = this.getWorld();
170 if (!world) throw( "null world in buildBuffers" ); 170 if (!world) throw( "null world in buildBuffers" );
171 if (!world._useWebGL) return; 171 if (!world._useWebGL) return;
172 172
173 // make sure RDGE has the correct context 173 // make sure RDGE has the correct context
174 g_Engine.setContext( world.getCanvas().uuid ); 174 g_Engine.setContext( world.getCanvas().uuid );
175 175
176 // create the gl buffer 176 // create the gl buffer
177 var gl = world.getGLContext(); 177 var gl = world.getGLContext();
178 178
179 this._strokeVerticesLen = 0; 179 this._strokeVerticesLen = 0;
180 180
181 var strokeVertices = []; 181 var strokeVertices = [];
182 var strokeTextures = []; 182 var strokeTextures = [];
183 var strokeNormals = []; 183 var strokeNormals = [];
184 var strokeColors = []; 184 var strokeColors = [];
185