aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-02-10 10:23:48 -0800
committerNivesh Rajbhandari2012-02-10 10:23:48 -0800
commit9e40945a5bf4330d1088b56b8011ee625b1adab9 (patch)
tree6597ec13d9c62b1097d18d04525ebe96673fcacc /js/helper-classes
parenta757d4d0064e0f09bb1a99651b8493514cbc4999 (diff)
downloadninja-9e40945a5bf4330d1088b56b8011ee625b1adab9.tar.gz
Support export/import of GLLine data.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/helper-classes')
-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
3 files changed, 67 insertions, 8 deletions
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;