示例#1
0
        override public bool FindRayIntersection(Ray3f ray, out SORayHit hit)
        {
            hit = null;

            Ray     sceneRay = GetScene().ToSceneRay(ray);
            Frame3f frameL   = GetLocalFrame(CoordSpace.ObjectCoords);
            Ray     localRay = frameL.ToFrame(sceneRay);

            float sceneWidth = GetScene().ToSceneDimension(visibleWidth);

            AxisAlignedBox3d hitBox = localBounds;

            hitBox.Expand(sceneWidth * 0.5f);
            Bounds hitBounds = new Bounds((Vector3)hitBox.Center, (Vector3)hitBox.Diagonal);

            if (hitBounds.IntersectRay(localRay) == false)
            {
                return(false);
            }

            double rayHitT;

            if (CurveUtils.FindClosestRayIntersection(curve, sceneWidth * 0.5f, localRay, out rayHitT))
            {
                hit           = new SORayHit();
                hit.fHitDist  = (float)rayHitT;
                hit.hitPos    = localRay.GetPoint(hit.fHitDist);
                hit.hitPos    = GetScene().ToWorldP(frameL.FromFrameP(hit.hitPos));
                hit.hitNormal = Vector3.zero;
                hit.hitGO     = root;
                hit.hitSO     = this;
                return(true);
            }
            return(false);
        }
示例#2
0
        void generate_points(PivotSO pivotSO, Frame3f targetSceneF)
        {
            PivotSOSnapPoint pt   = new PivotSOSnapPoint(pivotSO);
            Frame3f          objF = targetSceneF.ToFrame(pt.FrameS);

            snapFramesL.Add(objF);
        }
示例#3
0
        public static void SetBasePoint(FScene scene, DMeshSO so, Frame3f baseFrameS, bool bInteractive)
        {
            Frame3f curFrameS = so.GetLocalFrame(CoordSpace.SceneCoords);
            Frame3f relFrameS = baseFrameS.ToFrame(curFrameS);

            baseFrameS.AlignAxis(2, -Vector3f.AxisY);
            baseFrameS.Translate(-baseFrameS.Origin);

            Frame3f           newFrameS = baseFrameS.FromFrame(relFrameS);
            TransformSOChange change    = new TransformSOChange(so, curFrameS, newFrameS, CoordSpace.SceneCoords);

            change.Tags.Add("SetBasePoint");
            scene.History.PushChange(change, false);

            Frame3f pivotS = Frame3f.Identity;
            // WHAT why is it the scene pivot ?!
            //Frame3f pivotL = SceneTransforms.SceneToObject(so, pivotS);
            RepositionPivotChangeOp pivotChange = new RepositionPivotChangeOp(pivotS, so);

            scene.History.PushChange(pivotChange, false);

            if (bInteractive)
            {
                scene.History.PushInteractionCheckpoint();
            }
        }
示例#4
0
        void generate_points(PolyCurveSO curveSO, Frame3f targetSceneF)
        {
            CurveSnapGenerator snapGen = new CurveSnapGenerator();
            List <ISnapPoint>  points  = snapGen.GeneratePoints(curveSO);

            foreach (ISnapPoint pt in points)
            {
                Frame3f objF = targetSceneF.ToFrame(pt.FrameS);
                snapFramesL.Add(objF);
            }
        }
示例#5
0
        void generate_points(PrimitiveSO primSO, Frame3f targetSceneF)
        {
            PrimitiveSnapGenerator snapGen = new PrimitiveSnapGenerator();
            List <ISnapPoint>      points  = snapGen.GeneratePoints(primSO);

            foreach (ISnapPoint pt in points)
            {
                Frame3f objF = targetSceneF.ToFrame(pt.FrameS);
                snapFramesL.Add(objF);
            }
        }
示例#6
0
        public void BeginBrushStroke(Frame3f vFrame)
        {
            if (in_stroke)
            {
                throw new Exception("SculptCurveTool.BeginBrushStroke: already in brush stroke!");
            }

            if (targets.Count > 0)
            {
                Frame3f localFrame = targets[0].GetLocalFrame(CoordSpace.ObjectCoords);
                Frame3f vFrameL    = localFrame.ToFrame(scene.ToSceneFrame(vFrame));
                begin_stroke(vFrameL);
            }
            in_stroke    = true;
            lastBrushPos = vFrame;
        }
示例#7
0
 public static Frame3f GetSOLocalFrame(SceneObject so, CoordSpace eSpace)
 {
     if (eSpace == CoordSpace.SceneCoords)
     {
         Frame3f sceneW = UnityUtil.GetGameObjectFrame(so.GetScene().RootGameObject, CoordSpace.WorldCoords);
         Frame3f objW   = UnityUtil.GetGameObjectFrame(so.RootGameObject, CoordSpace.WorldCoords);
         Frame3f result = sceneW.ToFrame(objW);
         // world coords have scene scale applied, we don't want that in scene coords
         if (so.GetScene().GetSceneScale() != 1.0f)
         {
             result = result.Scaled(1.0f / so.GetScene().GetSceneScale());
         }
         return(result);
     }
     else
     {
         return(UnityUtil.GetGameObjectFrame(so.RootGameObject, eSpace));
     }
 }
