diff options
author | Nivesh Rajbhandari | 2012-04-04 17:24:27 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-04-04 17:24:27 -0700 |
commit | 01cf259da7aaa7d70789d9a7c32111d88b477463 (patch) | |
tree | 0bff3395ac681e5f685d2267f7dbc03a8e32bc4a /js/tools/Translate3DToolBase.js | |
parent | 331ea08655245e3532e48bf160d5f68a04d8723f (diff) | |
parent | 13368ca6ebbc13adeafccd898dfffd7ce37cb28a (diff) | |
download | ninja-01cf259da7aaa7d70789d9a7c32111d88b477463.tar.gz |
Merge branch 'refs/heads/ToolFixes' into WebGLMaterials
Conflicts:
js/document/templates/montage-html/default_html.css
js/mediators/element-mediator.js
js/panels/properties.reel/properties.js
js/tools/BrushTool.js
js/tools/LineTool.js
js/tools/PenTool.js
js/tools/SelectionTool.js
js/tools/ShapeTool.js
js/tools/TranslateObject3DTool.js
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/tools/Translate3DToolBase.js')
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index b7bce2be..3976c5b9 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js | |||
@@ -29,6 +29,8 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
29 | modifyElements : { | 29 | modifyElements : { |
30 | value : function(data, event) | 30 | value : function(data, event) |
31 | { | 31 | { |
32 | //console.log( "modifyElements, data: " + data.pt0 + " => " + data.pt1 ); | ||
33 | |||
32 | // form the translation vector and post translate the matrix by it. | 34 | // form the translation vector and post translate the matrix by it. |
33 | var delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); | 35 | var delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); |
34 | if(this._handleMode !== null) | 36 | if(this._handleMode !== null) |
@@ -66,15 +68,12 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
66 | delta[0] = 0; | 68 | delta[0] = 0; |
67 | delta[1] = 0; | 69 | delta[1] = 0; |
68 | } | 70 | } |
69 | else | ||
70 | { | ||
71 | delta[2] = 0; | ||
72 | } | ||
73 | this._delta = delta.slice(0); | 71 | this._delta = delta.slice(0); |
74 | } | 72 | } |
75 | 73 | ||
76 | var transMat = Matrix.Translation( delta ); | 74 | var transMat = Matrix.Translation( delta ); |
77 | 75 | ||
76 | //console.log( "Translate: " + delta ); | ||
78 | if(this._inLocalMode && (this._targets.length === 1) ) | 77 | if(this._inLocalMode && (this._targets.length === 1) ) |
79 | { | 78 | { |
80 | this._translateLocally(transMat); | 79 | this._translateLocally(transMat); |
@@ -137,6 +136,9 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
137 | // We will only translate single elements locally | 136 | // We will only translate single elements locally |
138 | _translateLocally: { | 137 | _translateLocally: { |
139 | value: function (transMat) { | 138 | value: function (transMat) { |
139 | //console.log( "_translateLocally, startMat: " + this._startMat ); | ||
140 | //console.log( "_translateLocally, transMat: " + transMat ); | ||
141 | //console.log( "_translateLocally, startMat: " + this._startMat + ", transMat: " + transMat ); | ||
140 | var mat = glmat4.multiply(this._startMat, transMat, []); | 142 | var mat = glmat4.multiply(this._startMat, transMat, []); |
141 | viewUtils.setMatrixForElement( this._target, mat, true ); | 143 | viewUtils.setMatrixForElement( this._target, mat, true ); |
142 | if(this._mode !== 1) | 144 | if(this._mode !== 1) |
@@ -148,14 +150,22 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
148 | 150 | ||
149 | _translateGlobally: { | 151 | _translateGlobally: { |
150 | value: function (transMat) { | 152 | value: function (transMat) { |
153 | //console.log( "_translateGlobally, startMat: " + this._startMat + ", transMat: " + transMat ); | ||
154 | //console.log( "_translateGlobally, transMat: " + transMat ); | ||
151 | var len = this._targets.length, | 155 | var len = this._targets.length, |
152 | i = 0, | 156 | i = 0, |
153 | item, | 157 | item, |
154 | elt, | 158 | elt, |
155 | curMat, | 159 | curMat = viewUtils.getMatrixFromElement( this._target ), |
156 | matInv = glmat4.inverse(this._startMat, []), | 160 | matInv = glmat4.inverse(this._startMat, []), |
157 | nMat = glmat4.multiply(transMat, this._startMat, [] ), | 161 | nMat = glmat4.multiply(transMat, this._startMat, [] ), |
158 | qMat = glmat4.multiply(matInv, nMat, []); | 162 | qMat = glmat4.multiply(matInv, nMat, []); |
163 | |||
164 | if (this._mode === 1) | ||
165 | { | ||
166 | var curInv = glmat4.inverse( curMat, [] ); | ||
167 | transMat = glmat4.multiply( nMat, curInv, [] ); | ||
168 | } | ||
159 | 169 | ||
160 | var shouldUpdateStartMat = true; | 170 | var shouldUpdateStartMat = true; |
161 | 171 | ||
@@ -184,6 +194,7 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
184 | 194 | ||
185 | if(shouldUpdateStartMat) | 195 | if(shouldUpdateStartMat) |
186 | { | 196 | { |
197 | //console.log( "\t\tshouldUpdateStartMat" ); | ||
187 | this._targets[i].mat = curMat; | 198 | this._targets[i].mat = curMat; |
188 | } | 199 | } |
189 | } | 200 | } |
@@ -191,14 +202,16 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, | |||
191 | }, | 202 | }, |
192 | 203 | ||
193 | _updateTargets: { | 204 | _updateTargets: { |
194 | value: function(addToUndoStack) { | 205 | value: function(addToUndoStack) |
206 | { | ||
207 | console.log( "_updateTargets" ); | ||
195 | var newStyles = [], | 208 | var newStyles = [], |
196 | previousStyles = [], | 209 | previousStyles = [], |
197 | len = this.application.ninja.selectedElements.length; | 210 | len = this.application.ninja.selectedElements.length; |
198 | this._targets = []; | 211 | this._targets = []; |
199 | for(var i = 0; i < len; i++) | 212 | for(var i = 0; i < len; i++) |
200 | { | 213 | { |
201 | var elt = this.application.ninja.selectedElements[i]._element; | 214 | var elt = this.application.ninja.selectedElements[i]; |
202 | 215 | ||
203 | var curMat = viewUtils.getMatrixFromElement(elt); | 216 | var curMat = viewUtils.getMatrixFromElement(elt); |
204 | var curMatInv = glmat4.inverse(curMat, []); | 217 | var curMatInv = glmat4.inverse(curMat, []); |