Error deserializing

Error deserializing

I have a series of .HKX files that contain a variety of information. Some have rigs, some have animations, and some others are supposed to have collision data.

The code I'm using to load these files is pretty simple:

    hkRootLevelContainer* container = hkSerializeUtil::loadObject<hkRootLevelContainer>(absolutePath);

However, I'm getting mixed results when loading these files. As far as I can tell, all of the rig and animation files load correctly, but it seems that every one of the files that are supposed to contain collision data are failing to load. So I made an hkSerializeUtil::ErrorDetails object to see what's happening - after a failed load, it contains the following information:

id: ERRORID_LOAD_FAILED

defaultMessage: "Failed to Load"

The documentation tells me "/// Stream was ok but some error in the data. " which doesn't much help me since I don't know the format of the binaries to check the validity of the data.

Looking at the files in a hex editor, both the working and non-working files contain the following version string: hk_2010.2.0-r1 -- The installation direction of my version tells me that I'm using hk2012_2_0_r1.

So a bunch of questions: Is there any combination of features or options that I need to be sure to enable so that havok will load these collision data files? Are there any known incompatibilities between the 2 versions? Should I be downloading the older version to work with these files? Is there some other way I can validate these files? I'm assuming that .HKX is a closed, proprietary format, but in case it isn't, is there documentation anywhere so that I can manually validate the data in the problem files? If the .HKX file contains data that can't be used by TryHavok (say, cloth), would that cause this error?

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Jeb,

I would first suggest trying to re-export your data using the same version of Havok Content Tools as you are loading it with. They shouldn't have to match exactly (but can only go 1 way, newer code can load older assets, not the other way around), but re-exporting their assets has fixed issues for other forum users in the past so it could be a quick solution for you.

You could also try exporting your data in an xml format from max/maya. If you still can't load this file the data in it is at least somewhat human readable and you can confirm whether or not your problem is with a particular file format.

Have you tried to load these files another way, e.g. "hkResource* m_loadedData = hkSerializeUtil::load(fileName);" ? (Search for hkSerializeUtil::load in the demos to see examples of how to then get the data you want from this resource)

What you didn't mention about the times the loading fails, was where it failed to load. Is it failing trying to get data out of the hkRootLevelContainer or failing to load the container in the first place?

If the file has a hkRootLevelContainer in it (and is a pc binary format) you should be able to drag-drop it into our stand alone preview tool, located in "..Havok\HavokContentTools\ToolStandAlone.exe" to check that the data in the file is valid.

Also, what do you mean by collision data? Are you talking about rigid bodies?

I'm not sure if other (non PCXS) data in the file would cause this error if it is still Havok data. What kind of data are you referring to? Do you have non-PCXS data in these files?

Amy Developer Support Engineer Havok www.havok.com

Unfortunately, I'm in a situation where re-exporting the data is not an option, so I won't be able to try that.

I've tried loading the data in a couple of different ways, but I'm not sure if I've tried your exact example -- I'll check after I get home from work today.

The file is a PC binary, and I've already tried loading it in the stand alone preview tool. It also gives me an error (via popup) that says it could not load the file.

Yes, I'm referring to rigid bodies, and any other data that may be related to collision detection.

These should be just standard havok .HKX files, so all data inside it should still be Havok data. There may be non-PCXS data (at least in the form of cloth physics data- whatever format that uses...) that I wish to ignore, in these files, which is why I questioned the possibility of non-PCXS content causing this problem.

Hi Jed,

One of the most obvious tests to see if there are versioning problems would be to try and load this file using the same Havok version it was exported with (perhaps the fastest way of doing this would be to uninstall your current HCT(havok content tools) and reinstall the appropriate version and retry loading the file in the stand alone preview tool).

I am assuming that after the line "hkRootLevelContainer* container = hkSerializeUtil::loadObject<hkRootLevelContainer>(absolutePath);" has executed, container is null and trying to reference it is where you notice the loading has failed.

I've looked into how exactly you might receive that ERRORID_LOAD_FAILED error id. There (thankfully) is only 1 function call which, if fails, will give this error id. Unfortunately there are a couple of ways this function could fail. Many of these ways should produce some other form of output, either an assert or a warning printed to your log file saying why it couldn't load the file. I assume you are trying to load this file in debug (and if not, please do) so you should be receiving all warnings and asserts (unless you have consciously disabled any of them). Please let me know what warnings/asserts (if any) you are getting, and what has been printed to your log file (in relation to the file loading) so I can narrow down where things could be failing in this function.

After looking into the above I'm not sure the other loading example I gave you will make a difference (with the error id you are getting), but if it isn't difficult to try, it can't hurt.

We are still looking into whether the file containing cloth data could cause this problem. Our initial belief was that this would be a problem and there was nothing we could do to help if you are not a cloth customer, but some quick tests seem to have proved otherwise :P so I'll let you know if we get a solid answer to this. (Although even if PCXS can read the binary file with cloth data, you of course still couldn't do anything with the cloth data as you won't have the libraries)

Amy Developer Support Engineer Havok www.havok.com

Hi Jed,

Something else I was made aware of that may be of help is AssetCC1(&2). Running AssetCc2 with the following options should convert your source binary file to an xml file you can actually read (replacing the appropriate file names and location of the AssetCc2.exe file of course).
C:\Program Files\Havok\HavokContentTools\BatchProcess\AssetCc > AssetCc2.exe -x sourcefile.hkx destinationfile.xml

