コード例 #1
0
        private void trackBar_Scroll(object sender, EventArgs e)
        {
            TrackBar tb   = (TrackBar)sender;
            DOFDesc  desc = (DOFDesc)((object[])tb.Tag)[0];
            Label    lb   = (Label)((object[])tb.Tag)[1];

            lb.Text = (tb.Value / desc.Scale).ToString();
            _fromWinformPort.Post(new FromWinformMsg(FromWinformMsg.MsgEnum.MoveJoint, null, new MoveJoint(tb.Value / desc.Scale, desc.Name)));
        }
コード例 #2
0
        void MoveJoint(MoveJoint move)
        {
            DOFDesc   dof            = _state.Joints[move.Name];
            JointDesc desc           = dof.Description;
            Vector3   targetVelocity = new Vector3(0, 0, 0);

            switch (dof.Type)
            {
            case DOFType.Twist:
                desc.TwistAngle = (float)move.Angle;
                targetVelocity  = new Vector3((float)-move.Angle, 0, 0);
                break;

            case DOFType.Swing1:
                desc.Swing1Angle = (float)move.Angle;
                targetVelocity   = new Vector3(0, (float)-move.Angle, 0);
                break;

            case DOFType.Swing2:
                desc.Swing2Angle = (float)move.Angle;
                targetVelocity   = new Vector3(0, 0, (float)-move.Angle);
                break;

            case DOFType.X:
                desc.X         = (float)move.Angle;
                targetVelocity = new Vector3((float)-move.Angle, 0, 0);
                break;

            case DOFType.Y:
                desc.Y         = (float)move.Angle;
                targetVelocity = new Vector3(0, (float)-move.Angle, 0);
                break;

            case DOFType.Z:
                desc.Z         = (float)move.Angle;
                targetVelocity = new Vector3(0, 0, (float)-move.Angle);
                break;
            }

            PhysicsJoint thisJoint = null;

            if (desc.Joint != null)
            {
                thisJoint = (PhysicsJoint)desc.Joint;
            }
            else
            {
                thisJoint = (PhysicsJoint)desc.JointEntity.ParentJoint;
            }

            if (IsVelocityDrive(thisJoint.State, dof.Type))
            {
                _entity.DeferredTaskQueue.Post(new Task(() => SetDriveInternal(thisJoint, targetVelocity)));
            }
            else
            {
                Task <Physics.PhysicsJoint, Quaternion, Vector3> deferredTask =
                    new Task <Physics.PhysicsJoint, Quaternion, Vector3>(thisJoint, desc.JointOrientation, desc.JointPosition, SetDriveInternal);
                _entity.DeferredTaskQueue.Post(deferredTask);
            }
        }