Пример #1
0
        public static void FixMeshRenderers([NotNull] ModelLoadResult loadResult)
        {
            var q = new Queue <GameObject>();

            q.Enqueue(loadResult.Body);

            while (q.Count > 0)
            {
                var obj = q.Dequeue();
                var t   = obj.transform;

                var childCount = t.childCount;

                if (childCount > 0)
                {
                    for (var i = 0; i < childCount; i += 1)
                    {
                        var childTransform = t.GetChild(i);
                        q.Enqueue(childTransform.gameObject);
                    }
                }

                if (obj.TryGetComponent <MeshRenderer>(out var renderer))
                {
                    renderer.shadowCastingMode = ShadowCastingMode.TwoSided;
                }
            }
        }
Пример #2
0
        public void ImportPhysics([NotNull] ModelLoadResult loadResult)
        {
            SwayAsset.FixSwayReferences(loadResult.HeadSway, loadResult.BodySway);

            var objectMap = new Dictionary <string, GameObject>();

            AddSwayColliders(loadResult.Body, loadResult.BodySway, objectMap);
            AddSwayColliders(loadResult.Head, loadResult.HeadSway, objectMap);

            AddSwayBones(loadResult.Body, loadResult.BodySway, objectMap);
            AddSwayBones(loadResult.Head, loadResult.HeadSway, objectMap);

            ProcessCollisionIgnores(loadResult, objectMap);
        }
Пример #3
0
        private static void ProcessCollisionIgnores([NotNull] ModelLoadResult loadResult, [NotNull] Dictionary <string, GameObject> cache)
        {
            var objectName = loadResult.Body.name;

            {
                // Hair nodes
                // Having hair colliding with each other part is more natural.
                // But hair collision avoiding is necessary for 045kar. It does not make much difference when applying to the others.
                var headT = loadResult.Head.transform;
                var hairT = headT.Find("KUBI/ATAMA/HAIR");

                if (hairT == null)
                {
                    Debug.LogWarning($"OMG there is no hair! ({objectName})");
                }

                var hair = hairT.gameObject;

                // We generate capsules instead of spheres on hair nodes
                var colliders = hair.GetComponentsInChildren <CapsuleCollider>();

                Debug.Assert(colliders.Length > 0, $"OMG there is no collider on the hair! ({objectName})");

                IgnoreColliderMatrix(colliders);
            }

            {
                // Skirt nodes
                var bodyT    = loadResult.Body.transform;
                var skirtGpT = bodyT.Find("MODEL_00/BODY_SCALE/BASE/KOSHI/skrt_GP");

                if (skirtGpT == null)
                {
                    skirtGpT = bodyT.Find("MODEL_00/BODY_SCALE/BASE/KOSHI/skirt_GP");
                }

                if (skirtGpT == null)
                {
                    Debug.Log($"OMG there is no skirt! ({objectName})");
                }

                var skirtGp = skirtGpT.gameObject;

                var colliders = skirtGp.GetComponentsInChildren <SphereCollider>();

                // For now we simply ignore all collisions in all skirt bodies
                IgnoreColliderMatrix(colliders);
            }
        }
Пример #4
0
 public static void FixGameObjectHierarchy([NotNull] ModelLoadResult loadResult)
 {
     AddBodyScaleNode(loadResult.Body);
     // BindHead(loadResult.Body, loadResult.Head);
 }