This should also update the version of your of your file to the version of HCT you have installed. This shouold work fine for any Havok data in the file, (I've just tested this using a PCXS HCT install with a cloth file and works fine) so you should be ok regardless of non-PCXS data in the file (unless there is non-Havok data in the file, then things may not work).

I can also confirm that if your file has non-PCXS data in it, it will not be able to load, but it should assert while trying to load with output that looks like:
[0x15A0905B] Assert: klass->getSignature() == registryClass->getSignature() Signature mismatch hclClothData (0x05388730) - 0x832C2CC0, 0x11247EFF

Amy Developer Support Engineer Havok www.havok.com

Hi Amy,

So I've got some good news and some bad news. The good news is that I found a problem with the files I was having issues loading, and have since corrected it as far as I know. The bad news is that they're still not loading, but now with a different outcome:

When I try to use the HCT from both hk2012_2_0_r1 (SIMD) and hk2010_2_0_r1, it just crashes. I get the Windows popup asking if I want to debug, close the program, or check for solutions. I also tried using AssetCC2 just as you suggested, and it crashes as well.

I currently have 3 pieces of code that I'm using to test whether these files load:

  1. hkSerializeUtil::ErrorDetails loadError;
    hkObjectResource* t = loadOnHeap(absolutePath, &loadError);
  2. hkRootLevelContainer* container = hkSerializeUtil::loadObject<hkRootLevelContainer>(absolutePath);    HK_ASSERT2(0xCAFE0003, container != HK_NULL, "Could not load asset");
  3. hkResource* m_loadedData = hkSerializeUtil::load(absolutePath); 

All 3 methods produce a similar result - they hit a breakpoint (on the getLoadedObjects line), and if I continue, they throw an AccessViolationException with the following stack trace:
     Havok.dll!hkClass::getName()  Line 64 + 0x3 bytes    C++
     Havok.dll!`anonymous namespace'::IsPublicClassObject()  Line 495 + 0x8 bytes    C++
     Havok.dll!hkBinaryPackfileReader::getLoadedObjects()  Line 1329 + 0x15 bytes    C++
     Havok.dll!hkSerializeDeprecated2::packfileToDictWorld()  Line 425 + 0xd bytes    C++
     Havok.dll!hkSerializeDeprecated2::packfileToDictWorld()  Line 565 + 0x1d bytes    C++
     Havok.dll!hkSerializeDeprecated2::loadOldPackfile()  Line 582 + 0x27 bytes    C++
     Havok.dll!`anonymous namespace'::loadPackfile()  Line 221 + 0x21 bytes    C++
     Havok.dll!hkSerializeUtil::load()  Line 407 + 0x2b bytes    C++
     Havok.dll!hkSerializeUtil::load()  Line 464 + 0x33 bytes    C++

I'm not rejecting the possibility that the files I'm working with are corrupt in some way (especially since the fix I mentioned earlier was that the files were being accidentally truncated before I tried to load them into Havok)-- if they are, I'd love to have a way to know in what way they are corrupted, so that I can correct the data.

I didn't know havok generated a log file during runtime. I took a brief look in my debug directory and didn't find anything. Where should I expect it to be?

Yes, I'm perfectly okay with being unable to use any non-PCXS havok data in these files while I'm using PCXS, so long as it doesn't interfere with my ability to actually LOAD these files >_<;;

You've mentioned non-havok data possibly being in the .HKX files- I wasn't aware this was possible. I guess I should read up on that to see what's possible, and what I might expect to be in these files that I hadn't thought of before @_@; Please excuse my lack of Havok understanding- I'm well versed in binary formats/structures and programming, but this is my first time working with Havok files.

Hi Jed,

From the call stack you posted and the error ID you were getting, I'd be willing to say with certainty that the files you are trying to load are binary packfiles (as apposed to binary tagfiles). This doesn't really make any difference to your situation but you could confirm this by looking at the first few bits of data, it should read 57 E0 E0 57 10 C0 C0 10 (or something similar, in my hex editor I see them in a different order, but it's the same pairs of values). This is just our way of identifying the file as packfile instead of tagfile, so we can deserialize each file appropriately. The documentation has a section on Serialization under Common Havok Components which could be of interest here.

By the sounds of things, you have gotten these files from someone else and so can't re-export them. So it is possible that these files contain some custom data that your copy Havok can't deserialize. This isn't necessarily cloth data or anything else that isn't non-PCXS, but if these files have a custom object in them ,that for example derives from a Havok class with new members and functions, without the definition of that class in your code, you won't know how to read or use the data. Serializing custom data is something we do allow (and is documented in "Using the Infrastructure" under Serialization in the docs) so this is a very likely possibility. Unfortunately, without the original code a custom class was constructed with, there isn't anything we can do to help deserialize it.

Re the logfile: Havok has an error reporting system that you need to set up to handle the information it gives in the way you want, although most of our example demos just print this info to the console by default. Check out the "Step By Step Demos" section of the QuickStart Guide which very briefly highlights which bit of code you need to look for.

Amy Developer Support Engineer Havok www.havok.com

Thank you Amy,

I'll take a look at setting things to work with the custom conent. You've been a great help with all of this.

Leave a Comment

Please sign in to add a comment. Not a member? Join today