コード例 #1
0
        public override void Start()
        {
            base.Start();
            _physicsHand = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogWarning("PhysicsWrist needs a PhysicsHand");
            }

            _phalange = HandFactory.GetPhalange(gameObject, 0, 0, DeviceType);
        }
コード例 #2
0
ファイル: PhysicsWrist.cs プロジェクト: h2oz/AlloHouston
        public override void Start()
        {
            base.Start();
            _selfRigidbody             = GetComponent <Rigidbody>();
            _selfRigidbody.constraints = RigidbodyConstraints.FreezeRotation;
            _physicsHand = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogWarning("PhysicsWrist needs a PhysicsHand");
            }

            _phalange = HandFactory.GetPhalange(gameObject, 0, 0, DeviceType);
        }
コード例 #3
0
        public override void Start()
        {
            base.Start();
            //_thumbRigidbody = Phalanges[1].GetComponent<Rigidbody>();
            _physicsHand = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogError("Physics thumb only works with a physics hand");
            }
            // Get the thumb of the target hand
            ConfigureThumb(Phalanges[1]);

            AddHingeJoint(Phalanges[2], -Hand.WristTransform.right, _thumbRigidbody);
            _phalange = HandFactory.GetPhalange(Phalanges[2], Index, 2, DeviceType);
        }
コード例 #4
0
        private void Start()
        {
            var controllers = GetComponents <PhysicsHand>();

            foreach (var controller in controllers)
            {
                if (controller.DeviceType == DeviceType)
                {
                    _physicsHand = controller;
                }
            }

            _throwHandler = gameObject.GetComponentsInChildren <ThrowHandler>()
                            .FirstOrDefault(handler => handler.DeviceType == DeviceType);

            if (_throwHandler == null)
            {
                _throwHandler            = gameObject.AddComponent <ThrowHandler>();
                _throwHandler.DeviceType = DeviceType;
            }
        }
コード例 #5
0
        void Start()
        {
            var controllers = GetComponents <PhysicsHand>();

            foreach (var controller in controllers)
            {
                if (controller.DeviceType == DeviceType)
                {
                    _physicsRegularHand = controller;
                }
            }

            _lineRendererMaterial = Resources.Load <Material>("LineMaterial");

            //TODO: Which gameobject should have these line renderers?
            if (_showInitialTrajectory)
            {
                _initialTrajectoryLineRenderer = InitializeLineRenderer(new GameObject(), _initialTrajectoryColor);
            }
            if (_showAssistedTrajectory)
            {
                _assistedTrajectoryLineRenderer = InitializeLineRenderer(new GameObject(), _assistedTrajectoryColor);
            }
        }
コード例 #6
0
        public override void Start()
        {
            base.Start();
            _initialThumbQuaternion = PhalangesGameObjects[1].transform.localRotation;
            _physicsHand            = Hand as PhysicsHand;
            if (_physicsHand == null)
            {
                Debug.LogError("PhysicsFinger needs a PhysicsHand");
            }

            for (var i = 1; i <= 2; i++)
            {
                if (Index == FingerIndex.thumb && i == 1)
                {
                    ConstraintThumbPosition(PhalangesGameObjects[i]);
                    ConstraintThumbRotation(PhalangesGameObjects[i]);
                    continue;
                }

                GameObject holder = PhalangesGameObjects[i];

                GameObject copy = new GameObject(PhalangesGameObjects[i].name);
                //copy.transform.parent = PhalangesGameObjects[i].transform.parent;
                copy.transform.parent   = Hand.transform;
                copy.transform.position = PhalangesGameObjects[i].transform.position;
                copy.transform.rotation = PhalangesGameObjects[i].transform.rotation;

                Collider targetCollider = PhalangesGameObjects[i].GetComponent <Collider>();
                Destroy(targetCollider);
                CopyCollider(targetCollider, copy);
                PhalangesGameObjects[i] = copy;

                // Get the rigidbody where it should connect to
                var connectedBody = ConnectedBody(i);

                // Add a hingejoint to the gameobject
                if (Index == FingerIndex.thumb && DeviceType != device_type_t.GLOVE_LEFT)
                {
                    _joints[i] = AddHingeJoint(PhalangesGameObjects[i],
                                               new Vector3(0, 0, 1), connectedBody);
                }
                else if (Index == FingerIndex.thumb)
                {
                    _joints[i] = AddHingeJoint(PhalangesGameObjects[i],
                                               new Vector3(0, 0, 1), connectedBody);
                }
                else
                {
                    _joints[i] = AddHingeJoint(PhalangesGameObjects[i],
                                               new Vector3(0, 0, 1), connectedBody);
                }

                _phalanges[i] = HandFactory.GetPhalange(PhalangesGameObjects[i], Index, i, DeviceType);
                PhalangesGameObjects[i].GetComponent <Rigidbody>().maxAngularVelocity = 100f;

                // Add limits to the hingejoints of the finger
                if (DeviceType == device_type_t.GLOVE_RIGHT)
                {
                    ChangeJointLimit(_joints[i], -10, 120);
                }
                else
                {
                    ChangeJointLimit(_joints[i], -120, 10);
                }
                PhalangesGameObjects[i] = holder;
            }
        }