ret2end / hkx2library Goto Github PK
View Code? Open in Web Editor NEWA HKX library to pack and unpack hkx for skyrim se.
License: MIT License
A HKX library to pack and unpack hkx for skyrim se.
License: MIT License
When trying to run a conversion on some custom made 64 bit behaviours it seems to have trouble processing them, it creates an error and just fails, there's quite a few behaviours I'm trying to convert and only one file gets converted, I haven't checked in the behaviour editor if it's working or not though
Also why is it trying to find a non existent user in the C Drive?
C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\
That's not my user name and I don't have the tool nor havok content tools/hkxcmd in my C drive
Here's the full error log:
Unhandled exception: System.InvalidCastException: Unable to cast object of type 'HKX2.hkbStateMachineStateInfo' to type 'HKX2.hkbExpressionDataArray'.
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.hkbEvaluateExpressionModifier.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbEvaluateExpressionModifier.cs:line 22
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.hkbModifierGenerator.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbModifierGenerator.cs:line 19
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.hkbStateMachineStateInfo.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbStateMachineStateInfo.cs:line 38
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.PackFileDeserializer.<>c__DisplayClass14_0`1.<ReadArrayBase>b__0(BinaryReaderEx _br, LocalFixup f) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 145
at HKX2.PackFileDeserializer.ReadPointerBase[T,F](Func`3 func, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 130
at HKX2.hkbStateMachine.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbStateMachine.cs:line 88
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.hkbModifierGenerator.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbModifierGenerator.cs:line 20
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.hkbStateMachineStateInfo.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbStateMachineStateInfo.cs:line 38
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.PackFileDeserializer.<>c__DisplayClass14_0`1.<ReadArrayBase>b__0(BinaryReaderEx _br, LocalFixup f) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 145
at HKX2.PackFileDeserializer.ReadPointerBase[T,F](Func`3 func, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 130
at HKX2.hkbStateMachine.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbStateMachine.cs:line 88
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.hkbBehaviorGraph.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Autogen\hkbBehaviorGraph.cs:line 82
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at HKX2.PackFileDeserializer.ReadClassPointer[T](BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 176
at HKX2.hkRootLevelContainerNamedVariant.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Manual\hkRootLevelContainerNamedVariant.cs:line 26
at HKX2.PackFileDeserializer.<ReadClassArray>b__15_0[T](BinaryReaderEx _br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 158
at HKX2.PackFileDeserializer.<>c__DisplayClass14_0`1.<ReadArrayBase>b__0(BinaryReaderEx _br, LocalFixup f) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 145
at HKX2.PackFileDeserializer.ReadPointerBase[T,F](Func`3 func, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 130
at HKX2.hkRootLevelContainer.Read(PackFileDeserializer des, BinaryReaderEx br) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\Manual\hkRootLevelContainer.cs:line 20
at HKX2.PackFileDeserializer.ConstructVirtualClass(BinaryReaderEx br, UInt32 offset, Type sourceType) in C:\Users\yee\source\repos\hkxconv\HKX2Library\HKX2\PackFileDeserializer.cs:line 39
at hkxconv.cmd.Convert.ConvertHKX(FileInfo inFile, FileInfo outFile, ConvertFormat format, Boolean verbose) in C:\Users\yee\source\repos\hkxconv\hkxconv\cmd\Convert.cs:line 88
at hkxconv.cmd.Convert.ConvertHKX(DirectoryInfo inDir, DirectoryInfo outDir, ConvertFormat format, Boolean verbose) in C:\Users\yee\source\repos\hkxconv\hkxconv\cmd\Convert.cs:line 49
at hkxconv.cmd.Convert.ToFormat(FileSystemInfo input, FileSystemInfo output, ConvertFormat format, Boolean verbose) in C:\Users\yee\source\repos\hkxconv\hkxconv\cmd\Convert.cs:line 30
at hkxconv.Program.<>c.<Main>b__0_3(ConvertFormat format, Boolean verbose, FileSystemInfo input, FileSystemInfo output) in C:\Users\yee\source\repos\hkxconv\hkxconv\Program.cs:line 31
at System.CommandLine.Handler.<>c__DisplayClass5_0`4.<SetHandler>b__0(InvocationContext context)
at System.CommandLine.Invocation.AnonymousCommandHandler.Invoke(InvocationContext context)
at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()
The library seems to mistakingly skip over the bone names for animation tracks in spline compressed animations, because reading string value returns empty when it cannot find a corresponding local fixup.
You can see here that the track names are blank in the deserialized xml files except when unpacking uncompressed animations.
compressedtest.txt
compressedtest2.txt
uncompressedtest.txt
From what I could discern this seems to be because the local and global fixup offsets are both 0 when initialising headers for compressed animation files.
compressed test 1 (blank track name):
Class Section
Section ID: 0 Step In: 400 AbsoluteDataStart: 208 LocalFixupsOffset 192
Section ID: 0 Step In: 400 AbsoluteDataStart: 208 GlobalFixupsOffset 192
Type Section
Section ID: 1 Step In: 400 AbsoluteDataStart: 400 LocalFixupsOffset 0
Section ID: 1 Step In: 400 AbsoluteDataStart: 400 GlobalFixupsOffset 0
Data Section
Section ID: 2 Step In: 28832 AbsoluteDataStart: 400 LocalFixupsOffset 28432
Section ID: 2 Step In: 28944 AbsoluteDataStart: 400 GlobalFixupsOffset 28544
uncompressed test 1 (working):
Class Section
Section ID: 0 Step In: 448 AbsoluteDataStart: 208 LocalFixupsOffset 240
Section ID: 0 Step In: 448 AbsoluteDataStart: 208 GlobalFixupsOffset 240
Type Section
Section ID: 1 Step In: 15216 AbsoluteDataStart: 448 LocalFixupsOffset 14768
Section ID: 1 Step In: 17696 AbsoluteDataStart: 448 GlobalFixupsOffset 17248
Data Section
Section ID: 2 Step In: 619168 AbsoluteDataStart: 18896 LocalFixupsOffset 600272
Section ID: 2 Step In: 620848 AbsoluteDataStart: 18896 GlobalFixupsOffset 601952
compressed test 2 (blank track names):
Class Section
Section ID: 0 Step In: 432 AbsoluteDataStart: 208 LocalFixupsOffset 224
Section ID: 0 Step In: 432 AbsoluteDataStart: 208 GlobalFixupsOffset 224
Type Section
Section ID: 1 Step In: 432 AbsoluteDataStart: 432 LocalFixupsOffset 0
Section ID: 1 Step In: 432 AbsoluteDataStart: 432 GlobalFixupsOffset 0
Data Section
Section ID: 2 Step In: 9776 AbsoluteDataStart: 432 LocalFixupsOffset 9344
Section ID: 2 Step In: 10688 AbsoluteDataStart: 432 GlobalFixupsOffset 10256
in actors\cow\behaviors\quadrupedbehavior.xml
converted from LE by hkxcmd
<hkparam name="characterPropertyInfos" numelements="25">
<hkobject>
<hkparam name="role">
<hkobject>
<hkparam name="role">ROLE_DEFAULT</hkparam>
<!-- this can parse -->
<hkparam name="flags">FLAG_NOT_VARIABLE|FLAG_RAGDOLL|FLAG_NONE|<!-- UNKNOWN BITS -->0x4c0</hkparam>
</hkobject>
</hkparam>
<hkparam name="type">VARIABLE_TYPE_BOOL</hkparam>
</hkobject>
<hkobject>
<!-- SKIP -->
<hkobject>
<hkparam name="role">
<hkobject>
<hkparam name="role">ROLE_DEFAULT</hkparam>
<!-- extra bits will discard-->
<hkparam name="flags">FLAG_HIDDEN|FLAG_NORMALIZED|FLAG_NONE|<!-- UNKNOWN BITS -->0xfffff300</hkparam>
</hkobject>
</hkparam>
<hkparam name="type">VARIABLE_TYPE_BOOL</hkparam>
</hkobject>
</hkparam>
currently type RoleFlags
is short
need a way to handle 0xfffff300
unknown bit
or RE skyrim check what unknown flags are used for.
seem only happen on modified hkx file
all hkx in skyrim se ./meshes/**/*.hkx
don't have this problem
cause by putting incompatible type to member
'hkbStateMachineStateInfo' to type 'hkbExpressionDataArray'
'hkbBlendingTransitionEffect' to type 'hkbStateMachineTransitionInfoArray'
e.g.
<hkobject name="#0050" class="hkbStateMachineStateInfo" signature="0x0ed7f9d0">
<hkparam name="variableBindingSet">null</hkparam>
<hkparam name="listeners" numelements="0"></hkparam>
<hkparam name="enterNotifyEvents">null</hkparam>
<hkparam name="exitNotifyEvents">null</hkparam>
<!--Original type 'hkbStateMachineTransitionInfoArray' -->
<!--but here referenced incompatible type 'hkbBlendingTransitionEffect' -->
<hkparam name="transitions">#0051</hkparam>
<hkparam name="generator">null</hkparam>
<!--SKIP -->
</hkobject>
<hkobject name="#0051" class="hkbBlendingTransitionEffect" signature="0xfd8584fe">
<!--SKIP -->
</hkobject>
interestingly hkxcmd still able pack it. and skyrim didn't crash(not sure behavior is working as intended ?)
with hkxcmd.exe Report
Report - Generate a simple report for all supported Havok classes
hkxconv's class was dump from skyrim se with SKSE plugin
currently missing class
hkpVehicleSuspensionSuspensionWheelParameters
hkpVehicleRayCastBatchingManager
hkMemoryMeshShape
hkpExtendedMeshShapeTrianglesSubpart
hkpVehicleAerodynamics
hkMeshSectionCinfo
hkpVehicleDefaultSuspension
hkMeshShape
hkpStorageExtendedMeshShapeMeshSubpartStorage
hkMemoryMeshTexture
hkaDeltaCompressedAnimationQuantizationFormat
hkIndexedTransformSet
hkMemoryMeshVertexBuffer
hkpVehicleVelocityDamper
hkpVehicleSteering
hkpVehicleFrictionStatus
hkpVehicleLinearCastWheelCollide
hkpVehicleDefaultSuspensionWheelSpringSuspensionParameters
hkMonitorStreamStringMapStringMap
hkpVehicleTransmission
hkpVehicleEngine
hkpSimpleMeshShape
hkpVehicleDefaultSteering
hkpVehicleWheelCollide
hkpVehicleDefaultBrakeWheelBrakingProperties
hkpVehicleRayCastWheelCollide
hkMemoryMeshMaterial
hkpVehicleDriverInput
hkMemoryMeshBody
hkpExtendedMeshShapeShapesSubpart
hkVertexFormatElement
hkpSimpleMeshShapeTriangle
hkpVehicleDefaultAnalogDriverInput
hkpVehicleSuspension
# hkbVariableInfo
hkpRejectChassisListener
hkpVehicleLinearCastBatchingManager
hkMultipleVertexBufferVertexBufferInfo
hkRootLevelContainerNamedVariant
hkpVehicleData
hkaDeltaCompressedAnimation
hkMonitorStreamColorTableColorPair
hkMeshBoneIndexMapping
hkpTyremarkPoint
hkpVehicleDriverInputAnalogStatus
hkMultipleVertexBuffer
# hkReferencedObject
hkMonitorStreamStringMap
hkMeshSection
hkpVehicleDefaultAerodynamics
hkpVehicleDefaultVelocityDamper
hkpVehicleDefaultEngine
hkpVehicleDriverInputStatus
hkVertexFormat
hkpVehicleInstanceWheelInfo
hkMeshVertexBuffer
hkMeshBody
hkaWaveletCompressedAnimationQuantizationFormat
hkMultipleVertexBufferLockedElement
hkMeshTexture
hkxcmd_cla
hkpVehicleFrictionDescriptionAxisDescription
hkpVehicleFrictionDescription
hkpStorageExtendedMeshShapeShapeSubpartStorage
hkMeshMaterial
hkpVehicleDefaultTransmission
hkpStorageExtendedMeshShape
hkpExtendedMeshShape
hkpTyremarksWheel
hkpVehicleDataWheelComponentParams
# hkRootLevelContainer
hkpTyremarksInfo
hkpExtendedMeshShapeSubpart
hkpVehicleCastBatchingManager
hkMonitorStreamColorTable
hkaWaveletCompressedAnimation
hkMultipleVertexBufferElementInfo
hkpMassProperties
hkpVehicleInstance
hkMonitorStreamFrameInfo
hkpVehicleBrake
# hkBaseObject
hkpStorageExtendedMeshShapeMaterial
hkpVehicleFrictionStatusAxisStatus
hkaWaveletCompressedAnimationCompressionParams
hkpVehicleDefaultBrake
hkpMultithreadedVehicleManager
hkpConvexPieceMeshShape
# hkpWorldCinfo_ # dumped name was hkpWorldCinfo
hkpVehicleLinearCastWheelCollideWheelState
hkpVehicleManager
\actors\cow\animations\turncannedl180.xml
\actors\troll\behaviors\trollbehavior.xml
m_namedVariants[0].m_variant.m_data.m_stringData.m_eventNames[84]
<hkcstring>SoundPlay.NPCTrollAttackB </hkcstring>
\actors\dlc02\benthiclurker\animations\combatturnl_180.xml
\actors\dlc02\benthiclurker\animations\combatturnl_90.xml
m_namedVariants[0].m_variant.m_animations[0].m_annotationTracks[0].m_annotations[1].m_text
actors\dlc02\benthiclurker\animations\combatturnl_90.xml
actors\dlc02\benthiclurker\animations\combatturnl_180.xml
actors\dlc02\benthiclurker\animations\combatturnr_90.xml
actors\dlc02\benthiclurker\animations\combatturnr_180.xml
actors\dlc02\benthiclurker\animations\stagger_large.xml
actors\dlc02\benthiclurker\animations\stagger_small.xml
actors\dlc02\boarriekling\animations\attackright1.xml
actors\dlc02\boarriekling\animations\recoilright.xml
actors\falmer\animations\magiccastrunleft.xml
actors\falmer\animations\magiccastrunright.xml
actors\falmer\animations\mtrunleft.xml
actors\falmer\animations\mtrunright.xml
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.