aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/line.js
diff options
context:
space:
mode:
authorhwc4872012-04-19 13:01:43 -0700
committerhwc4872012-04-19 13:01:43 -0700
commite6a20fe64574763483dc602bd759278ccf5e5e68 (patch)
tree69defe7200206f0257fe90697136fadef59d521e /js/lib/geom/line.js
parentae7eb87564632ce7c676bd728b8ff2710ff0bb83 (diff)
parent9284c19f076dec3b47ece7dc7bcd22d74e4246c3 (diff)
downloadninja-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/line.js')
-rwxr-xr-xjs/lib/geom/line.js82
1 files changed, 11 insertions, 71 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index e839e229..bb198d83 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -33,6 +33,8 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
33 this._scaleX = 1.0; 33 this._scaleX = 1.0;
34 this._scaleY = 1.0; 34 this._scaleY = 1.0;
35 35
36 this.canFill = false;
37
36 if (arguments.length > 0) { 38 if (arguments.length > 0) {
37 this._width = width; 39 this._width = width;
38 this._height = height; 40 this._height = height;
@@ -44,7 +46,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
44 46
45 this._slope = slope; 47 this._slope = slope;
46 this._strokeWidth = strokeSize; 48 this._strokeWidth = strokeSize;
47 if (strokeColor) this._strokeColor = strokeColor.slice(); 49 this._strokeColor = strokeColor;
48 50
49 this._strokeStyle = strokeStyle; 51 this._strokeStyle = strokeStyle;
50 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); 52 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
@@ -137,77 +139,15 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
137 this._strokeStyle = jObj.strokeStyle; 139 this._strokeStyle = jObj.strokeStyle;
138 this._strokeColor = jObj.strokeColor; 140 this._strokeColor = jObj.strokeColor;
139 var strokeMaterialName = jObj.strokeMat; 141 var strokeMaterialName = jObj.strokeMat;
140 this.importMaterialsJSON( jObj.materials );
141 };
142 142
143 this.export = function() { 143 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
144 var rtnStr = "type: " + this.geomType() + "\n"; 144 if (!strokeMat) {
145 145 console.log( "object material not found in library: " + strokeMaterialName );
146 rtnStr += "xoff: " + this._xOffset + "\n"; 146 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
147 rtnStr += "yoff: " + this._yOffset + "\n";
148 rtnStr += "width: " + this._width + "\n";
149 rtnStr += "height: " + this._height + "\n";
150 rtnStr += "xAdj: " + this._xAdj + "\n";
151 rtnStr += "yAdj: " + this._yAdj + "\n";
152 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
153
154 if(this._strokeColor.gradientMode) {
155 rtnStr += "strokeGradientMode: " + this._strokeColor.gradientMode + "\n";
156 rtnStr += "strokeColor: " + this.gradientToString(this._strokeColor.color) + "\n";
157 } else {
158 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n";
159 } 147 }
148 this._strokeMaterial = strokeMat;
160 149
161 rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; 150 this.importMaterialsJSON( jObj.materials );
162 rtnStr += "slope: " + String(this._slope) + "\n";
163
164 rtnStr += "strokeMat: ";
165 if (this._strokeMaterial) {
166 rtnStr += this._strokeMaterial.getName();
167 } else {
168 rtnStr += MaterialsModel.getDefaultMaterialName();
169 }
170
171 rtnStr += "\n";
172 return rtnStr;
173 };
174
175 this.import = function( importStr ) {
176 this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) );
177 this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) );
178 this._width = Number( this.getPropertyFromString( "width: ", importStr ) );
179 this._height = Number( this.getPropertyFromString( "height: ", importStr ) );
180 this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) );
181 this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) );
182 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) );
183 var slope = this.getPropertyFromString( "slope: ", importStr );
184
185 if(isNaN(Number(slope))) {
186 this._slope = slope;
187 } else {
188 this._slope = Number(slope);
189 }
190
191 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
192 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr );
193
194 if(importStr.indexOf("strokeGradientMode: ") < 0)
195 {
196 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" );
197 } else {
198 this._strokeColor = {};
199 this._strokeColor.gradientMode = this.getPropertyFromString( "strokeGradientMode: ", importStr );
200 this._strokeColor.color = this.stringToGradient(this.getPropertyFromString( "strokeColor: ", importStr ));
201 }
202
203 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
204 if (!strokeMat) {
205 console.log( "object material not found in library: " + strokeMaterialName );
206 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
207 }
208
209 this._strokeMaterial = strokeMat;
210
211 }; 151 };
212 152
213 /////////////////////////////////////////////////////////////////////// 153 ///////////////////////////////////////////////////////////////////////
@@ -220,7 +160,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
220 if (!world._useWebGL) return; 160 if (!world._useWebGL) return;
221 161
222 // make sure RDGE has the correct context 162 // make sure RDGE has the correct context
223 g_Engine.setContext( world.getCanvas().rdgeid ); 163 RDGE.globals.engine.setContext( world.getCanvas().rdgeid );
224 164
225 // create the gl buffer 165 // create the gl buffer
226 var gl = world.getGLContext(); 166 var gl = world.getGLContext();
@@ -381,7 +321,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
381 indices.push( index ); index++; 321 indices.push( index ); index++;
382 } 322 }
383 323
384 var prim = ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, g_Engine.getContext().renderer.TRIANGLES, indices.length); 324 var prim = ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, indices.length);
385 325
386 var strokeMaterial = this.makeStrokeMaterial(); 326 var strokeMaterial = this.makeStrokeMaterial();
387 327