diff options
author | Valerio Virgillito | 2012-02-08 10:18:36 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-08 10:18:36 -0800 |
commit | 763910b9d074137eb7dee80447b89407ce5750c9 (patch) | |
tree | 3c8820a06afd442fa5ba8e68665a4d2836230628 /js/helper-classes/RDGE/GLRectangle.js | |
parent | e5579374ff39b80b8c0c69faba37f6f581758fe0 (diff) | |
parent | 329a859e2666716c3a1d99c6bd2679e10c81fc8d (diff) | |
download | ninja-763910b9d074137eb7dee80447b89407ce5750c9.tar.gz |
Merge pull request #20 from mqg734/ToolFixes
Hooked up materials code to go through the ShapesController and updated the PI to reflect the currently selected shape's materials. Also fixed the following bugs:
Diffstat (limited to 'js/helper-classes/RDGE/GLRectangle.js')
-rw-r--r-- | js/helper-classes/RDGE/GLRectangle.js | 65 |
1 files changed, 5 insertions, 60 deletions
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 1334d7e6..8535a683 100644 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -33,14 +33,6 @@ function GLRectangle() | |||
33 | 33 | ||
34 | this._strokeWidth = 0.25; | 34 | this._strokeWidth = 0.25; |
35 | 35 | ||
36 | // stroke and fill colors | ||
37 | this._strokeColor; | ||
38 | this._fillColor; | ||
39 | |||
40 | // stroke and fill materials | ||
41 | this._fillMaterial; | ||
42 | this._strokeMaterial; | ||
43 | |||
44 | this._strokeStyle = "Solid"; | 36 | this._strokeStyle = "Solid"; |
45 | this.init = function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, | 37 | this.init = function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, |
46 | tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle) | 38 | tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle) |
@@ -279,8 +271,8 @@ function GLRectangle() | |||
279 | 271 | ||
280 | // stroke | 272 | // stroke |
281 | var strokeMaterial = this.makeStrokeMaterial(); | 273 | var strokeMaterial = this.makeStrokeMaterial(); |
282 | prim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial) | 274 | var strokePrim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial); |
283 | this._primArray.push( prim ); | 275 | this._primArray.push( strokePrim ); |
284 | this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); | 276 | this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); |
285 | 277 | ||
286 | // fill | 278 | // fill |
@@ -291,60 +283,13 @@ function GLRectangle() | |||
291 | xFill -= strokeSize; | 283 | xFill -= strokeSize; |
292 | yFill -= strokeSize; | 284 | yFill -= strokeSize; |
293 | var fillMaterial = this.makeFillMaterial(); | 285 | var fillMaterial = this.makeFillMaterial(); |
294 | prim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial) | 286 | var fillPrim = this.createFill([x,y], 2*xFill, 2*yFill, tlRadius, blRadius, brRadius, trRadius, fillMaterial); |
295 | this._primArray.push( prim ); | 287 | this._primArray.push( fillPrim ); |
296 | this._materialNodeArray.push( fillMaterial.getMaterialNode() ); | 288 | this._materialNodeArray.push( fillMaterial.getMaterialNode() ); |
297 | 289 | ||
298 | world.updateObject(this); | 290 | world.updateObject(this); |
299 | } | 291 | } |
300 | 292 | ||
301 | this.makeStrokeMaterial = function() | ||
302 | { | ||
303 | var strokeMaterial; | ||
304 | if (this.getStrokeMaterial()) | ||
305 | strokeMaterial = this.getStrokeMaterial().dup(); | ||
306 | else | ||
307 | strokeMaterial = new FlatMaterial(); | ||
308 | |||
309 | if (strokeMaterial) | ||
310 | { | ||
311 | strokeMaterial.init( this.getWorld() ); | ||
312 | if(this._strokeColor) | ||
313 | { | ||
314 | strokeMaterial.setProperty("color", this._strokeColor); | ||
315 | } | ||
316 | } | ||
317 | |||
318 | this._materialArray.push( strokeMaterial ); | ||
319 | this._materialTypeArray.push( "stroke" ); | ||
320 | |||
321 | return strokeMaterial; | ||
322 | } | ||
323 | |||
324 | this.makeFillMaterial = function() | ||
325 | { | ||
326 | var fillMaterial; | ||
327 | if (this.getFillMaterial()) | ||
328 | fillMaterial = this.getFillMaterial().dup(); | ||
329 | else | ||
330 | fillMaterial = new FlatMaterial(); | ||
331 | |||
332 | if (fillMaterial) | ||
333 | { | ||
334 | fillMaterial.init( this.getWorld() ); | ||
335 | //if(!this.getFillMaterial() && this._fillColor) | ||
336 | if (this._fillColor) | ||
337 | { | ||
338 | fillMaterial.setProperty("color", this._fillColor); | ||
339 | } | ||
340 | } | ||
341 | |||
342 | this._materialArray.push( fillMaterial ); | ||
343 | this._materialTypeArray.push( "fill" ); | ||
344 | |||
345 | return fillMaterial; | ||
346 | } | ||
347 | |||
348 | this.renderQuadraticBezier = function( bPts, ctx ) | 293 | this.renderQuadraticBezier = function( bPts, ctx ) |
349 | { | 294 | { |
350 | if (!bPts) return; | 295 | if (!bPts) return; |
@@ -1217,7 +1162,7 @@ ShapePrimitive.create = function(coords, normals, uvs, indices, primType, ver | |||
1217 | "a_normal":{'type':renderer.VS_ELEMENT_FLOAT3, 'bufferIndex':1, 'bufferUsage': renderer.BUFFER_STATIC}, | 1162 | "a_normal":{'type':renderer.VS_ELEMENT_FLOAT3, 'bufferIndex':1, 'bufferUsage': renderer.BUFFER_STATIC}, |
1218 | 1163 | ||
1219 | "texcoord":{'type':renderer.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': renderer.BUFFER_STATIC}, | 1164 | "texcoord":{'type':renderer.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': renderer.BUFFER_STATIC}, |
1220 | "a_texcoord":{'type':renderer.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': renderer.BUFFER_STATIC}, | 1165 | "a_texcoord":{'type':renderer.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': renderer.BUFFER_STATIC} |
1221 | }; | 1166 | }; |
1222 | 1167 | ||
1223 | 1168 | ||