aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE
diff options
context:
space:
mode:
authorPushkar Joshi2012-02-08 15:42:40 -0800
committerPushkar Joshi2012-02-08 15:42:40 -0800
commit18243deb66ab14a014756bfb0be1a52648c7771a (patch)
treec64660f7f69840cac5186fd730221335bd0a67af /js/helper-classes/RDGE
parent802e92eb70b00849dadacf2c6590d27edbe65d99 (diff)
parent0537f8f29e7b8dd48fd08f20b1533fbe92a54c4b (diff)
downloadninja-18243deb66ab14a014756bfb0be1a52648c7771a.tar.gz
Merge branch 'master' into pentool
Conflicts: js/helper-classes/RDGE/GLWorld.js js/helper-classes/RDGE/MaterialsLibrary.js
Diffstat (limited to 'js/helper-classes/RDGE')
-rw-r--r--js/helper-classes/RDGE/GLCircle.js79
-rw-r--r--js/helper-classes/RDGE/GLGeomObj.js51
-rw-r--r--js/helper-classes/RDGE/GLLine.js27
-rw-r--r--js/helper-classes/RDGE/GLRectangle.js65
-rw-r--r--js/helper-classes/RDGE/GLWorld.js3
-rw-r--r--js/helper-classes/RDGE/MaterialsLibrary.js42
6 files changed, 96 insertions, 171 deletions
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js
index 8f7a5d30..942eb528 100644
--- a/js/helper-classes/RDGE/GLCircle.js
+++ b/js/helper-classes/RDGE/GLCircle.js
@@ -33,14 +33,6 @@ function GLCircle()
33 33
34 this._ovalHeight = this._ovalHeight = 2.0*this.radius; 34 this._ovalHeight = this._ovalHeight = 2.0*this.radius;
35 35
36 // stroke and fill colors
37 this._strokeColor = [0.4, 0.4, 0.4, 1.0];
38 this._fillColor = [0.0, 0.6, 0.0, 1.0];
39
40 // stroke and fill materials
41 this._fillMaterial;
42 this._strokeMaterial;
43
44 this._strokeStyle = "Solid"; 36 this._strokeStyle = "Solid";
45 37
46 this._aspectRatio = 1.0; 38 this._aspectRatio = 1.0;
@@ -191,19 +183,19 @@ function GLCircle()
191 var reverseRotMat = Matrix.RotationZ( -angle ); 183 var reverseRotMat = Matrix.RotationZ( -angle );
192 184
193 // calculate matrices to scale the circle and stroke to fit the bounds of the ellipse 185 // calculate matrices to scale the circle and stroke to fit the bounds of the ellipse
194 strokeScaleMat = Matrix.I(4); 186 var strokeScaleMat = Matrix.I(4);
195 strokeScaleMat[0] = xRad; 187 strokeScaleMat[0] = xRad;
196 strokeScaleMat[5] = yRad; 188 strokeScaleMat[5] = yRad;
197 189
198 fillScaleMat = Matrix.I(4); 190 var fillScaleMat = Matrix.I(4);
199 fillScaleMat[0] = xRad - xStroke; 191 fillScaleMat[0] = xRad - xStroke;
200 fillScaleMat[5] = yRad - yStroke; 192 fillScaleMat[5] = yRad - yStroke;
201 193
202 innerRadiusScaleMat = Matrix.I(4); 194 var innerRadiusScaleMat = Matrix.I(4);
203 innerRadiusScaleMat[0] = xInnRad; 195 innerRadiusScaleMat[0] = xInnRad;
204 innerRadiusScaleMat[5] = yInnRad; 196 innerRadiusScaleMat[5] = yInnRad;
205 197
206 innerStrokeScaleMat = Matrix.I(4); 198 var innerStrokeScaleMat = Matrix.I(4);
207 innerStrokeScaleMat[0] = xInnRad - xStroke; 199 innerStrokeScaleMat[0] = xInnRad - xStroke;
208 innerStrokeScaleMat[5] = yInnRad - yStroke; 200 innerStrokeScaleMat[5] = yInnRad - yStroke;
209 201
@@ -235,69 +227,24 @@ function GLCircle()
235 227
236 if (fillPrim) 228 if (fillPrim)
237 { 229 {
238 this._primArray.push( fillPrim ); 230 fillMaterial = this.makeFillMaterial();
239
240 if (this.getFillMaterial())
241 fillMaterial = this.getFillMaterial().dup();
242 else
243 fillMaterial = new FlatMaterial();
244 231
245 if (fillMaterial) 232 this._primArray.push( fillPrim );
246 { 233 this._materialNodeArray.push( fillMaterial.getMaterialNode() );
247 fillMaterial.init( this.getWorld() );
248 if(!this.getFillMaterial() && this._fillColor)
249 {
250 fillMaterial.setProperty("color", this._fillColor);
251 }
252 this._materialArray.push( fillMaterial );
253 this._materialTypeArray.push( "fill" );
254 var matNode = fillMaterial.getMaterialNode();
255 this._materialNodeArray.push( matNode );
256 }
257 } 234 }
258 if (strokePrim0) 235 if (strokePrim0)
259 { 236 {
260 if (this.getStrokeMaterial()) 237 strokeMaterial0 = this.makeStrokeMaterial();
261 strokeMaterial = this.getStrokeMaterial().dup();
262 else
263 strokeMaterial = new FlatMaterial();
264 238
265 if (strokeMaterial) 239 this._primArray.push( strokePrim0 );
266 { 240 this._materialNodeArray.push( strokeMaterial0.getMaterialNode() );
267 strokeMaterial.init( this.getWorld() );
268 if(!this.getStrokeMaterial() && this._strokeColor)
269 {
270 strokeMaterial.setProperty("color", this._strokeColor);
271 }
272 this._primArray.push( strokePrim0 );
273
274 var materialNode = createMaterialNode("ovalFillMaterial");
275 this._materialArray.push( strokeMaterial );
276 this._materialTypeArray.push( "stroke" );
277 this._materialNodeArray.push( strokeMaterial.getMaterialNode() );
278 }
279 } 241 }
280 if (strokePrim1) 242 if (strokePrim1)
281 { 243 {
282 if (this.getStrokeMaterial()) 244 strokeMaterial2 = this.makeStrokeMaterial();
283 strokeMaterial = this.getStrokeMaterial().dup();
284 else
285 strokeMaterial = new FlatMaterial();
286 245
287 if (strokeMaterial) 246 this._primArray.push( strokePrim1 );
288 { 247 this._materialNodeArray.push( strokeMaterial2.getMaterialNode() );
289 strokeMaterial.init( this.getWorld() );
290 if(!this.getStrokeMaterial() && this._strokeColor)
291 {
292 strokeMaterial.setProperty("color", this._strokeColor);
293 }
294 this._primArray.push( strokePrim1 );
295
296 var materialNode = createMaterialNode("ovalFillMaterial");
297 this._materialArray.push( strokeMaterial );
298 this._materialTypeArray.push( "stroke" );
299 this._materialNodeArray.push( strokeMaterial.getMaterialNode() );
300 }
301 } 248 }
302 249
303 world.updateObject(this); 250 world.updateObject(this);
diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js
index e04b3283..5d7497ad 100644
--- a/js/helper-classes/RDGE/GLGeomObj.js
+++ b/js/helper-classes/RDGE/GLGeomObj.js
@@ -37,6 +37,10 @@ function GLGeomObj()
37 37
38 this.m_world = null; 38 this.m_world = null;
39 39
40 // stroke and fill colors
41 this._strokeColor;
42 this._fillColor;
43
40 // stroke and fill materials 44 // stroke and fill materials
41 this._fillMaterial; 45 this._fillMaterial;
42 this._strokeMaterial; 46 this._strokeMaterial;
@@ -107,6 +111,53 @@ function GLGeomObj()
107 this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); } 111 this.setFillColor = function(c) { this.setMaterialColor(c, "fill"); }
108 this.setStrokeColor = function(c) { this.setMaterialColor(c, "stroke"); } 112 this.setStrokeColor = function(c) { this.setMaterialColor(c, "stroke"); }
109 113
114 this.makeStrokeMaterial = function()
115 {
116 var strokeMaterial;
117 if (this.getStrokeMaterial())
118 strokeMaterial = this.getStrokeMaterial().dup();
119 else
120 strokeMaterial = new FlatMaterial();
121
122 if (strokeMaterial)
123 {
124 strokeMaterial.init( this.getWorld() );
125 if(this._strokeColor)
126 {
127 strokeMaterial.setProperty("color", this._strokeColor);
128 }
129 }
130
131 this._materialArray.push( strokeMaterial );
132 this._materialTypeArray.push( "stroke" );
133
134 return strokeMaterial;
135 }
136
137 this.makeFillMaterial = function()
138 {
139 var fillMaterial;
140 if (this.getFillMaterial())
141 fillMaterial = this.getFillMaterial().dup();
142 else
143 fillMaterial = new FlatMaterial();
144
145 if (fillMaterial)
146 {
147 fillMaterial.init( this.getWorld() );
148 //if(!this.getFillMaterial() && this._fillColor)
149 if (this._fillColor)
150 {
151 fillMaterial.setProperty("color", this._fillColor);
152 }
153 }
154
155 this._materialArray.push( fillMaterial );
156 this._materialTypeArray.push( "fill" );
157
158 return fillMaterial;
159 }
160
110 161
111 this.translate = function(v) 162 this.translate = function(v)
112 { 163 {
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index 9eaa69d1..bd3cbc26 100644
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -27,12 +27,6 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
27 27
28 this._strokeWidth = 0.25; 28 this._strokeWidth = 0.25;
29 29
30 // stroke colors
31 this._strokeColor = [0.4, 0.4, 0.4, 1.0];
32
33 // stroke materials
34 this._strokeMaterial;
35
36 this._strokeStyle = "Solid"; 30 this._strokeStyle = "Solid";
37