Exemple #1
0
        public bool UpdateCapture(MMDModel target, RayWrap worldRay)
        {
            int normalAxis = 2;

            if (nRotationAxis == 2)
            {
                normalAxis = 1;
            }

            // ray-hit with plane perpendicular to rotateAxisW
            var planeHitWOpt = raycastFrame.RayPlaneIntersection(worldRay.From, worldRay.Dir, normalAxis);

            if (!planeHitWOpt.HasValue)
            {
                return(false);
            }
            var planeHitW = planeHitWOpt.Value;

            // find angle of hitpos in 2D plane perp to rotateAxis, and compute delta-angle
            Vector3f dv = planeHitW - rotateFrameW.Origin;
            int      iX = (nRotationAxis + 1) % 3;
            int      iY = (nRotationAxis + 2) % 3;
            float    fX = Vector3.Dot(dv, rotateFrameW.GetAxis(iX));
            float    fY = Vector3.Dot(dv, rotateFrameW.GetAxis(iY));

            Util.DebugWrite("dv " + dv.ToString( ));
            Util.DebugWrite("planeHitW " + planeHitW.ToString( ));
            Util.DebugWrite("rotateFrameW " + rotateFrameW.Origin.ToString( ));

            float fNewAngle = (float)Math.Atan2(fY, fX);

            //if ( AbsoluteAngleConstraintF != null )
            //	fNewAngle = AbsoluteAngleConstraintF( rotateFrameL , nRotationAxis , fNewAngle );

            float fDeltaAngle = (fNewAngle - fRotateStartAngle);

            //if (DeltaAngleConstraintF != null)
            //    fDeltaAngle = DeltaAngleConstraintF(rotateFrameL, nRotationAxis, fDeltaAngle);

            Util.DebugWrite("fDeltaAngle " + fDeltaAngle);

            fDeltaAngle *= 0.03f;

            bool on_snap = false;

            if (EnableSnapping)
            {
                //double dist = (planeHitW - rotateFrameW.Origin).Length();
                //on_snap = Math.Abs(dist - gizmoRadiusW) < gizmoRadiusW * 0.15f;
                //if (on_snap)
                //    fDeltaAngle = (float)Snapping.SnapToIncrement(fDeltaAngle, SnapIncrementDeg * MathUtil.Deg2Radf);
                //enable_snap_indicator(true);
                //update_snap_indicator(-fDeltaAngle, on_snap);
            }

            // 軸を中心に回るターゲットのための新しいフレームを作る
            Vector3f   rotateAxisL = rotateFrameL.GetAxis(nRotationAxis);
            Quaternion q           = Quaternion.RotationAxis(rotateAxisL, fDeltaAngle.Deg());
            Frame3f    newFrame    = rotateFrameL;

            newFrame.Rotation = q * newFrame.Rotation;                          // order matters here!

            // update target
            target.SetLocalFrame(newFrame, CoordSpace.ObjectCoords);

            if (EnableSnapping)
            {
                //update_circle_indicator(on_snap);
            }

            return(true);
        }
Exemple #2
0
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String"/> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(string.Format(CultureInfo.CurrentCulture, "Minimum:{0} Maximum:{1}", Minimum.ToString(), Maximum.ToString()));
 }
Exemple #3
0
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String"/> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(string.Format(CultureInfo.CurrentCulture, "Position:{0} Direction:{1}", Position.ToString(), Direction.ToString()));
 }
Exemple #4
0
 /// <summary>
 /// Returns a <see cref="System.String"/> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String"/> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(string.Format(CultureInfo.CurrentCulture, "Center:{0} Radius:{1}", Center.ToString(), Radius.ToString()));
 }