示例#1
0
        public bool BeginCapture(MMDModel target, HitResult hit)
        {
            // save local and world frames
            rotateFrameL = target.GetGameObjectFrame(CoordSpace.ObjectCoords);
            rotateFrameW = target.GetGameObjectFrame(CoordSpace.WorldCoords);
            rotateAxisW  = rotateFrameW.GetAxis(nRotationAxis);

            // save angle of hitpos in 2D plane perp to rotateAxis, so we can find delta-angle later
            Vector3f vWorldHitPos = hit.HitPosition;
            Vector3f dv           = vWorldHitPos - rotateFrameW.Origin;
            int      iX           = (nRotationAxis + 1) % 3;
            int      iY           = (nRotationAxis + 2) % 3;
            float    fX           = Vector3f.Dot(dv, rotateFrameW.GetAxis(iX));
            float    fY           = Vector3f.Dot(dv, rotateFrameW.GetAxis(iY));

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

            // construct plane we will ray-intersect with in UpdateCapture()
            raycastFrame = new Frame3f(vWorldHitPos, rotateAxisW);
            if (EnableSnapping)
            {
                //enable_circle_indicator(true);
            }

            return(true);
        }
示例#2
0
        public bool BeginCapture(MMDModel target, HitResult hit)
        {
            // save local and world frames
            translateFrameL = target.GetGameObjectFrame(CoordSpace.ObjectCoords);
            translateFrameW = target.GetGameObjectFrame(CoordSpace.WorldCoords);
            translateAxisW  = translateFrameW.GetAxis(nTranslationAxis);

            // save t-value of closest point on translation axis, so we can find delta-t
            Vector3 vWorldHitPos = hit.HitPosition;

            fTranslateStartT = ClosestPointOnLineT(
                translateFrameW.Origin, translateAxisW, vWorldHitPos);

            // construct plane we will ray-intersect with in UpdateCapture()
            Vector3 makeUp       = Vector3.Cross(Platform.Program.Camera.Forward, translateAxisW).GetNormalized( );
            Vector3 vPlaneNormal = Vector3.Cross(makeUp, translateAxisW).GetNormalized( );

            raycastFrame = new Frame3f(vWorldHitPos, vPlaneNormal);

            return(true);
        }