Пример #1
0
        protected virtual void CreatePhysics()
        {
            //foreach (OVRSkeleton.BoneId f in QuickUtils.GetEnumValues<OVRSkeleton.BoneId>())
            for (int f = 0; f < (int)OVRSkeleton.BoneId.Hand_End; f++)
            {
                //float r = f == HandBone.HandCenter ? 0.025f : BONE_RADIUS;
                QuickOVRHandBonePhysics result = CreatePhysicsBone(f, BONE_RADIUS);
                _handBonePhysics[f] = result;
            }

            Vector3 p1 = GetOVRBoneTransform(OVRSkeleton.BoneId.Hand_Thumb1).position;
            Vector3 p2 = GetOVRBoneTransform(OVRSkeleton.BoneId.Hand_Index1).position;
            Vector3 p3 = GetOVRBoneTransform(OVRSkeleton.BoneId.Hand_Pinky1).position;
            Vector3 p4 = GetOVRBoneTransform(OVRSkeleton.BoneId.Hand_Pinky0).position;

            _handCollider = transform.CreateChild("__HandCollider__").GetOrCreateComponent <BoxCollider>();
            MeshRenderer r = _handCollider.GetOrCreateComponent <MeshRenderer>();

            r.material = Resources.Load <Material>("Materials/QuickDiffuseWhite");
            _handCollider.isTrigger = true;
            //_handCollider.GetOrCreateComponent<MeshFilter>().mesh = QuickUtils.GetUnityPrimitiveMesh(PrimitiveType.Cube);

            _handCollider.transform.position = (p1 + p2 + p3 + p4) * 0.25f;
            _handCollider.transform.LookAt(_handCollider.transform.position + (p2 - p3).normalized, transform.up);

            float sx = Vector3.Distance(p3, p4);
            float sz = Vector3.Distance(p2, p3);
            float sy = Vector3.Distance(p1, p2);

            _handCollider.transform.localScale = Vector3.Scale(new Vector3(sx, sy, sz), new Vector3(1.75f, 1.75f, 1.2f));
        }
Пример #2
0
        protected virtual QuickOVRHandBonePhysics CreatePhysicsBone(int boneID, float boneRadius)
        {
            Transform tBone = GetOVRBoneTransform(boneID);
            QuickOVRHandBonePhysics result = tBone.CreateChild("__Physics__").GetOrCreateComponent <QuickOVRHandBonePhysics>();

            result.SetRadius(boneRadius);

            return(result);
        }