diff options
Diffstat (limited to 'js/helper-classes/RDGE/GLLine.js')
-rwxr-xr-x[-rw-r--r--] | js/helper-classes/RDGE/GLLine.js | 644 |
1 files changed, 361 insertions, 283 deletions
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index 67379b52..0d815145 100644..100755 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js | |||
@@ -11,76 +11,74 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
11 | /////////////////////////////////////////////////////////////////////// | 11 | /////////////////////////////////////////////////////////////////////// |
12 | function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj) | 12 | function 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 | |||
28 | this._strokeWidth = 0.25; | ||
29 | |||
30 | this._strokeStyle = "Solid"; | ||
31 | 27 | ||
32 | if (arguments.length > 0) | 28 | this._strokeWidth = 0.25; |
33 | { | ||
34 | this._width = width; | ||
35 | this._height = height; | ||
36 | this._xOffset = xOffset; | ||
37 | this._yOffset = yOffset; | ||
38 | 29 | ||
39 | this._xAdj = xAdj; | 30 | this._strokeStyle = "Solid"; |
40 | this._yAdj = yAdj; | 31 | this._scaleX = 1.0; |
32 | this._scaleY = 1.0; | ||
41 | 33 | ||
42 | this._slope = slope; | 34 | if (arguments.length > 0) |
43 | this._strokeWidth = strokeSize; | 35 | { |
44 | this._strokeColor = strokeColor; | 36 | this._width = width; |
37 | this._height = height; | ||
38 | this._xOffset = xOffset; | ||
39 | this._yOffset = yOffset; | ||
45 | 40 | ||
46 | this._strokeStyle = strokeStyle; | 41 | this._xAdj = xAdj; |
47 | } | 42 | this._yAdj = yAdj; |
48 | 43 | ||
49 | this._scaleX = 1.0; | 44 | this._slope = slope; |
50 | this._scaleY = 1.0; | 45 | this._strokeWidth = strokeSize; |
46 | this._strokeColor = strokeColor; | ||
51 | 47 | ||
52 | this._scaleX = (world._viewportWidth)/(world._viewportHeight); | 48 | this._strokeStyle = strokeStyle; |
49 | this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); | ||
50 | } | ||
53 | 51 | ||
54 | this._strokeVerticesLen = 0; | 52 | this._strokeVerticesLen = 0; |
55 | 53 | ||
56 | this.m_world = world; | 54 | this.m_world = world; |
57 | 55 | ||
58 | this._materialAmbient = [0.2, 0.2, 0.2, 1.0]; | 56 | this._materialAmbient = [0.2, 0.2, 0.2, 1.0]; |
59 | this._materialDiffuse = [0.4, 0.4, 0.4, 1.0]; | 57 | this._materialDiffuse = [0.4, 0.4, 0.4, 1.0]; |
60 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; | 58 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; |
61 | 59 | ||
62 | // initialize the inherited members | 60 | // initialize the inherited members |
63 | this.inheritedFrom = GLGeomObj; | 61 | this.inheritedFrom = GLGeomObj; |
64 | this.inheritedFrom(); | 62 | this.inheritedFrom(); |
65 | 63 | ||
66 | if(strokeMaterial) | 64 | if(strokeMaterial) |
67 | { | 65 | { |
68 | this._strokeMaterial = strokeMaterial; | 66 | this._strokeMaterial = strokeMaterial; |
69 | } | 67 | } |
70 | 68 | ||
71 | /////////////////////////////////////////////////////////////////////// | 69 | /////////////////////////////////////////////////////////////////////// |
72 | // Property Accessors | 70 | // Property Accessors |
73 | /////////////////////////////////////////////////////////////////////// | 71 | /////////////////////////////////////////////////////////////////////// |
74 | this.getStrokeWidth = function() { return this._strokeWidth; } | 72 | this.getStrokeWidth = function() { return this._strokeWidth; } |
75 | this.setStrokeWidth = function(w) { this._strokeWidth = w; } | 73 | this.setStrokeWidth = function(w) { this._strokeWidth = w; } |
76 | 74 | ||
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; } |
85 | 83 | ||
86 | this.getFillMaterial = function() { return null; } | 84 | this.getFillMaterial = function() { return null; } |
@@ -88,42 +86,102 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro | |||
88 | this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } | 86 | this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } |
89 | this.getStrokeMaterial = function() { return this._strokeMaterial; } | 87 | this.getStrokeMaterial = function() { return this._strokeMaterial; } |
90 | 88 | ||
91 | this.getWidth = function() { return this._width; } | 89 | this.getWidth = function() { return this._width; } |
92 | this.setWidth = function(w) { this._width = w; } | 90 | this.setWidth = function(w) { this._width = w; } |
93 | 91 | ||
94 | this.getHeight = function() { return this._height; } | 92 | this.getHeight = function() { return this._height; } |
95 | this.setHeight = function(h) { this._height = h; } | 93 | this.setHeight = function(h) { this._height = h; } |
96 | 94 | ||
97 | this.getXAdj = function() { return this._xAdj; } | 95 | this.getXAdj = function() { return this._xAdj; } |
98 | this.setXAdj = function(x) { this._xAdj = x; } | 96 | this.setXAdj = function(x) { this._xAdj = x; } |
99 | 97 | ||
100 | this.getYAdj = function() { return this._yAdj; } | 98 | this.getYAdj = function() { return this._yAdj; } |
101 | this.setYAdj = function(y) { this._yAdj = y; } | 99 | this.setYAdj = function(y) { this._yAdj = y; } |
102 | 100 | ||
103 | this.getSlope = function() { return this._slope; } | 101 | this.getSlope = function() { return this._slope; } |
104 | this.setSlope = function(m) { this._slope = m; } | 102 | this.setSlope = function(m) { this._slope = m; } |
105 | 103 | ||
106 | this.geomType = function() { return this.GEOM_TYPE_LINE; } | 104 | this.geomType = function() { return this.GEOM_TYPE_LINE; } |
107 | 105 | ||
108 | /////////////////////////////////////////////////////////////////////// | 106 | /////////////////////////////////////////////////////////////////////// |
109 | // Methods | 107 | // Methods |
110 | /////////////////////////////////////////////////////////////////////// | 108 | /////////////////////////////////////////////////////////////////////// |
111 | this.buildBuffers = function() | 109 | this.export = function() |
112 | { | 110 | { |
113 | // get the world | 111 | var rtnStr = "type: " + this.geomType() + "\n"; |
114 | var world = this.getWorld(); | 112 | |
115 | if (!world) throw( "null world in buildBuffers" ); | 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() | ||