diff options
author | Jon Reid | 2012-04-05 16:36:22 -0700 |
---|---|---|
committer | Jon Reid | 2012-04-05 16:36:22 -0700 |
commit | eb694fa5d39733264bce7ba832aabbe9c3d6c81e (patch) | |
tree | 049aaa66a6621e9f54b33b9861f50c20667ba0e3 /js/lib/geom/geom-obj.js | |
parent | a8ea8f377919c7f1a6af69311f55fd57727d9058 (diff) | |
parent | e186c49247689b5c2df6125037e2473636701d17 (diff) | |
download | ninja-eb694fa5d39733264bce7ba832aabbe9c3d6c81e.tar.gz |
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-x | js/lib/geom/geom-obj.js | 442 |
1 files changed, 181 insertions, 261 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index f1aa9f8a..bb5b4a9a 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -14,19 +14,19 @@ var GeomObj = function GLGeomObj() { | |||
14 | /////////////////////////////////////////////////////////////////////// | 14 | /////////////////////////////////////////////////////////////////////// |
15 | // Constants | 15 | // Constants |
16 | /////////////////////////////////////////////////////////////////////// | 16 | /////////////////////////////////////////////////////////////////////// |
17 | this.GEOM_TYPE_RECTANGLE = 1; | 17 | this.GEOM_TYPE_RECTANGLE = 1; |
18 | this.GEOM_TYPE_CIRCLE = 2; | 18 | this.GEOM_TYPE_CIRCLE = 2; |
19 | this.GEOM_TYPE_LINE = 3; | 19 | this.GEOM_TYPE_LINE = 3; |
20 | this.GEOM_TYPE_PATH = 4; | 20 | this.GEOM_TYPE_PATH = 4; |
21 | this.GEOM_TYPE_CUBIC_BEZIER = 5; | 21 | this.GEOM_TYPE_CUBIC_BEZIER = 5; |
22 | this.GEOM_TYPE_BRUSH_STROKE = 6; | 22 | this.GEOM_TYPE_BRUSH_STROKE = 6; |
23 | this.GEOM_TYPE_UNDEFINED = -1; | 23 | this.GEOM_TYPE_UNDEFINED = -1; |
24 | 24 | ||
25 | // Needed for calculating dashed/dotted strokes | 25 | // Needed for calculating dashed/dotted strokes |
26 | this.DASH_LENGTH = 0.15; | 26 | this.DASH_LENGTH = 0.15; |
27 | this.DOT_LENGTH = 0.05; | 27 | this.DOT_LENGTH = 0.05; |
28 | this.GAP_LENGTH = 0.05; | 28 | this.GAP_LENGTH = 0.05; |
29 | 29 | ||
30 | /////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////// |
31 | // Instance variables | 31 | // Instance variables |
32 | /////////////////////////////////////////////////////////////////////// | 32 | /////////////////////////////////////////////////////////////////////// |
@@ -40,109 +40,111 @@ var GeomObj = function GLGeomObj() { | |||
40 | this.m_world = null; | 40 | this.m_world = null; |
41 | 41 | ||
42 | // stroke and fill colors | 42 | // stroke and fill colors |
43 | this._strokeColor = [0,0,0,0]; | 43 | this._strokeColor = [0, 0, 0, 0]; |
44 | this._fillColor = [0,0,0,0]; | 44 | this._fillColor = [0, 0, 0, 0]; |
45 | 45 | ||
46 | // stroke and fill materials | 46 | // stroke and fill materials |
47 | this._fillMaterial = null; | 47 | this._fillMaterial = null; |
48 | this._strokeMaterial = null; | 48 | this._strokeMaterial = null; |
49 | 49 | ||
50 | // array of primitives - used in RDGE | 50 | // array of primitives - used in RDGE |
51 | this._primArray = []; | 51 | this._primArray = []; |
52 | this._materialNodeArray = []; | 52 | this._materialNodeArray = []; |
53 | this._materialArray = []; | 53 | this._materialArray = []; |
54 | this._materialTypeArray = []; | 54 | this._materialTypeArray = []; |
55 | 55 | ||
56 | // the transform node used by RDGE | 56 | // the transform node used by RDGE |
57 | this._trNode = null; | 57 | this._trNode = null; |
58 | 58 | ||
59 | /////////////////////////////////////////////////////////////////////// | 59 | /////////////////////////////////////////////////////////////////////// |
60 | // Property accessors | 60 | // Property accessors |
61 | /////////////////////////////////////////////////////////////////////// | 61 | /////////////////////////////////////////////////////////////////////// |
62 | this.setWorld = function( world ) { | 62 | this.setWorld = function (world) { |
63 | this.m_world = world; | 63 | this.m_world = world; |
64 | }; | 64 | }; |
65 | 65 | ||
66 | this.getWorld = function() { | 66 | this.getWorld = function () { |
67 | return this.m_world; | 67 | return this.m_world; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | this.getMatrix = function() { | 70 | this.getMatrix = function () { |
71 | return this._matrix.slice(0); | 71 | return this._matrix.slice(0); |
72 | }; | 72 | }; |
73 | 73 | ||
74 | this.setMatrix = function(m) { | 74 | this.setMatrix = function (m) { |
75 | this._matrix = m.slice(0); | 75 | this._matrix = m.slice(0); |
76 | }; | 76 | }; |
77 | 77 | ||
78 | this.setNext = function( next ) { | 78 | this.setNext = function (next) { |
79 | this._next = next; | 79 | this._next = next; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | this.getNext = function() { | 82 | this.getNext = function () { |
83 | return this._next; | 83 | return this._next; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | this.setPrev = function( prev ) { | 86 | this.setPrev = function (prev) { |
87 | this._prev = prev; | 87 | this._prev = prev; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | this.getPrev = function() { | 90 | this.getPrev = function () { |
91 | return this._prev; | 91 | return this._prev; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | this.setChild = function( child ) { | 94 | this.setChild = function (child) { |
95 | this._child = child; | 95 | this._child = child; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | this.getChild = function() { | 98 | this.getChild = function () { |
99 | return this._child; | 99 | return this._child; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | this.setParent = function( parent ) { | 102 | this.setParent = function (parent) { |
103 | this._parent = parent; | 103 | this._parent = parent; |
104 | }; | 104 | }; |
105 | 105 | ||
106 | this.getParent = function() { | 106 | this.getParent = function () { |
107 | return this._parent; | 107 | return this._parent; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | this.geomType = function() { | 110 | this.geomType = function () { |
111 | return this.GEOM_TYPE_UNDEFINED; | 111 | return this.GEOM_TYPE_UNDEFINED; |
112 | }; | 112 | }; |
113 | 113 | ||
114 | this.getPrimitiveArray = function() { return this._primArray; | 114 | this.getPrimitiveArray = function () { |
115 | return this._primArray; | ||
115 | }; | 116 | }; |
116 | 117 | ||
117 | this.getMaterialNodeArray = function() { | 118 | this.getMaterialNodeArray = function () { |
118 | return this._materialNodeArray; | 119 | return this._materialNodeArray; |
119 | }; | 120 | }; |
120 | 121 | ||
121 | this.getMaterialArray = function() { return this._materialArray; | 122 | this.getMaterialArray = function () { |
123 | return this._materialArray; | ||
122 | }; | 124 | }; |
123 | 125 | ||
124 | this.getTransformNode = function() { | 126 | this.getTransformNode = function () { |
125 | return this._trNode; | 127 | return this._trNode; |
126 | }; | 128 | }; |
127 | 129 | ||
128 | this.setTransformNode = function(t) { | 130 | this.setTransformNode = function (t) { |
129 | this._trNode = t; | 131 | this._trNode = t; |
130 | }; | 132 | }; |
131 | 133 | ||
132 | this.setFillColor = function(c) { | 134 | this.setFillColor = function (c) { |
133 | this.setMaterialColor(c, "fill"); | 135 | this.setMaterialColor(c, "fill"); |
134 | }; | 136 | }; |
135 | 137 | ||
136 | this.setStrokeColor = function(c) { | 138 | this.setStrokeColor = function (c) { |
137 | this.setMaterialColor(c, "stroke"); | 139 | this.setMaterialColor(c, "stroke"); |
138 | }; | 140 | }; |
139 | /////////////////////////////////////////////////////////////////////// | 141 | /////////////////////////////////////////////////////////////////////// |
140 | // Methods | 142 | // Methods |
141 | /////////////////////////////////////////////////////////////////////// | 143 | /////////////////////////////////////////////////////////////////////// |
142 | this.setMaterialColor = function(c, type) { | 144 | this.setMaterialColor = function (c, type) { |
143 | var i = 0, | 145 | var i = 0, |
144 | nMats = 0; | 146 | nMats = 0; |
145 | if(c.gradientMode) { | 147 | if (c.gradientMode) { |
146 | // Gradient support | 148 | // Gradient support |
147 | if (this._materialArray && this._materialTypeArray) { | 149 | if (this._materialArray && this._materialTypeArray) { |
148 | nMats = this._materialArray.length; | 150 | nMats = this._materialArray.length; |
@@ -153,21 +155,21 @@ var GeomObj = function GLGeomObj() { | |||
153 | 155 | ||
154 | var len = colors.length; | 156 | var len = colors.length; |
155 | // TODO - Current shaders only support 4 color stops | 157 | // TODO - Current shaders only support 4 color stops |
156 | if(len > 4) { | 158 | if (len > 4) { |
157 | len = 4; | 159 | len = 4; |
158 | } | 160 | } |
159 | 161 | ||
160 | for(var n=0; n<len; n++) { | 162 | for (var n = 0; n < len; n++) { |
161 | var position = colors[n].position/100; | 163 | var position = colors[n].position / 100; |
162 | var cs = colors[n].value; | 164 | var cs = colors[n].value; |
163 | var stop = [cs.r/255, cs.g/255, cs.b/255, cs.a]; | 165 | var stop = [cs.r / 255, cs.g / 255, cs.b / 255, cs.a]; |
164 | stops.push(stop); | 166 | stops.push(stop); |
165 | 167 | ||
166 | if (nMats === this._materialTypeArray.length) { | 168 | if (nMats === this._materialTypeArray.length) { |
167 | for (i=0; i<nMats; i++) { | 169 | for (i = 0; i < nMats; i++) { |
168 | if (this._materialTypeArray[i] == type) { | 170 | if (this._materialTypeArray[i] == type) { |
169 | this._materialArray[i].setProperty( "color"+(n+1), stop.slice(0) ); | 171 | this._materialArray[i].setProperty("color" + (n + 1), stop.slice(0)); |
170 | this._materialArray[i].setProperty( "colorStop"+(n+1), position ); | 172 | this._materialArray[i].setProperty("colorStop" + (n + 1), position); |
171 | } | 173 | } |
172 | } | 174 | } |
173 | } | 175 | } |
@@ -187,44 +189,44 @@ var GeomObj = function GLGeomObj() { | |||
187 | if (this._materialArray && this._materialTypeArray) { | 189 | if (this._materialArr |