diff options
author | Valerio Virgillito | 2012-07-09 14:16:17 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-09 14:18:36 -0700 |
commit | 1bbba17e8605434356de0a477710d6a0136986fc (patch) | |
tree | 7cdc80226b776c6fb2250e250acdbcd53fdb1ddd /js | |
parent | dc5b7a479a185dda8e9a09f4bbe26bd290641624 (diff) | |
parent | ab80aa9c7da912db384ec48c656f84fd673b5253 (diff) | |
download | ninja-1bbba17e8605434356de0a477710d6a0136986fc.tar.gz |
Merge branch 'Taper' of https://github.com/ericmueller/ninja-internal
Conflicts:
js/lib/geom/circle.js
js/lib/rdge/materials/linear-gradient-material.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js')
28 files changed, 1522 insertions, 874 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 26f33a64..2b76161f 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js | |||
@@ -466,6 +466,7 @@ World.prototype.updateObject = function (obj) { | |||
466 | if (prims.length != materialNodes.length) | 466 | if (prims.length != materialNodes.length) |
467 | throw new Error("inconsistent material and primitive counts"); | 467 | throw new Error("inconsistent material and primitive counts"); |
468 | var nPrims = prims.length; | 468 | var nPrims = prims.length; |
469 | var iPrim = 0; | ||
469 | var ctrTrNode; | 470 | var ctrTrNode; |
470 | if (nPrims > 0) | 471 | if (nPrims > 0) |
471 | { | 472 | { |
@@ -483,8 +484,12 @@ World.prototype.updateObject = function (obj) { | |||
483 | ); | 484 | ); |
484 | ctrTrNode.meshes = []; | 485 | ctrTrNode.meshes = []; |
485 | 486 | ||
486 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); | ||
487 | ctrTrNode.attachMaterial(materialNodes[0]); | 487 | ctrTrNode.attachMaterial(materialNodes[0]); |
488 | while ((iPrim < nPrims) && (materialNodes[iPrim] == materialNodes[0])) | ||
489 | { | ||
490 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); | ||
491 | iPrim++; | ||
492 | } | ||
488 | } | 493 | } |
489 | 494 | ||
490 | // delete all of the child nodes | 495 | // delete all of the child nodes |
@@ -505,16 +510,18 @@ World.prototype.updateObject = function (obj) { | |||
505 | } | 510 | } |
506 | ctrTrNode.children = []; | 511 | ctrTrNode.children = []; |
507 | 512 | ||
508 | for (var i = 1; i < nPrims; i++) | 513 | while (iPrim < nPrims) |
509 | { | 514 | { |
510 | // get the next primitive | ||
511 | childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); | 515 | childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); |
512 | ctrTrNode.insertAsChild(childTrNode); | 516 | ctrTrNode.insertAsChild(childTrNode); |
517 | var matNode = materialNodes[iPrim]; | ||
518 | childTrNode.attachMaterial(matNode); | ||
513 | 519 | ||
514 | // attach the instanced box goe | 520 | while ((iPrim < nPrims) && (materialNodes[iPrim] == matNode)) |
515 | var prim = prims[i]; | 521 | { |
516 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); | 522 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]); |
517 | childTrNode.attachMaterial(materialNodes[i]); | 523 | iPrim++; |
524 | } | ||
518 | } | 525 | } |
519 | 526 | ||
520 | // send a notification that the tree has changed | 527 | // send a notification that the tree has changed |
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index 12781ab8..2cd5a21f 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js | |||
@@ -42,49 +42,49 @@ var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; | |||
42 | /////////////////////////////////////////////////////////////////////// | 42 | /////////////////////////////////////////////////////////////////////// |
43 | exports.Circle = Object.create(GeomObj, { | 43 | exports.Circle = Object.create(GeomObj, { |
44 | 44 | ||
45 | /////////////////////////////////////////////////////////////////////// | 45 | /////////////////////////////////////////////////////////////////////// |
46 | // Instance variables | 46 | // Instance variables |
47 | /////////////////////////////////////////////////////////////////////// | 47 | /////////////////////////////////////////////////////////////////////// |
48 | _width: { value : 2.0, writable: true }, | 48 | _width: { value : 2.0, writable: true }, |
49 | _height: { value : 2.0, writable: true }, | 49 | _height: { value : 2.0, writable: true }, |
50 | _xOffset: { value : 0, writable: true }, | 50 | _xOffset: { value : 0, writable: true }, |
51 | _yOffset: { value : 0, writable: true }, | 51 | _yOffset: { value : 0, writable: true }, |
52 | 52 | ||
53 | _radius: { value : 2.0, writable: true }, | 53 | _radius: { value : 2.0, writable: true }, |
54 | _strokeWidth: { value : 0.25, writable: true }, | 54 | _strokeWidth: { value : 0.25, writable: true }, |
55 | _innerRadius: { value : 0, writable: true }, | 55 | _innerRadius: { value : 0, writable: true }, |
56 | _ovalHeight: { value : 4.0, writable: true }, | 56 | _ovalHeight: { value : 4.0, writable: true }, |
57 | _strokeStyle: { value : "Solid", writable: true }, | 57 | _strokeStyle: { value : "Solid", writable: true }, |
58 | _aspectRatio: { value : 1.0, writable: true }, | 58 | _aspectRatio: { value : 1.0, writable: true }, |
59 | 59 | ||
60 | init: { | 60 | init: { |
61 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { | 61 | value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { |
62 | if(arguments.length > 0) { | 62 | if(arguments.length > 0) { |
63 | this._width = width; | 63 | this._width = width; |
64 | this._height = height; | 64 | this._height = height; |
65 | this._xOffset = xOffset; | 65 | this._xOffset = xOffset; |
66 | this._yOffset = yOffset; | 66 | this._yOffset = yOffset; |
67 | this._ovalHeight = 2.0 * this._radius; | 67 | this._ovalHeight = 2.0 * this._radius; |
68 | 68 | ||
69 | this._strokeWidth = strokeSize; | 69 | this._strokeWidth = strokeSize; |
70 | this._innerRadius = innerRadius; | 70 | this._innerRadius = innerRadius; |
71 | this._strokeColor = strokeColor; | 71 | this._strokeColor = strokeColor; |
72 | this._fillColor = fillColor; | 72 | this._fillColor = fillColor; |
73 | 73 | ||
74 | this._strokeStyle = strokeStyle; | 74 | this._strokeStyle = strokeStyle; |
75 | 75 | ||
76 | this._matrix = Matrix.I(4); | 76 | this._matrix = Matrix.I(4); |
77 | //this._matrix[12] = xOffset; | 77 | //this._matrix[12] = xOffset; |
78 | //this._matrix[13] = yOffset; | 78 | //this._matrix[13] = yOffset; |
79 | } | 79 | } |
80 | 80 | ||
81 | this.m_world = world; | 81 | this.m_world = world; |
82 | 82 | ||
83 | if(strokeMaterial) { | 83 | if(strokeMaterial) { |
84 | this._strokeMaterial = strokeMaterial.dup(); | 84 | this._strokeMaterial = strokeMaterial.dup(); |
85 | } else { | 85 | } else { |
86 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 86 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
87 | } | 87 | } |
88 | 88 | ||
89 | if(strokeColor) { | 89 | if(strokeColor) { |
90 | if(this._strokeMaterial.hasProperty("color")) { | 90 | if(this._strokeMaterial.hasProperty("color")) { |
@@ -94,135 +94,135 @@ exports.Circle = Object.create(GeomObj, { | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | if(fillMaterial) { | 97 | if(fillMaterial) { |
98 | this._fillMaterial = fillMaterial.dup(); | 98 | this._fillMaterial = fillMaterial.dup(); |
99 | } else { | 99 | } else { |
100 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 100 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
101 | } | 101 | } |
102 | 102 | ||
103 | if(fillColor) { | 103 | if(fillColor) { |
104 | if(this._fillMaterial.hasProperty("color")) { | 104 | if(this._fillMaterial.hasProperty("color")) { |
105 | this._fillMaterial.setProperty( "color", this._fillColor ); | 105 | this._fillMaterial.setProperty( "color", this._fillColor ); |
106 | } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { | 106 | } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { |
107 | this._fillMaterial.setGradientData(this._fillColor.color); | 107 | this._fillMaterial.setGradientData(this._fillColor.color); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | } | 110 | } |
111 | }, | 111 | }, |
112 | 112 | ||
113 | /////////////////////////////////////////////////////////////////////// | 113 | /////////////////////////////////////////////////////////////////////// |
114 | // Property Accessors | 114 | // Property Accessors |
115 | /////////////////////////////////////////////////////////////////////// | 115 | /////////////////////////////////////////////////////////////////////// |
116 | // TODO - Use getters/setters in the future | 116 | // TODO - Use getters/setters in the future |
117 | getStrokeWidth: { | 117 | getStrokeWidth: { |
118 | value: function() { | 118 | value: function() { |
119 | return this._strokeWidth; | 119 | return this._strokeWidth; |
120 | } | 120 | } |
121 | }, | 121 | }, |
122 | 122 | ||
123 | setStrokeWidth: { | 123 | setStrokeWidth: { |
124 | value: function(w) { | 124 | value: function(w) { |
125 | this._strokeWidth = w; |