Beispiel #1
0
        private void ProcessMouseManipulation()
        {
            if (!MouseTracker.LeftMousePressed)
            {
                checkForHit = true;
                hitActor    = null;

                HookPoint            = Point3d.Unset;
                HookPointOnMouseLine = Point3d.Unset;
            }
            else
            {
                if (checkForHit)
                {
                    checkForHit = false;
                    Vector3d mouseLineDirection = MouseTracker.MouseLine.Direction;
                    mouseLineDirection.Unitize();
                    PxGhManager.Scene.Raycast(
                        MouseTracker.MouseLine.From.ToSystemVector(),
                        mouseLineDirection.ToSystemVector(),
                        9999f,
                        999,
                        HitCallback,
                        HitFlag.Position);
                }

                if (hitActor != null)
                {
                    Rhino.Geometry.Plane frame = hitActor.GlobalPose.ToRhinoPlane();
                    HookPoint            = frame.Origin + frame.XAxis * hookPoint.X + frame.YAxis * hookPoint.Y + frame.ZAxis * hookPoint.Z;
                    HookPointOnMouseLine = MouseTracker.MouseLine.ClosestPoint(HookPoint, false);

                    if (MouseManipulationMode == MouseManipulationMode.Position)
                    {
                        frame.Origin            = HookPointOnMouseLine + (frame.Origin - HookPoint);
                        hitActor.GlobalPose     = frame.ToMatrix();
                        hitActor.LinearVelocity = Vector3.Zero;
                        hitActor.AddForceAtLocalPosition((hitActor.Mass * -Gravity).ToSystemVector(), hookPoint.ToSystemVector(), ForceMode.Force, true);
                    }
                    else
                    {
                        Vector3d force = (HookPointOnMouseLine - HookPoint) * MouseManipulationStrength *
                                         (MouseManipulationMode == MouseManipulationMode.Acceleration ? hitActor.Mass : 1.0);
                        hitActor.AddForceAtLocalPosition(force.ToSystemVector(), hookPoint.ToSystemVector(), ForceMode.Force, true);
                    }
                }
            }
        }
Beispiel #2
0
        protected override void ProcessKeyboard(Key[] pressedKeys)
        {
            if (pressedKeys.Contains(Key.P))
            {
                _sphereC.AddForceAtLocalPosition(new Vector3(25, 0, 0), new Vector3(0, 0, 0));
            }

            base.ProcessKeyboard(pressedKeys);
        }
Beispiel #3
0
 public void ApplyForceLocal(OpenTK.Vector3 imp, OpenTK.Vector3 local)
 {
     ID.AddForceAtLocalPosition(new System.Numerics.Vector3(imp.X, imp.Y, imp.Z), new System.Numerics.Vector3(local.X, local.Y, local.Z), ForceMode.Force, true);
 }
 public override void ApplyImpulse(Vector3 position, Vector3 force)
 {
     rigidActor.AddForceAtLocalPosition(force.AsPhysX(), position.AsPhysX());
 }