diff options
author | Ananya Sen | 2012-04-17 18:11:55 -0700 |
---|---|---|
committer | Ananya Sen | 2012-04-17 18:11:55 -0700 |
commit | 35abad196cc9feb76ef50c1b63032a38233a6d51 (patch) | |
tree | 914689c66d4ab6c6e088b571eade0a0e35082916 /js/lib/geom/geom-obj.js | |
parent | 1f891c58bad0b7746659aa4138001b5ee76d9a0e (diff) | |
parent | 616a8532099fec2a15855eac97cd85cb60c4451c (diff) | |
download | ninja-35abad196cc9feb76ef50c1b63032a38233a6d51.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-x | js/lib/geom/geom-obj.js | 533 |
1 files changed, 238 insertions, 295 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index f1aa9f8a..f2991bdb 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -1,8 +1,8 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | 2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> |
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | 7 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; |
8 | 8 | ||
@@ -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,191 +40,216 @@ 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 | |||
46 | // stroke and fill materials | ||
47 | this._fillMaterial = null; | ||
48 | this._strokeMaterial = null; | ||
45 | 49 | ||
46 | // stroke and fill materials | 50 | // Shapes (such as lines) that don't support fill should set this to false |
47 | this._fillMaterial = null; | 51 | this.canFill = true; |
48 | this._strokeMaterial = null; | ||
49 | 52 | ||
50 | // array of primitives - used in RDGE | 53 | // array of primitives - used in RDGE |
51 | this._primArray = []; | 54 | this._primArray = []; |
52 | this._materialNodeArray = []; | 55 | this._materialNodeArray = []; |
53 | this._materialArray = []; | 56 | this._materialArray = []; |
54 | this._materialTypeArray = []; | 57 | this._materialTypeArray = []; |
55 | 58 | ||
56 | // the transform node used by RDGE | 59 | // the transform node used by RDGE |
57 | this._trNode = null; | 60 | this._trNode = null; |
58 | 61 | ||
59 | /////////////////////////////////////////////////////////////////////// | 62 | /////////////////////////////////////////////////////////////////////// |
60 | // Property accessors | 63 | // Property accessors |
61 | /////////////////////////////////////////////////////////////////////// | 64 | /////////////////////////////////////////////////////////////////////// |
62 | this.setWorld = function( world ) { | 65 | this.setWorld = function (world) { |
63 | this.m_world = world; | 66 | this.m_world = world; |
64 | }; | 67 | }; |
65 | 68 | ||
66 | this.getWorld = function() { | 69 | this.getWorld = function () { |
67 | return this.m_world; | 70 | return this.m_world; |
68 | }; | 71 | }; |
69 | 72 | ||
70 | this.getMatrix = function() { | 73 | this.getMatrix = function () { |
71 | return this._matrix.slice(0); | 74 | return this._matrix.slice(0); |
72 | }; | 75 | }; |
73 | 76 | ||
74 | this.setMatrix = function(m) { | 77 | this.setMatrix = function (m) { |
75 | this._matrix = m.slice(0); | 78 | this._matrix = m.slice(0); |
76 | }; | 79 | }; |
77 | 80 | ||
78 | this.setNext = function( next ) { | 81 | this.setNext = function (next) { |
79 | this._next = next; | 82 | this._next = next; |
80 | }; | 83 | }; |
81 | 84 | ||
82 | this.getNext = function() { | 85 | this.getNext = function () { |
83 | return this._next; | 86 | return this._next; |
84 | }; | 87 | }; |
85 | 88 | ||
86 | this.setPrev = function( prev ) { | 89 | this.setPrev = function (prev) { |
87 | this._prev = prev; | 90 | this._prev = prev; |
88 | }; | 91 | }; |
89 | 92 | ||
90 | this.getPrev = function() { | 93 | this.getPrev = function () { |
91 | return this._prev; | 94 | return this._prev; |
92 | }; | 95 | }; |
93 | 96 | ||
94 | this.setChild = function( child ) { | 97 | this.setChild = function (child) { |
95 | this._child = child; | 98 | this._child = child; |
96 | }; | 99 | }; |
97 | 100 | ||
98 | this.getChild = function() { | 101 | this.getChild = function () { |
99 | return this._child; | 102 | return this._child; |
100 | }; | 103 | }; |
101 | 104 | ||
102 | this.setParent = function( parent ) { | 105 | this.setParent = function (parent) { |
103 | this._parent = parent; | 106 | this._parent = parent; |
104 | }; | 107 | }; |
105 | 108 | ||
106 | this.getParent = function() { | 109 | this.getParent = function () { |
107 | return this._parent; | 110 | return this._parent; |
108 | }; | 111 | }; |
109 | 112 | ||
110 | this.geomType = function() { | 113 | this.geomType = function () { |
111 | return this.GEOM_TYPE_UNDEFINED; | 114 | return this.GEOM_TYPE_UNDEFINED; |
112 | }; | 115 | }; |
113 | 116 | ||
114 | this.getPrimitiveArray = function() { return this._primArray; | 117 | this.getPrimitiveArray = function () { |
118 | return this._primArray; | ||
115 | }; | 119 | }; |
116 | 120 | ||
117 | this.getMaterialNodeArray = function() { | 121 | this.getMaterialNodeArray = function () { |
118 | return this._materialNodeArray; | 122 | return this._materialNodeArray; |
119 | }; | 123 | }; |
120 | 124 | ||
121 | this.getMaterialArray = function() { return this._materialArray; | 125 | this.getMaterialArray = function () { |
126 | return this._materialArray; | ||
122 | }; | 127 | }; |
123 | 128 | ||
124 | this.getTransformNode = function() { | 129 | this.getTransformNode = function () { |
125 | return this._trNode; | 130 | return this._trNode; |
126 | }; | 131 | }; |
127 | 132 | ||
128 | this.setTransformNode = function(t) { | 133 | this.setTransformNode = function (t) { |
129 | this._trNode = t; | 134 | this._trNode = t; |
130 | }; | 135 | }; |
131 | 136 | ||
132 | this.setFillColor = function(c) { | 137 | this.setFillColor = function (c) { |
133 | this.setMaterialColor(c, "fill"); | 138 | this.setMaterialColor(c, "fill"); |
134 | }; | 139 | }; |
135 | 140 | ||
136 | this.setStrokeColor = function(c) { | 141 | this.setStrokeColor = function (c) { |
137 | this.setMaterialColor(c, "stroke"); | 142 | this.setMaterialColor(c, "stroke"); |
138 | }; | 143 | }; |
139 | /////////////////////////////////////////////////////////////////////// | 144 | /////////////////////////////////////////////////////////////////////// |
140 | // Methods | 145 | // Methods |
141 | /////////////////////////////////////////////////////////////////////// | 146 | /////////////////////////////////////////////////////////////////////// |
142 | this.setMaterialColor = function(c, type) { | 147 | this.setMaterialColor = function (c, type) { |
143 | var i = 0, | 148 | var i = 0, |
144 | nMats = 0; | 149 | nMats = 0; |
145 | if(c.gradientMode) { | 150 | if (c) { |
146 | // Gradient support | 151 | if (c.gradientMode) { |
147 | if (this._materialArray && this._materialTypeArray) { | 152 | // Gradient support |
148 | nMats = this._materialArray.length; | 153 | if (this._materialArray && this._materialTypeArray) { |
149 | } | 154 | nMats = this._materialArray.length; |
150 | 155 | } | |
151 | var stops = [], | ||
152 | colors = c.color; | ||
153 | 156 | ||
154 | var len = colors.length; | 157 | var stops = [], |
155 | // TODO - Current shaders only support 4 color stops | 158 | colors = c.color; |
156 | if(len > 4) { | ||
157 | len = 4; | ||
158 | } | ||
159 | 159 | ||
160 | for(var n=0; n<len; n++) { | 160 | var len = colors.length; |
161 | var position = colors[n].position/100; | 161 | // TODO - Current shaders only support 4 color stops |
162 | var cs = colors[n].value; | 162 | if (len > 4) { |
163 | var stop =< |