コード例 #1
0
        internal ColliderPatch GenerateInitialPatch()
        {
            ColliderGeometry colliderGeo = null;

            if (_collider is SphereCollider sphereCollider)
            {
                colliderGeo = new SphereColliderGeometry()
                {
                    Radius = sphereCollider.radius,
                    Center = sphereCollider.center.ToMWVector3()
                };
            }
            else if (_collider is BoxCollider boxCollider)
            {
                colliderGeo = new BoxColliderGeometry()
                {
                    Size   = boxCollider.size.ToMWVector3(),
                    Center = boxCollider.center.ToMWVector3()
                };
            }
            else if (_collider is MeshCollider meshCollider)
            {
                colliderGeo = new MeshColliderGeometry();
            }
            else if (_collider is CapsuleCollider capsuleCollider)
            {
                colliderGeo = new CapsuleColliderGeometry();
            }
            else
            {
                _ownerActor.App.Logger.LogWarning($"MRE SDK does not support the following Unity collider and will not " +
                                                  $"be available in the MRE app.  Collider Type: {_collider.GetType()}");
            }

            return(colliderGeo == null ? null : new ColliderPatch()
            {
                IsEnabled = _collider.enabled,
                IsTrigger = _collider.isTrigger,
                ColliderGeometry = colliderGeo
            });
        }
コード例 #2
0
        internal ColliderPatch GenerateInitialPatch()
        {
            ColliderGeometry colliderGeo = null;

            // Note: SDK has no "mesh" collider type
            if (Shape == ColliderType.Auto || Shape == ColliderType.Mesh)
            {
                colliderGeo = new AutoColliderGeometry();
            }
            else if (_collider is SphereCollider sphereCollider)
            {
                colliderGeo = new SphereColliderGeometry()
                {
                    Radius = sphereCollider.radius,
                    Center = sphereCollider.center.CreateMWVector3()
                };
            }
            else if (_collider is BoxCollider boxCollider)
            {
                colliderGeo = new BoxColliderGeometry()
                {
                    Size   = boxCollider.size.CreateMWVector3(),
                    Center = boxCollider.center.CreateMWVector3()
                };
            }
            else if (_collider is CapsuleCollider capsuleCollider)
            {
                // The size vector describes the dimensions of the bounding box containing the collider
                MWVector3 size;
                if (capsuleCollider.direction == 0)
                {
                    size = new MWVector3(capsuleCollider.height, 2 * capsuleCollider.radius, 2 * capsuleCollider.radius);
                }
                else if (capsuleCollider.direction == 1)
                {
                    size = new MWVector3(2 * capsuleCollider.radius, capsuleCollider.height, 2 * capsuleCollider.radius);
                }
                else
                {
                    size = new MWVector3(2 * capsuleCollider.radius, 2 * capsuleCollider.radius, capsuleCollider.height);
                }

                colliderGeo = new CapsuleColliderGeometry()
                {
                    Center = capsuleCollider.center.CreateMWVector3(),
                    Size   = size
                };
            }
            else
            {
                _ownerActor.App.Logger.LogWarning($"MRE SDK does not support the following Unity collider and will not " +
                                                  $"be available in the MRE app.  Collider Type: {_collider.GetType()}");
            }

            return(colliderGeo == null ? null : new ColliderPatch()
            {
                IsEnabled = _collider.enabled,
                IsTrigger = _collider.isTrigger,
                Geometry = colliderGeo
            });
        }