diff options
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-x | js/lib/geom/geom-obj.js | 451 |
1 files changed, 235 insertions, 216 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index f285f24a..2cde8a75 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -1,30 +1,10 @@ | |||
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 | var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial; | ||
9 | var LinearGradientMaterial = require("js/lib/rdge/materials/linear-gradient-material").LinearGradientMaterial; | ||
10 | var RadialGradientMaterial = require("js/lib/rdge/materials/radial-gradient-material").RadialGradientMaterial; | ||
11 | var BumpMetalMaterial = require("js/lib/rdge/materials/bump-metal-material").BumpMetalMaterial; | ||
12 | var UberMaterial = require("js/lib/rdge/materials/uber-material").UberMaterial; | ||
13 | var RadialBlurMaterial = require("js/lib/rdge/materials/radial-blur-material").RadialBlurMaterial; | ||
14 | var PlasmaMaterial = require("js/lib/rdge/materials/plasma-material").PlasmaMaterial; | ||
15 | var PulseMaterial = require("js/lib/rdge/materials/pulse-material").PulseMaterial; | ||
16 | var TunnelMaterial = require("js/lib/rdge/materials/tunnel-material").TunnelMaterial; | ||
17 | var ReliefTunnelMaterial = require("js/lib/rdge/materials/relief-tunnel-material").ReliefTunnelMaterial; | ||
18 | var SquareTunnelMaterial = require("js/lib/rdge/materials/square-tunnel-material").SquareTunnelMaterial; | ||
19 | var FlyMaterial = require("js/lib/rdge/materials/fly-material").FlyMaterial; | ||
20 | var WaterMaterial = require("js/lib/rdge/materials/water-material").WaterMaterial; | ||
21 | var ZInvertMaterial = require("js/lib/rdge/materials/z-invert-material").ZInvertMaterial; | ||
22 | var DeformMaterial = require("js/lib/rdge/materials/deform-material").DeformMaterial; | ||
23 | var StarMaterial = require("js/lib/rdge/materials/star-material").StarMaterial; | ||
24 | var TwistMaterial = require("js/lib/rdge/materials/twist-material").TwistMaterial; | ||
25 | var JuliaMaterial = require("js/lib/rdge/materials/julia-material").JuliaMaterial; | ||
26 | var KeleidoscopeMaterial = require("js/lib/rdge/materials/keleidoscope-material").KeleidoscopeMaterial; | ||
27 | var MandelMaterial = require("js/lib/rdge/materials/mandel-material").MandelMaterial; | ||
28 | 8 | ||
29 | /////////////////////////////////////////////////////////////////////// | 9 | /////////////////////////////////////////////////////////////////////// |
30 | // Class GLGeomObj | 10 | // Class GLGeomObj |
@@ -34,18 +14,19 @@ var GeomObj = function GLGeomObj() { | |||
34 | /////////////////////////////////////////////////////////////////////// | 14 | /////////////////////////////////////////////////////////////////////// |
35 | // Constants | 15 | // Constants |
36 | /////////////////////////////////////////////////////////////////////// | 16 | /////////////////////////////////////////////////////////////////////// |
37 | this.GEOM_TYPE_RECTANGLE = 1; | 17 | this.GEOM_TYPE_RECTANGLE = 1; |
38 | this.GEOM_TYPE_CIRCLE = 2; | 18 | this.GEOM_TYPE_CIRCLE = 2; |
39 | this.GEOM_TYPE_LINE = 3; | 19 | this.GEOM_TYPE_LINE = 3; |
40 | this.GEOM_TYPE_PATH = 4; | 20 | this.GEOM_TYPE_PATH = 4; |
41 | this.GEOM_TYPE_CUBIC_BEZIER = 5; | 21 | this.GEOM_TYPE_CUBIC_BEZIER = 5; |
42 | this.GEOM_TYPE_UNDEFINED = -1; | 22 | this.GEOM_TYPE_BRUSH_STROKE = 6; |
23 | this.GEOM_TYPE_UNDEFINED = -1; | ||
43 | 24 | ||
44 | // Needed for calculating dashed/dotted strokes | 25 | // Needed for calculating dashed/dotted strokes |
45 | this.DASH_LENGTH = 0.15; | 26 | this.DASH_LENGTH = 0.15; |
46 | this.DOT_LENGTH = 0.05; | 27 | this.DOT_LENGTH = 0.05; |
47 | this.GAP_LENGTH = 0.05; | 28 | this.GAP_LENGTH = 0.05; |
48 | 29 | ||
49 | /////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////// |
50 | // Instance variables | 31 | // Instance variables |
51 | /////////////////////////////////////////////////////////////////////// | 32 | /////////////////////////////////////////////////////////////////////// |
@@ -59,191 +40,213 @@ var GeomObj = function GLGeomObj() { | |||
59 | this.m_world = null; | 40 | this.m_world = null; |
60 | 41 | ||
61 | // stroke and fill colors | 42 | // stroke and fill colors |
62 | this._strokeColor = [0,0,0,0]; | 43 | this._strokeColor = [0, 0, 0, 0]; |
63 | this._fillColor = [0,0,0,0]; | 44 | this._fillColor = [0, 0, 0, 0]; |
64 | 45 | ||
65 | // stroke and fill materials | 46 | // stroke and fill materials |
66 | this._fillMaterial = null; | 47 | this._fillMaterial = null; |
67 | this._strokeMaterial = null; | 48 | this._strokeMaterial = null; |
68 | 49 | ||
69 | // array of primitives - used in RDGE | 50 | // array of primitives - used in RDGE |
70 | this._primArray = []; | 51 | this._primArray = []; |
71 | this._materialNodeArray = []; | 52 | this._materialNodeArray = []; |
72 | this._materialArray = []; | 53 | this._materialArray = []; |
73 | this._materialTypeArray = []; | 54 | this._materialTypeArray = []; |
74 | 55 | ||
75 | // the transform node used by RDGE | 56 | // the transform node used by RDGE |
76 | this._trNode = null; | 57 | this._trNode = null; |
77 | 58 | ||
78 | /////////////////////////////////////////////////////////////////////// | 59 | /////////////////////////////////////////////////////////////////////// |
79 | // Property accessors | 60 | // Property accessors |
80 | /////////////////////////////////////////////////////////////////////// | 61 | /////////////////////////////////////////////////////////////////////// |
81 | this.setWorld = function( world ) { | 62 | this.setWorld = function (world) { |
82 | this.m_world = world; | 63 | this.m_world = world; |
83 | }; | 64 | }; |
84 | 65 | ||
85 | this.getWorld = function() { | 66 | this.getWorld = function () { |
86 | return this.m_world; | 67 | return this.m_world; |
87 | }; | 68 | }; |
88 | 69 | ||
89 | this.getMatrix = function() { | 70 | this.getMatrix = function () { |
90 | return this._matrix.slice(0); | 71 | return this._matrix.slice(0); |
91 | }; | 72 | }; |
92 | 73 | ||
93 | this.setMatrix = function(m) { | 74 | this.setMatrix = function (m) { |
94 | this._matrix = m.slice(0); | 75 | this._matrix = m.slice(0); |
95 | }; | 76 | }; |
96 | 77 | ||
97 | this.setNext = function( next ) { | 78 | this.setNext = function (next) { |
98 | this._next = next; | 79 | this._next = next; |
99 | }; | 80 | }; |
100 | 81 | ||
101 | this.getNext = function() { | 82 | this.getNext = function () { |
102 | return this._next; | 83 | return this._next; |
103 | }; | 84 | }; |
104 | 85 | ||
105 | this.setPrev = function( prev ) { | 86 | this.setPrev = function (prev) { |
106 | this._prev = prev; | 87 | this._prev = prev; |
107 | }; | 88 | }; |
108 | 89 | ||
109 | this.getPrev = function() { | 90 | this.getPrev = function () { |
110 | return this._prev; | 91 | return this._prev; |
111 | }; | 92 | }; |
112 | 93 | ||
113 | this.setChild = function( child ) { | 94 | this.setChild = function (child) { |
114 | this._child = child; | 95 | this._child = child; |
115 | }; | 96 | }; |
116 | 97 | ||
117 | this.getChild = function() { | 98 | this.getChild = function () { |
118 | return this._child; | 99 | return this._child; |
119 | }; | 100 | }; |
120 | 101 | ||
121 | this.setParent = function( parent ) { | 102 | this.setParent = function (parent) { |
122 | this._parent = parent; | 103 | this._parent = parent; |
123 | }; | 104 | }; |
124 | 105 | ||
125 | this.getParent = function() { | 106 | this.getParent = function () { |
126 | return this._parent; | 107 | return this._parent; |
127 | }; | 108 | }; |
128 | 109 | ||
129 | this.geomType = function() { | 110 | this.geomType = function () { |
130 | return this.GEOM_TYPE_UNDEFINED; | 111 | return this.GEOM_TYPE_UNDEFINED; |
131 | }; | 112 | }; |
132 | 113 | ||
133 | this.getPrimitiveArray = function() { return this._primArray; | 114 | this.getPrimitiveArray = function () { |
115 | return this._primArray; | ||
134 | }; | 116 | }; |
135 | 117 | ||
136 | this.getMaterialNodeArray = function() { | 118 | this.getMaterialNodeArray = function () { |
137 | return this._materialNodeArray; | 119 | return this._materialNodeArray; |
138 | }; | 120 | }; |
139 | 121 | ||
140 | this.getMaterialArray = function() { return this._materialArray; | 122 | this.getMaterialArray = function () { |
123 | return this._materialArray; | ||
141 | }; | 124 | }; |
142 | 125 | ||
143 | this.getTransformNode = function() { | 126 | this.getTransformNode = function () { |
144 | return this._trNode; | 127 | return this._trNode; |
145 | }; | 128 | }; |
146 | 129 | ||
147 | this.setTransformNode = function(t) { | 130 | this.setTransformNode = function (t) { |
148 | this._trNode = t; | 131 | this._trNode = t; |
149 | }; | 132 | }; |
150 | 133 | ||
151 | this.setFillColor = function(c) { | 134 | this.setFillColor = function (c) { |
152 | this.setMaterialColor(c, "fill"); | 135 | this.setMaterialColor(c, "fill"); |
153 | }; | 136 | }; |
154 | 137 | ||
155 | this.setStrokeColor = function(c) { | 138 | this.setStrokeColor = function (c) { |
156 | this.setMaterialColor(c, "stroke"); | 139 | this.setMaterialColor(c, "stroke"); |
157 | }; | 140 | }; |
158 | /////////////////////////////////////////////////////////////////////// | 141 | /////////////////////////////////////////////////////////////////////// |
159 | // Methods | 142 | // Methods |
160 | /////////////////////////////////////////////////////////////////////// | 143 | /////////////////////////////////////////////////////////////////////// |
161 | this.setMaterialColor = function(c, type) { | 144 | this.setMaterialColor = function (c, type) { |
162 | var i = 0, | 145 | var i = 0, |
163 | nMats = 0; | 146 | nMats = 0; |
164 | if(c.gradientMode) { | 147 | if (c) { |
165 | // Gradient support | 148 | if (c.gradientMode) { |
166 | if (this._materialArray && this._materialTypeArray) { | 149 | // Gradient support |
167 | nMats = this._materialArray.length; | 150 | if (this._materialArray && this._materialTypeArray) { |
168 | } | 151 | nMats = this._materialArray.length; |
169 | 152 | } | |
170 | var stops = [], | ||
171 | colors = c.color; | ||
172 | 153 | ||
173 | var len = colors.length; | 154 | var stops = [], |
174 | // TODO - Curren |