Particles types progress

This commit is contained in:
dexy 2020-01-27 05:48:17 +11:00
parent 923c3e8a76
commit ad61b39920
4 changed files with 159 additions and 61 deletions

View File

@ -12,7 +12,7 @@ namespace CodeWalker.GameFiles
{ {
public ParticleEffectsList PtfxList { get; set; } public ParticleEffectsList PtfxList { get; set; }
public Dictionary<uint, Drawable> DrawableDict { get; set; } public Dictionary<uint, DrawableBase> DrawableDict { get; set; }
public string ErrorMessage { get; set; } public string ErrorMessage { get; set; }
@ -76,7 +76,7 @@ namespace CodeWalker.GameFiles
if ((dDict?.Drawables?.data_items != null) && (dDict?.Hashes != null)) if ((dDict?.Drawables?.data_items != null) && (dDict?.Hashes != null))
{ {
DrawableDict = new Dictionary<uint, Drawable>(); DrawableDict = new Dictionary<uint, DrawableBase>();
var drawables = dDict.Drawables.data_items; var drawables = dDict.Drawables.data_items;
var hashes = dDict.Hashes; var hashes = dDict.Hashes;
for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++)
@ -87,23 +87,23 @@ namespace CodeWalker.GameFiles
drawable.Owner = this; drawable.Owner = this;
} }
for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) //for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++)
{ //{
var drawable = drawables[i]; // var drawable = drawables[i];
var hash = hashes[i]; // var hash = hashes[i];
if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd"))) // if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd")))
{ // {
string hstr = JenkIndex.TryGetString(hash); // string hstr = JenkIndex.TryGetString(hash);
if (!string.IsNullOrEmpty(hstr)) // if (!string.IsNullOrEmpty(hstr))
{ // {
drawable.Name = hstr; // drawable.Name = hstr;
} // }
else // else
{ // {
drawable.Name = "0x" + hash.ToString("X").PadLeft(8, '0'); // drawable.Name = "0x" + hash.ToString("X").PadLeft(8, '0');
} // }
} // }
} //}
} }
} }

View File

