From 51b4e61d6c6df5e88e9a5dfcdfd7944e2a3f64e7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 13:25:15 -0800 Subject: Syncing stage view when rotating stage. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 3fd6e8fc..c26a5cd1 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -107,6 +107,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementDeleted", this, false); + this.eventManager.addEventListener("elementChange", this, false); } }, @@ -124,6 +125,27 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { }, + handleElementChange: { + value: function(event) { + var els = event.detail.data.els; + if(els) + { + var len = els.length, + i = 0, + item, + el; + + for(i=0; i < len; i++) { + item = els[i]; + el = item._element || item; + el.elementModel.props3D.elementPlane.init(); + } + + this.drawWorkingPlane(); + } + } + }, + /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// @@ -150,6 +172,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { plane.setElement( elt ); plane.init(); this._planesArray.push( plane ); + elt.elementModel.props3D.elementPlane = plane; } }, @@ -166,6 +189,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // Then remove the element this._eltArray.splice(i, 1); + + // TODO - May need to delete props3D and elementPlane as well return; } } -- cgit v1.2.3 From cbdc001ea4afd054e7a9e1b4e54629254a68376b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 30 Jan 2012 16:14:43 -0800 Subject: Removing unused Properties3D file since those values are now saved with the models. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/Properties3D.js | 82 --------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 js/helper-classes/Properties3D.js (limited to 'js/helper-classes') diff --git a/js/helper-classes/Properties3D.js b/js/helper-classes/Properties3D.js deleted file mode 100644 index 42499877..00000000 --- a/js/helper-classes/Properties3D.js +++ /dev/null @@ -1,82 +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 that holds all 3d properties per element. -*/ - -exports.Properties3D = Object.create(Object.prototype, { - m_element : {value : null, writable:true, enumerable:true, configurable:true}, - -// m_upVector : {value : Vector.create( [0,1,0] ), writable: true, enumerable: true, configurable: true}, - m_azimuth : {value : 0.0, writable: true, enumerable: true, configurable: true}, - m_altitude : {value : 0.0, writable: true, enumerable: true, configurable: true}, - - m_transformCtr : {value : null, writable: true, enumerable: true, configurable: true}, -// m_targetPos : {value : Vector.create( [0,0,0] ), writable: true, enumerable: true, configurable: true}, - - m_endAzimuth : {value : 0, writable: true, enumerable: true, configurable: true}, - m_endAltitude : {value : 0, writable: true, enumerable: true, configurable: true}, - -// m_objStartPos : {value : Vector.create( [0,0,0] ), writable: true, enumerable: true, configurable: true}, - - //TODO - not sure if this should be part of the tool or stage or a utility - perspectiveDist : { value : 1400, writable: true, enumerable: true, configurable: true}, - - // keep a referenceto the GLWorld (if any) - _world : {value : null, writable:true, enumerable:true, configurable:true}, - - // keep a flag indicating the element is in the 2D snap cache - _eltIsIn2DSnapCache : { value: false, writable: true, enumerable: true, configurable: true}, - - Init : { - value : function(elt) - { - this.m_element = elt; - - this.m_azimuth = 0.0; - this.m_altitude = 0.0; - - this.m_endAzimuth = 0.0; - this.m_endAltitude = 0.0; - -// this.m_upVector = Vector.create( [0,1,0] ); -// this.m_viewDir = Vector.create( [0,0,1] ); -// this.m_endUpVector = Vector.create( [0,1,0] ); - - this.m_transformCtr = null; -// this.m_targetPos = Vector.create( [0,0,0] ); - -// this.m_objStartPos = Vector.create( [0,0,0] ); - - this.perspectiveDist = 1400; - } - }, - - ResetRotationValues : { - value : function(elt) - { -// this.m_upVector = Vector.create( [0,1,0] ); -// this.m_viewDir = Vector.create( [0,0,1] ); - - this.m_azimuth = 0.0; - this.m_altitude = 0.0; - - this.m_endAzimuth = 0.0; - this.m_endAltitude = 0.0; - - this.m_transformCtr = null; -// this.m_targetPos = Vector.create( [0,0,0] ); - } - }, - - ResetTranslationValues : { - value : function(elt) - { -// this.m_objStartPos = Vector.create( [0,0,0] ); - this.perspectiveDist = 1400; - } - } -}); \ No newline at end of file -- cgit v1.2.3 From 7534bd7acc822dea641b1547cd955801920055aa Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 2 Feb 2012 13:55:55 -0800 Subject: Adding legal attribution for decompose matrix routine. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/math-utils.js | 54 ++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 25 deletions(-) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 49c77c41..71ed62a0 100644 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js @@ -891,36 +891,32 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { } }, +/** +* decompose matrix in javascript found at https://github.com/joelambert/morf/blob/master/js/src/WebkitCSSMatrix.ext.js +* used with permission from Joe Lambert: "as long as the original licence text and attribution is left in then you're +* good to use it as you see fit." +* +* WebKitCSSMatrix Extensions +* +* Copyright 2011, Joe Lambert (http://www.joelambert.co.uk) +* Free to use under the MIT license. +* http://joelambert.mit-license.org/ +*/ + +/** +* Decomposes the matrix into its component parts. +* A Javascript implementation of the pseudo code available from http://www.w3.org/TR/css3-2d-transforms/#matrix-decomposition +* @author Joe Lambert +* @returns {Object} An object with each of the components of the matrix (perspective, translate, skew, scale, rotate) or identity matrix on failure +*/ + // Input: matrix ; a 4x4 matrix // Output: translation ; a 3 component vector // rotation ; Euler angles, represented as a 3 component vector // scale ; a 3 component vector // skew ; skew factors XY,XZ,YZ represented as a 3 component vector // perspective ; a 4 component vector -// Returns false if the matrix cannot be decomposed, an object with the above output values if it can -// -// Supporting functions (point is a 3 component vector, matrix is a 4x4 matrix): -// float determinant(matrix) returns the 4x4 determinant of the matrix -// matrix inverse(matrix) returns the inverse of the passed matrix -// matrix transpose(matrix) returns the transpose of the passed matrix -// point multVecMatrix(point, matrix) multiplies the passed point by the passed matrix -// and returns the transformed point -// float length(point) returns the length of the passed vector -// point normalize(point) normalizes the length of the passed point to 1 -// float dot(point, point) returns the dot product of the passed points -// float cos(float) returns the cosine of the passed angle in radians -// float asin(float) returns the arcsine in radians of the passed value -// float atan2(float y, float x) returns the principal value of the arc tangent of -// y/x, using the signs of both arguments to determine -// the quadrant of the return value -// -// Decomposition also makes use of the following function: -// point combine(point a, point b, float ascl, float bscl) -// result[0] = (ascl * a[0]) + (bscl * b[0]) -// result[1] = (ascl * a[1]) + (bscl * b[1]) -// result[2] = (ascl * a[2]) + (bscl * b[2]) -// return result -// +// Returns false if the matrix cannot be decomposed. An object with the above output values if it can. decomposeMatrix2: { value: function(m) { @@ -1077,7 +1073,6 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { rotate[2] = 0; } -// return true; return {translation: translate, rotation: rotate, scale: scale, @@ -1087,6 +1082,15 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { } }, +/** +* Helper function required for matrix decomposition +* A Javascript implementation of pseudo code available from http://www.w3.org/TR/css3-2d-transforms/#matrix-decomposition +* @param {Vector4} aPoint A 3D point +* @param {float} ascl +* @param {float} bscl +* @author Joe Lambert +* @returns {Vector4} +*/ combine: { value: function(a, b, ascl, bscl) { -- cgit v1.2.3 From d41dee0c552a30724a146965ae4272a268777fc5 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 2 Feb 2012 14:53:14 -0800 Subject: Integrating Pan and Zoom tool and snap manager fixes. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 3 ++- js/helper-classes/3D/snap-manager.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index c26a5cd1..fd96af4d 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -1089,7 +1089,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { var resMat = glmat4.multiply( tMat, mat, [] ); var origin = [0,0,0,1]; - var arrowSize = 50; + var zoomFactor = this.application.ninja.documentBar.zoomFactor/100.0; + var arrowSize = 50 / zoomFactor; var xAxis = [arrowSize,0,0,1]; //var rO = resMat.multiply(origin); var rO = glmat4.multiplyVec3( resMat, origin, []); diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 3ed96082..8819f637 100644 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -1780,7 +1780,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { var mergedSnap = this.mergeHitRecords( hitRecs ); if (mergedSnap) { - while (hitRecs.length > 0) hitRecs.pop(); + while (hitRecs.length > 0) hitRecs.pop(); hitRecs.push( mergedSnap ); //console.log( "merged snaps" ); } @@ -1836,6 +1836,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hSnap.setLocalPoint( localPt ); hSnap.setScreenPoint( scrPt ); hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); + hSnap.setElement( stage ); + hSnap.setPlane( [0,0,1,0] ); + hSnap.setPlaneMatrix( Matrix.I(4) ); if (vSnap.hasAssociatedScreenPoint() ) hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); if (vSnap.hasAssociatedScreenPoint2() ) @@ -1882,6 +1885,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hSnap.setLocalPoint( localPt ); hSnap.setScreenPoint( scrPt ); hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); + hSnap.setElement( stage ); + hSnap.setPlane( [0,0,1,0] ); + hSnap.setPlaneMatrix( Matrix.I(4) ); if (vSnap.hasAssociatedScreenPoint() ) hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); if (vSnap.hasAssociatedScreenPoint2() ) @@ -1934,6 +1940,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hSnap.setLocalPoint( localPt ); hSnap.setScreenPoint( scrPt ); hSnap.setType( hSnap.SNAP_TYPE_ALIGN_MERGED ); + hSnap.setElement( stage ); + hSnap.setPlane( [0,0,1,0] ); + hSnap.setPlaneMatrix( Matrix.I(4) ); if (vSnap.hasAssociatedScreenPoint() ) hSnap.setAssociatedScreenPoint( vSnap.getAssociatedScreenPoint() ); if (vSnap.hasAssociatedScreenPoint2() ) -- cgit v1.2.3 From 1a8bcab85cd71447bbd1b66daf95d1c8fbca8c2b Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 1 Feb 2012 23:53:47 -0800 Subject: Fixes for montage integration Signed-off-by: Valerio Virgillito --- js/helper-classes/RDGE/GLBrushStroke.js | 1 + js/helper-classes/RDGE/GLSubpath.js | 1 + 2 files changed, 2 insertions(+) (limited to 'js/helper-classes') diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js index 89292ad8..e3b14bf7 100644 --- a/js/helper-classes/RDGE/GLBrushStroke.js +++ b/js/helper-classes/RDGE/GLBrushStroke.js @@ -4,6 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ +// Todo: This shoudl be converted to a module var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js index 25b12093..55b7e49a 100644 --- a/js/helper-classes/RDGE/GLSubpath.js +++ b/js/helper-classes/RDGE/GLSubpath.js @@ -4,6 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ +// Todo: This shoudl be converted to a module var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; -- cgit v1.2.3