Пример #1
0
 private static RigidbodyConstraints GetConstraints(glTF_VCAST_vci_Rigidbody rigidbody)
 {
     return
         ((rigidbody.freezePositionX ? RigidbodyConstraints.FreezePositionX : 0) |
          (rigidbody.freezePositionY ? RigidbodyConstraints.FreezePositionY : 0) |
          (rigidbody.freezePositionZ ? RigidbodyConstraints.FreezePositionZ : 0) |
          (rigidbody.freezeRotationX ? RigidbodyConstraints.FreezeRotationX : 0) |
          (rigidbody.freezeRotationY ? RigidbodyConstraints.FreezeRotationY : 0) |
          (rigidbody.freezeRotationZ ? RigidbodyConstraints.FreezeRotationZ : 0)
         );
 }
Пример #2
0
        public static Rigidbody AddRigidbodyComponent(GameObject go, glTF_VCAST_vci_Rigidbody rigidbody)
        {
            var result = go.GetOrAddComponent <Rigidbody>();

            result.mass                   = rigidbody.mass;
            result.drag                   = rigidbody.drag;
            result.angularDrag            = rigidbody.angularDrag;
            result.useGravity             = rigidbody.useGravity;
            result.isKinematic            = rigidbody.isKinematic;
            result.interpolation          = InterpolateString.GetInterpolationFromString(rigidbody.interpolate);
            result.collisionDetectionMode =
                CollisionDetectionModeString.GetDetectionModeFromString(rigidbody.collisionDetection);
            result.constraints = GetConstraints(rigidbody);
            return(result);
        }
Пример #3
0
        public static glTF_VCAST_vci_Rigidbody GetglTfRigidbodyFromUnityRigidbody(Rigidbody rigidbody)
        {
            var result = new glTF_VCAST_vci_Rigidbody();

            result.mass               = rigidbody.mass;
            result.drag               = rigidbody.drag;
            result.angularDrag        = rigidbody.angularDrag;
            result.useGravity         = rigidbody.useGravity;
            result.isKinematic        = rigidbody.isKinematic;
            result.interpolate        = InterpolateString.GetStringFromInterpolation(rigidbody.interpolation);
            result.collisionDetection =
                CollisionDetectionModeString.GetStringFromCollisionDetectionMode(rigidbody.collisionDetectionMode);
            result.freezePositionX = rigidbody.constraints.HasFlag(RigidbodyConstraints.FreezePositionX);
            result.freezePositionY = rigidbody.constraints.HasFlag(RigidbodyConstraints.FreezePositionY);
            result.freezePositionZ = rigidbody.constraints.HasFlag(RigidbodyConstraints.FreezePositionZ);
            result.freezeRotationX = rigidbody.constraints.HasFlag(RigidbodyConstraints.FreezeRotationX);
            result.freezeRotationY = rigidbody.constraints.HasFlag(RigidbodyConstraints.FreezeRotationY);
            result.freezeRotationZ = rigidbody.constraints.HasFlag(RigidbodyConstraints.FreezeRotationZ);
            return(result);
        }
        public static void Serialize_vci_rigidbodies_ITEM(JsonFormatter f, glTF_VCAST_vci_Rigidbody value)
        {
            f.BeginMap();


            if (true)
            {
                f.Key("mass");
                f.Value(value.mass);
            }

            if (true)
            {
                f.Key("drag");
                f.Value(value.drag);
            }

            if (true)
            {
                f.Key("angularDrag");
                f.Value(value.angularDrag);
            }

            if (true)
            {
                f.Key("useGravity");
                f.Value(value.useGravity);
            }

            if (true)
            {
                f.Key("isKinematic");
                f.Value(value.isKinematic);
            }

            if (!string.IsNullOrEmpty(value.interpolate))
            {
                f.Key("interpolate");
                f.Value(value.interpolate);
            }

            if (!string.IsNullOrEmpty(value.collisionDetection))
            {
                f.Key("collisionDetection");
                f.Value(value.collisionDetection);
            }

            if (true)
            {
                f.Key("freezePositionX");
                f.Value(value.freezePositionX);
            }

            if (true)
            {
                f.Key("freezePositionY");
                f.Value(value.freezePositionY);
            }

            if (true)
            {
                f.Key("freezePositionZ");
                f.Value(value.freezePositionZ);
            }

            if (true)
            {
                f.Key("freezeRotationX");
                f.Value(value.freezeRotationX);
            }

            if (true)
            {
                f.Key("freezeRotationY");
                f.Value(value.freezeRotationY);
            }

            if (true)
            {
                f.Key("freezeRotationZ");
                f.Value(value.freezeRotationZ);
            }

            f.EndMap();
        }
        public static glTF_VCAST_vci_Rigidbody glTF_VCAST_vci_rigidbody_Deserializevci_rigidbodies_ITEM(JsonNode parsed)
        {
            var value = new glTF_VCAST_vci_Rigidbody();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "mass")
                {
                    value.mass = kv.Value.GetSingle();
                    continue;
                }

                if (key == "drag")
                {
                    value.drag = kv.Value.GetSingle();
                    continue;
                }

                if (key == "angularDrag")
                {
                    value.angularDrag = kv.Value.GetSingle();
                    continue;
                }

                if (key == "useGravity")
                {
                    value.useGravity = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "isKinematic")
                {
                    value.isKinematic = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "interpolate")
                {
                    value.interpolate = kv.Value.GetString();
                    continue;
                }

                if (key == "collisionDetection")
                {
                    value.collisionDetection = kv.Value.GetString();
                    continue;
                }

                if (key == "freezePositionX")
                {
                    value.freezePositionX = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "freezePositionY")
                {
                    value.freezePositionY = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "freezePositionZ")
                {
                    value.freezePositionZ = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "freezeRotationX")
                {
                    value.freezeRotationX = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "freezeRotationY")
                {
                    value.freezeRotationY = kv.Value.GetBoolean();
                    continue;
                }

                if (key == "freezeRotationZ")
                {
                    value.freezeRotationZ = kv.Value.GetBoolean();
                    continue;
                }
            }
            return(value);
        }