コード例 #1
0
        /**
         *  Clean up old surfacess
         **/
        private ArrayMesh cleanOldSlots(ArrayMesh oldMesh, UMAReciepe reciepe)
        {
            List <string> oldSurfaces = new List <string>();

            for (int surface = 0; surface < oldMesh.GetSurfaceCount(); surface++)
            {
                oldSurfaces.Add(oldMesh.SurfaceGetName(surface));
            }

            var allSlotNames = reciepe.slots.Select(tf => tf.Key).ToList();

            //clean up current surface by new slots
            foreach (var oldSurface in oldSurfaces)
            {
                bool exist = false;
                foreach (var reicpeSlotName in allSlotNames)
                {
                    if (oldSurface.Contains(reicpeSlotName))
                    {
                        exist = true;
                    }
                }

                if (!exist)
                {
                    Console.WriteLine("[UMA] Delete surface " + oldSurface);
                    oldMesh.SurfaceRemove(oldMesh.SurfaceFindByName(oldSurface));

                    changes++;
                }
            }

            return(oldMesh);
        }
コード例 #2
0
        /**
         *  create overlay
         */
        private ArrayMesh createOverlays(ArrayMesh oldMesh, UMAReciepe reciepe)
        {
            Dictionary <int, string> oldSurfaces = new Dictionary <int, string>();

            for (int surface = 0; surface < oldMesh.GetSurfaceCount(); surface++)
            {
                var name = oldMesh.SurfaceGetName(surface);
                oldSurfaces.Add(surface, name);
            }

            foreach (var slot in reciepe.slots)
            {
                var slotName = slot.Key;

                var path      = System.IO.Path.Combine(reciepe.slotPath, slot.Key + ".tscn");
                var restBones = extractBinds(path);

                foreach (var overlay in slot.Value)
                {
                    var overlayName = slotName + "/Overlay_" + overlay.Key;
                    if (!oldSurfaces.ContainsValue(overlayName))
                    {
                        var overlayPath = System.IO.Path.Combine(overlay.Value.overlayPath, overlay.Key + ".tscn");
                        oldMesh = createSurfaceOverlay(oldMesh, slotName, overlayPath, overlayName, restBones);
                    }
                }
            }

            return(oldMesh);
        }
コード例 #3
0
    protected void assignMaterialOverlay(ArrayMesh oldMesh, string overlayName, bool useAlbedo, Color albedoColor, string materialPath, float glow)
    {
        if (oldMesh == null)
        {
            return;
        }

        for (int surface = 0; surface < oldMesh.GetSurfaceCount(); surface++)
        {
            var name = oldMesh.SurfaceGetName(surface);

            if (!name.Contains(overlayName))
            {
                continue;
            }

            var material = oldMesh.SurfaceGetMaterial(surface);
            if (!String.IsNullOrEmpty(materialPath))
            {
                //fix path combine (system.io)
                materialPath = materialPath.Replace(@"\", @"/");

                if ((material == null) || (material.ResourcePath != materialPath))
                {
                    var newMaterial = GD.Load <Material>(materialPath);

                    if (newMaterial is SpatialMaterial)
                    {
                        (newMaterial as SpatialMaterial).ParamsGrow       = true;
                        (newMaterial as SpatialMaterial).ParamsGrowAmount = glow;
                    }

                    newMaterial.ResourceLocalToScene = true;
                    material = newMaterial;
                }
            }

            if (material != null)
            {
                if (useAlbedo)
                {
                    (material as SpatialMaterial).AlbedoColor = albedoColor;
                }

                (material as SpatialMaterial).ParamsGrow       = true;
                (material as SpatialMaterial).ParamsGrowAmount = glow;

                oldMesh.SurfaceSetMaterial(surface, material);
            }
        }
    }
コード例 #4
0
ファイル: ArrayMeshSurface.cs プロジェクト: kitfka/AlleyCat
        public ArrayMeshSurface(ArrayMesh mesh, int index)
        {
            Ensure.That(mesh, nameof(mesh)).IsNotNull();
            Ensure.That(index, nameof(index)).IsGte(0);

            Mesh  = mesh;
            Index = index;

            Key            = mesh.SurfaceGetName(index);
            FormatMask     = Mesh.SurfaceGetFormat(index);
            PrimitiveType  = Mesh.SurfaceGetPrimitiveType(Index);
            BlendShapeMode = Mesh.BlendShapeMode;

            _material = memo(() => Optional(Mesh.SurfaceGetMaterial(index)));
        }
コード例 #5
0
        private ArrayMesh cleanOldOverlays(ArrayMesh oldMesh, UMAReciepe reciepe)
        {
            List <string> oldSurfaces = new List <string>();

            for (int surface = 0; surface < oldMesh.GetSurfaceCount(); surface++)
            {
                oldSurfaces.Add(oldMesh.SurfaceGetName(surface));
            }

            foreach (var oldSurface in oldSurfaces)
            {
                bool exist = false;

                if (!oldSurface.Contains("Overlay_"))
                {
                    continue;
                }

                foreach (var slot in reciepe.slots)
                {
                    var slotName = slot.Key;

                    foreach (var overlay in slot.Value)
                    {
                        var overlayName = slotName + "/Overlay_" + overlay.Key;

                        if (oldSurface.Contains(overlayName))
                        {
                            exist = true;
                        }
                    }
                }

                if (!exist)
                {
                    Console.WriteLine("[UMA] Delete overlay " + oldSurface);
                    oldMesh.SurfaceRemove(oldMesh.SurfaceFindByName(oldSurface));

                    changes++;
                }
            }

            return(oldMesh);
        }
コード例 #6
0
        /**
         * create slots
         */
        private ArrayMesh createNewSlots(ArrayMesh oldMesh, UMAReciepe reciepe)
        {
            Dictionary <int, string> oldSurfaces = new Dictionary <int, string>();

            for (int surface = 0; surface < oldMesh.GetSurfaceCount(); surface++)
            {
                var name = oldMesh.SurfaceGetName(surface);
                oldSurfaces.Add(surface, name);
            }

            foreach (var slot in reciepe.slots)
            {
                if (!oldSurfaces.ContainsValue(slot.Key))
                {
                    var path = System.IO.Path.Combine(reciepe.slotPath, slot.Key + ".tscn");
                    //create slot
                    Console.WriteLine("[UMA] Create slot: " + path);
                    oldMesh = createSurface(oldMesh, path, slot.Key);
                }
            }

            return(oldMesh);
        }