aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-02-10 10:23:48 -0800
committerNivesh Rajbhandari2012-02-10 10:23:48 -0800
commit9e40945a5bf4330d1088b56b8011ee625b1adab9 (patch)
tree6597ec13d9c62b1097d18d04525ebe96673fcacc
parenta757d4d0064e0f09bb1a99651b8493514cbc4999 (diff)
downloadninja-9e40945a5bf4330d1088b56b8011ee625b1adab9.tar.gz
Support export/import of GLLine data.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rw-r--r--js/controllers/elements/shapes-controller.js19
-rw-r--r--js/data/pi/pi-data.js6
-rw-r--r--js/helper-classes/RDGE/GLLine.js67
-rw-r--r--js/helper-classes/RDGE/GLRectangle.js2
-rw-r--r--js/helper-classes/RDGE/GLWorld.js6
5 files changed, 85 insertions, 15 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index 44723a1e..640119c4 100644
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -351,12 +351,17 @@ exports.ShapesController = Montage.create(CanvasController, {
351 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 351 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
352 352
353 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 353 sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
354 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); 354 if(sm)
355 if(sm && fm)
356 { 355 {
357 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); 356 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm);
358 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
359 el.elementModel.shapeModel.strokeMaterial = sm; 357 el.elementModel.shapeModel.strokeMaterial = sm;
358 }
359 fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial"));
360 // TODO - Use consts after GL code is converted to object literal notation
361// if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) )
362 if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) )
363 {
364 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm);
360 el.elementModel.shapeModel.fillMaterial = fm; 365 el.elementModel.shapeModel.fillMaterial = fm;
361 } 366 }
362 } 367 }
@@ -381,9 +386,13 @@ exports.ShapesController = Montage.create(CanvasController, {
381 world.import(worldData); 386 world.import(worldData);
382 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); 387 el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot();
383 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null); 388 el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(null);
384 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
385 el.elementModel.shapeModel.strokeMaterial = null; 389 el.elementModel.shapeModel.strokeMaterial = null;
386 el.elementModel.shapeModel.fillMaterial = null; 390 // TODO - Use consts after GL code is converted to object literal notation
391 if(el.elementModel.shapeModel.GLGeomObj.geomType() !== 3)
392 {
393 el.elementModel.shapeModel.GLGeomObj.setFillMaterial(null);
394 el.elementModel.shapeModel.fillMaterial = null;
395 }
387 } 396 }
388 } 397 }
389 } 398 }
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js
index 10b33a0e..8ffd0ec7 100644
--- a/js/data/pi/pi-data.js
+++ b/js/data/pi/pi-data.js
@@ -459,12 +459,14 @@ exports.PiData = Montage.create( Montage, {
459 [ 459 [
460 { 460 {
461 type: "dropdown", 461 type: "dropdown",
462 id: "stroke", 462 id: "strokeMaterial",
463 prop: "strokeMaterial",
463 label: "Stroke", 464 label: "Stroke",
464 labelField: "_name", 465 labelField: "_name",
465 dataField: "_name", 466 dataField: "_name",
466 items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" }, 467 items : { boundObject: "this.application.ninja.appModel", boundProperty: "materials" },
467 enabled: { boundObject: "this.controls", boundProperty: "useWebGl" } 468 enabled: { boundObject: "this.controls", boundProperty: "useWebGl" },
469 divider : true
468 } 470 }
469 ] 471 ]
470 ] 472 ]
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index 1cd70575..5ec51230 100644
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -28,6 +28,8 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
28 this._strokeWidth = 0.25; 28 this._strokeWidth = 0.25;
29 29
30 this._strokeStyle = "Solid"; 30 this._strokeStyle = "Solid";
31 this._scaleX = 1.0;
32 this._scaleY = 1.0;
31 33
32 if (arguments.length > 0) 34 if (arguments.length > 0)
33 { 35 {
@@ -44,13 +46,9 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
44 this._strokeColor = strokeColor; 46 this._strokeColor = strokeColor;
45 47
46 this._strokeStyle = strokeStyle; 48 this._strokeStyle = strokeStyle;
49 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
47 } 50 }
48 51
49 this._scaleX = 1.0;
50 this._scaleY = 1.0;
51
52 this._scaleX = (world._viewportWidth)/(world._viewportHeight);
53
54 this._strokeVerticesLen = 0; 52 this._strokeVerticesLen = 0;
55 53
56 this.m_world = world; 54 this.m_world = world;
@@ -104,7 +102,64 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
104 this.setSlope = function(m) { this._slope = m; } 102 this.setSlope = function(m) { this._slope = m; }
105 103
106 this.geomType = function() { return this.GEOM_TYPE_LINE; } 104 this.geomType = function() { return this.GEOM_TYPE_LINE; }
107 105
106 ///////////////////////////////////////////////////////////////////////
107 // Methods
108 ///////////////////////////////////////////////////////////////////////
109 this.export = function()
110 {
111 var rtnStr = "type: " + this.geomType() + "\n";
112
113 rtnStr += "xoff: " + this._xOffset + "\n";
114 rtnStr += "yoff: " + this._yOffset + "\n";
115 rtnStr += "width: " + this._width + "\n";
116 rtnStr += "height: " + this._height + "\n";
117 rtnStr += "xAdj: " + this._xAdj + "\n";
118 rtnStr += "yAdj: " + this._yAdj + "\n";
119 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
120 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n";
121 rtnStr += "strokeStyle: " + this._strokeStyle + "\n";
122 rtnStr += "slope: " + String(this._slope) + "\n";
123
124 rtnStr += "strokeMat: ";
125 if (this._strokeMaterial)
126 rtnStr += this._strokeMaterial.getName();
127 else
128 rtnStr += "flatMaterial";
129 rtnStr += "\n";
130
131 return rtnStr;
132 }
133
134 this.import = function( importStr )
135 {
136 this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) );
137 this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) );
138 this._width = Number( this.getPropertyFromString( "width: ", importStr ) );
139 this._height = Number( this.getPropertyFromString( "height: ", importStr ) );
140 this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) );
141 this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) );
142 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) );
143 var slope = this.getPropertyFromString( "slope: ", importStr );
144 if(isNaN(Number(slope)))
145 this._slope = slope;
146 else
147 this._slope = Number(slope);
148
149 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
150 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr );
151 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" );
152
153 var strokeMat = MaterialsLibrary.getMaterial( strokeMaterialName );
154 if (!strokeMat)
155 {
156 console.log( "object material not found in library: " + strokeMaterialName );
157 strokeMat = new FlatMaterial();
158 }
159 this._strokeMaterial = strokeMat;
160
161 }
162
108 /////////////////////////////////////////////////////////////////////// 163 ///////////////////////////////////////////////////////////////////////
109 // Methods 164 // Methods
110 /////////////////////////////////////////////////////////////////////// 165 ///////////////////////////////////////////////////////////////////////
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js
index d24ade2b..4216fe53 100644
--- a/js/helper-classes/RDGE/GLRectangle.js
+++ b/js/helper-classes/RDGE/GLRectangle.js
@@ -180,7 +180,7 @@ function GLRectangle()
180 this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) ); 180 this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) );
181 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); 181 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
182 var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr ); 182 var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr );
183 this._strokeStyle = Number( this.getPropertyFromString( "strokeColor: ", importStr ) ); 183 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr );
184 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); 184 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" );
185 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); 185 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" );
186 this._tlRadius = Number( this.getPropertyFromString( "tlRadius: ", importStr ) ); 186 this._tlRadius = Number( this.getPropertyFromString( "tlRadius: ", importStr ) );
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js
index f9081248..c8327064 100644
--- a/js/helper-classes/RDGE/GLWorld.js
+++ b/js/helper-classes/RDGE/GLWorld.js
@@ -973,7 +973,11 @@ GLWorld.prototype.importObject = function( objStr, parentNode )
973 obj.import( objStr ); 973 obj.import( objStr );
974 break; 974 break;
975 975
976 case 3: // line - not implemented 976 case 3: // line
977 obj = new GLLine();
978 obj.import( objStr );
979 break;
980
977 default: 981 default:
978 throw new Error( "Unrecognized object type: " + type ); 982 throw new Error( "Unrecognized object type: " + type );
979 break; 983 break;