aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D
diff options
context:
space:
mode:
authorhwc4872012-07-09 16:08:02 -0700
committerhwc4872012-07-09 16:08:02 -0700
commit5085d0f67df89a21715308956004164597a6ba79 (patch)
tree2c896163143a66331205a39b0a3b1b45d51bf12a /js/helper-classes/3D
parent51f1691f792dbda9b740ded8aa0457c9406db156 (diff)
parent84b3327bd92faafab7954b5eb64c7abe24a3fe13 (diff)
downloadninja-5085d0f67df89a21715308956004164597a6ba79.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
Conflicts: js/helper-classes/3D/StageLine.js
Diffstat (limited to 'js/helper-classes/3D')
-rwxr-xr-xjs/helper-classes/3D/LinePlaneIntersectRec.js16
-rwxr-xr-xjs/helper-classes/3D/Rectangle.js10
-rwxr-xr-xjs/helper-classes/3D/StageLine.js87
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js2093
-rwxr-xr-xjs/helper-classes/3D/hit-record.js322
-rwxr-xr-xjs/helper-classes/3D/math-utils.js252
-rwxr-xr-xjs/helper-classes/3D/snap-2d-record.js84
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js4046
-rwxr-xr-xjs/helper-classes/3D/vec-utils.js146
-rwxr-xr-xjs/helper-classes/3D/view-utils.js328
10 files changed, 3693 insertions, 3691 deletions
diff --git a/js/helper-classes/3D/LinePlaneIntersectRec.js b/js/helper-classes/3D/LinePlaneIntersectRec.js
index 71ee81f4..ec2d6d57 100755
--- a/js/helper-classes/3D/LinePlaneIntersectRec.js
+++ b/js/helper-classes/3D/LinePlaneIntersectRec.js
@@ -60,17 +60,17 @@ var LinePlaneIntersectRec = exports.LinePlaneIntersectRec = Object.create(Object
60 getElementPlanes: { value: function() { return this._elementPlanes; } }, 60 getElementPlanes: { value: function() { return this._elementPlanes; } },
61 setElementPlanes: { value: function(p) { this._elementPlanes = p; } }, 61 setElementPlanes: { value: function(p) { this._elementPlanes = p; } },
62 62
63 getT: { value: function() { return this._t; } }, 63 getT: { value: function() { return this._t; } },
64 setT: { value: function(t) { this._t = t; } }, 64 setT: { value: function(t) { this._t = t; } },
65 65
66 setDeltaVis: { value: function(d) { this._deltaVis = d; } }, 66 setDeltaVis: { value: function(d) { this._deltaVis = d; } },
67 getDeltaVis: { value: function() { return this._deltaVis; } }, 67 getDeltaVis: { value: function() { return this._deltaVis; } },
68 68
69 setNext: { value: function(n) { this._next = n; } }, 69 setNext: { value: function(n) { this._next = n; } },
70 getNext: { value: function() { return this._next; } }, 70 getNext: { value: function() { return this._next; } },
71 71
72 getPrev: { value: function() { return this._prev; } }, 72 getPrev: { value: function() { return this._prev; } },
73 setPrev: { value: function(p) { this._prev = p; } } 73 setPrev: { value: function(p) { this._prev = p; } }
74 74
75 /////////////////////////////////////////////////////////////////////// 75 ///////////////////////////////////////////////////////////////////////
76 // Methods 76 // Methods
diff --git a/js/helper-classes/3D/Rectangle.js b/js/helper-classes/3D/Rectangle.js
index 1922bd91..15f812ab 100755
--- a/js/helper-classes/3D/Rectangle.js
+++ b/js/helper-classes/3D/Rectangle.js
@@ -67,7 +67,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, {
67 getHeight: { value: function() { return this.m_height; } }, 67 getHeight: { value: function() { return this.m_height; } },
68 setHeight: { value: function(h) { this.m_height = h; } }, 68 setHeight: { value: function(h) { this.m_height = h; } },
69 69
70 geomType: { value: function() { return this.GEOM_TYPE_RECTANGLE; } }, 70 geomType: { value: function() { return this.GEOM_TYPE_RECTANGLE; } },
71 71
72 /////////////////////////////////////////////////////////////////////// 72 ///////////////////////////////////////////////////////////////////////
73 // Methods 73 // Methods
@@ -84,7 +84,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, {
84 } 84 }
85 }, 85 },
86 86
87 dup: { 87 dup: {
88 value: function() 88 value: function()
89 { 89 {
90 var rtnRec = Object.create(Rectangle, {}); 90 var rtnRec = Object.create(Rectangle, {});
@@ -122,7 +122,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, {
122 } 122 }
123 }, 123 },
124 124
125 setToBounds: { 125 setToBounds: {
126 value: function( bounds ) 126 value: function( bounds )
127 { 127 {
128 var pt = bounds[0]; 128 var pt = bounds[0];
@@ -166,7 +166,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, {
166 } 166 }
167 }, 167 },
168 168
169 getQuadrant: { 169 getQuadrant: {
170 value: function( iQuad ) 170 value: function( iQuad )
171 { 171 {
172 // quadrant ordering starts at upper left and continues around counter-clockwise 172 // quadrant ordering starts at upper left and continues around counter-clockwise
@@ -220,7 +220,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, {
220 this.setTop( yMin ); this.setHeight( yMax - yMin ); 220 this.setTop( yMin ); this.setHeight( yMax - yMin );
221 } 221 }
222 }, 222 },
223 223
224 224
225 translate: { 225 translate: {
226 value: function( dx, dy ) 226 value: function( dx, dy )
diff --git a/js/helper-classes/3D/StageLine.js b/js/helper-classes/3D/StageLine.js
index 8292c469..c358108f 100755
--- a/js/helper-classes/3D/StageLine.js
+++ b/js/helper-classes/3D/StageLine.js
@@ -122,7 +122,7 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, {
122 // add the intersection 122 // add the intersection
123 var dot = MathUtils.dot3( pt0, planeEq ) + planeEq[3]; 123 var dot = MathUtils.dot3( pt0, planeEq ) + planeEq[3];
124 var deltaVis = (dot > 0) ? 1 : -1; 124 var deltaVis = (dot > 0) ? 1 : -1;
125// if (plane.isBackFacing()) 125// if (plane.isBackFacing())
126// deltaVis = (dot < 0) ? 1 : -1; 126// deltaVis = (dot < 0) ? 1 : -1;
127 127
128 this.addIntersection( plane, t, deltaVis ); 128 this.addIntersection( plane, t, deltaVis );
@@ -194,14 +194,14 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, {
194 MathUtils.negate( vec ); 194 MathUtils.negate( vec );
195 planeEq = [-vec[1], vec[0], 0]; 195 planeEq = [-vec[1], vec[0], 0];
196 var normal = [planeEq[0], planeEq[1], planeEq[2]]; 196 var normal = [planeEq[0], planeEq[1], planeEq[2]];
197// var d = -planeEq.dot(bPt0); 197// var d = -planeEq.dot(bPt0);
198 var d = -vecUtils.vecDot(3, planeEq, bPt0); 198 var d = -vecUtils.vecDot(3, planeEq, bPt0);
199 planeEq[3] = d; 199 planeEq[3] = d;
200 200
201 t = MathUtils.vecIntersectPlaneForParam( pt0, lineDir, planeEq ); 201 t = MathUtils.vecIntersectPlaneForParam( pt0, lineDir, planeEq );
202 if (t) 202 if (t)
203 { 203 {
204 if ((MathUtils.fpSign(t) > 0) && (MathUtils.fpCmp(t,1.0) <= 0)) // the strict vs not-strict inequality comparisons are IMPORTANT! 204 if ((MathUtils.fpSign(t) > 0) && (MathUtils.fpCmp(t,1.0) <= 0)) // the strict vs not-strict inequality comparisons are IMPORTANT!
205 { 205 {
206 // get the intersection point 206 // get the intersection point
207 var pt = MathUtils.interpolateLine3D( pt0, pt1, t ); 207 var pt = MathUtils.interpolateLine3D( pt0, pt1, t );
@@ -384,50 +384,51 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, {
384 if ((st0 >= 0) && (st1 >= 0)) 384 if ((st0 >= 0) && (st1 >= 0))
385 { 385 {
386 //if ( (plane.isBackFacing() && (s1 < 0)) || (!plane.isBackFacing() && (s1 > 0)) ) // entering the material from the beginning of the line that is to be drawn 386 //if ( (plane.isBackFacing() && (s1 < 0)) || (!plane.isBackFacing() && (s1 > 0)) ) // entering the material from the beginning of the line that is to be drawn
387 if (s1 > 0) // entering the material from the beginning of the line that is to be drawn
387 if (s1 > 0) 388 if (s1 > 0)
389 {
390 // see if the start point of the line is at a corner of the bounded plane
391 var lineDir = vecUtils.vecSubtract(3, pt1, pt0);
392 vecUtils.vecNormalize(3, lineDir);
393 var dist = vecUtils.vecDist( 3, pt0, bp1 );
394 var bp2, bv0, bv1, cross1, cross2, cross3;
395 if ( MathUtils.fpSign(dist) == 0)
388 { 396 {
389 // see if the start point of the line is at a corner of the bounded plane 397 bp2 = boundaryPts[(i+1) % 4];
390 var lineDir = vecUtils.vecSubtract(3, pt1, pt0); 398 bv0 = vecUtils.vecSubtract(3, bp2, bp1);
391 vecUtils.vecNormalize(3, lineDir); 399 bv1 = vecUtils.vecSubtract(3, bp0, bp1);
392 var dist = vecUtils.vecDist( 3, pt0, bp1 ); 400 cross1 = vecUtils.vecCross(3, bv0, lineDir);
393 var bp2, bv0, bv1, cross1, cross2, cross3; 401 cross2 = vecUtils.vecCross(3, lineDir, bv1);
394 if ( MathUtils.fpSign(dist) == 0) 402 cross3 = vecUtils.vecCross(3, bv0, bv1);
395 { 403 if ( (MathUtils.fpSign(vecUtils.vecDot(3, cross1, cross3)) == 0) && (MathUtils.fpSign(vecUtils.vecDot(3, cross2, cross3)) == 0))
396 bp2 = boundaryPts[(i+1) % 4];
397 bv0 = vecUtils.vecSubtract(3, bp2, bp1);
398 bv1 = vecUtils.vecSubtract(3, bp0, bp1);
399 cross1 = vecUtils.vecCross(3, bv0, lineDir);
400 cross2 = vecUtils.vecCross(3, lineDir, bv1);
401 cross3 = vecUtils.vecCross(3, bv0, bv1);
402 if ( (MathUtils.fpSign(vecUtils.vecDot(3, cross1, cross3)) == 0) && (MathUtils.fpSign(vecUtils.vecDot(3, cross2, cross3)) == 0))
403 {
404 gotEnter = true;
405 this.addIntersection( plane, t, 1 );
406 }
407 }
408 else if (MathUtils.fpSign( vecUtils.vecDist(3, pt0, bp0)) === 0)
409 { 404 {
410 bp2 = boundaryPts[(i+2) % 4]; 405 gotEnter = true;
411 bv0 = vecUtils.vecSubtract(3, bp2, bp0); 406 this.addIntersection( plane, t, 1 );
412 bv1 = vecUtils.vecSubtract(3, bp1, bp0);
413 cross1 = vecUtils.vecCross(3, bv0, lineDir);
414 cross2 = vecUtils.vecCross(3, lineDir, bv1);
415 cross3 = vecUtils.vecCross(3, bv0, bv1);
416 if ( (MathUtils.fpSign(vecUtils.vecDot(3, cross1, cross3)) == 0) && (MathUtils.fpSign(vecUtils.vecDot(3, cross2, cross3)) == 0))
417 {
418 gotEnter = true;
419 this.addIntersection( plane, t, 1 );
420 }
421 } 407 }
422 else 408 }
409 else if (MathUtils.fpSign( vecUtils.vecDist(3, pt0, bp0)) === 0)
410 {
411 bp2 = boundaryPts[(i+2) % 4];
412 bv0 = vecUtils.vecSubtract(3, bp2, bp0);
413 bv1 = vecUtils.vecSubtract(3, bp1, bp0);
414 cross1 = vecUtils.vecCross(3, bv0, lineDir);
415 cross2 = vecUtils.vecCross(3, lineDir, bv1);
416 cross3 = vecUtils.vecCross(3, bv0, bv1);
417 if ( (MathUtils.fpSign(vecUtils.vecDot(3, cross1, cross3)) == 0) && (MathUtils.fpSign(vecUtils.vecDot(3, cross2, cross3)) == 0))
423 { 418 {
424 // check if the line is on the edge of the boundary or goes to the interior
425 gotEnter = true; 419 gotEnter = true;
426 this.addIntersection( plane, t, 1 ); 420