mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-26 23:42:56 +08:00
Peds facial animations progress
This commit is contained in:
parent
917407c2e6
commit
26183af00d
@ -15,6 +15,10 @@ namespace CodeWalker.GameFiles
|
|||||||
public string LoadException { get; set; }
|
public string LoadException { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public Dictionary<MetaHash, Expression> ExprMap { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public YedFile() : base(null, GameFileType.Yed)
|
public YedFile() : base(null, GameFileType.Yed)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -48,6 +52,14 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
ExpressionDictionary = rd?.ReadBlock<ExpressionDictionary>();
|
ExpressionDictionary = rd?.ReadBlock<ExpressionDictionary>();
|
||||||
|
|
||||||
|
|
||||||
|
InitDictionaries();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitDictionaries()
|
||||||
|
{
|
||||||
|
ExprMap = ExpressionDictionary?.ExprMap ?? new Dictionary<MetaHash, Expression>();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public Dictionary<uint, RpfFileEntry> YftDict { get; private set; }
|
public Dictionary<uint, RpfFileEntry> YftDict { get; private set; }
|
||||||
public Dictionary<uint, RpfFileEntry> YbnDict { get; private set; }
|
public Dictionary<uint, RpfFileEntry> YbnDict { get; private set; }
|
||||||
public Dictionary<uint, RpfFileEntry> YcdDict { get; private set; }
|
public Dictionary<uint, RpfFileEntry> YcdDict { get; private set; }
|
||||||
|
public Dictionary<uint, RpfFileEntry> YedDict { get; private set; }
|
||||||
public Dictionary<uint, RpfFileEntry> YnvDict { get; private set; }
|
public Dictionary<uint, RpfFileEntry> YnvDict { get; private set; }
|
||||||
public Dictionary<uint, RpfFileEntry> Gxt2Dict { get; private set; }
|
public Dictionary<uint, RpfFileEntry> Gxt2Dict { get; private set; }
|
||||||
|
|
||||||
@ -925,6 +926,7 @@ namespace CodeWalker.GameFiles
|
|||||||
YtdDict = new Dictionary<uint, RpfFileEntry>();
|
YtdDict = new Dictionary<uint, RpfFileEntry>();
|
||||||
YftDict = new Dictionary<uint, RpfFileEntry>();
|
YftDict = new Dictionary<uint, RpfFileEntry>();
|
||||||
YcdDict = new Dictionary<uint, RpfFileEntry>();
|
YcdDict = new Dictionary<uint, RpfFileEntry>();
|
||||||
|
YedDict = new Dictionary<uint, RpfFileEntry>();
|
||||||
foreach (var rpffile in AllRpfs)
|
foreach (var rpffile in AllRpfs)
|
||||||
{
|
{
|
||||||
if (rpffile.AllEntries == null) continue;
|
if (rpffile.AllEntries == null) continue;
|
||||||
@ -958,6 +960,11 @@ namespace CodeWalker.GameFiles
|
|||||||
YcdDict[entry.NameHash] = fentry;
|
YcdDict[entry.NameHash] = fentry;
|
||||||
YcdDict[entry.ShortNameHash] = fentry;
|
YcdDict[entry.ShortNameHash] = fentry;
|
||||||
}
|
}
|
||||||
|
else if (entry.NameLower.EndsWith(".yed"))
|
||||||
|
{
|
||||||
|
YedDict[entry.NameHash] = fentry;
|
||||||
|
YedDict[entry.ShortNameHash] = fentry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2148,6 +2155,41 @@ namespace CodeWalker.GameFiles
|
|||||||
return ycd;
|
return ycd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public YedFile GetYed(uint hash)
|
||||||
|
{
|
||||||
|
if (!IsInited) return null;
|
||||||
|
lock (requestSyncRoot)
|
||||||
|
{
|
||||||
|
var key = new GameFileCacheKey(hash, GameFileType.Yed);
|
||||||
|
YedFile yed = mainCache.TryGet(key) as YedFile;
|
||||||
|
if (yed == null)
|
||||||
|
{
|
||||||
|
var e = GetYedEntry(hash);
|
||||||
|
if (e != null)
|
||||||
|
{
|
||||||
|
yed = new YedFile(e);
|
||||||
|
if (mainCache.TryAdd(key, yed))
|
||||||
|
{
|
||||||
|
TryLoadEnqueue(yed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yed.LoadQueued = false;
|
||||||
|
//ErrorLog("Out of cache space - couldn't load yed: " + JenkIndex.GetString(hash)); //too spammy...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//ErrorLog("Yed not found: " + JenkIndex.GetString(hash)); //too spammy...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!yed.Loaded)
|
||||||
|
{
|
||||||
|
TryLoadEnqueue(yed);
|
||||||
|
}
|
||||||
|
return yed;
|
||||||
|
}
|
||||||
|
}
|
||||||
public YnvFile GetYnv(uint hash)
|
public YnvFile GetYnv(uint hash)
|
||||||
{
|
{
|
||||||
if (!IsInited) return null;
|
if (!IsInited) return null;
|
||||||
@ -2230,6 +2272,12 @@ namespace CodeWalker.GameFiles
|
|||||||
YcdDict.TryGetValue(hash, out entry);
|
YcdDict.TryGetValue(hash, out entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
public RpfFileEntry GetYedEntry(uint hash)
|
||||||
|
{
|
||||||
|
RpfFileEntry entry;
|
||||||
|
YedDict.TryGetValue(hash, out entry);
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
public RpfFileEntry GetYnvEntry(uint hash)
|
public RpfFileEntry GetYnvEntry(uint hash)
|
||||||
{
|
{
|
||||||
RpfFileEntry entry;
|
RpfFileEntry entry;
|
||||||
@ -2319,6 +2367,9 @@ namespace CodeWalker.GameFiles
|
|||||||
case GameFileType.Ycd:
|
case GameFileType.Ycd:
|
||||||
req.Loaded = LoadFile(req as YcdFile);
|
req.Loaded = LoadFile(req as YcdFile);
|
||||||
break;
|
break;
|
||||||
|
case GameFileType.Yed:
|
||||||
|
req.Loaded = LoadFile(req as YedFile);
|
||||||
|
break;
|
||||||
case GameFileType.Ynv:
|
case GameFileType.Ynv:
|
||||||
req.Loaded = LoadFile(req as YnvFile);
|
req.Loaded = LoadFile(req as YnvFile);
|
||||||
break;
|
break;
|
||||||
|
@ -47,6 +47,10 @@ namespace CodeWalker.GameFiles
|
|||||||
public ResourceSimpleList64_s<MetaHash> ExpressionNameHashes { get; set; }
|
public ResourceSimpleList64_s<MetaHash> ExpressionNameHashes { get; set; }
|
||||||
public ResourcePointerList64<Expression> Expressions { get; set; }
|
public ResourcePointerList64<Expression> Expressions { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public Dictionary<MetaHash, Expression> ExprMap { get; set; }
|
||||||
|
|
||||||
|
|
||||||
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);
|
||||||
@ -58,6 +62,8 @@ namespace CodeWalker.GameFiles
|
|||||||
this.Unknown_1Ch = reader.ReadUInt32();
|
this.Unknown_1Ch = reader.ReadUInt32();
|
||||||
this.ExpressionNameHashes = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
|
this.ExpressionNameHashes = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
|
||||||
this.Expressions = reader.ReadBlock<ResourcePointerList64<Expression>>();
|
this.Expressions = reader.ReadBlock<ResourcePointerList64<Expression>>();
|
||||||
|
|
||||||
|
BuildMap();
|
||||||
}
|
}
|
||||||
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
public override void Write(ResourceDataWriter writer, params object[] parameters)
|
||||||
{
|
{
|
||||||
@ -84,6 +90,27 @@ namespace CodeWalker.GameFiles
|
|||||||
new Tuple<long, IResourceBlock>(0x30, Expressions)
|
new Tuple<long, IResourceBlock>(0x30, Expressions)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void BuildMap()
|
||||||
|
{
|
||||||
|
ExprMap = new Dictionary<MetaHash, Expression>();
|
||||||
|
|
||||||
|
if ((Expressions?.data_items != null) && (ExpressionNameHashes?.data_items != null))
|
||||||
|
{
|
||||||
|
var exprs = Expressions.data_items;
|
||||||
|
var names = ExpressionNameHashes.data_items;
|
||||||
|
|
||||||
|
for (int i = 0; i < exprs.Length; i++)
|
||||||
|
{
|
||||||
|
var expr = exprs[i];
|
||||||
|
var name = (i < names.Length) ? names[i] : (MetaHash)JenkHash.GenHash(expr?.Name?.ToString()?.ToLowerInvariant() ?? "");
|
||||||
|
ExprMap[name] = expr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +131,7 @@ namespace CodeWalker.GameFiles
|
|||||||
public uint Unknown_18h { get; set; } // 0x00000000
|
public uint Unknown_18h { get; set; } // 0x00000000
|
||||||
public uint Unknown_1Ch { get; set; } // 0x00000000
|
public uint Unknown_1Ch { get; set; } // 0x00000000
|
||||||
public ResourcePointerList64<ExpressionUnk1> Unknown_20h { get; set; }
|
public ResourcePointerList64<ExpressionUnk1> Unknown_20h { get; set; }
|
||||||
public ResourceSimpleList64_s<ExpressionUnk3> Unknown_30h { get; set; } // bone tags / animation tracks..??
|
public ResourceSimpleList64_s<ExpressionBoneTrack> BoneTracks { get; set; } // bone tags / animation tracks..??
|
||||||
public ResourceSimpleList64<ExpressionUnk2> Unknown_40h { get; set; }
|
public ResourceSimpleList64<ExpressionUnk2> Unknown_40h { get; set; }
|
||||||
public ResourceSimpleList64_s<MetaHash> Unknown_50h { get; set; } // only for: faceinit.expr, independent_mover.expr
|
public ResourceSimpleList64_s<MetaHash> Unknown_50h { get; set; } // only for: faceinit.expr, independent_mover.expr
|
||||||
public ulong NamePointer { get; set; }
|
public ulong NamePointer { get; set; }
|
||||||
@ -124,6 +151,10 @@ namespace CodeWalker.GameFiles
|
|||||||
// reference data
|
// reference data
|
||||||
public string_r Name;
|
public string_r Name;
|
||||||
|
|
||||||
|
|
||||||
|
public Dictionary<ExpressionBoneTrack, ExpressionBoneTrack> BoneTracksDict { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public override void Read(ResourceDataReader reader, params object[] parameters)
|
public override void Read(ResourceDataReader reader, params object[] parameters)
|
||||||
{
|
{
|
||||||
// read structure data
|
// read structure data
|
||||||
@ -136,7 +167,7 @@ namespace CodeWalker.GameFiles
|
|||||||
this.Unknown_18h = reader.ReadUInt32();
|
this.Unknown_18h = reader.ReadUInt32();
|
||||||
this.Unknown_1Ch = reader.ReadUInt32();
|
this.Unknown_1Ch = reader.ReadUInt32();
|
||||||
this.Unknown_20h = reader.ReadBlock<ResourcePointerList64<ExpressionUnk1>>();
|
this.Unknown_20h = reader.ReadBlock<ResourcePointerList64<ExpressionUnk1>>();
|
||||||
this.Unknown_30h = reader.ReadBlock<ResourceSimpleList64_s<ExpressionUnk3>>();
|
this.BoneTracks = reader.ReadBlock<ResourceSimpleList64_s<ExpressionBoneTrack>>();
|
||||||
this.Unknown_40h = reader.ReadBlock<ResourceSimpleList64<ExpressionUnk2>>();
|
this.Unknown_40h = reader.ReadBlock<ResourceSimpleList64<ExpressionUnk2>>();
|
||||||
this.Unknown_50h = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
|
this.Unknown_50h = reader.ReadBlock<ResourceSimpleList64_s<MetaHash>>();
|
||||||
this.NamePointer = reader.ReadUInt64();
|
this.NamePointer = reader.ReadUInt64();
|
||||||
@ -161,6 +192,8 @@ namespace CodeWalker.GameFiles
|
|||||||
//if (Unknown_50h?.data_items?.Length > 0)
|
//if (Unknown_50h?.data_items?.Length > 0)
|
||||||
//{ } // faceinit.expr, independent_mover.expr
|
//{ } // faceinit.expr, independent_mover.expr
|
||||||
|
|
||||||
|
BuildBoneTracksDict();
|
||||||
|
|
||||||
#region testing
|
#region testing
|
||||||
//long tlen = 0;
|
//long tlen = 0;
|
||||||
//if (Unknown_20h?.data_items != null) foreach (var item in Unknown_20h.data_items) tlen = Math.Max(tlen, item.BlockLength);
|
//if (Unknown_20h?.data_items != null) foreach (var item in Unknown_20h.data_items) tlen = Math.Max(tlen, item.BlockLength);
|
||||||
@ -229,7 +262,7 @@ namespace CodeWalker.GameFiles
|
|||||||
writer.Write(this.Unknown_18h);
|
writer.Write(this.Unknown_18h);
|
||||||
writer.Write(this.Unknown_1Ch);
|
writer.Write(this.Unknown_1Ch);
|
||||||
writer.WriteBlock(this.Unknown_20h);
|
writer.WriteBlock(this.Unknown_20h);
|
||||||
writer.WriteBlock(this.Unknown_30h);
|
writer.WriteBlock(this.BoneTracks);
|
||||||
writer.WriteBlock(this.Unknown_40h);
|
writer.WriteBlock(this.Unknown_40h);
|
||||||
writer.WriteBlock(this.Unknown_50h);
|
writer.WriteBlock(this.Unknown_50h);
|
||||||
writer.Write(this.NamePointer);
|
writer.Write(this.NamePointer);
|
||||||
@ -257,13 +290,37 @@ namespace CodeWalker.GameFiles
|
|||||||
{
|
{
|
||||||
return new Tuple<long, IResourceBlock>[] {
|
return new Tuple<long, IResourceBlock>[] {
|
||||||
new Tuple<long, IResourceBlock>(0x20, Unknown_20h),
|
new Tuple<long, IResourceBlock>(0x20, Unknown_20h),
|
||||||
new Tuple<long, IResourceBlock>(0x30, Unknown_30h),
|
new Tuple<long, IResourceBlock>(0x30, BoneTracks),
|
||||||
new Tuple<long, IResourceBlock>(0x40, Unknown_40h),
|
new Tuple<long, IResourceBlock>(0x40, Unknown_40h),
|
||||||
new Tuple<long, IResourceBlock>(0x50, Unknown_50h)
|
new Tuple<long, IResourceBlock>(0x50, Unknown_50h)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void BuildBoneTracksDict()
|
||||||
|
{
|
||||||
|
BoneTracksDict = new Dictionary<ExpressionBoneTrack, ExpressionBoneTrack>();
|
||||||
|
|
||||||
|
if (BoneTracks?.data_items == null) return;
|
||||||
|
|
||||||
|
var mapto = new ExpressionBoneTrack();
|
||||||
|
for(int i=0; i< BoneTracks.data_items.Length;i++)
|
||||||
|
{
|
||||||
|
var bt = BoneTracks.data_items[i];
|
||||||
|
if ((bt.Flags & 128) == 0)
|
||||||
|
{
|
||||||
|
mapto = bt;
|
||||||
|
}
|
||||||
|
else if (bt.BoneTag != 0)
|
||||||
|
{
|
||||||
|
bt.Flags &= 0x7F;
|
||||||
|
BoneTracksDict[bt] = mapto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return (Name?.ToString() ?? base.ToString()) + " " + Unknown_74h.ToString();
|
return (Name?.ToString() ?? base.ToString()) + " " + Unknown_74h.ToString();
|
||||||
@ -347,24 +404,24 @@ namespace CodeWalker.GameFiles
|
|||||||
case 0x0A: break;
|
case 0x0A: break;
|
||||||
case 0x0B: break;
|
case 0x0B: break;
|
||||||
case 0x0E: break;
|
case 0x0E: break;
|
||||||
case 0x10: item.Children = new[] { stack.Pop()/*, stack.Pop()*/ }; break; //####### maybe not
|
case 0x10: item.Children = new[] { stack.Pop() }; break; //####### maybe not
|
||||||
case 0x11: item.Children = new[] { stack.Pop() }; break;
|
case 0x11: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x1B: item.Children = new[] { stack.Pop() }; break;
|
case 0x1B: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x1D: item.Children = new[] { stack.Pop() }; break;
|
case 0x1D: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x1E: item.Children = new[] { stack.Pop() }; break;
|
case 0x1E: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x1F: item.Children = new[] { stack.Pop() }; break;
|
case 0x1F: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x20: break;//first in list
|
case 0x20: break;//first in list
|
||||||
case 0x21: item.Children = new[] { stack.Pop()/*, stack.Pop()*/ }; break;
|
case 0x21: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x22: item.Children = new[] { stack.Pop() }; break;
|
case 0x22: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x23: item.Children = new[] { stack.Pop() }; break;
|
case 0x23: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x26: item.Children = new[] { stack.Pop() }; break;
|
case 0x26: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x27: item.Children = new[] { stack.Pop() }; break;
|
case 0x27: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x28: item.Children = new[] { stack.Pop() }; break;
|
case 0x28: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x2A: item.Children = new[] { stack.Pop() }; break;
|
case 0x2A: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x2B: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
case 0x2B: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x2C: item.Children = new[] { stack.Pop()/*, stack.Pop()*/ }; break; //##########################
|
case 0x2C: item.Children = new[] { stack.Pop() }; break;
|
||||||
case 0x2D: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
case 0x2D: item.Children = new[] { stack.Pop(), stack.Pop() }; break;//4 maybe?
|
||||||
case 0x2E: item.Children = new[] { stack.Pop(), stack.Pop()/*, stack.Pop()*/ }; break; //maybe
|
case 0x2E: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x2F: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
case 0x2F: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x30: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
case 0x30: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x31: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
case 0x31: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
||||||
@ -372,7 +429,7 @@ namespace CodeWalker.GameFiles
|
|||||||
case 0x33: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
case 0x33: item.Children = new[] { stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x35: item.Children = new[] { stack.Pop(), stack.Pop() }; break;//can't be more than 2
|
case 0x35: item.Children = new[] { stack.Pop(), stack.Pop() }; break;//can't be more than 2
|
||||||
case 0x36: item.Children = new[] { stack.Pop(), stack.Pop() }; break; //can't be more than 2
|
case 0x36: item.Children = new[] { stack.Pop(), stack.Pop() }; break; //can't be more than 2
|
||||||
case 0x37: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop(), stack.Pop()/**/ }; break;
|
case 0x37: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x38: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
case 0x38: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x39: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
case 0x39: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
||||||
case 0x3A: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
case 0x3A: item.Children = new[] { stack.Pop(), stack.Pop(), stack.Pop() }; break;
|
||||||
@ -1127,15 +1184,15 @@ namespace CodeWalker.GameFiles
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
[TypeConverter(typeof(ExpandableObjectConverter))] public struct ExpressionUnk3
|
[TypeConverter(typeof(ExpandableObjectConverter))] public struct ExpressionBoneTrack
|
||||||
{
|
{
|
||||||
public ushort Unk0 { get; set; } // bone tag? need to check
|
public ushort BoneTag { get; set; }
|
||||||
public byte Unk2 { get; set; } // animation track?
|
public byte Track { get; set; }
|
||||||
public byte Unk3 { get; set; } // ..flags?
|
public byte Flags { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return Unk0.ToString() + ", " + Unk2.ToString() + ", " + Unk3.ToString();
|
return BoneTag.ToString() + ", " + Track.ToString() + ", " + Flags.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ namespace CodeWalker.World
|
|||||||
public YtdFile Ytd { get; set; } = null; //ped textures
|
public YtdFile Ytd { get; set; } = null; //ped textures
|
||||||
public YldFile Yld { get; set; } = null; //ped clothes
|
public YldFile Yld { get; set; } = null; //ped clothes
|
||||||
public YcdFile Ycd { get; set; } = null; //ped animations
|
public YcdFile Ycd { get; set; } = null; //ped animations
|
||||||
|
public YedFile Yed { get; set; } = null; //ped expressions
|
||||||
public YftFile Yft { get; set; } = null; //ped skeleton YFT
|
public YftFile Yft { get; set; } = null; //ped skeleton YFT
|
||||||
public PedFile Ymt { get; set; } = null; //ped variation info
|
public PedFile Ymt { get; set; } = null; //ped variation info
|
||||||
public Dictionary<MetaHash, RpfFileEntry> DrawableFilesDict { get; set; } = null;
|
public Dictionary<MetaHash, RpfFileEntry> DrawableFilesDict { get; set; } = null;
|
||||||
@ -28,9 +29,11 @@ namespace CodeWalker.World
|
|||||||
public RpfFileEntry[] TextureFiles { get; set; } = null;
|
public RpfFileEntry[] TextureFiles { get; set; } = null;
|
||||||
public RpfFileEntry[] ClothFiles { get; set; } = null;
|
public RpfFileEntry[] ClothFiles { get; set; } = null;
|
||||||
public ClipMapEntry AnimClip { get; set; } = null;
|
public ClipMapEntry AnimClip { get; set; } = null;
|
||||||
|
public Expression Expression { get; set; } = null;
|
||||||
public string[] DrawableNames { get; set; } = new string[12];
|
public string[] DrawableNames { get; set; } = new string[12];
|
||||||
public Drawable[] Drawables { get; set; } = new Drawable[12];
|
public Drawable[] Drawables { get; set; } = new Drawable[12];
|
||||||
public Texture[] Textures { get; set; } = new Texture[12];
|
public Texture[] Textures { get; set; } = new Texture[12];
|
||||||
|
public Expression[] Expressions { get; set; } = new Expression[12];
|
||||||
public ClothInstance[] Clothes { get; set; } = new ClothInstance[12];
|
public ClothInstance[] Clothes { get; set; } = new ClothInstance[12];
|
||||||
public bool EnableRootMotion { get; set; } = false; //used to toggle whether or not to include root motion when playing animations
|
public bool EnableRootMotion { get; set; } = false; //used to toggle whether or not to include root motion when playing animations
|
||||||
public Skeleton Skeleton { get; set; } = null;
|
public Skeleton Skeleton { get; set; } = null;
|
||||||
@ -55,7 +58,9 @@ namespace CodeWalker.World
|
|||||||
InitData = null;
|
InitData = null;
|
||||||
Ydd = null;
|
Ydd = null;
|
||||||
Ytd = null;
|
Ytd = null;
|
||||||
|
Yld = null;
|
||||||
Ycd = null;
|
Ycd = null;
|
||||||
|
Yed = null;
|
||||||
Yft = null;
|
Yft = null;
|
||||||
Ymt = null;
|
Ymt = null;
|
||||||
AnimClip = null;
|
AnimClip = null;
|
||||||
@ -63,6 +68,7 @@ namespace CodeWalker.World
|
|||||||
{
|
{
|
||||||
Drawables[i] = null;
|
Drawables[i] = null;
|
||||||
Textures[i] = null;
|
Textures[i] = null;
|
||||||
|
Expressions[i] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -70,6 +76,7 @@ namespace CodeWalker.World
|
|||||||
if (!gfc.PedsInitDict.TryGetValue(pedhash, out initdata)) return;
|
if (!gfc.PedsInitDict.TryGetValue(pedhash, out initdata)) return;
|
||||||
|
|
||||||
var ycdhash = JenkHash.GenHash(initdata.ClipDictionaryName.ToLowerInvariant());
|
var ycdhash = JenkHash.GenHash(initdata.ClipDictionaryName.ToLowerInvariant());
|
||||||
|
var yedhash = JenkHash.GenHash(initdata.ExpressionDictionaryName.ToLowerInvariant());
|
||||||
|
|
||||||
//bool pedchange = NameHash != pedhash;
|
//bool pedchange = NameHash != pedhash;
|
||||||
//Name = pedname;
|
//Name = pedname;
|
||||||
@ -78,6 +85,7 @@ namespace CodeWalker.World
|
|||||||
Ydd = gfc.GetYdd(pedhash);
|
Ydd = gfc.GetYdd(pedhash);
|
||||||
Ytd = gfc.GetYtd(pedhash);
|
Ytd = gfc.GetYtd(pedhash);
|
||||||
Ycd = gfc.GetYcd(ycdhash);
|
Ycd = gfc.GetYcd(ycdhash);
|
||||||
|
Yed = gfc.GetYed(yedhash);
|
||||||
Yft = gfc.GetYft(pedhash);
|
Yft = gfc.GetYft(pedhash);
|
||||||
|
|
||||||
PedFile pedFile = null;
|
PedFile pedFile = null;
|
||||||
@ -123,6 +131,11 @@ namespace CodeWalker.World
|
|||||||
Thread.Sleep(1);//kinda hacky
|
Thread.Sleep(1);//kinda hacky
|
||||||
Ycd = gfc.GetYcd(ycdhash);
|
Ycd = gfc.GetYcd(ycdhash);
|
||||||
}
|
}
|
||||||
|
while ((Yed != null) && (!Yed.Loaded))
|
||||||
|
{
|
||||||
|
Thread.Sleep(1);//kinda hacky
|
||||||
|
Yed = gfc.GetYed(yedhash);
|
||||||
|
}
|
||||||
while ((Yft != null) && (!Yft.Loaded))
|
while ((Yft != null) && (!Yft.Loaded))
|
||||||
{
|
{
|
||||||
Thread.Sleep(1);//kinda hacky
|
Thread.Sleep(1);//kinda hacky
|
||||||
@ -137,6 +150,11 @@ namespace CodeWalker.World
|
|||||||
Ycd?.ClipMap?.TryGetValue(cliphash, out cme);
|
Ycd?.ClipMap?.TryGetValue(cliphash, out cme);
|
||||||
AnimClip = cme;
|
AnimClip = cme;
|
||||||
|
|
||||||
|
var exprhash = JenkHash.GenHash(initdata.ExpressionName.ToLowerInvariant());
|
||||||
|
Expression expr = null;
|
||||||
|
Yed?.ExprMap?.TryGetValue(exprhash, out expr);
|
||||||
|
Expression = expr;
|
||||||
|
|
||||||
|
|
||||||
UpdateEntity();
|
UpdateEntity();
|
||||||
}
|
}
|
||||||
@ -152,6 +170,7 @@ namespace CodeWalker.World
|
|||||||
DrawableNames[index] = null;
|
DrawableNames[index] = null;
|
||||||
Drawables[index] = null;
|
Drawables[index] = null;
|
||||||
Textures[index] = null;
|
Textures[index] = null;
|
||||||
|
Expressions[index] = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,10 +251,17 @@ namespace CodeWalker.World
|
|||||||
c.Init(cc, Skeleton);
|
c.Init(cc, Skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Expression e = null;
|
||||||
|
if (Yed?.ExprMap != null)
|
||||||
|
{
|
||||||
|
Yed.ExprMap.TryGetValue(namehash, out e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (d != null) Drawables[index] = d.ShallowCopy() as Drawable;
|
if (d != null) Drawables[index] = d.ShallowCopy() as Drawable;
|
||||||
if (t != null) Textures[index] = t;
|
if (t != null) Textures[index] = t;
|
||||||
if (c != null) Clothes[index] = c;
|
if (c != null) Clothes[index] = c;
|
||||||
|
if (e != null) Expressions[index] = e;
|
||||||
|
|
||||||
DrawableNames[index] = name;
|
DrawableNames[index] = name;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ namespace CodeWalker.Rendering
|
|||||||
public double CurrentAnimTime = 0;
|
public double CurrentAnimTime = 0;
|
||||||
public YcdFile ClipDict;
|
public YcdFile ClipDict;
|
||||||
public ClipMapEntry ClipMapEntry;
|
public ClipMapEntry ClipMapEntry;
|
||||||
|
public Expression Expression;
|
||||||
public Dictionary<ushort, RenderableModel> ModelBoneLinks;
|
public Dictionary<ushort, RenderableModel> ModelBoneLinks;
|
||||||
|
|
||||||
public bool EnableRootMotion = false; //used to toggle whether or not to include root motion when playing animations
|
public bool EnableRootMotion = false; //used to toggle whether or not to include root motion when playing animations
|
||||||
@ -520,10 +521,27 @@ namespace CodeWalker.Rendering
|
|||||||
for (int i = 0; i < anim.BoneIds.data_items.Length; i++)
|
for (int i = 0; i < anim.BoneIds.data_items.Length; i++)
|
||||||
{
|
{
|
||||||
var boneiditem = anim.BoneIds.data_items[i];
|
var boneiditem = anim.BoneIds.data_items[i];
|
||||||
|
var boneid = boneiditem.BoneId;
|
||||||
var track = boneiditem.Track;
|
var track = boneiditem.Track;
|
||||||
|
|
||||||
|
if (Expression?.BoneTracksDict != null)
|
||||||
|
{
|
||||||
|
var exprbt = new ExpressionBoneTrack() { BoneTag = boneid, Track = track, Flags = boneiditem.Unk0 };
|
||||||
|
var exprbtmap = exprbt;
|
||||||
|
|
||||||
|
if ((track == 24) || (track == 25) || (track == 26))
|
||||||
|
{
|
||||||
|
if (Expression.BoneTracksDict.TryGetValue(exprbt, out exprbtmap))
|
||||||
|
{
|
||||||
|
boneid = exprbtmap.BoneTag;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bone bone = null;
|
Bone bone = null;
|
||||||
skel?.BonesMap?.TryGetValue(boneiditem.BoneId, out bone);
|
skel?.BonesMap?.TryGetValue(boneid, out bone);
|
||||||
if (bone == null)
|
if (bone == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -564,11 +582,19 @@ namespace CodeWalker.Rendering
|
|||||||
break;
|
break;
|
||||||
case 8://quaternion... (camera rotation?)
|
case 8://quaternion... (camera rotation?)
|
||||||
break;
|
break;
|
||||||
case 24://face stuff?
|
case 24://face stuff
|
||||||
|
v = anim.EvaluateVector4(frame, i, interpolate); //single float
|
||||||
|
//bone.AnimTranslation = v.XYZ();
|
||||||
|
//bone.AnimRotation = Quaternion.RotationYawPitchRoll(v.X, 0.0f, 0.0f);
|
||||||
break;
|
break;
|
||||||
case 25://face stuff?
|
case 25://face stuff
|
||||||
|
v = anim.EvaluateVector4(frame, i, interpolate); //vector3 roll/pitch/yaw
|
||||||
|
var mult = -0.314159265f;
|
||||||
|
bone.AnimRotation = Quaternion.RotationYawPitchRoll(v.Z * mult, v.Y * mult, v.X * mult);
|
||||||
break;
|
break;
|
||||||
case 26://face stuff?
|
case 26://face stuff
|
||||||
|
q = anim.EvaluateQuaternion(frame, i, interpolate);
|
||||||
|
//bone.AnimRotation = q;
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
case 50:
|
case 50:
|
||||||
|
@ -2833,7 +2833,7 @@ namespace CodeWalker.Rendering
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RenderDrawable(DrawableBase drawable, Archetype arche, YmapEntityDef entity, uint txdHash = 0, TextureDictionary txdExtra = null, Texture diffOverride = null, ClipMapEntry animClip = null, ClothInstance cloth = null)
|
public bool RenderDrawable(DrawableBase drawable, Archetype arche, YmapEntityDef entity, uint txdHash = 0, TextureDictionary txdExtra = null, Texture diffOverride = null, ClipMapEntry animClip = null, ClothInstance cloth = null, Expression expr = null)
|
||||||
{
|
{
|
||||||
//enqueue a single drawable for rendering.
|
//enqueue a single drawable for rendering.
|
||||||
|
|
||||||
@ -2859,7 +2859,7 @@ namespace CodeWalker.Rendering
|
|||||||
}
|
}
|
||||||
|
|
||||||
rndbl.Cloth = cloth;
|
rndbl.Cloth = cloth;
|
||||||
|
rndbl.Expression = expr;
|
||||||
|
|
||||||
return RenderRenderable(rndbl, arche, entity);
|
return RenderRenderable(rndbl, arche, entity);
|
||||||
}
|
}
|
||||||
@ -3150,6 +3150,7 @@ namespace CodeWalker.Rendering
|
|||||||
var drawable = ped.Drawables[i];
|
var drawable = ped.Drawables[i];
|
||||||
var texture = ped.Textures[i];
|
var texture = ped.Textures[i];
|
||||||
var cloth = ped.Clothes[i];
|
var cloth = ped.Clothes[i];
|
||||||
|
var expr = ped.Expressions[i];
|
||||||
|
|
||||||
//if (compData == null) return;
|
//if (compData == null) return;
|
||||||
if (drawable == null) return;
|
if (drawable == null) return;
|
||||||
@ -3192,7 +3193,7 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
if (drawFlag)
|
if (drawFlag)
|
||||||
{
|
{
|
||||||
RenderDrawable(drawable, null, ped.RenderEntity, 0, td, texture, ac, cloth);
|
RenderDrawable(drawable, null, ped.RenderEntity, 0, td, texture, ac, cloth, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user