@ -4582,10 +4582,8 @@ namespace CodeWalker.GameFiles
} }
// structure data // structure data
public uint Unknown_10h { get; set; } public ulong Unknown_10h; // 0x0000000000000000
public uint Unknown_14h { get; set; } public ulong Unknown_18h = 1; // 0x0000000000000001
public uint Unknown_18h { get; set; }
public uint Unknown_1Ch { get; set; }
public ulong HashesPointer { get; set; } public ulong HashesPointer { get; set; }
public ushort HashesCount1 { get; set; } public ushort HashesCount1 { get; set; }
public ushort HashesCount2 { get; set; } public ushort HashesCount2 { get; set; }
@ -4604,18 +4602,13 @@ namespace CodeWalker.GameFiles
private ResourceSystemStructBlock<uint> HashesBlock = null;//only used for saving private ResourceSystemStructBlock<uint> HashesBlock = null;//only used for saving
/// <summary>
/// Reads the data-block from a stream.
/// </summary>
public override void Read(ResourceDataReader reader, params object[] parameters) public override void Read(ResourceDataReader reader, params object[] parameters)
{ {
base.Read(reader, parameters); base.Read(reader, parameters);
// read structure data // read structure data
this.Unknown_10h = reader.ReadUInt32(); this.Unknown_10h = reader.ReadUInt64();
this.Unknown_14h = reader.ReadUInt32(); this.Unknown_18h = reader.ReadUInt64();
this.Unknown_18h = reader.ReadUInt32();
this.Unknown_1Ch = reader.ReadUInt32();
this.HashesPointer = reader.ReadUInt64(); this.HashesPointer = reader.ReadUInt64();
this.HashesCount1 = reader.ReadUInt16(); this.HashesCount1 = reader.ReadUInt16();
this.HashesCount2 = reader.ReadUInt16(); this.HashesCount2 = reader.ReadUInt16();
@ -4626,21 +4619,18 @@ namespace CodeWalker.GameFiles
this.Unknown_3Ch = reader.ReadUInt32(); this.Unknown_3Ch = reader.ReadUInt32();
// read reference data // read reference data
//this.Hashes = reader.ReadBlockAt<ResourceSimpleArray<uint_r>>(
// this.HashesPointer, // offset
// this.HashesCount1
//);
this.Hashes = reader.ReadUintsAt(this.HashesPointer, this.HashesCount1); this.Hashes = reader.ReadUintsAt(this.HashesPointer, this.HashesCount1);
this.Drawables = reader.ReadBlockAt<ResourcePointerArray64<DrawableBase>>(this.DrawablesPointer, this.DrawablesCount1);
this.Drawables = reader.ReadBlockAt<ResourcePointerArray64<DrawableBase>>( //if (Unknown_10h != 0)
this.DrawablesPointer, // offset //{ }
this.DrawablesCount1 //if (Unknown_18h != 1)
); //{ }
//if (Unknown_2Ch != 0)
//{ }
//if (Unknown_3Ch != 0)
//{ }
} }
/// <summary>
/// Writes the data-block to a stream.
/// </summary>
public override void Write(ResourceDataWriter writer, params object[] parameters) public override void Write(ResourceDataWriter writer, params object[] parameters)
{ {
base.Write(writer, parameters); base.Write(writer, parameters);
@ -4655,9 +4645,7 @@ namespace CodeWalker.GameFiles
// write structure data // write structure data
writer.Write(this.Unknown_10h); writer.Write(this.Unknown_10h);
writer.Write(this.Unknown_14h);
writer.Write(this.Unknown_18h); writer.Write(this.Unknown_18h);
writer.Write(this.Unknown_1Ch);
writer.Write(this.HashesPointer); writer.Write(this.HashesPointer);
writer.Write(this.HashesCount1); writer.Write(this.HashesCount1);
writer.Write(this.HashesCount2); writer.Write(this.HashesCount2);
@ -4668,9 +4656,6 @@ namespace CodeWalker.GameFiles
writer.Write(this.Unknown_3Ch); writer.Write(this.Unknown_3Ch);
} }
/// <summary>
/// Returns a list of data blocks which are referenced by this block.
/// </summary>
public override IResourceBlock[] GetReferences() public override IResourceBlock[] GetReferences()
{ {
var list = new List<IResourceBlock>(base.GetReferences()); var list = new List<IResourceBlock>(base.GetReferences());

View File

@ -61,7 +61,7 @@ namespace CodeWalker.GameFiles
// reference data // reference data
public string_r Name { get; set; } public string_r Name { get; set; }
public TextureDictionary TextureDictionary { get; set; } public TextureDictionary TextureDictionary { get; set; }
public DrawableDictionary DrawableDictionary { get; set; } public DrawableBaseDictionary DrawableDictionary { get; set; }
public ParticleRuleDictionary ParticleRuleDictionary { get; set; } public ParticleRuleDictionary ParticleRuleDictionary { get; set; }
public ParticleEffectRuleDictionary EffectRuleDictionary { get; set; } public ParticleEffectRuleDictionary EffectRuleDictionary { get; set; }
public ParticleEmitterRuleDictionary EmitterRuleDictionary { get; set; } public ParticleEmitterRuleDictionary EmitterRuleDictionary { get; set; }
@ -86,7 +86,7 @@ namespace CodeWalker.GameFiles
// read reference data // read reference data
this.Name = reader.ReadBlockAt<string_r>(this.NamePointer); this.Name = reader.ReadBlockAt<string_r>(this.NamePointer);
this.TextureDictionary = reader.ReadBlockAt<TextureDictionary>(this.TextureDictionaryPointer); this.TextureDictionary = reader.ReadBlockAt<TextureDictionary>(this.TextureDictionaryPointer);
this.DrawableDictionary = reader.ReadBlockAt<DrawableDictionary>(this.DrawableDictionaryPointer); this.DrawableDictionary = reader.ReadBlockAt<DrawableBaseDictionary>(this.DrawableDictionaryPointer);
this.ParticleRuleDictionary = reader.ReadBlockAt<ParticleRuleDictionary>(this.ParticleRuleDictionaryPointer); this.ParticleRuleDictionary = reader.ReadBlockAt<ParticleRuleDictionary>(this.ParticleRuleDictionaryPointer);
this.EffectRuleDictionary = reader.ReadBlockAt<ParticleEffectRuleDictionary>(this.EmitterRuleDictionaryPointer); this.EffectRuleDictionary = reader.ReadBlockAt<ParticleEffectRuleDictionary>(this.EmitterRuleDictionaryPointer);
this.EmitterRuleDictionary = reader.ReadBlockAt<ParticleEmitterRuleDictionary>(this.EffectRuleDictionaryPointer); this.EmitterRuleDictionary = reader.ReadBlockAt<ParticleEmitterRuleDictionary>(this.EffectRuleDictionaryPointer);
@ -866,6 +866,11 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(0x210, UnknownList2) new Tuple<long, IResourceBlock>(0x210, UnknownList2)
}; };
} }
public override string ToString()
{
return Name?.ToString() ?? base.ToString();
}
} }
@ -957,6 +962,12 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(0x40, Unknown_40h) new Tuple<long, IResourceBlock>(0x40, Unknown_40h)
}; };
} }
public override string ToString()
{
var n = Name.ToString();
return (!string.IsNullOrEmpty(n)) ? n : base.ToString();
}
} }
@ -977,7 +988,7 @@ namespace CodeWalker.GameFiles
// reference data // reference data
public string_r String1 { get; set; } public string_r String1 { get; set; }
public Drawable Drawable { get; set; } public DrawableBase Drawable { get; set; }
public override void Read(ResourceDataReader reader, params object[] parameters) public override void Read(ResourceDataReader reader, params object[] parameters)
{ {
@ -994,7 +1005,7 @@ namespace CodeWalker.GameFiles
// read reference data // read reference data
this.String1 = reader.ReadBlockAt<string_r>(this.String1Pointer); this.String1 = reader.ReadBlockAt<string_r>(this.String1Pointer);
this.Drawable = reader.ReadBlockAt<Drawable>(this.DrawablePointer); this.Drawable = reader.ReadBlockAt<DrawableBase>(this.DrawablePointer);
switch (Unknown_0h) switch (Unknown_0h)
@ -1073,7 +1084,7 @@ namespace CodeWalker.GameFiles
case 0xb1178b81: // case 0xb1178b81: //
break; break;
default: default:
break;//no hit break;
} }
//if (Unknown_24h != 0) //if (Unknown_24h != 0)
//{ }//no hit //{ }//no hit
@ -1105,6 +1116,13 @@ namespace CodeWalker.GameFiles
if (Drawable != null) list.Add(Drawable); if (Drawable != null) list.Add(Drawable);
return list.ToArray(); return list.ToArray();
} }
public override string ToString()
{
if (!string.IsNullOrEmpty(String1?.Value)) return String1.Value;
if (Unknown_20h != 0) return Unknown_20h.ToString();
return base.ToString();
}
} }
@ -1378,6 +1396,12 @@ namespace CodeWalker.GameFiles
if (String1 != null) list.Add(String1); if (String1 != null) list.Add(String1);
return list.ToArray(); return list.ToArray();
} }
public override string ToString()
{
var str = String1?.ToString();
return (!string.IsNullOrEmpty(str)) ? str : base.ToString();
}
} }
@ -1906,6 +1930,11 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(768, KeyframeProp4) new Tuple<long, IResourceBlock>(768, KeyframeProp4)
}; };
} }
public override string ToString()
{
return Name?.ToString() ?? base.ToString();
}
} }
@ -2110,6 +2139,11 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(0x70, Items) new Tuple<long, IResourceBlock>(0x70, Items)
}; };
} }
public override string ToString()
{
return Unknown_68h.ToString();
}
} }
@ -2235,6 +2269,11 @@ namespace CodeWalker.GameFiles
writer.Write(this.Unknown_18h); writer.Write(this.Unknown_18h);
writer.Write(this.Unknown_1Ch); writer.Write(this.Unknown_1Ch);
} }
public override string ToString()
{
return string.Format("{0}, {1}, {2}, {3}, {4}, {5}", Unknown_0h, Unknown_4h, Unknown_10h, Unknown_14h, Unknown_18h, Unknown_1Ch);
}
} }
@ -2467,6 +2506,11 @@ namespace CodeWalker.GameFiles
if (ParticleRule != null) list.Add(ParticleRule); if (ParticleRule != null) list.Add(ParticleRule);
return list.ToArray(); return list.ToArray();
} }
public override string ToString()
{
return String1?.ToString() ?? String2?.ToString() ?? base.ToString();
}
} }
@ -2672,6 +2716,11 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(1416, KeyframeProps1[9]), new Tuple<long, IResourceBlock>(1416, KeyframeProps1[9]),
}; };
} }
public override string ToString()
{
return Name?.ToString() ?? base.ToString();
}
} }
@ -2731,6 +2780,11 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(0x28, Unknown_28h) new Tuple<long, IResourceBlock>(0x28, Unknown_28h)
}; };
} }
public override string ToString()
{
return base.ToString();
}
} }
@ -2762,7 +2816,6 @@ namespace CodeWalker.GameFiles
//if (Unknown_10h != 0) //if (Unknown_10h != 0)
//{ }//no hit //{ }//no hit
} }
public override void Write(ResourceDataWriter writer, params object[] parameters) public override void Write(ResourceDataWriter writer, params object[] parameters)
{ {
// update structure data // update structure data
@ -2780,6 +2833,11 @@ namespace CodeWalker.GameFiles
if (String1 != null) list.Add(String1); if (String1 != null) list.Add(String1);
return list.ToArray(); return list.ToArray();
} }
public override string ToString()
{
return String1?.ToString() ?? base.ToString();
}
} }
@ -2858,13 +2916,12 @@ namespace CodeWalker.GameFiles
case 0xff864d6c: // case 0xff864d6c: //
break; break;
default: default:
break;//no hit break;
} }
//if (Unknown_4h != 0) //if (Unknown_4h != 0)
//{ }//no hit //{ }//no hit
} }
public override void Write(ResourceDataWriter writer, params object[] parameters) public override void Write(ResourceDataWriter writer, params object[] parameters)
{ {
// update structure data // update structure data
@ -2882,6 +2939,11 @@ namespace CodeWalker.GameFiles
if (Item != null) list.Add(Item); if (Item != null) list.Add(Item);
return list.ToArray(); return list.ToArray();
} }
public override string ToString()
{
return Unknown_0h.ToString();
}
} }
@ -2951,7 +3013,7 @@ namespace CodeWalker.GameFiles
case 0xff864d6c: // case 0xff864d6c: //
break; break;
default: default:
break;//no hit break;
} }
//switch (Unknown_14h) //switch (Unknown_14h)
//{ //{
@ -2962,7 +3024,6 @@ namespace CodeWalker.GameFiles
// break;//no hit // break;//no hit
//} //}
} }
public override void Write(ResourceDataWriter writer, params object[] parameters) public override void Write(ResourceDataWriter writer, params object[] parameters)
{ {
// write structure data // write structure data
@ -2977,6 +3038,11 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(0, Unknown_0h) new Tuple<long, IResourceBlock>(0, Unknown_0h)
}; };
} }
public override string ToString()
{
return Unknown_10h.ToString();
}
} }
@ -3028,7 +3094,6 @@ namespace CodeWalker.GameFiles
//if (Unknown_28h != 0) //if (Unknown_28h != 0)
//{ }//no hit //{ }//no hit
} }
public override void Write(ResourceDataWriter writer, params object[] parameters) public override void Write(ResourceDataWriter writer, params object[] parameters)
{ {
// write structure data // write structure data
@ -3046,6 +3111,11 @@ namespace CodeWalker.GameFiles
new Tuple<long, IResourceBlock>(0, Unknown_0h) new Tuple<long, IResourceBlock>(0, Unknown_0h)
}; };
} }
public override string ToString()
{
return Unknown_20h.ToString() + ", " + Unknown_24h.ToString();
}
} }
@ -3215,6 +3285,10 @@ namespace CodeWalker.GameFiles
} }
} }
public override string ToString()
{
return "Domain: " + DomainType.ToString();
}
} }
[TC(typeof(EXP))] public class ParticleDomainBox : ParticleDomain [TC(typeof(EXP))] public class ParticleDomainBox : ParticleDomain
@ -3345,6 +3419,11 @@ namespace CodeWalker.GameFiles
default: return null;// throw new Exception("Unknown behaviour type"); default: return null;// throw new Exception("Unknown behaviour type");
} }
} }
public override string ToString()
{
return "Behaviour: " + Type.ToString();
}
} }
[TC(typeof(EXP))] public class ParticleBehaviourAge : ParticleBehaviour [TC(typeof(EXP))] public class ParticleBehaviourAge : ParticleBehaviour
@ -5857,6 +5936,11 @@ namespace CodeWalker.GameFiles
default: return null;// throw new Exception("Unknown shader var type"); default: return null;// throw new Exception("Unknown shader var type");
} }
} }
public override string ToString()
{
return Unknown_10h.ToString() + ": " + Type.ToString();
}
} }
[TC(typeof(EXP))] public class ParticleShaderVarVector : ParticleShaderVar [TC(typeof(EXP))] public class ParticleShaderVarVector : ParticleShaderVar
@ -5987,7 +6071,7 @@ namespace CodeWalker.GameFiles
public override long BlockLength => 0x40; public override long BlockLength => 0x40;
// structure data // structure data
public uint Unknown_18h { get; set; } // 3, 4, 6, 7 public uint Unknown_18h { get; set; } // 3, 4, 6, 7 //shader var index..?
public uint Unknown_1Ch; // 0x00000000 public uint Unknown_1Ch; // 0x00000000
public uint Unknown_20h; // 0x00000000 public uint Unknown_20h; // 0x00000000
public uint Unknown_24h; // 0x00000000 public uint Unknown_24h; // 0x00000000
@ -6089,7 +6173,7 @@ namespace CodeWalker.GameFiles
public override long BlockLength => 0x50; public override long BlockLength => 0x50;
// structure data // structure data
public uint Unknown_18h { get; set; } // 9, 14, 15, 16, 17, 20, 23, 31 public uint Unknown_18h { get; set; } // 9, 14, 15, 16, 17, 20, 23, 31 //shader var index..?
public uint Unknown_1Ch = 1; // 0x00000001 public uint Unknown_1Ch = 1; // 0x00000001
public ulong Unknown_20h; // 0x0000000000000000 public ulong Unknown_20h; // 0x0000000000000000
public ResourceSimpleList64<ParticleShaderVarKeyframeItem> Items { get; set; } public ResourceSimpleList64<ParticleShaderVarKeyframeItem> Items { get; set; }

