private void DecrementTextureUsage() { if (sideEntity.NativeObject == null) { return; } switch (dataSource) { case LevelEntity_Side.DataSources.Primary: MaterialGeneration_Geometry.DecrementTextureUsage(sideEntity.NativeObject.Primary.Texture); break; case LevelEntity_Side.DataSources.Secondary: MaterialGeneration_Geometry.DecrementTextureUsage(sideEntity.NativeObject.Secondary.Texture); break; case LevelEntity_Side.DataSources.Transparent: MaterialGeneration_Geometry.DecrementTextureUsage(sideEntity.NativeObject.Transparent.Texture); break; default: throw new NotImplementedException($"DataSource '{dataSource}' is not implemented."); } }
public override void RefreshValuesInInspector() { Value_Id.text = InspectedSide.NativeIndex.ToString(); Value_Type.text = InspectedSide.NativeObject.Type.ToString(); var hasPrimaryData = !InspectedSide.NativeObject.Primary.Texture.IsEmpty(); Value_Primary_Texture.texture = hasPrimaryData ? MaterialGeneration_Geometry.GetTexture(InspectedSide.NativeObject.Primary.Texture) : Resources.Load <Texture2D>("Walls/UnassignedSurfaceUIPlaceholder"); Value_Primary_Offset.text = hasPrimaryData ? $"X: {InspectedSide.NativeObject.Primary.X}\nY: {InspectedSide.NativeObject.Primary.Y}" : "X: -\nY: -"; Value_Primary_LightIndex.text = hasPrimaryData ? InspectedSide.NativeObject.PrimaryLightsourceIndex.ToString() : "-"; Value_Primary_TransferMode.text = hasPrimaryData ? InspectedSide.NativeObject.PrimaryTransferMode.ToString() : "-"; var hasSecondaryData = !InspectedSide.NativeObject.Secondary.Texture.IsEmpty(); Value_Secondary_Texture.texture = hasSecondaryData ? MaterialGeneration_Geometry.GetTexture(InspectedSide.NativeObject.Secondary.Texture) : Resources.Load <Texture2D>("Walls/UnassignedSurfaceUIPlaceholder"); Value_Secondary_Offset.text = hasSecondaryData ? $"X: {InspectedSide.NativeObject.Secondary.X}\nY: {InspectedSide.NativeObject.Secondary.Y}" : "X: -\nY: -"; Value_Secondary_LightIndex.text = hasSecondaryData ? InspectedSide.NativeObject.SecondaryLightsourceIndex.ToString() : "-"; Value_Secondary_TransferMode.text = hasSecondaryData ? InspectedSide.NativeObject.SecondaryTransferMode.ToString() : "-"; var hasTransparentData = !InspectedSide.NativeObject.Transparent.Texture.IsEmpty(); Value_Transparent_Texture.texture = hasTransparentData ? MaterialGeneration_Geometry.GetTexture(InspectedSide.NativeObject.Transparent.Texture) : Resources.Load <Texture2D>("Walls/UnassignedSurfaceUIPlaceholder"); Value_Transparent_Offset.text = hasTransparentData ? $"X: {InspectedSide.NativeObject.Transparent.X}\nY: {InspectedSide.NativeObject.Transparent.Y}" : "X: -\nY: -"; Value_Transparent_LightIndex.text = hasTransparentData ? InspectedSide.NativeObject.TransparentLightsourceIndex.ToString() : "-"; Value_Transparent_TransferMode.text = hasTransparentData ? InspectedSide.NativeObject.TransparentTransferMode.ToString() : "-"; }
public void SetInitialValues(KeyValuePair <ShapeDescriptor, Texture2D> textureEntry, ToggleGroup toggleGroup) { ShapeDescriptor = textureEntry.Key; label.text = $"C: {ShapeDescriptor.Collection} B: {ShapeDescriptor.Bitmap}"; texturePreview.texture = textureEntry.Value; texturePreview.GetComponent <AspectRatioFitter>().aspectRatio = (float)texturePreview.texture.width / (float)texturePreview.texture.height; var toggle = GetComponent <Toggle>(); toggle.group = toggleGroup; usageIndicator.SetActive(MaterialGeneration_Geometry.GetTextureIsInUse(ShapeDescriptor)); }
public override void RefreshValuesInInspector() { var polygon = inspectedObject as LevelEntity_Polygon; Value_Id.text = polygon.NativeIndex.ToString(); var floorTexture = MaterialGeneration_Geometry.GetTexture(polygon.NativeObject.FloorTexture); Value_Floor_Texture.texture = floorTexture ? floorTexture : Resources.Load <Texture2D>("Walls/UnassignedSurfaceUIPlaceholder"); Value_Floor_Offset.text = $"X: {polygon.NativeObject.FloorOrigin.X}\nY: {polygon.NativeObject.FloorOrigin.Y}"; Value_Floor_TransferMode.text = polygon.NativeObject.FloorTransferMode.ToString(); Value_Floor_LightIndex.text = polygon.NativeObject.FloorLight.ToString(); var ceilingTexture = MaterialGeneration_Geometry.GetTexture(polygon.NativeObject.CeilingTexture); Value_Ceiling_Texture.texture = ceilingTexture ? ceilingTexture : Resources.Load <Texture2D>("Walls/UnassignedSurfaceUIPlaceholder"); Value_Ceiling_Offset.text = $"X: {polygon.NativeObject.CeilingOrigin.X}\nY: {polygon.NativeObject.CeilingOrigin.Y}"; Value_Ceiling_TransferMode.text = polygon.NativeObject.CeilingTransferMode.ToString(); Value_Ceiling_LightIndex.text = polygon.NativeObject.CeilingLight.ToString(); }
private void DecrementTextureUsage() { switch (dataSource) { case LevelEntity_Polygon.DataSources.Floor: MaterialGeneration_Geometry.DecrementTextureUsage(polygonEntity.NativeObject.FloorTexture); break; case LevelEntity_Polygon.DataSources.Ceiling: MaterialGeneration_Geometry.DecrementTextureUsage(polygonEntity.NativeObject.CeilingTexture); break; case LevelEntity_Polygon.DataSources.Media: // Media surfaces do not increment texture usage when calling WallsCollection.GetMaterial() break; default: throw new NotImplementedException($"DataSource '{dataSource}' is not implemented."); } }
public override void ApplyBatchKeyMaterial(bool innerLayer) { DecrementTextureUsage(); var modifiedBatchKey = BatchKey; if (sideEntity.NativeObject == null) { modifiedBatchKey.sourceMaterial = MaterialGeneration_Geometry.GetMaterial(ShapeDescriptor.Empty, transferMode: 0, isOpaqueSurface: true, MaterialGeneration_Geometry.SurfaceTypes.Normal, incrementUsageCounter: false); } else if (innerLayer) { switch (dataSource) { case LevelEntity_Side.DataSources.Primary: #if USE_TEXTURE_ARRAYS modifiedBatchKey.sourceShapeDescriptor = sideEntity.NativeObject.Primary.Texture; #endif modifiedBatchKey.sourceMaterial = MaterialGeneration_Geometry.GetMaterial(sideEntity.NativeObject.Primary.Texture, sideEntity.NativeObject.PrimaryTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.Normal, incrementUsageCounter: true); #if USE_TEXTURE_ARRAYS lastTextureIndex = MaterialGeneration_Geometry.GetTextureArrayIndex( sideEntity.NativeObject.Primary.Texture, sideEntity.NativeObject.PrimaryTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.Normal); #endif break; case LevelEntity_Side.DataSources.Secondary: #if USE_TEXTURE_ARRAYS modifiedBatchKey.sourceShapeDescriptor = sideEntity.NativeObject.Secondary.Texture; #endif modifiedBatchKey.sourceMaterial = MaterialGeneration_Geometry.GetMaterial(sideEntity.NativeObject.Secondary.Texture, sideEntity.NativeObject.SecondaryTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.Normal, incrementUsageCounter: true); #if USE_TEXTURE_ARRAYS lastTextureIndex = MaterialGeneration_Geometry.GetTextureArrayIndex( sideEntity.NativeObject.Secondary.Texture, sideEntity.NativeObject.SecondaryTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.Normal); #endif break; case LevelEntity_Side.DataSources.Transparent: #if USE_TEXTURE_ARRAYS modifiedBatchKey.sourceShapeDescriptor = sideEntity.NativeObject.Transparent.Texture; #endif modifiedBatchKey.sourceMaterial = MaterialGeneration_Geometry.GetMaterial(sideEntity.NativeObject.Transparent.Texture, sideEntity.NativeObject.TransparentTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.Normal, incrementUsageCounter: true); #if USE_TEXTURE_ARRAYS lastTextureIndex = MaterialGeneration_Geometry.GetTextureArrayIndex( sideEntity.NativeObject.Transparent.Texture, sideEntity.NativeObject.TransparentTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.Normal); #endif break; default: throw new NotImplementedException($"DataSource '{dataSource}' is not implemented."); } } else { #if USE_TEXTURE_ARRAYS modifiedBatchKey.layeredTransparentSideShapeDescriptor = sideEntity.NativeObject.Transparent.Texture; #endif modifiedBatchKey.layeredTransparentSideSourceMaterial = MaterialGeneration_Geometry.GetMaterial(sideEntity.NativeObject.Transparent.Texture, sideEntity.NativeObject.TransparentTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.LayeredTransparentOuter, incrementUsageCounter: true); #if USE_TEXTURE_ARRAYS lastLayeredTransparentSideTextureIndex = MaterialGeneration_Geometry.GetTextureArrayIndex( sideEntity.NativeObject.Transparent.Texture, sideEntity.NativeObject.TransparentTransferMode, sideEntity.NativeObject.SurfaceShouldBeOpaque(dataSource, sideEntity.ParentLevel.Level), MaterialGeneration_Geometry.SurfaceTypes.LayeredTransparentOuter); #endif } if (innerLayer) { var UVs = SurfaceMesh.uv.Select(uv => new Vector4(uv.x, uv.y, lastLightIndex, lastTextureIndex)).ToArray(); SurfaceMesh.SetUVs(0, UVs); } else { var UVs = SurfaceMesh.uv.Select(uv => new Vector4(uv.x, uv.y, lastLayeredTransparentSideLightIndex, lastLayeredTransparentSideTextureIndex)).ToArray(); SurfaceMesh.SetUVs(1, UVs); } BatchKey = modifiedBatchKey; }
private async Task BuildLevel() { #if !UNITY_EDITOR GarbageCollector.GCMode = GarbageCollector.Mode.Disabled; #endif var initializeLevelStartTime = DateTime.Now; runtimeLevel = new GameObject($"Level ({LevelName})").AddComponent <LevelEntity_Level>(); runtimeLevel.Level = level; runtimeLevel.Index = (short)LevelIndex; runtimeLevel.Polygons = new Dictionary <short, LevelEntity_Polygon>(); runtimeLevel.Lines = new Dictionary <short, LevelEntity_Line>(); runtimeLevel.Sides = new Dictionary <short, LevelEntity_Side>(); runtimeLevel.Lights = new Dictionary <short, LevelEntity_Light>(); runtimeLevel.Medias = new Dictionary <short, LevelEntity_Media>(); runtimeLevel.CeilingPlatforms = new Dictionary <short, LevelEntity_Platform>(); runtimeLevel.FloorPlatforms = new Dictionary <short, LevelEntity_Platform>(); runtimeLevel.MapObjects = new Dictionary <short, LevelEntity_MapObject>(); runtimeLevel.Annotations = new Dictionary <short, LevelEntity_Annotation>(); runtimeLevel.EditableSurface_Polygons = new List <EditableSurface_Polygon>(); runtimeLevel.EditableSurface_Sides = new List <EditableSurface_Side>(); runtimeLevel.EditableSurface_Medias = new List <EditableSurface_Media>(); // Clear out Walls Materials so it can be repopulated with the correct set MaterialGeneration_Geometry.ClearCollection(); Debug.Log($"--- LevelBuild: Initialized Level in timespan: {DateTime.Now - initializeLevelStartTime}"); await Task.Yield(); #region Initialization_Textures var buildTexturesStartTime = DateTime.Now; #if !NO_EDITING // Initialize Textures here so they in proper index order for the texturing interface var landscapeShapeDescriptor = new ShapeDescriptor(); // Note: Landscape collections in Shapes are respectively sequential to Landscape map info starting at 27 landscapeShapeDescriptor.Collection = (byte)(level.Landscape + 27); MaterialGeneration_Geometry.GetTexture(landscapeShapeDescriptor, returnPlaceholderIfNotFound: false); var wallShapeDescriptor = new ShapeDescriptor(); // Note: Walls collections in Shapes are respectively sequential to Environment map info starting at 17 wallShapeDescriptor.Collection = (byte)(level.Environment + 17); for (var i = 0; i < 256; i++) { wallShapeDescriptor.Bitmap = (byte)i; if (!MaterialGeneration_Geometry.GetTexture(wallShapeDescriptor, returnPlaceholderIfNotFound: false)) { break; } } #endif Debug.Log($"--- LevelBuild: Built Textures in timespan: {DateTime.Now - buildTexturesStartTime}"); #endregion Initialization_Textures await Task.Yield(); #region Initialization_Lights var buildLightsStartTime = DateTime.Now; // Initialize Lights here so they are in proper index order for (var i = 0; i < level.Lights.Count; i++) { runtimeLevel.Lights[(short)i] = new LevelEntity_Light((short)i, level.Lights[i], runtimeLevel); } Debug.Log($"--- LevelBuild: Built & started Lights in timespan: {DateTime.Now - buildLightsStartTime}"); #endregion Initialization_Lights await Task.Yield(); #region Initialization_Medias var buildMediasStartTime = DateTime.Now; // Initialize Medias here so they are in proper index order for (var i = 0; i < level.Medias.Count; i++) { runtimeLevel.Medias[(short)i] = new LevelEntity_Media((short)i, level.Medias[i], runtimeLevel); } Debug.Log($"--- LevelBuild: Built & started Medias in timespan: {DateTime.Now - buildMediasStartTime}"); #endregion Initialization_Medias await Task.Yield(); #if USE_TEXTURE_ARRAYS MaterialGeneration_Geometry.TextureArraysArePopulating = true; #endif var chunkLoadStartTime = DateTime.Now; #region Polygons_And_Media var buildPolygonsStartTime = DateTime.Now; var polygonsGroupGO = new GameObject("Polygons"); polygonsGroupGO.transform.SetParent(runtimeLevel.transform); for (short polygonIndex = 0; polygonIndex < level.Polygons.Count; polygonIndex++) { var polygon = level.Polygons[polygonIndex]; var polygonRootGO = new GameObject($"Polygon ({polygonIndex})"); polygonRootGO.transform.SetParent(polygonsGroupGO.transform); var runtimePolygon = polygonRootGO.AddComponent <LevelEntity_Polygon>(); runtimeLevel.Polygons[polygonIndex] = runtimePolygon; runtimePolygon.InitializeEntity(runtimeLevel, polygonIndex, polygon); chunkLoadStartTime = await ChunkLoadYield(chunkLoadStartTime); } Debug.Log($"--- LevelBuild: Built Polygons, Medias, & Platforms in timespan: {DateTime.Now - buildPolygonsStartTime}"); #endregion Polygons_And_Media await Task.Yield(); #region Lines_And_Sides var buildSidesStartTime = DateTime.Now; var linesGroupGO = new GameObject("Lines"); linesGroupGO.transform.SetParent(runtimeLevel.transform); for (short lineIndex = 0; lineIndex < level.Lines.Count; lineIndex++) { GameObject lineRootGO = new GameObject($"Line ({lineIndex})"); lineRootGO.transform.SetParent(linesGroupGO.transform); var line = level.Lines[lineIndex]; var runtimeLine = lineRootGO.AddComponent <LevelEntity_Line>(); runtimeLevel.Lines[lineIndex] = runtimeLine; runtimeLine.NativeIndex = lineIndex; runtimeLine.NativeObject = line; runtimeLine.ParentLevel = runtimeLevel; runtimeLine.GenerateSurfaces(); chunkLoadStartTime = await ChunkLoadYield(chunkLoadStartTime); } Debug.Log($"--- LevelBuild: Built Lines & Sides in timespan: {DateTime.Now - buildSidesStartTime}"); #endregion Lines_And_Sides await Task.Yield(); #if USE_TEXTURE_ARRAYS MaterialGeneration_Geometry.ApplyTextureArrays(); MaterialGeneration_Geometry.TextureArraysArePopulating = false; await Task.Yield(); #endif #region Objects_And_Placements var buildObjectsStartTime = DateTime.Now; var mapObjectsGroupGO = new GameObject("MapObjects"); mapObjectsGroupGO.transform.SetParent(runtimeLevel.transform); for (short objectIndex = 0; objectIndex < level.Objects.Count; objectIndex++) { var mapObject = level.Objects[objectIndex]; var mapObjectRootGO = new GameObject($"MapObject: {mapObject.Type} ({objectIndex})"); mapObjectRootGO.transform.SetParent(mapObjectsGroupGO.transform); var runtimeMapObject = mapObjectRootGO.AddComponent <LevelEntity_MapObject>(); runtimeLevel.MapObjects[(short)objectIndex] = runtimeMapObject; runtimeMapObject.NativeIndex = (short)objectIndex; runtimeMapObject.NativeObject = mapObject; runtimeMapObject.ParentLevel = runtimeLevel; runtimeMapObject.GenerateObject(); chunkLoadStartTime = await ChunkLoadYield(chunkLoadStartTime); } Debug.Log($"--- LevelBuild: Built Objects in timespan: {DateTime.Now - buildObjectsStartTime}"); #endregion Objects_And_Placements await Task.Yield(); #region Annotations var annotationsGroupGO = new GameObject("Annotations"); annotationsGroupGO.transform.SetParent(runtimeLevel.transform); for (var i = 0; i < level.Annotations.Count; i++) { var annotation = level.Annotations[i]; var annotationInstance = UnityEngine.Object.Instantiate(LevelEntity_Annotation.Prefab); annotationInstance.NativeIndex = (short)i; annotationInstance.NativeObject = annotation; annotationInstance.ParentLevel = runtimeLevel; annotationInstance.RefreshLabel(); var positionalHeight = (runtimeLevel.Polygons[annotation.PolygonIndex].NativeObject.FloorHeight + runtimeLevel.Polygons[annotation.PolygonIndex].NativeObject.CeilingHeight) / 2f / GeometryUtilities.WorldUnitIncrementsPerMeter; annotationInstance.transform.position = new Vector3(annotation.X / GeometryUtilities.WorldUnitIncrementsPerMeter, positionalHeight, -annotation.Y / GeometryUtilities.WorldUnitIncrementsPerMeter); annotationInstance.transform.SetParent(annotationsGroupGO.transform, worldPositionStays: true); runtimeLevel.Annotations[(short)i] = annotationInstance; } #endregion Annotations await Task.Yield(); #if !UNITY_EDITOR GarbageCollector.GCMode = GarbageCollector.Mode.Enabled; #endif }
public override void UnloadFile() { MaterialGeneration_Geometry.ClearCollection(); base.UnloadFile(); }
private void UpdatePaletteToMatchMode(ModeManager.PrimaryModes primaryMode) { Clear(); if (LevelEntity_Level.Instance) { switch (primaryMode) { case ModeManager.PrimaryModes.Geometry: paletteToggleGroup.allowSwitchOff = false; // TODO: populate with tools // - Line Drawing // - Polygon Fill (oh man... should this auto-fill when a poly is completed?) break; case ModeManager.PrimaryModes.Textures: paletteToggleGroup.allowSwitchOff = false; var loadedTextureEntries = MaterialGeneration_Geometry.GetAllLoadedTextures().ToList(); loadedTextureEntries.Sort((entryA, entryB) => (entryA.Key.Collection == entryB.Key.Collection ? entryA.Key.Bitmap.CompareTo(entryB.Key.Bitmap) : ((entryA.Key.UsesLandscapeCollection() || entryB.Key.UsesLandscapeCollection()) ? -entryA.Key.Collection.CompareTo(entryB.Key.Collection) : entryA.Key.Collection.CompareTo(entryB.Key.Collection)))); GameObject currentHorizontalHelper = null; var activatedFirstSwatch = false; foreach (var textureEntry in loadedTextureEntries) { if (textureEntry.Key.UsesLandscapeCollection()) { currentHorizontalHelper = null; var swatch = Instantiate(textureSwatchPrefab, swatchesParent); swatch.SetInitialValues(textureEntry, paletteToggleGroup); currentSwatches.Add(swatch.gameObject); } else { if (!currentHorizontalHelper) { currentHorizontalHelper = Instantiate(horizontalLayoutHelperPrefab, swatchesParent); currentLayoutHelpers.Add(currentHorizontalHelper); var swatch = Instantiate(textureSwatchPrefab, currentHorizontalHelper.transform); swatch.SetInitialValues(textureEntry, paletteToggleGroup); currentSwatches.Add(swatch.gameObject); } else { var swatch = Instantiate(textureSwatchPrefab, currentHorizontalHelper.transform); swatch.SetInitialValues(textureEntry, paletteToggleGroup); currentSwatches.Add(swatch.gameObject); currentHorizontalHelper = null; } } if (!activatedFirstSwatch) { currentSwatches[0].GetComponent <Toggle>().isOn = true; activatedFirstSwatch = true; } } break; case ModeManager.PrimaryModes.Lights: paletteToggleGroup.allowSwitchOff = true; foreach (var light in LevelEntity_Level.Instance.Lights.Values) { var swatch = Instantiate(lightSwatchPrefab, swatchesParent); swatch.SetInitialValues(light, paletteToggleGroup); currentSwatches.Add(swatch.gameObject); } break; case ModeManager.PrimaryModes.Media: paletteToggleGroup.allowSwitchOff = true; foreach (var media in LevelEntity_Level.Instance.Medias.Values) { var swatch = Instantiate(mediaSwatchPrefab, swatchesParent); swatch.SetInitialValues(media, paletteToggleGroup); currentSwatches.Add(swatch.gameObject); } break; case ModeManager.PrimaryModes.Platforms: paletteToggleGroup.allowSwitchOff = true; // TODO: populate with shortcuts that focus the camera on the associated platform polygon when clicked. break; case ModeManager.PrimaryModes.Objects: paletteToggleGroup.allowSwitchOff = false; // TODO: populate with placement tools // - Players // - Monsters // - foldout to show all subtypes // - load view-0, frame-0 sprite // - Items // - foldout to show all subtypes // - load view-0, frame-0 sprite // - Sceneries // - foldout to show all subtypes // - load view-0, frame-0 sprite // - Sounds // - foldout to show all subtypes // - plays sound when clicked // - Goals break; case ModeManager.PrimaryModes.Annotations: break; case ModeManager.PrimaryModes.Level: break; case ModeManager.PrimaryModes.None: default: break; } } }
public override void ApplyBatchKeyMaterial(bool innerLayer = true) { DecrementTextureUsage(); var modifiedBatchKey = BatchKey; switch (dataSource) { case LevelEntity_Polygon.DataSources.Floor: #if USE_TEXTURE_ARRAYS modifiedBatchKey.sourceShapeDescriptor = polygonEntity.NativeObject.FloorTexture; #endif modifiedBatchKey.sourceMaterial = MaterialGeneration_Geometry.GetMaterial( polygonEntity.NativeObject.FloorTexture, polygonEntity.NativeObject.FloorTransferMode, isOpaqueSurface: true, MaterialGeneration_Geometry.SurfaceTypes.Normal, incrementUsageCounter: true); #if USE_TEXTURE_ARRAYS lastTextureIndex = MaterialGeneration_Geometry.GetTextureArrayIndex( polygonEntity.NativeObject.FloorTexture, polygonEntity.NativeObject.FloorTransferMode, isOpaqueSurface: true, MaterialGeneration_Geometry.SurfaceTypes.Normal); #endif break; case LevelEntity_Polygon.DataSources.Ceiling: #if USE_TEXTURE_ARRAYS modifiedBatchKey.sourceShapeDescriptor = polygonEntity.NativeObject.CeilingTexture; #endif modifiedBatchKey.sourceMaterial = MaterialGeneration_Geometry.GetMaterial( polygonEntity.NativeObject.CeilingTexture, polygonEntity.NativeObject.CeilingTransferMode, isOpaqueSurface: true, MaterialGeneration_Geometry.SurfaceTypes.Normal, incrementUsageCounter: true); #if USE_TEXTURE_ARRAYS lastTextureIndex = MaterialGeneration_Geometry.GetTextureArrayIndex( polygonEntity.NativeObject.CeilingTexture, polygonEntity.NativeObject.CeilingTransferMode, isOpaqueSurface: true, MaterialGeneration_Geometry.SurfaceTypes.Normal); #endif break; case LevelEntity_Polygon.DataSources.Media: var mediaShapeDescriptor = new ShapeDescriptor((ushort)polygonEntity.NativeObject.FloorTexture); switch (BatchKey.sourceMedia.NativeObject.Type) { case MediaType.Water: mediaShapeDescriptor.Collection = 17; mediaShapeDescriptor.Bitmap = 19; break; case MediaType.Lava: mediaShapeDescriptor.Collection = 18; mediaShapeDescriptor.Bitmap = 12; break; case MediaType.Goo: mediaShapeDescriptor.Collection = 21; mediaShapeDescriptor.Bitmap = 5; break; case MediaType.Sewage: mediaShapeDescriptor.Collection = 19; mediaShapeDescriptor.Bitmap = 13; break; case MediaType.Jjaro: mediaShapeDescriptor.Collection = 20; mediaShapeDescriptor.Bitmap = 13; break; } #if USE_TEXTURE_ARRAYS modifiedBatchKey.sourceShapeDescriptor = mediaShapeDescriptor; #endif modifiedBatchKey.sourceMaterial = MaterialGeneration_Geometry.GetMaterial( mediaShapeDescriptor, (short)TransferModes.Normal, isOpaqueSurface: true, MaterialGeneration_Geometry.SurfaceTypes.Media, incrementUsageCounter: false); #if USE_TEXTURE_ARRAYS lastTextureIndex = MaterialGeneration_Geometry.GetTextureArrayIndex( mediaShapeDescriptor, (short)TransferModes.Normal, isOpaqueSurface: true, MaterialGeneration_Geometry.SurfaceTypes.Media); #endif break; default: throw new NotImplementedException($"DataSource '{dataSource}' is not implemented."); } var UVs = SurfaceMesh.uv.Select(uv => new Vector4(uv.x, uv.y, lastLightIndex, lastTextureIndex)).ToArray(); SurfaceMesh.SetUVs(0, UVs); BatchKey = modifiedBatchKey; }