/// <summary> /// Stores scenery flats. /// </summary> /// <param name="block">Block data.</param> /// <param name="climateSettings">Desired climate settings for block.</param> private void AddRMBSceneryFlats(ref DFBlock block, DFLocation.ClimateSettings climateSettings) { // Add block scenery for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { // Get scenery item DFBlock.RmbGroundScenery scenery = block.RmbBlock.FldHeader.GroundData.GroundScenery[x, y]; // Ignore 0 as this appears to be a marker/waypoint of some kind if (scenery.TextureRecord > 0) { BlockFlat flat = new BlockFlat { Dungeon = false, Archive = climateSettings.SceneryArchive, Record = scenery.TextureRecord, Position = new Vector3(x * BlocksFile.TileDimension, 0, y * BlocksFile.TileDimension) * ModelManager.GlobalScale, Type = FlatTypes.ClimateScenery, }; blockFlats.Add(flat); } } } }
public static void AddNatureFlats( DaggerfallUnity dfUnity, ref DFBlock blockData, Transform parent = null, ClimateNatureSets climateNature = ClimateNatureSets.SubTropical, ClimateSeason climateSeason = ClimateSeason.Summer) { int archive = ClimateSwaps.GetNatureArchive(climateNature, climateSeason); // Add block scenery for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { // Get scenery item DFBlock.RmbGroundScenery scenery = blockData.RmbBlock.FldHeader.GroundData.GroundScenery[x, 15 - y]; // Ignore 0 as this appears to be a marker/waypoint of some kind if (scenery.TextureRecord > 0) { // Spawn billboard gameobject GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(archive, scenery.TextureRecord, parent); Vector3 billboardPosition = new Vector3( x * BlocksFile.TileDimension, NatureFlatsOffsetY, y * BlocksFile.TileDimension + BlocksFile.TileDimension) * MeshReader.GlobalScale; // Set transform go.transform.position = billboardPosition; } } } }
/// <summary> /// Add nature billboards. /// </summary> public static void AddNatureFlats( ref DFBlock blockData, Transform flatsParent, DaggerfallBillboardBatch billboardBatch = null, ClimateNatureSets climateNature = ClimateNatureSets.TemperateWoodland, ClimateSeason climateSeason = ClimateSeason.Summer) { DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) { return; } for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { // Get scenery item - ignore indices -1 (empty) and 0 (marker/waypoint of some kind) DFBlock.RmbGroundScenery scenery = blockData.RmbBlock.FldHeader.GroundData.GroundScenery[x, 15 - y]; if (scenery.TextureRecord < 1) { continue; } // Calculate position Vector3 billboardPosition = new Vector3( x * BlocksFile.TileDimension, natureFlatsOffsetY, y * BlocksFile.TileDimension + BlocksFile.TileDimension) * MeshReader.GlobalScale; // Get Archive int natureArchive = ClimateSwaps.GetNatureArchive(climateNature, climateSeason); // Import custom 3d gameobject instead of flat if (MeshReplacement.ImportCustomFlatGameobject(natureArchive, scenery.TextureRecord, billboardPosition, flatsParent) != null) { continue; } // Add billboard to batch or standalone if (billboardBatch != null) { billboardBatch.AddItem(scenery.TextureRecord, billboardPosition); } else { GameObject go = GameObjectHelper.CreateDaggerfallBillboardGameObject(natureArchive, scenery.TextureRecord, flatsParent); go.transform.position = billboardPosition; AlignBillboardToBase(go); } } } }
/// <summary> /// Adds RMB scenery flats to block node. /// </summary> /// <param name="block">DFBlock</param> /// <param name="blockNode">BlockNode.</param> /// <param name="sceneryArchive">Scenery texture archive index.</param> private void AddRMBSceneryFlats(ref DFBlock block, BlockNode blockNode, int sceneryArchive) { // Flags TextureManager.TextureCreateFlags flags = TextureManager.TextureCreateFlags.Dilate | TextureManager.TextureCreateFlags.PreMultiplyAlpha; if (Core.GraphicsProfile == GraphicsProfile.HiDef) { flags |= TextureManager.TextureCreateFlags.MipMaps; } // Add block scenery for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { // Get scenery item DFBlock.RmbGroundScenery scenery = block.RmbBlock.FldHeader.GroundData.GroundScenery[x, y]; // Ignore 0 as this appears to be a marker/waypoint of some kind if (scenery.TextureRecord > 0) { // Load flat int textureKey; Vector2 startSize; Vector2 finalSize; if (true == LoadDaggerfallFlat( sceneryArchive, scenery.TextureRecord, flags, out textureKey, out startSize, out finalSize)) { // Calcuate position Vector3 position = new Vector3( x * tileSide, (finalSize.Y / 2) - 4, -rmbSide + y * tileSide); // Create billboard node BillboardNode billboardNode = new BillboardNode( BillboardNode.BillboardType.ClimateScenery, textureKey, finalSize); billboardNode.Position = position; blockNode.Add(billboardNode); } } } } }
public static void AddNatureFlatsToBatch( DaggerfallBillboardBatch batch, ref DFBlock blockData) { for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { // Get scenery item DFBlock.RmbGroundScenery scenery = blockData.RmbBlock.FldHeader.GroundData.GroundScenery[x, 15 - y]; // Ignore 0 as this appears to be a marker/waypoint of some kind if (scenery.TextureRecord > 0) { Vector3 billboardPosition = new Vector3( x * BlocksFile.TileDimension, NatureFlatsOffsetY, y * BlocksFile.TileDimension + BlocksFile.TileDimension) * MeshReader.GlobalScale; batch.AddItem(scenery.TextureRecord, billboardPosition); } } } }