View File

@ -1023,6 +1023,35 @@ namespace CodeWalker.Forms
ToolsPanel.Visible = true; //show the panel by default for dictionaries... ToolsPanel.Visible = true; //show the panel by default for dictionaries...
} }
private void UpdateModelsUI(Dictionary<uint, DrawableBase> dict)
{
//DetailsPropertyGrid.SelectedObject = dict; //this won't look good...
DrawableDrawFlags.Clear();
Renderer.SelectionModelDrawFlags.Clear();
Renderer.SelectionGeometryDrawFlags.Clear();
ModelsTreeView.Nodes.Clear();
ModelsTreeView.ShowRootLines = true;
TexturesTreeView.Nodes.Clear();
bool check = true;
if (dict != null)
{
List<KeyValuePair<uint, DrawableBase>> items = new List<KeyValuePair<uint, DrawableBase>>();
foreach (var kvp in dict)
{
items.Add(kvp);
}
//items.Sort((a, b) => { return a.Value?.Name?.CompareTo(b.Value?.Name ?? "") ?? 0; });
foreach (var kvp in items)
{
AddDrawableTreeNode(kvp.Value, kvp.Key, check);
check = false;
}
}
ToolsPanel.Visible = true; //show the panel by default for dictionaries...
}
private void UpdateBoundsUI(YbnFile bounds) private void UpdateBoundsUI(YbnFile bounds)
{ {
DetailsPropertyGrid.SelectedObject = bounds; DetailsPropertyGrid.SelectedObject = bounds;
@ -1878,7 +1907,7 @@ namespace CodeWalker.Forms
} }
else if ((Ypt != null) && (Ypt.Loaded)) else if ((Ypt != null) && (Ypt.Loaded))
{ {
dict = Ypt.DrawableDict; //dict = Ypt.DrawableDict;
} }
else else
{ {