Пример #1
0
        public void HandleEntry(FileInfo sourceFile, Entry entry, List <Model3D> modelCollection, DataTreeObject dataTreeParent = null, Transform3D globalTransform = null)
        {
            TileEntry tile = (TileEntry)entry;

            //Transform3D trs = new Transform3D();
            //tile.getTransform(tile.getConfig(scene.getConfigManager()), trs);

            SetupCosmeticInformation(tile, dataTreeParent);
            // TODO: Some config references have SK data that I need. I need to do a hybrid of my shallow implementation on
            // top of the bootstrapper that loads the actual filtered game data so that I can grab everything.
            TileConfig[] tileCfgs = ConfigReferenceBootstrapper.ConfigReferences["tile"].OfType <TileConfig>().ToArray();
            TileConfig   tileCfg  = tileCfgs.GetEntryByName(tile.tile.getName());

            if (tileCfg == null)
            {
                XanLogger.WriteLine($"Unable to find data for tile [{tile.tile.getName()}]!");
                return;
            }


            // First things first: Tiles are offset and in the wrong position. Fix it.

            SKAnimatorToolsProxy.IncrementEnd();
            TileConfig.Original originalImpl;
            do
            {
                if (tileCfg == null)
                {
                    XanLogger.WriteLine("ALERT: A tile was null!", color: System.Drawing.Color.Red);
                    return;
                }
                if (tileCfg.getConfigManager() != null)
                {
                    originalImpl = tileCfg.getOriginal(tileCfg.getConfigManager());
                    break;
                }
                else
                {
                    if (tileCfg.implementation is TileConfig.Original original)
                    {
                        originalImpl = original;
                        break;
                    }
                    else if (tileCfg.implementation is TileConfig.Derived derived)
                    {
                        tileCfg = tileCfgs.GetEntryByName(derived.tile.getName());
                    }
                    else
                    {
                        originalImpl = null;
                        break;
                    }
                }
            } while (true);


            //tile.GetExportTransform(originalImpl, out Transform3D transform);
            // All transforms are relative to the center of the object. the origin of the actual models is in their lower-back-left bounds.
            // I need to add a flag to tell the exporter to move the geometry based on bounds center.
            Transform3D transform = new Transform3D();

            tile.getTransform(originalImpl, transform);
            //transform.getTranslation().addLocal(new Vector3f(0, tile.elevation / 2, 0));


            string relativeModelPath = originalImpl.model.getName();

            XanLogger.WriteLine("Grabbing tile [" + tile.tile.getName() + "] at " + relativeModelPath, XanLogger.DEBUG);
            ConfigReferenceUtil.HandleConfigReference(sourceFile, originalImpl.model, modelCollection, dataTreeParent, globalTransform.compose(transform));
            SKAnimatorToolsProxy.IncrementProgress();
        }
Пример #2
0
        public void HandleEntry(FileInfo sourceFile, Entry entry, List <Model3D> modelCollection, DataTreeObject dataTreeParent = null, Transform3D globalTransform = null)
        {
            PlaceableEntry placeable = (PlaceableEntry)entry;

            SetupCosmeticInformation(placeable, dataTreeParent);

            // TODO: Why the hell does referencing the transform field treat it like a method?
            // Is this some really stupid inheritence problem? I didn't even know this was possible.
            // EDIT: Yeah it is. Entry has a method called "transform", but placeable has a field called "transform". Great.
            // This may have been caused by the transpiler, which is to be expected. I'm actually quite suprised that I've not run into any errors until now.

            SKAnimatorToolsProxy.IncrementEnd();
            // TEST: Is this, by some slim chance, a file ref? (This can happen!)
            if (placeable.placeable.IsRealReference())
            {
                PlaceableConfig[] placeableCfgs = ConfigReferenceBootstrapper.ConfigReferences["placeable"].OfType <PlaceableConfig>().ToArray();
                PlaceableConfig   placeableCfg  = placeableCfgs.GetEntryByName(placeable.placeable.getName());
                if (placeableCfg == null)
                {
                    XanLogger.WriteLine($"Unable to find data for placeable [{placeable.placeable.getName()}]!");
                    return;
                }

                PlaceableConfig.Original originalImpl;
                do
                {
                    if (placeableCfg == null)
                    {
                        XanLogger.WriteLine("ALERT: A placeable was null!", color: System.Drawing.Color.Red);
                        return;
                    }
                    if (placeableCfg.getConfigManager() != null)
                    {
                        originalImpl = placeableCfg.getOriginal(placeableCfg.getConfigManager());
                        break;
                    }
                    else
                    {
                        if (placeableCfg.implementation is PlaceableConfig.Original org)
                        {
                            originalImpl = org;
                            break;
                        }
                        else if (placeableCfg.implementation is PlaceableConfig.Derived der)
                        {
                            placeableCfg = placeableCfgs.GetEntryByName(der.placeable.getName());
                        }
                        else
                        {
                            originalImpl = null;
                            break;
                        }
                    }
                } while (true);
                if (originalImpl != null)
                {
                    Transform3D transform         = GetTransformField(placeable);
                    string      relativeModelPath = originalImpl.model.getName();
                    XanLogger.WriteLine("Grabbing placeable [" + placeable.placeable.getName() + "] at " + relativeModelPath, XanLogger.DEBUG);
                    ConfigReferenceUtil.HandleConfigReference(sourceFile, originalImpl.model, modelCollection, dataTreeParent, globalTransform.compose(transform));
                }
                else
                {
                    XanLogger.WriteLine($"Implementation for placeable [{placeable.placeable.getName()}] does not exist!");
                }
            }
            else
            {
                Transform3D trs = GetTransformField(placeable);
                XanLogger.WriteLine("Grabbing placeable at " + placeable.placeable.getName(), XanLogger.DEBUG);
                ConfigReferenceUtil.HandleConfigReference(sourceFile, placeable.placeable, modelCollection, dataTreeParent, globalTransform.compose(trs));
            }
            SKAnimatorToolsProxy.IncrementProgress();
        }