示例#8
0
        public void UpdateBrushStroke(Frame3f vFrame)
        {
            if (in_stroke == false)
            {
                throw new Exception("SculptCurveTool.UpdateBrushStroke: not in brush stroke!");
            }

            // ignore large jumps in brush position, which make a mess of curve
            if (lastBrushPos.Origin.Distance(vFrame.Origin) > Radius.WorldValue)
            {
                return;
            }

            Frame3f localFrame = targets[0].GetLocalFrame(CoordSpace.ObjectCoords);
            Frame3f vFrameL    = localFrame.ToFrame(scene.ToSceneFrame(vFrame));
            bool    bModified  = update_stroke(vFrameL);

            if (bModified && ProjectionTarget != null)
            {
                project_to_target();
            }

            lastBrushPos = vFrame;
        }
示例#9
0
        override public bool FindRayIntersection(Ray3f ray, out SORayHit hit)
        {
            hit = null;

            Frame3f frameW   = GetLocalFrame(CoordSpace.WorldCoords);
            Ray     localRay = frameW.ToFrame(ray);

            Bounds hitBounds = GetLocalBoundingBox();

            if (hitBounds.IntersectRay(localRay) == false)
            {
                return(false);
            }

            GameObjectRayHit goHit;

            if (UnityUtil.FindGORayIntersection(ray, meshGO, out goHit))
            {
                hit = new SORayHit(goHit, this);
                return(true);
            }

            return(false);
        }
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            if ((data.which == CaptureSide.Left && input.bLeftShoulderReleased) ||
                (data.which == CaptureSide.Right && input.bRightShoulderReleased) ||
                (data.which == CaptureSide.Left && input.bRightShoulderPressed) ||
                (data.which == CaptureSide.Right && input.bLeftShoulderPressed))
            {
                cockpit.ActiveCamera.SetTargetVisible(false);
                return(Capture.End);
            }

            // [RMS] this is a hack to release input for shoulder+trigger gestures
            if ((data.which == CaptureSide.Left && input.bLeftTriggerPressed) ||
                (data.which == CaptureSide.Right && input.bRightTriggerPressed))
            {
                cockpit.ActiveCamera.SetTargetVisible(false);
                return(Capture.End);
            }

            cockpit.ActiveCamera.SetTargetVisible(false);

            GrabHandInfo hi = (GrabHandInfo)data.custom_data;

            Frame3f StartF = Frame3f.Identity;
            Frame3f CurF   = Frame3f.Identity;

            if (data.which == CaptureSide.Left)
            {
                StartF = hi.leftStartF;
                CurF   = input.LeftHandFrame;
            }
            else if (data.which == CaptureSide.Right)
            {
                StartF = hi.rightStartF;
                CurF   = input.RightHandFrame;
            }

/*          orbit-style variant, does not work yet
 *          // translation is just controller world-movement
 *          Vector3f translation = CurF.Origin - StartF.Origin;
 *
 *          // We figure out orbit by rotating cur & start frames such that the axis we
 *          // want to measure around is that world axis. This produces more stable angles
 *          // as the controller twists
 *
 *          Frame3f YAlignedStartF = StartF; YAlignedStartF.AlignAxis(1, Vector3f.AxisY);
 *          Frame3f YAlignedCurF = CurF; YAlignedCurF.AlignAxis(1, Vector3f.AxisY);
 *          float fAngleX = (float)MathUtil.PlaneAngleSignedD(YAlignedStartF.X, YAlignedCurF.X, Vector3f.AxisY);
 *
 *          Frame3f XAlignedStartF = StartF; XAlignedStartF.AlignAxis(0, Vector3f.AxisX);
 *          Frame3f XAlignedCurF = CurF; XAlignedCurF.AlignAxis(0, Vector3f.AxisX);
 *          float fAngleY = (float)MathUtil.PlaneAngleSignedD(XAlignedStartF.Y, XAlignedCurF.Y, Vector3f.AxisX);
 */

            Frame3f relStartF = StartF.ToFrame(hi.startCamF);
            Frame3f curF      = CurF.FromFrame(relStartF);

            // apply camera xforms
            //cockpit.ActiveCamera.Manipulator().SetCurrentSceneState(cockpit.Scene, hi.camState);

            //cockpit.ActiveCamera.Manipulator().SceneOrbitAround(cockpit.Scene,
            //    CurF.Origin, -RotationSpeed * fAngleX, RotationSpeed * fAngleY);
            //cockpit.ActiveCamera.Manipulator().SceneTumbleAround(cockpit.Scene,
            //    CurF.Origin, RotationSpeed * fAngleX, RotationSpeed * fAngleY);
            //cockpit.ActiveCamera.Manipulator().SceneRotateAround(cockpit.Scene, relF.Rotation, CurF.Origin);

            cockpit.ActiveCamera.Manipulator().SceneSetFrame(cockpit.Scene, curF);

            //cockpit.ActiveCamera.Manipulator().SceneTranslate(cockpit.Scene, TranslationSpeed * translation);

            return(Capture.Continue);
        }