diff options
author | Pushkar Joshi | 2012-02-28 14:19:25 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-28 14:19:25 -0800 |
commit | 16d6a90579cdafede931a9c818689fad2e622d8b (patch) | |
tree | e87f5d4a131d3574ef06cff1c46373d5b1046956 /js/helper-classes/RDGE | |
parent | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (diff) | |
parent | 63307c9abf120985d979a40a53a0598d3f0d5c5a (diff) | |
download | ninja-16d6a90579cdafede931a9c818689fad2e622d8b.tar.gz |
Merge branch 'pentool' into brushtool
Diffstat (limited to 'js/helper-classes/RDGE')
-rwxr-xr-x | js/helper-classes/RDGE/GLAnchorPoint.js | 7 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLCircle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLLine.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLRectangle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLSubpath.js | 66 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLWorld.js | 27 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 28 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/CanvasDataManager.js | 98 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/GLRuntime.js | 159 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/rdge-compiled.js | 28 |
10 files changed, 365 insertions, 54 deletions
diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js index 716f59d4..c3e95b34 100755 --- a/js/helper-classes/RDGE/GLAnchorPoint.js +++ b/js/helper-classes/RDGE/GLAnchorPoint.js | |||
@@ -133,6 +133,13 @@ GLAnchorPoint.prototype.translateAll = function (x, y, z) { | |||
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){ | ||
137 | this._x *= sx;this._prevX *= sx;this._nextX *= sx; | ||
138 | this._y *= sy;this._prevY *= sy;this._nextY *= sy; | ||
139 | this._z *= sz;this._prevZ *= sz;this._nextZ *= sz; | ||
140 | } | ||
141 | |||
142 | |||
136 | // ********* getters ********** | 143 | // ********* getters ********** |
137 | GLAnchorPoint.prototype.getPosX = function () { return this._x; } | 144 | GLAnchorPoint.prototype.getPosX = function () { return this._x; } |
138 | GLAnchorPoint.prototype.getPosY = function () { return this._y; } | 145 | GLAnchorPoint.prototype.getPosY = function () { return this._y; } |
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index 5b32547e..712544c0 100755 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -135,7 +135,7 @@ function GLCircle() | |||
135 | if (!world._useWebGL) return; | 135 | if (!world._useWebGL) return; |
136 | 136 | ||
137 | // make sure RDGE has the correct context | 137 | // make sure RDGE has the correct context |
138 | g_Engine.setContext( world.getCanvas().uuid ); | 138 | g_Engine.setContext( world.getCanvas().rdgeid ); |
139 | 139 | ||
140 | // create the gl buffer | 140 | // create the gl buffer |
141 | var gl = world.getGLContext(); | 141 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index 0d815145..f715a43c 100755 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js | |||
@@ -171,7 +171,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro | |||
171 | if (!world._useWebGL) return; | 171 | if (!world._useWebGL) return; |
172 | 172 | ||
173 | // make sure RDGE has the correct context | 173 | // make sure RDGE has the correct context |
174 | g_Engine.setContext( world.getCanvas().uuid ); | 174 | g_Engine.setContext( world.getCanvas().rdgeid ); |
175 | 175 | ||
176 | // create the gl buffer | 176 | // create the gl buffer |
177 | var gl = world.getGLContext(); | 177 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 5b6ff94f..3c1cb7dc 100755 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -214,7 +214,7 @@ function GLRectangle() | |||
214 | if (!world._useWebGL) return; | 214 | if (!world._useWebGL) return; |
215 | 215 | ||
216 | // make sure RDGE has the correct context | 216 | // make sure RDGE has the correct context |
217 | g_Engine.setContext( world.getCanvas().uuid ); | 217 | g_Engine.setContext( world.getCanvas().rdgeid ); |
218 | 218 | ||
219 | // create the gl buffer | 219 | // create the gl buffer |
220 | var gl = world.getGLContext(); | 220 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js index 3200cf59..f3d8ad36 100755 --- a/js/helper-classes/RDGE/GLSubpath.js +++ b/js/helper-classes/RDGE/GLSubpath.js | |||
@@ -178,6 +178,67 @@ function GLSubpath() { | |||
178 | } //render() | 178 | } //render() |
179 | 179 | ||
180 | this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; } | 180 | this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; } |
181 | |||
182 | |||
183 | this.setWidth = function (newW) { | ||
184 | if (newW<1) | ||
185 | newW=1; //clamp minimum width to 1 | ||
186 | //scale the contents of this subpath to lie within this width | ||
187 | //determine the scale factor by comparing with the old width | ||
188 | var oldWidth = this._BBoxMax[0]-this._BBoxMin[0]; | ||
189 | if (oldWidth<1){ | ||
190 | oldWidth=1; | ||
191 | } | ||
192 | var scaleX = newW/oldWidth; | ||
193 | if (scaleX===1){ | ||
194 | return; //no need to do anything | ||
195 | } | ||
196 | |||
197 | //scale the anchor point positions such that the width of the bbox is the newW | ||
198 | var origX = this._BBoxMin[0]; | ||
199 | var numAnchors = this._Anchors.length; | ||
200 | for (var i=0;i<numAnchors;i++){ | ||
201 | //compute the distance from the bboxMin | ||
202 | var oldW = this._Anchors[i].getPosX() - origX; | ||
203 | var prevW = this._Anchors[i].getPrevX() - origX; | ||
204 | var nextW = this._Anchors[i].getNextX() - origX; | ||
205 | |||
206 | this._Anchors[i].setPos(origX + oldW*scaleX,this._Anchors[i].getPosY(),this._Anchors[i].getPosZ()); | ||
207 | this._Anchors[i].setPrevPos(origX + prevW*scaleX,this._Anchors[i].getPrevY(),this._Anchors[i].getPrevZ()); | ||
208 | this._Anchors[i].setNextPos(origX + nextW*scaleX,this._Anchors[i].getNextY(),this._Anchors[i].getNextZ()); | ||
209 | } | ||
210 | this.makeDirty(); | ||
211 | } | ||
212 | this.setHeight = function (newH) { | ||
213 | if (newH<1) | ||
214 | newH=1; //clamp minimum width to 1 | ||
215 | //scale the contents of this subpath to lie within this height | ||
216 | //determine the scale factor by comparing with the old height | ||
217 | var oldHeight = this._BBoxMax[1]-this._BBoxMin[1]; | ||
218 | if (oldHeight<1){ | ||
219 | oldHeight=1; | ||
220 | } | ||
221 | var scaleY = newH/oldHeight; | ||
222 | if (scaleY===1){ | ||
223 | return; //no need to do anything | ||
224 | } | ||
225 | |||
226 | //scale the anchor point positions such that the height of the bbox is the newH | ||
227 | var origY = this._BBoxMin[1]; | ||
228 | var numAnchors = this._Anchors.length; | ||
229 | for (var i=0;i<numAnchors;i++){ | ||
230 | //compute the distance from the bboxMin | ||
231 | var oldW = this._Anchors[i].getPosY() - origY; | ||
232 | var prevW = this._Anchors[i].getPrevY() - origY; | ||
233 | var nextW = this._Anchors[i].getNextY() - origY; | ||
234 | |||
235 | this._Anchors[i].setPos(this._Anchors[i].getPosX(), origY + oldW*scaleY,this._Anchors[i].getPosZ()); | ||
236 | this._Anchors[i].setPrevPos(this._Anchors[i].getPrevX(), origY + prevW*scaleY,this._Anchors[i].getPrevZ()); | ||
237 | this._Anchors[i].setNextPos(this._Anchors[i].getNextX(), origY + nextW*scaleY,this._Anchors[i].getNextZ()); | ||
238 | } | ||
239 | this.makeDirty(); | ||
240 | } | ||
241 | |||
181 | } //function GLSubpath ...class definition | 242 | } //function GLSubpath ...class definition |
182 | 243 | ||
183 | 244 | ||
@@ -573,11 +634,6 @@ GLSubpath.prototype.setFillMaterial = function(m){ this._fillMaterial = m;} | |||
573 | GLSubpath.prototype.getFillColor = function() {return this._fillColor;} | 634 | GLSubpath.prototype.getFillColor = function() {return this._fillColor;} |
574 | GLSubpath.prototype.setFillColor = function(c){this._fillColor = c;} | 635 | GLSubpath.prototype.setFillColor = function(c){this._fillColor = c;} |
575 | 636 | ||
576 | GLSubpath.prototype.setWidth = function () {//NO-OP for now | ||
577 | } | ||
578 | GLSubpath.prototype.setHeight = function () {//NO-OP for now | ||
579 | } | ||
580 | |||
581 | GLSubpath.prototype.copyFromSubpath = function (subpath) { | 637 | GLSubpath.prototype.copyFromSubpath = function (subpath) { |
582 | this.clearAllAnchors(); | 638 | this.clearAllAnchors(); |
583 | for (var i = 0; i < subpath.getNumAnchors(); i++) { | 639 | for (var i = 0; i < subpath.getNumAnchors(); i++) { |
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index 1edd5cff..64086bee 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -136,13 +136,6 @@ function GLWorld( canvas, use3D ) | |||
136 | var camMat = Matrix.I(4); | 136 | var camMat = Matrix.I(4); |
137 | camMat[14] = this.getViewDistance(); | 137 | camMat[14] = this.getViewDistance(); |
138 | this.setCameraMat( camMat ); | 138 | this.setCameraMat( camMat ); |
139 | |||
140 | ////////////////////////////////////////// | ||
141 | // test call to SVG importer | ||
142 | // console.log( "***** SVG TEST *****" ); | ||
143 | // var svgImporter = new SVGParse( this ); | ||
144 | // svgImporter.importSVG(); | ||
145 | ////////////////////////////////////////// | ||
146 | 139 | ||
147 | // post-load processing of the scene | 140 | // post-load processing of the scene |
148 | this.init = function() | 141 | this.init = function() |
@@ -198,7 +191,9 @@ function GLWorld( canvas, use3D ) | |||
198 | this.myScene.addNode(lightTr); | 191 | this.myScene.addNode(lightTr); |
199 | 192 | ||
200 | // Add the scene to the engine - necessary if you want the engine to draw for you | 193 | // Add the scene to the engine - necessary if you want the engine to draw for you |
201 | g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); | 194 | //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); |
195 | var name = this._canvas.getAttribute( "data-RDGE-id" ); | ||
196 | g_Engine.AddScene("myScene" + name, this.myScene); | ||
202 | } | 197 | } |
203 | 198 | ||
204 | // main code for handling user interaction and updating the scene | 199 | // main code for handling user interaction and updating the scene |
@@ -227,11 +222,11 @@ function GLWorld( canvas, use3D ) | |||
227 | } | 222 | } |
228 | 223 | ||
229 | // defining the draw function to control how the scene is rendered | 224 | // defining the draw function to control how the scene is rendered |
230 | this.draw = function() | 225 | this.draw = function() |
231 | { | 226 | { |
232 | if (this._useWebGL) | 227 | if (this._useWebGL) |
233 | { | 228 | { |
234 | g_Engine.setContext( this._canvas.uuid ); | 229 | g_Engine.setContext( this._canvas.rdgeid ); |
235 | var ctx = g_Engine.getContext(); | 230 | var ctx = g_Engine.getContext(); |
236 | var renderer = ctx.renderer; | 231 | var renderer = ctx.renderer; |
237 | if (renderer.unloadedTextureCount <= 0) | 232 | if (renderer.unloadedTextureCount <= 0) |
@@ -391,12 +386,10 @@ function GLWorld( canvas, use3D ) | |||
391 | if (this._useWebGL) | 386 | if (this._useWebGL) |
392 | { | 387 | { |
393 | rdgeStarted = true; | 388 | rdgeStarted = true; |
394 | this._canvas.rdgeid = this._canvas.uuid; | 389 | var id = this._canvas.getAttribute( "data-RDGE-id" ); |
390 | this._canvas.rdgeid = id; | ||
395 | g_Engine.registerCanvas(this._canvas, this); | 391 | g_Engine.registerCanvas(this._canvas, this); |
396 | RDGEStart( this._canvas ); | 392 | RDGEStart( this._canvas ); |