Ejemplo n.º 1
0
        private void GenerateStaticAsteroidPreviews(int sizeInPixels, DirectoryInfo directoryInfo)
        {
            var directoryGuiHelpers = Directory.CreateDirectory(Path.Combine(directoryInfo.FullName, "GuiHelpers"));
            int index = 1;

            foreach (MyMwcObjectBuilder_StaticAsteroid_TypesEnum enumValue in MyGuiAsteroidHelpers.MyMwcStaticAsteroidTypesEnumValues)
            {
                Debug.WriteLine(string.Format("Exporting Static Asteroid Preview {0}/{1} ..", index++,
                                              MyGuiAsteroidHelpers.MyMwcStaticAsteroidTypesEnumValues.Count));

                var modelEnum = MyStaticAsteroid.GetModelsFromType(enumValue).LOD0;
                var model     = MyModels.GetModelOnlyData(modelEnum);
                model.SetDrawTechnique(MyMeshDrawTechnique.MESH);

                string assetName = Path.GetFileName(MyModels.GetModelAssetName(modelEnum));
                assetName = assetName.Substring(assetName.Length - 5, 5) == "_LOD0"
                                ? assetName.Substring(0, assetName.Length - 5)
                                : assetName;

                var    result   = RenderModelPreview(model, sizeInPixels, sizeInPixels);
                string fileName = Path.Combine(directoryGuiHelpers.FullName, string.Format("{0}.dds", assetName));
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                //TODO
                //MyDDSFile.DDSToFile(fileName, true, result, false);
            }
        }
Ejemplo n.º 2
0
        private void GenerateSmallShipPreviews(int sizeInPixels, DirectoryInfo directoryInfo)
        {
            var directoryGuiHelpers = Directory.CreateDirectory(Path.Combine(directoryInfo.FullName, "GuiHelpers"));
            int index = 1;

            foreach (MyMwcObjectBuilder_SmallShip_TypesEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues)
            {
                Debug.WriteLine(string.Format("Exporting SmallShip Preview {0}/{1} ..", index++,
                                              MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues.Length));

                var modelEnum = MyShipTypeConstants.GetShipTypeProperties(enumValue).Visual.ModelLod0Enum;
                var model     = MyModels.GetModelForDraw(modelEnum);

                string assetName = Path.GetFileName(MyModels.GetModelAssetName(modelEnum));

                var    result   = RenderModelPreview(model, sizeInPixels, sizeInPixels);
                string fileName = Path.Combine(directoryGuiHelpers.FullName, string.Format("{0}.dds", assetName));
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                //TODO
                //MyDDSFile.DDSToFile(fileName, true, result, false);
            }
        }
Ejemplo n.º 3
0
        private void OnGenerateListOfAssets(MyGuiControlButton sender)
        {
            string trimPath = @"Models2\";
            foreach (MyMwcObjectBuilderTypeEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues)
            {
                foreach (int prefabId in MyMwcObjectBuilder_Base.GetObjectBuilderIDs(enumValue))
                {
                    MyGuiPrefabHelper prefabModuleHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(enumValue, prefabId) as MyGuiPrefabHelper;
                    MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(enumValue, prefabId);
                    string assetName = MyModels.GetModelAssetName(config.ModelLod0Enum);
                    int trimIndex = assetName.IndexOf(trimPath);
                    if (trimIndex >= 0)
                    {
                        assetName = assetName.Substring(trimIndex + trimPath.Length);
                    }

                    MyMwcLog.WriteLine(string.Format("{0};{1}", prefabModuleHelper.Description, assetName));
                }
            }

            foreach (MyMwcObjectBuilder_SmallShip_TypesEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues)
            {
                MyGuiSmallShipHelperSmallShip smallShipHelper = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)enumValue) as MyGuiSmallShipHelperSmallShip;
                var properties = MyShipTypeConstants.GetShipTypeProperties(enumValue);
                string assetName = MyModels.GetModelAssetName(properties.Visual.ModelLod0Enum);
                int trimIndex = assetName.IndexOf(trimPath);
                if (trimIndex >= 0)
                {
                    assetName = assetName.Substring(trimIndex + trimPath.Length);
                }

                MyMwcLog.WriteLine(string.Format("{0};{1}", smallShipHelper.Description, assetName));
            }
        }
Ejemplo n.º 4
0
        public static string GetPreviewFileName(MyPrefabConfiguration config, int prefabId)
        {
            if (config.BuildType == BuildTypesEnum.MODULES && config.CategoryType == CategoryTypesEnum.WEAPONRY)
            {
                MyModelsEnum baseModelEnum, barelModelEnum;
                if (MyLargeShipGunBase.GetModelEnums((MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum)prefabId, out baseModelEnum, out barelModelEnum))
                {
                    return(Path.GetFileName(MyModels.GetModelAssetName(baseModelEnum)));
                }
            }

            return(Path.GetFileName(MyModels.GetModelAssetName(config.ModelLod0Enum)));
        }
Ejemplo n.º 5
0
        private void ShowModelsChange(MyGuiControlCheckbox sender, List<MyEntity> entities, string modelPath, MyMeshDrawTechnique? drawTechnique = null, bool staticAsteroids = false, MyMwcVoxelMaterialsEnum? voxelMaterial = null, List<MyMwcObjectBuilder_StaticAsteroid_TypesEnum> asteroidEnums = null)
        {
            if (sender.Checked)
            {
                string[] modelNames = Enum.GetNames(typeof(MyModelsEnum));
                int numModels = modelNames.Length;

                Vector3 forward = MySession.PlayerShip.GetWorldRotation().Forward;
                Vector3 currentPosition = MySession.PlayerShip.GetPosition() + forward * 20;

                if (!staticAsteroids)
                {
                    for (int i = 0; i < numModels; i++)
                    {
                        if (!MyModels.GetModelAssetName((MyModelsEnum)i).StartsWith(modelPath))
                            continue;

                        MyModel model = MyModels.GetModelOnlyData((MyModelsEnum)i);

                        MyEntity debugDebris = addDebris(new StringBuilder(modelNames[i]), (MyModelsEnum)i, null, ref currentPosition, forward, drawTechnique);

                        MyEntities.Add(debugDebris);
                        entities.Add(debugDebris);
                    }
                }
                else
                {
                      //foreach(MyMwcObjectBuilder_StaticAsteroid_TypesEnum statEnum in Enum.GetValues(typeof(MyMwcObjectBuilder_StaticAsteroid_TypesEnum)))
                      foreach(MyMwcObjectBuilder_StaticAsteroid_TypesEnum statEnum in asteroidEnums)
                      {
                          MyEntity debugDebris = addStaticAsteroid(new StringBuilder(statEnum.ToString()), statEnum, ref currentPosition, forward, null, voxelMaterial.Value);
                          MyEntities.Add(debugDebris);
                          entities.Add(debugDebris);
                      }
                }
            }
            else
            {
                foreach (MyEntity entity in entities)
                {
                    entity.MarkForClose();
                }
                entities.Clear();
            }
        }