diff --git a/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs b/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs index b7ebf45..2c7108d 100644 --- a/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs +++ b/CodeWalker.Core/GameFiles/FileTypes/YmapFile.cs @@ -29,6 +29,7 @@ namespace CodeWalker.GameFiles public Unk_975711773[] CBoxOccluders { get; set; } public Unk_2741784237[] COccludeModels { get; set; } + public rage__fwGrassInstanceListDef[] GrassInstanceList { get; set; } public string[] Strings { get; set; } @@ -571,6 +572,26 @@ namespace CodeWalker.GameFiles } } + public void BuildInstances() + { + if (GrassInstanceBatches == null) + { + GrassInstanceList = null; + return; + } + + if (PropInstanceBatches == null) + { } + + int count = GrassInstanceBatches.Length; + GrassInstanceList = new rage__fwGrassInstanceListDef[count]; + for (int i = 0; i < count; i++) + { + GrassInstanceList[i] = GrassInstanceBatches[i].Batch; + } + + } + public byte[] Save() { //direct save to a raw, compressed ymap file (openIV-compatible format) @@ -909,6 +930,46 @@ namespace CodeWalker.GameFiles } + public void AddGrassBatch(YmapGrassInstanceBatch newbatch) + { + List batches = new List(); + if (GrassInstanceBatches != null) batches.AddRange(GrassInstanceBatches); + newbatch.Ymap = this; + batches.Add(newbatch); + GrassInstanceBatches = batches.ToArray(); + + HasChanged = true; + } + + public bool RemoveGrassBatch(YmapGrassInstanceBatch batch) + { + if (batch == null) return false; + + List batches = new List(); + + if (GrassInstanceBatches != null) + { + for (int i = 0; i < GrassInstanceBatches.Length; i++) + { + var gb = GrassInstanceBatches[i]; + if (gb != batch) + { + batches.Add(gb); + } + } + if (batches.Count == GrassInstanceBatches.Length) + { + return false; //nothing removed... wasn't present? + } + } + + + GrassInstanceBatches = batches.ToArray(); + + HasChanged = true; + + return true; + } @@ -1049,14 +1110,14 @@ namespace CodeWalker.GameFiles if (GrassInstanceBatches != null) { - var lodoffset = Vector3.Zero;// new Vector3(0, 0, 100); //IDK WHY -neos7 //dexy: i guess it's not completely necessary... + //var lodoffset = Vector3.Zero;// new Vector3(0, 0, 100); //IDK WHY -neos7 //dexy: i guess it's not completely necessary... //blame neos foreach (var batch in GrassInstanceBatches) //thanks to Neos7 { emin = Vector3.Min(emin, batch.AABBMin); emax = Vector3.Max(emax, batch.AABBMax); - smin = Vector3.Min(smin, (batch.AABBMin - batch.Batch.lodDist) + lodoffset); - smax = Vector3.Min(smax, (batch.AABBMax + batch.Batch.lodDist) - lodoffset); + smin = Vector3.Min(smin, (batch.AABBMin - batch.Batch.lodDist)); // + lodoffset + smax = Vector3.Max(smax, (batch.AABBMax + batch.Batch.lodDist)); // - lodoffset } } diff --git a/CodeWalker.Core/GameFiles/Resources/Drawable.cs b/CodeWalker.Core/GameFiles/Resources/Drawable.cs index 089b290..a03a5dd 100644 --- a/CodeWalker.Core/GameFiles/Resources/Drawable.cs +++ b/CodeWalker.Core/GameFiles/Resources/Drawable.cs @@ -2032,11 +2032,12 @@ namespace CodeWalker.GameFiles public byte ColorR { get; set; } public byte ColorG { get; set; } public byte ColorB { get; set; } - public byte Unknown_1Bh { get; set; } + public byte Flashiness { get; set; } public float Intensity { get; set; } public uint Flags { get; set; } public ushort BoneId { get; set; } - public ushort Type { get; set; } + public byte Type { get; set; } + public byte GroupId { get; set; } public uint TimeFlags { get; set; } public float Falloff { get; set; } public float FalloffExponent { get; set; } diff --git a/ProjectForm.cs b/ProjectForm.cs index 3cd8617..91d5de9 100644 --- a/ProjectForm.cs +++ b/ProjectForm.cs @@ -1300,6 +1300,19 @@ namespace CodeWalker ccgnode.Tag = cargen; } } + if ((ymap.GrassInstanceBatches != null) && (ymap.GrassInstanceBatches.Length > 0)) + { + var grassbatchesnodes = node.Nodes.Add("Grass Batches (" + ymap.GrassInstanceBatches.Length.ToString() + ")"); + grassbatchesnodes.Name = "GrassBatches"; + grassbatchesnodes.Tag = ymap; + var grassbatches = ymap.GrassInstanceBatches; + for (int i = 0; i < grassbatches.Length; i++) + { + var batch = grassbatches[i]; + var gbnode = grassbatchesnodes.Nodes.Add(batch.ToString()); + gbnode.Tag = batch; + } + } }