From 342fb451bd251358068a0dcb10e9dc218b79a176 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Tue, 6 Mar 2012 11:38:39 -0800 Subject: Squashed commit of the following: commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari Signed-off-by: Jonathan Duran --- js/helper-classes/RDGE/GLAnchorPoint.js | 168 --- js/helper-classes/RDGE/GLBrushStroke.js | 397 ------- js/helper-classes/RDGE/GLCircle.js | 710 ----------- js/helper-classes/RDGE/GLGeomObj.js | 278 ----- js/helper-classes/RDGE/GLLight.js | 30 - js/helper-classes/RDGE/GLLine.js | 507 -------- js/helper-classes/RDGE/GLMaterial.js | 308 ----- js/helper-classes/RDGE/GLPath.js | 232 ---- js/helper-classes/RDGE/GLRectangle.js | 1236 -------------------- js/helper-classes/RDGE/GLSubpath.js | 1185 ------------------- js/helper-classes/RDGE/GLWorld.js | 1014 ---------------- .../RDGE/Materials/BumpMetalMaterial.js | 302 ----- js/helper-classes/RDGE/Materials/DeformMaterial.js | 133 --- js/helper-classes/RDGE/Materials/FlatMaterial.js | 161 --- js/helper-classes/RDGE/Materials/FlyMaterial.js | 133 --- js/helper-classes/RDGE/Materials/JuliaMaterial.js | 150 --- .../RDGE/Materials/KeleidoscopeMaterial.js | 149 --- .../RDGE/Materials/LinearGradientMaterial.js | 379 ------ js/helper-classes/RDGE/Materials/MandelMaterial.js | 151 --- js/helper-classes/RDGE/Materials/PlasmaMaterial.js | 134 --- js/helper-classes/RDGE/Materials/PulseMaterial.js | 263 ----- .../RDGE/Materials/RadialBlurMaterial.js | 257 ---- .../RDGE/Materials/RadialGradientMaterial.js | 303 ----- .../RDGE/Materials/ReliefTunnelMaterial.js | 133 --- .../RDGE/Materials/SquareTunnelMaterial.js | 133 --- js/helper-classes/RDGE/Materials/StarMaterial.js | 133 --- js/helper-classes/RDGE/Materials/TaperMaterial.js | 223 ---- js/helper-classes/RDGE/Materials/TunnelMaterial.js | 133 --- js/helper-classes/RDGE/Materials/TwistMaterial.js | 149 --- .../RDGE/Materials/TwistVertMaterial.js | 248 ---- js/helper-classes/RDGE/Materials/UberMaterial.js | 673 ----------- js/helper-classes/RDGE/Materials/WaterMaterial.js | 133 --- .../RDGE/Materials/ZInvertMaterial.js | 133 --- js/helper-classes/RDGE/MaterialsLibrary.js | 230 ---- 34 files changed, 10901 deletions(-) delete mode 100755 js/helper-classes/RDGE/GLAnchorPoint.js delete mode 100755 js/helper-classes/RDGE/GLBrushStroke.js delete mode 100755 js/helper-classes/RDGE/GLCircle.js delete mode 100755 js/helper-classes/RDGE/GLGeomObj.js delete mode 100755 js/helper-classes/RDGE/GLLight.js delete mode 100755 js/helper-classes/RDGE/GLLine.js delete mode 100755 js/helper-classes/RDGE/GLMaterial.js delete mode 100755 js/helper-classes/RDGE/GLPath.js delete mode 100755 js/helper-classes/RDGE/GLRectangle.js delete mode 100755 js/helper-classes/RDGE/GLSubpath.js delete mode 100755 js/helper-classes/RDGE/GLWorld.js delete mode 100755 js/helper-classes/RDGE/Materials/BumpMetalMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/DeformMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/FlatMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/FlyMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/JuliaMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/LinearGradientMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/MandelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/PlasmaMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/PulseMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/RadialBlurMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/RadialGradientMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/ReliefTunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/SquareTunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/StarMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TaperMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TwistMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TwistVertMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/UberMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/WaterMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/ZInvertMaterial.js delete mode 100755 js/helper-classes/RDGE/MaterialsLibrary.js (limited to 'js/helper-classes/RDGE') diff --git a/js/helper-classes/RDGE/GLAnchorPoint.js b/js/helper-classes/RDGE/GLAnchorPoint.js deleted file mode 100755 index c3e95b34..00000000 --- a/js/helper-classes/RDGE/GLAnchorPoint.js +++ /dev/null @@ -1,168 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -///////////////////////////////////////////// -// Class GLAnchorPoint -// GL representation of a point clicked -// and dragged during pen tool -// -// -///////////////////////////////////////////// -function GLAnchorPoint() { - ///////////////////////////////////////// - // Instance variables - ///////////////////////////////////////// - this._x = 0.0; - this._y = 0.0; - this._z = 0.0; - - this._prevX = 0.0; - this._prevY = 0.0; - this._prevZ = 0.0; - - this._nextX = 0.0; - this._nextY = 0.0; - this._nextZ = 0.0; -} - // *********** setters ************ -GLAnchorPoint.prototype.setPos = function (x, y, z) { this._x = x; this._y = y; this._z = z; } -GLAnchorPoint.prototype.setPrevPos = function (x, y, z) { this._prevX = x; this._prevY = y; this._prevZ = z; } -GLAnchorPoint.prototype.setNextPos = function (x, y, z) { this._nextX = x; this._nextY = y; this._nextZ = z; } - -GLAnchorPoint.prototype.setPrevFromNext = function () { - //set the previous control point by reflecting the next control point - var dispX = this._nextX - this._x; - var dispY = this._nextY - this._y; - var dispZ = this._nextZ - this._z; - - this._prevX = this._x - dispX; - this._prevY = this._y - dispY; - this._prevZ = this._z - dispZ; -} -GLAnchorPoint.prototype.setNextFromPrev = function () { - //set the previous control point by reflecting the next control point - var dispX = this._prevX - this._x; - var dispY = this._prevY - this._y; - var dispZ = this._prevZ - this._z; - - this._nextX = this._x - dispX; - this._nextY = this._y - dispY; - this._nextZ = this._z - dispZ; -} - -//translate the next point from the translation that was applied to the prev. point -GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) { - //do nothing if the total translation is zero - var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz); - if (totalTransSq < 0.0000001) - return; - - // *** compute the rotation of the prev vector *** - var oldP = Vector.create([this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z]); - var newP = Vector.create([this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]); - //compute angle between the two vectors - var axis = Vector.create([0, 0, 0]); - var angle = MathUtils.getAxisAngleBetween3DVectors(oldP, newP, axis); - if (angle === 0) - return; - - // *** compute the vector from anchor to next - var oldN = Vector.create([this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]); - var rotMat = Matrix.Rotation(-angle, axis); - var newN = MathUtils.transformVector(oldN, rotMat); - - //TEMP for some situations the axis angle computation returns NaNs - if (isNaN(newN[0]) || isNaN(newN[1]) || isNaN(newN[2])) { - console.log("NaN in translateNextFromPrev"); - return; - } - //end TEMP - this._nextX = this._x + newN[0]; - this._nextY = this._y + newN[1]; - this._nextZ = this._z + newN[2]; -} -//translate the next point from the translation that was applied to the prev. point -GLAnchorPoint.prototype.translatePrevFromNext = function (tx, ty, tz) { - //do nothing if the total translation is zero - var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz); - if (totalTransSq < 0.0000001) - return; - - // *** compute the rotation of the next vector *** - var oldN = Vector.create([this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z]); - var newN = Vector.create([this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]); - //compute angle between the two vectors - var axis = Vector.create([0, 0, 0]); - var angle = MathUtils.getAxisAngleBetween3DVectors(oldN, newN, axis); - if (angle === 0) - return; - - // *** compute the vector from anchor to prev - var oldP = Vector.create([this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]); - var rotMat = Matrix.Rotation(-angle, axis); - var newP = MathUtils.transformVector(oldP, rotMat); - - //TEMP for some situations the axis angle computation returns NaNs - if (isNaN(newP[0]) || isNaN(newP[1]) || isNaN(newP[2])) { - return; - } - //end TEMP - this._prevX = this._x + newP[0]; - this._prevY = this._y + newP[1]; - this._prevZ = this._z + newP[2]; -} - - -// ******* modifiers ******* -GLAnchorPoint.prototype.translatePrev = function (x, y, z) { - this._prevX += x; this._prevY += y; this._prevZ += z; -} -GLAnchorPoint.prototype.translateNext = function (x, y, z) { - this._nextX += x; this._nextY += y; this._nextZ += z; -} -GLAnchorPoint.prototype.translate = function (x, y, z) { - this._x += x; this._y += y; this._z += z; -} -GLAnchorPoint.prototype.translateAll = function (x, y, z) { - this.translate(x, y, z); - this.translatePrev(x, y, z); - this.translateNext(x, y, z); -} - - -GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){ - this._x *= sx;this._prevX *= sx;this._nextX *= sx; - this._y *= sy;this._prevY *= sy;this._nextY *= sy; - this._z *= sz;this._prevZ *= sz;this._nextZ *= sz; -} - - -// ********* getters ********** -GLAnchorPoint.prototype.getPosX = function () { return this._x; } -GLAnchorPoint.prototype.getPosY = function () { return this._y; } -GLAnchorPoint.prototype.getPosZ = function () { return this._z; } -GLAnchorPoint.prototype.getPrevX = function () { return this._prevX; } -GLAnchorPoint.prototype.getPrevY = function () { return this._prevY; } -GLAnchorPoint.prototype.getPrevZ = function () { return this._prevZ; } -GLAnchorPoint.prototype.getNextX = function () { return this._nextX; } -GLAnchorPoint.prototype.getNextY = function () { return this._nextY; } -GLAnchorPoint.prototype.getNextZ = function () { return this._nextZ; } -GLAnchorPoint.prototype.getPos = function() { return Vector.create([this._x, this._y, this._z]);} -GLAnchorPoint.prototype.getPrev = function() { return Vector.create([this._prevX, this._prevY, this._prevZ]);} -GLAnchorPoint.prototype.getNext = function() { return Vector.create([this._nextX, this._nextY, this._nextZ]);} -//return the square of distance from passed in point to the anchor position -GLAnchorPoint.prototype.getDistanceSq = function (x, y, z) { - return (this._x - x) * (this._x - x) + (this._y - y) * (this._y - y) + (this._z - z) * (this._z - z); -} -//return sq. of distance to prev. -GLAnchorPoint.prototype.getPrevDistanceSq = function (x, y, z) { - return (this._prevX - x) * (this._prevX - x) + (this._prevY - y) * (this._prevY - y) + (this._prevZ - z) * (this._prevZ - z); -} -//return sq. of distance to next -GLAnchorPoint.prototype.getNextDistanceSq = function (x, y, z) { - return (this._nextX - x) * (this._nextX - x) + (this._nextY - y) * (this._nextY - y) + (this._nextZ - z) * (this._nextZ - z); -} - diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js deleted file mode 100755 index 5d773c2d..00000000 --- a/js/helper-classes/RDGE/GLBrushStroke.js +++ /dev/null @@ -1,397 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -// Todo: This entire class should be converted to a module -var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; - -/////////////////////////////////////////////////////////////////////// -// Class GLBrushStroke -// representation a sequence points (polyline) created by brush tool. -// Derived from class GLGeomObj -/////////////////////////////////////////////////////////////////////// -function GLBrushStroke() { - /////////////////////////////////////////////////// - // Instance variables - /////////////////////////////////////////////////// - this._Points = []; - this._BBoxMin = [0, 0, 0]; - this._BBoxMax = [0, 0, 0]; - this._dirty = true; - - //whether or not to use the canvas drawing to stroke/fill - this._useCanvasDrawing = true; - - //the X and Y location of this subpath's canvas in stage world space of Ninja - this._canvasX = 0; - this._canvasY = 0; - - //stroke information - this._strokeWidth = 0.0; - this._strokeColor = [0.4, 0.4, 0.4, 1.0]; - this._strokeMaterial; - this._strokeStyle = "Solid"; - - //the wetness of the brush (currently this is multiplied to the square of the stroke width, but todo should be changed to not depend on stroke width entirely - //smaller value means more samples for the path - this._WETNESS_FACTOR = 0.25; - - //prevent extremely long paths that can take a long time to render - this._MAX_ALLOWED_SAMPLES = 500; - - //drawing context - this._world = null; - - //tool that owns this brushstroke - this._drawingTool = null; - this._planeMat = null; - this._planeMatInv = null; - this._planeCenter = null; - - // initialize the inherited members - this.inheritedFrom = GLGeomObj; - this.inheritedFrom(); - - ///////////////////////////////////////////////////////// - // Property Accessors/Setters - ///////////////////////////////////////////////////////// - this.setWorld = function (world) { this._world = world; } - this.getWorld = function () { return this._world; } - this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; } - this.setDrawingTool = function (tool) {this._drawingTool = tool;} - this.getDrawingTool = function () {return this._drawingTool;} - this.setPlaneMatrix = function(planeMat){this._planeMat = planeMat;} - this.setPlaneMatrixInverse = function(planeMatInv){this._planeMatInv = planeMatInv;} - this.setPlaneCenter = function(pc){this._planeCenter = pc;} - - this.getCanvasX = function(){return this._canvasX;} - this.getCanvasY = function(){return this._canvasY;} - this.setCanvasX = function(cx){this._canvasX=cx;} - this.setCanvasY = function(cy){this._canvasY=cy;} - - - this.getNumPoints = function () { return this._Points.length; } - this.getPoint = function (index) { return this._Points[index]; } - this.addPoint = function (pt) - { - //add the point only if it is some epsilon away from the previous point - var numPoints = this._Points.length; - if (numPoints>0) { - var threshold = this._WETNESS_FACTOR*this._strokeWidth; - var prevPt = this._Points[numPoints-1]; - var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]]; - var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]); - if (diffPtMag>threshold){ - this._Points.push(pt); - this._dirty=true; - } - }else{ - this._Points.push(pt); - this._dirty=true; - } - } - - this.insertPoint = function(pt, index){ this._Points.splice(index, 0, pt); this._dirty=true;} - this.isDirty = function(){return this._dirty;} - this.makeDirty = function(){this._dirty=true;} - - this.getBBoxMin = function () { return this._BBoxMin; } - this.getBBoxMax = function () { return this._BBoxMax; } - - this.getStrokeWidth = function () { return this._strokeWidth; } - this.setStrokeWidth = function (w) { this._strokeWidth = w; this._dirty=true;} - this.getStrokeMaterial = function () { return this._strokeMaterial; } - this.setStrokeMaterial = function (m) { this._strokeMaterial = m; } - this.getStrokeColor = function () { return this._strokeColor; } - this.setStrokeColor = function (c) { this._strokeColor = c; } - this.getStrokeStyle = function () { return this._strokeStyle; } - this.setStrokeStyle = function (s) { this._strokeStyle = s; } - - this.setWidth = function () { }//NO-OP for now - this.setHeight = function () {}//NO-OP for now - - - //remove and return anchor at specified index, return null on error - this.removePoint = function (index) { - var retAnchor = null; - if (index < this._Points.length) { - retPt = this._Points.splice(index, 1); - this._dirty=true; - } - return retPoint; - } - - //remove all the points - this.clear = function () { this._Points = []; this._dirty=true;} - - this.translate = function (tx, ty, tz) { - for (var i=0;i1) { - var threshold = this._WETNESS_FACTOR*this._strokeWidth; - var prevPt = this._Points[0]; - var prevIndex = 0; - for (var i=1;ithreshold){ - //insert points along the prev. to current point - var numNewPoints = Math.floor(distance/threshold); - for (var j=0;j this._MAX_ALLOWED_SAMPLES){ - console.log("leaving the resampling because numPoints is greater than limit:"+this._MAX_ALLOWED_SAMPLES); - break; - } - } - } - - // *** compute the bounding box ********* - this._BBoxMin = [Infinity, Infinity, Infinity]; - this._BBoxMax = [-Infinity, -Infinity, -Infinity]; - numPoints = this._Points.length; - if (numPoints === 0) { - this._BBoxMin = [0, 0, 0]; - this._BBoxMax = [0, 0, 0]; - } else { - for (var i=0;i pt[d]) { - this._BBoxMin[d] = pt[d]; - } - if (this._BBoxMax[d] < pt[d]) { - this._BBoxMax[d] = pt[d]; - } - }//for every dimension d from 0 to 2 - } - } - //increase the bbox given the stroke width - for (var d = 0; d < 3; d++) { - this._BBoxMin[d]-= this._strokeWidth/2; - this._BBoxMax[d]+= this._strokeWidth/2; - }//for every dimension d from 0 to 2 - } - this._dirty = false; - } - - this.buildBuffers = function () { - return; //no need to do anything for now - }//buildBuffers() - - //render - // specify how to render the subpath in Canvas2D - this.render = function () { - // get the world - var world = this.getWorld(); - if (!world) throw( "null world in brushstroke render" ); - - // get the context - var ctx = world.get2DContext(); - if (!ctx) throw ("null context in brushstroke render") - - var numPoints = this.getNumPoints(); - if (numPoints === 0) - return; //nothing to do for empty paths - - ctx.save(); - - this.computeMetaGeometry(); - var bboxMin = this.getBBoxMin(); - var bboxMax = this.getBBoxMax(); - var bboxWidth = bboxMax[0] - bboxMin[0]; - var bboxHeight = bboxMax[1] - bboxMin[1]; - ctx.clearRect(0, 0, bboxWidth, bboxHeight); - - /* - ctx.lineWidth = this._strokeWidth; - ctx.strokeStyle = "black"; - if (this._strokeColor) - ctx.strokeStyle = MathUtils.colorToHex( this._strokeColor ); - ctx.fillStyle = "blue"; - if (this._fillColor) - ctx.fillStyle = MathUtils.colorToHex( this._fillColor ); - var lineCap = ['butt','round','square']; - ctx.lineCap = lineCap[1]; - ctx.beginPath(); - var firstPoint = this._Points[0]; - ctx.moveTo(firstPoint[0]-bboxMin[0], firstPoint[1]-bboxMin[1]); - for (var i = 1; i < numPoints; i++) { - var pt = this._Points[i]; - ctx.lineTo(pt[0]-bboxMin[0], pt[1]-bboxMin[1]); - } - ctx.stroke(); - */ - - /* - var isDebug = false; - var prevPt = this._Points[0]; - var prevX = prevPt[0]-bboxMin[0]; - var prevY = prevPt[1]-bboxMin[1]; - prevPt = [prevX,prevY]; - for (var i = 1; i < numPoints; i++) { - var pt = this._Points[i]; - ctx.globalCompositeOperation = 'source-over'; - var x = pt[0]-bboxMin[0]; - var y = pt[1]-bboxMin[1]; - pt = [x,y]; - - //vector from prev to current pt - var seg = VecUtils.vecSubtract(2, pt, prevPt); - var segDir = VecUtils.vecNormalize(2, seg, 1.0); - - var segMidPt = VecUtils.vecInterpolate(2, pt, prevPt, 0.5); - var w2 = this._strokeWidth*0.5; - var segDirOrtho = [w2*segDir[1], -w2*segDir[0]]; - - //add half the strokewidth to the segMidPt - var lgStart = VecUtils.vecAdd(2, segMidPt, segDirOrtho); - var lgEnd = VecUtils.vecSubtract(2, segMidPt, segDirOrtho); - - ctx.save(); - ctx.beginPath(); - - if (isDebug) { - ctx.strokeStyle="black"; - ctx.lineWidth = 1; - - ctx.moveTo(lgStart[0], lgStart[1]); - ctx.lineTo(lgEnd[0], lgEnd[1]); - ctx.stroke(); - } - - var lg = ctx.createLinearGradient(lgStart[0], lgStart[1], lgEnd[0], lgEnd[1]); - lg.addColorStop(1, 'rgba(0,0,0,0.0)'); - lg.addColorStop(0.5,'rgba(255,0,0,1.0)'); - lg.addColorStop(0, 'rgba(0,0,0,0.0)'); - ctx.fillStyle = lg; - - if (isDebug){ - ctx.strokeStyle="blue"; - ctx.lineWidth=0.5; - } - ctx.moveTo(prevX-w2, prevY); - ctx.lineTo(prevX+w2, prevY); - ctx.lineTo(x+w2, y); - ctx.lineTo(x-w2, y); - ctx.lineTo(prevX-w2, prevY); - ctx.fill(); - ctx.closePath(); - - ctx.restore(); - - prevPt = pt; - prevX = x; - prevY = y; - } - - - if (isDebug) - ctx.stroke(); - - if (isDebug){ - //draw the skeleton of this stroke - ctx.lineWidth = 1; - ctx.strokeStyle = "black"; - var pt = this._Points[0]; - ctx.beginPath(); - ctx.moveTo(pt[0]-bboxMin[0],pt[1]-bboxMin[1]); - for (var i = 1; i < numPoints; i++) { - pt = this._Points[i]; - var x = pt[0]-bboxMin[0]; - var y = pt[1]-bboxMin[1]; - ctx.lineTo(x,y); - } - ctx.stroke(); - } - */ - - - var R2 = this._strokeWidth; - var R = R2*0.5; - var hardness = 0; //for a pencil, this is always 1 //TODO get hardness parameter from user interface - var innerRadius = (hardness*R)-1; - if (innerRadius<1) - innerRadius=1; - - var r = ctx.createRadialGradient(0,0,innerRadius, 0,0,R); - var midColor = "rgba("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+",1)"; - r.addColorStop(0, midColor); - var endColor = "rgba("+parseInt(255*this._strokeColor[0])+","+parseInt(255*this._strokeColor[1])+","+parseInt(255*this._strokeColor[2])+",0.0)"; - r.addColorStop(1, endColor); - ctx.fillStyle = r; - - for (var i = 0; i < numPoints; i++) { - var pt = this._Points[i]; - ctx.globalCompositeOperation = 'source-over'; - var x = pt[0]-bboxMin[0]; - var y = pt[1]-bboxMin[1]; - ctx.save(); - ctx.translate(x,y); - ctx.arc(0, 0, R, 0, 2 * Math.PI, false); - ctx.fill(); - ctx.restore(); - //ctx.globalCompositeOperation = 'source-in'; - //ctx.rect(x-R, y-R, R2, R2); - } - - ctx.restore(); - } //render() - - - this.export = function() - { - var rtnStr = "type: " + this.geomType() + "\n"; - return rtnStr; - } - - this.import = function( importStr ) - { - } - - this.collidesWithPoint = function (x, y, z) { - if (x < this._BBoxMin[0]) return false; - if (x > this._BBoxMax[0]) return false; - if (y < this._BBoxMin[1]) return false; - if (y > this._BBoxMax[1]) return false; - if (z < this._BBoxMin[2]) return false; - if (z > this._BBoxMax[2]) return false; - - return true; - } - - this.collidesWithPoint = function (x, y) { - if (x < this._BBoxMin[0]) return false; - if (x > this._BBoxMax[0]) return false; - if (y < this._BBoxMin[1]) return false; - if (y > this._BBoxMax[1]) return false; - - return true; - } - -} //function GLSubpath ...class definition \ No newline at end of file diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js deleted file mode 100755 index 15ed6b6d..00000000 --- a/js/helper-classes/RDGE/GLCircle.js +++ /dev/null @@ -1,710 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -/////////////////////////////////////////////////////////////////////// -// Class GLCircle -// GL representation of a circle. -// Derived from class GLGeomObj -// The position and dimensions of the stroke, fill, and inner Radius should be in pixels -/////////////////////////////////////////////////////////////////////// -function GLCircle() -{ - - // initialize the inherited members - this.inheritedFrom = GLGeomObj; - this.inheritedFrom(); - - this.init = function( world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) - { - /////////////////////////////////////////////////////////////////////// - // Instance variables - /////////////////////////////////////////////////////////////////////// - this._width = 2.0; - this._height = 2.0; - this._xOffset = 0; - this._yOffset = 0; - - this._radius = 2.0; - this._strokeWidth = 0.25; - this._innerRadius = 0; - - this._ovalHeight = this._ovalHeight = 2.0*this.radius; - - this._strokeStyle = "Solid"; - - this._aspectRatio = 1.0; - - - if (arguments.length > 0) - { - this._width = width; - this._height = height; - this._xOffset = xOffset; - this._yOffset = yOffset; - - this._strokeWidth = strokeSize; - this._innerRadius = innerRadius; - if (strokeColor) this._strokeColor = strokeColor; - if (fillColor) this._fillColor = fillColor; - - this._strokeStyle = strokeStyle; - } - - this.m_world = world; - - - if(strokeMaterial) - this._strokeMaterial = strokeMaterial; - else - this._strokeMaterial = new FlatMaterial(); - - if(fillMaterial) - this._fillMaterial = fillMaterial; - else - this._fillMaterial = new FlatMaterial(); - } - - /////////////////////////////////////////////////////////////////////// - // Property Accessors - /////////////////////////////////////////////////////////////////////// - this.getStrokeWidth = function() { return this._strokeWidth; } - this.setStrokeWidth = function(w) { this._strokeWidth = w; } - - this.getStrokeMaterial = function() { return this._strokeMaterial; } - this.setStrokeMaterial = function(m) { this._strokeMaterial = m; } - - this.getFillMaterial = function() { return this._fillMaterial; } - this.setFillMaterial = function(m) { this._fillMaterial = m; } - - this.getRadius = function() { return this._radius; } - this.setRadius = function(r) { this._radius = r; } - - this.getWorld = function() { return this._world; } - this.setWorld = function(w) { this._world = w; } - - this.getInnerRadius = function() { return this._innerRadius; } - this.setInnerRadius = function(r) { this._innerRadius = r; } - - this.getStrokeStyle = function() { return this._strokeStyle; } - this.setStrokeStyle = function(s) { this._strokeStyle = s; } - - this.getWidth = function() { return this._width; } - this.setWidth = function(w) { this._width = w; } - - this.getHeight = function() { return this._height; } - this.setHeight = function(h) { this._height = h; } - - this.geomType = function() { return this.GEOM_TYPE_CIRCLE; } - - /////////////////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////////// - // update the "color of the material - this.getFillColor = function() - { - return this._fillColor; - } - -// this.setFillColor = function(c) -// { -// this._fillColor = c; -// } - - this.getStrokeColor = function() - { - return this._strokeColor; - } - -// this.setStrokeColor = function(c) -// { -// this._strokeColor = c; -// } - /////////////////////////////////////////////////////////////////////// - - this.buildBuffers = function() - { - // get the world - var world = this.getWorld(); - if (!world) throw( "null world in buildBuffers" ); - - if (!world._useWebGL) return; - - // make sure RDGE has the correct context - g_Engine.setContext( world.getCanvas().rdgeid ); - - // create the gl buffer - var gl = world.getGLContext(); - - // determine the number of triangles to generate - var nTriangles = 60; // yes, we will do better than this - - // get the normalized device coordinates (NDC) for - // all position and dimensions. - var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); - var xNDC = 2*this._xOffset/vpw, yNDC = 2*this._yOffset/vph, - xRadNDC = this._width/vpw, yRadNDC = this._height/vph, - xStrokeNDC = 2*this._strokeWidth/vpw, yStrokeNDC = 2*this._strokeWidth/vph, - xInnRadNDC = this._innerRadius*xRadNDC, yInnRadNDC = this._innerRadius*yRadNDC; - - var aspect = world.getAspect(); - var zn = world.getZNear(), zf = world.getZFar(); - var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0), - b = -t, - r = aspect*t, - l = -r; - - // calculate the object coordinates from their NDC coordinates - var z = -world.getViewDistance(); - - // get the position of the origin - var x = -z*(r-l)/(2.0*zn)*xNDC, - y = -z*(t-b)/(2.0*zn)*yNDC; - - // get the x and y radii - var xRad = -z*(r-l)/(2.0*zn)*xRadNDC, - yRad = -z*(t-b)/(2.0*zn)*yRadNDC; - - // save the overall dimensions to be used in the uv calculations - this._ovalWidth = xRad; this._ovalHeight = yRad; - - // get the x & y stroke size - var xStroke = -z*(r-l)/(2.0*zn)*xStrokeNDC, - yStroke = -z*(t-b)/(2.0*zn)*yStrokeNDC; - - // get the inner radius - var xInnRad = -z*(r-l)/(2.0*zn)*xInnRadNDC, - yInnRad = -z*(t-b)/(2.0*zn)*yInnRadNDC; - - // get a matrix to rotate a point around the circle - var angle = 2.0*Math.PI/Number(nTriangles); - var mat = Matrix.RotationZ( angle ); - var reverseRotMat = Matrix.RotationZ( -angle ); - - // calculate matrices to scale the circle and stroke to fit the bounds of the ellipse - var strokeScaleMat = Matrix.I(4); - strokeScaleMat[0] = xRad; - strokeScaleMat[5] = yRad; - - var fillScaleMat = Matrix.I(4); - fillScaleMat[0] = xRad - xStroke; - fillScaleMat[5] = yRad - yStroke; - - var innerRadiusScaleMat = Matrix.I(4); - innerRadiusScaleMat[0] = xInnRad; - innerRadiusScaleMat[5] = yInnRad; - - var innerStrokeScaleMat = Matrix.I(4); - innerStrokeScaleMat[0] = xInnRad - xStroke; - innerStrokeScaleMat[5] = yInnRad - yStroke; - - var fillPrim, strokePrim0, strokePrim1; - var fillMaterial, strokeMaterial0, strokeMaterial2; - - this._primArray = []; - this._materialArray = []; - this._materialTypeArray = []; - this._materialNodeArray = []; - - ///////////////////////////////////////////////////////////// - // Strokes - if(this._strokeWidth > 0) - { - var numStrokes = 1; - if(this._innerRadius !== 0) - strokePrim0 = this.generateOvalRing(x, y, reverseRotMat, innerStrokeScaleMat, innerRadiusScaleMat, nTriangles); - - strokePrim1 = this.generateOvalRing(x, y, reverseRotMat, fillScaleMat, strokeScaleMat, nTriangles); - } - - ///////////////////////////////////////////////////////////// - // Fill - if(this._innerRadius === 0) - fillPrim = this.generateOval(x, y, mat, fillScaleMat, nTriangles); - else - fillPrim = this.generateOvalRing(x, y, reverseRotMat, innerRadiusScaleMat, fillScaleMat, nTriangles); - - if (fillPrim) - { - fillMaterial = this.makeFillMaterial(); - - this._primArray.push( fillPrim ); - this._materialNodeArray.push( fillMaterial.getMaterialNode() ); - } - if (strokePrim0) - { - strokeMaterial0 = this.makeStrokeMaterial(); - - this._primArray.push( strokePrim0 ); - this._materialNodeArray.push( strokeMaterial0.getMaterialNode() ); - } - if (strokePrim1) - { - strokeMaterial2 = this.makeStrokeMaterial(); - - this._primArray.push( strokePrim1 ); - this._materialNodeArray.push( strokeMaterial2.getMaterialNode() ); - } - - world.updateObject(this); - } - - - this.generateOval = function(xOff, yOff, rotationMat, scaleMat, nTriangles) - { - var pt = [1.0, 0.0, 0.0]; - //var pts = scaleMat.multiply(pt); - var pts = glmat4.multiplyVec3( scaleMat, pt, []); - var x = pts[0], y = pts[1], z = 0; - var xs = scaleMat[0], ys = scaleMat[4]; - - var vrts = [], nrms = [], uvs = [], indices = []; - var index = 0; - for (var i=0; i 0) - { - xScale = 0.5*innerRad*this._width; - yScale = 0.5*innerRad*this._height; - mat[0] = xScale; - mat[5] = yScale; - - // get the bezier points - var bezPts = MathUtils.circularArcToBezier( Vector.create([0,0,0]), Vector.create([1,0,0]), -2.0*Math.PI ); - if (bezPts) - { - var n = bezPts.length; - p = MathUtils.transformPoint( bezPts[0], mat ); - ctx.moveTo( p[0], p[1] ); - index = 1; - while (index < n) - { - p0 = MathUtils.transformPoint( bezPts[index], mat ); - p1 = MathUtils.transformPoint( bezPts[index+1], mat ); - - var x0 = p0[0], y0 = p0[1], - x1 = p1[0], y1 = p1[1]; - ctx.quadraticCurveTo( x0, y0, x1, y1 ); - index += 2; - } - } - } - - // fill the path - ctx.fill(); - } - - // calculate the stroke matrix - xScale = 0.5*this._width - 0.5*lineWidth; - yScale = 0.5*this._height - 0.5*lineWidth; - mat[0] = xScale; - mat[5] = yScale; - - // set up the stroke style - ctx.beginPath(); - ctx.lineWidth = lineWidth; - if (this._strokeColor) - { - var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; - ctx.strokeStyle = c; - - // draw the stroke - p = MathUtils.transformPoint( bezPts[0], mat ); - ctx.moveTo( p[0], p[1] ); - index = 1; - while (index < n) - { - var p0 = MathUtils.transformPoint( bezPts[index], mat ); - var p1 = MathUtils.transformPoint( bezPts[index+1], mat ); - - var x0 = p0[0], y0 = p0[1], - x1 = p1[0], y1 = p1[1]; - ctx.quadraticCurveTo( x0, y0, x1, y1 ); - index += 2; - } - - if (MathUtils.fpSign(innerRad) > 0) - { - // calculate the stroke matrix - xScale = 0.5*innerRad*this._width - 0.5*lineWidth; - yScale = 0.5*innerRad*this._height - 0.5*lineWidth; - mat[0] = xScale; - mat[5] = yScale; - - // draw the stroke - p = MathUtils.transformPoint( bezPts[0], mat ); - ctx.moveTo( p[0], p[1] ); - index = 1; - while (index < n) - { - var p0 = MathUtils.transformPoint( bezPts[index], mat ); - var p1 = MathUtils.transformPoint( bezPts[index+1], mat ); - - var x0 = p0[0], y0 = p0[1], - x1 = p1[0], y1 = p1[1]; - ctx.quadraticCurveTo( x0, y0, x1, y1 ); - index += 2; - } - } - - // render the stroke - ctx.stroke(); - } - } - } - - this.export = function() - { - var rtnStr = "type: " + this.geomType() + "\n"; - - rtnStr += "xoff: " + this._xOffset + "\n"; - rtnStr += "yoff: " + this._yOffset + "\n"; - rtnStr += "width: " + this._width + "\n"; - rtnStr += "height: " + this._height + "\n"; - rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; - rtnStr += "innerRadius: " + this._innerRadius + "\n"; - rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; - rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; - rtnStr += "fillColor: " + String(this._fillColor) + "\n"; - - rtnStr += "strokeMat: "; - if (this._strokeMaterial) - rtnStr += this._strokeMaterial.getName(); - else - rtnStr += "flatMaterial"; - rtnStr += "\n"; - - rtnStr += "fillMat: "; - if (this._fillMaterial) - rtnStr += this._fillMaterial.getName(); - else - rtnStr += "flatMaterial"; - rtnStr += "\n"; - - return rtnStr; - } - - this.import = function( importStr ) - { - this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) ); - this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); - this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); - this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); - this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); - this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) ); - this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); - var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); - var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr ); - this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); - this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); - - var strokeMat = MaterialsLibrary.getMaterial( strokeMaterialName ); - if (!strokeMat) - { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = new FlatMaterial(); - } - this._strokeMaterial = strokeMat; - - var fillMat = MaterialsLibrary.getMaterial( fillMaterialName ); - if (!fillMat) - { - console.log( "object material not found in library: " + fillMaterialName ); - fillMat = new FlatMaterial(); - } - this._fillMaterial = fillMat; - } - - this.collidesWithPoint = function( x, y ) - { -// if(x < this._xOffset) return false; -// if(x > (this._xOffset + this._width)) return false; -// if(y < this._yOffset) return false; -// if(y > (this._yOffset + this._height)) return false; - - return true; - } - - this.containsPoint = function( pt, dir ) - { - var world = this.getWorld(); - if (!world) throw( "null world in containsPoint" ); - - // get a point on the plane of the circle - // the point is in NDC, as is the input parameters - var mat = this.getMatrix(); - var plane = [0,0,1,0]; - plane = MathUtils.transformPlane( plane, mat ); - var projPt = MathUtils.vecIntersectPlane ( pt, dir, plane ); - - // transform the projected point back to the XY plane - //var invMat = mat.inverse(); - var invMat = glmat4.inverse( mat, [] ); - var planePt = MathUtils.transformPoint( projPt, invMat ); - - // get the normalized device coordinates (NDC) for - // the position and radii. - var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); - var xNDC = 2*this._xOffset/vpw, yNDC = 2*this._yOffset/vph, - xRadNDC = this._width/vpw, yRadNDC = this._height/vph; - var projMat = world.makePerspectiveMatrix(); - var z = -world.getViewDistance(); - var planePtNDC = planePt.slice(0); - planePtNDC[2] = z; - planePtNDC = MathUtils.transformHomogeneousPoint( planePtNDC, projMat ); - planePtNDC = MathUtils.applyHomogeneousCoordinate( planePtNDC ); - - // get the gl coordinates - var aspect = world.getAspect(); - var zn = world.getZNear(), zf = world.getZFar(); - var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0), - b = -t, - r = aspect*t, - l = -r; - - var angle = Math.atan2( planePtNDC[1] - yNDC, planePtNDC[0] - xNDC ); - var degrees = angle*180.0/Math.PI; - var objPtNDC = [Math.cos(angle)*xRadNDC + xNDC, Math.sin(angle)*yRadNDC + yNDC, 0]; - - var ctrNDC = [xNDC, yNDC]; - - var distToBoundary = VecUtils.vecDist( 2, ctrNDC, objPtNDC ), - distToPt = VecUtils.vecDist( 2, ctrNDC, planePtNDC ); - - return (MathUtils.fpCmp(distToPt,distToBoundary) <= 0); - } - - this.getNearPoint = function( pt, dir ) - { - var world = this.getWorld(); - if (!world) throw( "null world in getNearPoint" ); - - // get a point on the plane of the circle - // the point is in NDC, as is the input parameters - var mat = this.getMatrix(); - var plane = [0,0,1,0]; - plane = MathUtils.transformPlane( plane, mat ); - var projPt = MathUtils.vecIntersectPlane ( pt, dir, plane ); - - // transform the projected point back to the XY plane - //var invMat = mat.inverse(); - var invMat = glmat4.inverse( mat, [] ); - var planePt = MathUtils.transformPoint( projPt, invMat ); - - // get the normalized device coordinates (NDC) for - // the position and radii. - var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); - var xNDC = 2*this._xOffset/vpw, yNDC = 2*this._yOffset/vph, - xRadNDC = this._width/vpw, yRadNDC = this._height/vph; - var projMat = world.makePerspectiveMatrix(); - var z = -world.getViewDistance(); - var planePtNDC = planePt.slice(0); - planePtNDC[2] = z; - planePtNDC = MathUtils.transformHomogeneousPoint( planePtNDC, projMat ); - planePtNDC = MathUtils.applyHomogeneousCoordinate( planePtNDC ); - - // get the gl coordinates - var aspect = world.getAspect(); - var zn = world.getZNear(), zf = world.getZFar(); - var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0), - b = -t, - r = aspect*t, - l = -r; - - var angle = Math.atan2( planePtNDC[1] - yNDC, planePtNDC[0] - xNDC ); - var degrees = angle*180.0/Math.PI; - var objPt = [Math.cos(angle)*xRadNDC + xNDC, Math.sin(angle)*yRadNDC + yNDC, 0]; - - // convert to GL coordinates - objPt[0] = -z*(r-l)/(2.0*zn)*objPt[0]; - objPt[1] = -z*(t-b)/(2.0*zn)*objPt[1]; - - // re-apply the transform - objPt = MathUtils.transformPoint( objPt, mat ); - - return objPt; - } - - this.recalcTexMapCoords = function( vrts, uvs ) - { - var n = vrts.length/3; - var ivrt = 0, iuv = 0; - var uMin = 1.e8, uMax = -1.e8, - vMin = 1.e8, vMax = -1.e8 - for (var i=0; i uMax) uMax = uvs[iuv]; - - iuv++; ivrt++; - uvs[iuv] = 0.5*(vrts[ivrt]/this._ovalHeight + 1); - if (uvs[iuv] < vMin) vMin = uvs[iuv]; - if (uvs[iuv] > vMax) vMax = uvs[iuv]; - iuv++; ivrt += 2; - } - - //console.log( "remap: " + uvs ); - //console.log( "uRange: " + uMin + " => " + uMax ); - //console.log( "vRange: " + vMin + " => " + vMax ); - } - } - - diff --git a/js/helper-classes/RDGE/GLGeomObj.js b/js/helper-classes/RDGE/GLGeomObj.js deleted file mode 100755 index c1ee01ba..00000000 --- a/js/helper-classes/RDGE/GLGeomObj.js +++ /dev/null @@ -1,278 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -/////////////////////////////////////////////////////////////////////// -// Class GLGeomObj -// Super class for all geometry classes -/////////////////////////////////////////////////////////////////////// -function GLGeomObj() -{ - /////////////////////////////////////////////////////////////////////// - // Constants - /////////////////////////////////////////////////////////////////////// - this.GEOM_TYPE_RECTANGLE = 1; - this.GEOM_TYPE_CIRCLE = 2; - this.GEOM_TYPE_LINE = 3; - this.GEOM_TYPE_PATH = 4; - this.GEOM_TYPE_CUBIC_BEZIER = 5; - this.GEOM_TYPE_UNDEFINED = -1; - - // Needed for calculating dashed/dotted strokes - this.DASH_LENGTH = 0.15; - this.DOT_LENGTH = 0.05; - this.GAP_LENGTH = 0.05; - - /////////////////////////////////////////////////////////////////////// - // Instance variables - /////////////////////////////////////////////////////////////////////// - this._matrix = Matrix.I(4); - - this._next = undefined; - this._prev = undefined; - this._child = undefined; - this._parent = undefined; - - this.m_world = null; - - // stroke and fill colors - this._strokeColor = [0,0,0,0]; - this._fillColor = [0,0,0,0]; - - // stroke and fill materials - this._fillMaterial; - this._strokeMaterial; - - // array of primitives - used in RDGE - this._primArray = []; - this._materialNodeArray = []; - this._materialArray = []; - this._materialTypeArray = []; - - // the transform node used by RDGE - this._trNode = null; - - - /////////////////////////////////////////////////////////////////////// - // Property accessors - /////////////////////////////////////////////////////////////////////// - this.setWorld = function( world ) { this.m_world = world; } - this.getWorld = function() { return this.m_world; } - - this.getMatrix = function() { return this._matrix.slice(0); } - this.setMatrix = function(m) { this._matrix = m.slice(0); } - - this.setNext = function( next ) { this._next = next; } - this.getNext = function() { return this._next; } - this.setPrev = function( prev ) { this._prev = prev; } - this.getPrev = function() { return this._prev; } - this.setChild = function( child ) { this._child = child; } - this.getChild = function() { return this._child; } - this.setParent = function( parent ) { this._parent = parent; } - this.getParent = function() { return this._parent; } - - this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; } - - this.getPrimitiveArray = function() { return this._primArray; } - this.getMaterialNodeArray = function() { return this._materialNodeArray; } - this.getMaterialArray = function() { return this._materialArray; } - - this.getTransformNode = function() { return this._trNode; } - this.setTransformNode = function(t) { this._trNode = t; } - - /////////////////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////////////////// - this.setMaterialColor = function(c, type) - { - if (type == "fill") - this._fillColor = c.slice(0); - else - this._strokeColor = c.slice(0); - if (this._materialArray && this._materialTypeArray) - { - var nMats = this._materialArray.length; - if (nMats === this._materialTypeArray.length) - { - for (var i=0; i= 0) - rtnStr = rtnStr.substr(0, index); - - return rtnStr; - } - - this.export = function() - { - var rtnStr; - - /* - var matNodeArr = this.getMaterialNodeArray(); - if (matNodeArr) - { - var nMats = matNodeArr.length; - if (nMats > 0) - { - for (var i=0; i