diff options
author | hwc487 | 2012-04-19 13:01:43 -0700 |
---|---|---|
committer | hwc487 | 2012-04-19 13:01:43 -0700 |
commit | e6a20fe64574763483dc602bd759278ccf5e5e68 (patch) | |
tree | 69defe7200206f0257fe90697136fadef59d521e /js/lib/geom/geom-obj.js | |
parent | ae7eb87564632ce7c676bd728b8ff2710ff0bb83 (diff) | |
parent | 9284c19f076dec3b47ece7dc7bcd22d74e4246c3 (diff) | |
download | ninja-e6a20fe64574763483dc602bd759278ccf5e5e68.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts:
js/lib/drawing/world.js
js/lib/geom/geom-obj.js
js/lib/rdge/materials/cloud-material.js
js/lib/rdge/materials/deform-material.js
js/lib/rdge/materials/flat-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/relief-tunnel-material.js
js/lib/rdge/materials/square-tunnel-material.js
js/lib/rdge/materials/star-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/tunnel-material.js
js/lib/rdge/materials/twist-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/uber-material.js
js/lib/rdge/materials/water-material.js
js/lib/rdge/materials/z-invert-material.js
Diffstat (limited to 'js/lib/geom/geom-obj.js')
-rwxr-xr-x | js/lib/geom/geom-obj.js | 538 |
1 files changed, 259 insertions, 279 deletions
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 0c0d7c01..2f5559a7 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 | ||
@@ -10,22 +10,24 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel; | |||
10 | // Class GLGeomObj | 10 | // Class GLGeomObj |
11 | // Super class for all geometry classes | 11 | // Super class for all geometry classes |
12 | /////////////////////////////////////////////////////////////////////// | 12 | /////////////////////////////////////////////////////////////////////// |
13 | var GeomObj = function GLGeomObj() { | 13 | var GeomObj = function GLGeomObj() |
14 | { | ||
14 | /////////////////////////////////////////////////////////////////////// | 15 | /////////////////////////////////////////////////////////////////////// |
15 | // Constants | 16 | // Constants |
16 | /////////////////////////////////////////////////////////////////////// | 17 | /////////////////////////////////////////////////////////////////////// |
17 | this.GEOM_TYPE_RECTANGLE = 1; | 18 | this.GEOM_TYPE_RECTANGLE = 1; |
18 | this.GEOM_TYPE_CIRCLE = 2; | 19 | this.GEOM_TYPE_CIRCLE = 2; |
19 | this.GEOM_TYPE_LINE = 3; | 20 | this.GEOM_TYPE_LINE = 3; |
20 | this.GEOM_TYPE_PATH = 4; | 21 | this.GEOM_TYPE_PATH = 4; |
21 | this.GEOM_TYPE_CUBIC_BEZIER = 5; | 22 | this.GEOM_TYPE_CUBIC_BEZIER = 5; |
22 | this.GEOM_TYPE_UNDEFINED = -1; | 23 | this.GEOM_TYPE_BRUSH_STROKE = 6; |
24 | this.GEOM_TYPE_UNDEFINED = -1; | ||
23 | 25 | ||
24 | // Needed for calculating dashed/dotted strokes | 26 | // Needed for calculating dashed/dotted strokes |
25 | this.DASH_LENGTH = 0.15; | 27 | this.DASH_LENGTH = 0.15; |
26 | this.DOT_LENGTH = 0.05; | 28 | this.DOT_LENGTH = 0.05; |
27 | this.GAP_LENGTH = 0.05; | 29 | this.GAP_LENGTH = 0.05; |
28 | 30 | ||
29 | /////////////////////////////////////////////////////////////////////// | 31 | /////////////////////////////////////////////////////////////////////// |
30 | // Instance variables | 32 | // Instance variables |
31 | /////////////////////////////////////////////////////////////////////// | 33 | /////////////////////////////////////////////////////////////////////// |
@@ -39,184 +41,230 @@ var GeomObj = function GLGeomObj() { | |||
39 | this.m_world = null; | 41 | this.m_world = null; |
40 | 42 | ||
41 | // stroke and fill colors | 43 | // stroke and fill colors |
42 | this._strokeColor = [0,0,0,0]; | 44 | this._strokeColor = [0, 0, 0, 0]; |
43 | this._fillColor = [0,0,0,0]; | 45 | this._fillColor = [0, 0, 0, 0]; |
46 | |||
47 | // stroke and fill materials | ||
48 | this._fillMaterial = null; | ||
49 | this._strokeMaterial = null; | ||
44 | 50 | ||
45 | // stroke and fill materials | 51 | // Shapes (such as lines) that don't support fill should set this to false |
46 | this._fillMaterial = null; | 52 | this.canFill = true; |
47 | this._strokeMaterial = null; | ||
48 | 53 | ||
49 | // array of primitives - used in RDGE | 54 | // array of primitives - used in RDGE |
50 | this._primArray = []; | 55 | this._primArray = []; |
51 | this._materialNodeArray = []; | 56 | this._materialNodeArray = []; |
52 | this._materialArray = []; | 57 | this._materialArray = []; |
53 | this._materialTypeArray = []; | 58 | this._materialTypeArray = []; |
54 | 59 | ||
55 | // the transform node used by RDGE | 60 | // the transform node used by RDGE |
56 | this._trNode = null; | 61 | this._trNode = null; |
57 | 62 | ||
58 | /////////////////////////////////////////////////////////////////////// | 63 | /////////////////////////////////////////////////////////////////////// |
59 | // Property accessors | 64 | // Property accessors |
60 | /////////////////////////////////////////////////////////////////////// | 65 | /////////////////////////////////////////////////////////////////////// |
61 | this.setWorld = function( world ) { | 66 | this.setWorld = function (world) { |
62 | this.m_world = world; | 67 | this.m_world = world; |
63 | }; | 68 | }; |
64 | 69 | ||
65 | this.getWorld = function() { | 70 | this.getWorld = function () { |
66 | return this.m_world; | 71 | return this.m_world; |
67 | }; | 72 | }; |
68 | 73 | ||
69 | this.getMatrix = function() { | 74 | this.getMatrix = function () { |
70 | return this._matrix.slice(0); | 75 | return this._matrix.slice(0); |
71 | }; | 76 | }; |
72 | 77 | ||
73 | this.setMatrix = function(m) { | 78 | this.setMatrix = function (m) { |
74 | this._matrix = m.slice(0); | 79 | this._matrix = m.slice(0); |
75 | }; | 80 | }; |
76 | 81 | ||
77 | this.setNext = function( next ) { | 82 | this.setNext = function (next) { |
78 | this._next = next; | 83 | this._next = next; |
79 | }; | 84 | }; |
80 | 85 | ||
81 | this.getNext = function() { | 86 | this.getNext = function () { |
82 | return this._next; | 87 | return this._next; |
83 | }; | 88 | }; |
84 | 89 | ||
85 | this.setPrev = function( prev ) { | 90 | this.setPrev = function (prev) { |
86 | this._prev = prev; | 91 | this._prev = prev; |
87 | }; | 92 | }; |
88 | 93 | ||
89 | this.getPrev = function() { | 94 | this.getPrev = function () { |
90 | return this._prev; | 95 | return this._prev; |
91 | }; | 96 | }; |
92 | 97 | ||
93 | this.setChild = function( child ) { | 98 | this.setChild = function (child) { |
94 | this._child = child; | 99 | this._child = child; |
95 | }; | 100 | }; |
96 | 101 | ||
97 | this.getChild = function() { | 102 | this.getChild = function () { |
98 | return this._child; | 103 | return this._child; |
99 | }; | 104 | }; |
100 | 105 | ||
101 | this.setParent = function( parent ) { | 106 | this.setParent = function (parent) { |
102 | this._parent = parent; | 107 | this._parent = parent; |
103 | }; | 108 | }; |
104 | 109 | ||
105 | this.getParent = function() { | 110 | this.getParent = function () { |
106 | return this._parent; | 111 | return this._parent; |
107 | }; | 112 | }; |
108 | 113 | ||
109 | this.geomType = function() { | 114 | this.geomType = function () { |
110 | return this.GEOM_TYPE_UNDEFINED; | 115 | return this.GEOM_TYPE_UNDEFINED; |
111 | }; | 116 | }; |
112 | 117 | ||
113 | this.getPrimitiveArray = function() { return this._primArray; | 118 | this.getPrimitiveArray = function () { |
119 | return this._primArray; | ||
114 | }; | 120 | }; |
115 | 121 | ||
116 | this.getMaterialNodeArray = function() { | 122 | this.getMaterialNodeArray = function () { |
117 | return this._materialNodeArray; | 123 | return this._materialNodeArray; |
118 | }; | 124 | }; |
119 | 125 | ||
120 | this.getMaterialArray = function() { return this._materialArray; | 126 | this.getMaterialArray = function () { |
127 | return this._materialArray; | ||
121 | }; | 128 | }; |
122 | 129 | ||
123 | this.getTransformNode = function() { | 130 | this.getTransformNode = function () { |
124 | return this._trNode; | 131 | return this._trNode; |
125 | }; | 132 | }; |
126 | 133 | ||
127 | this.setTransformNode = function(t) { | 134 | this.setTransformNode = function (t) { |
128 | this._trNode = t; | 135 | this._trNode = t; |
129 | }; | 136 | }; |
130 | 137 | ||
131 | this.setFillColor = function(c) { | 138 | this.setFillColor = function (c) { |
132 | this.setMaterialColor(c, "fill"); | 139 | this.setMaterialColor(c, "fill"); |
133 | }; | 140 | }; |
134 | 141 | ||
135 | this.setStrokeColor = function(c) { | 142 | this.setStrokeColor = function (c) { |
136 | this.setMaterialColor(c, "stroke"); | 143 | this.setMaterialColor(c, "stroke"); |
137 | }; | 144 | }; |
145 | |||
138 | /////////////////////////////////////////////////////////////////////// | 146 | /////////////////////////////////////////////////////////////////////// |
139 | // Methods | 147 | // Methods |
140 | /////////////////////////////////////////////////////////////////////// | 148 | /////////////////////////////////////////////////////////////////////// |
141 | this.setMaterialColor = function(c, type) { | 149 | this.setMaterialColor = function (c, type) |
150 | { | ||
142 | var i = 0, | 151 | var i = 0, |
143 | nMats = 0; | 152 | nMats = 0; |
144 | if(c.gradientMode) { | 153 | if (c) |
145 | // Gradient support | 154 | { |
146 | if (this._materialArray && this._materialTypeArray) { | 155 | if (c.gradientMode) |
147 | nMats = this._materialArray.length; | 156 | { |
148 | } | 157 | // Gradient support |
158 | if (this._materialArray && this._materialTypeArray) { | ||
159 | nMats = this._materialArray.length; | ||
160 | } | ||
149 | 161 | ||
150 | var stops = [], | 162 | var stops = [], |
151 | colors = c.color; | 163 | colors = c.color; |
152 | 164 | ||
153 | var len = colors.length; | 165 | var len = colors.length; |
154 | // TODO - Current shaders only support 4 color stops | 166 | // TODO - Current shaders only support 4 color stops |