Crash when loading skeleton
I am trying to load a skeleton into my app without the demo framework and I cannot seem to see why this crashes
void CreateSkeleton() { hkLoader* m_loader; hkaSkeleton* m_skeleton;
// Load the data m_loader = new hkLoader();
wstring MediaDirectory = L"../../Media/"; wstring HavokDirectory = L"Resources/Animation/HavokGirl/"; wstring FileName = L"hkRig_L4101.hkx";// hkRig.hkx hkRig_L4101.hkx wstring FinalFileName = MediaDirectory + HavokDirectory + FileName;
hkRootLevelContainer* container = m_loader->load( JWStringToString(FinalFileName).c_str() );
if(container != HK_NULL) MessageBox( NULL,L"You got the container",L"Error", MB_OK ); else MessageBox( NULL,L"No container loaded",L"Error", MB_OK );
hkaAnimationContainer* ac = reinterpret_cast<hkaAnimationContainer*>( container->findObjectByType( hkaAnimationContainerClass.getName() )); if(ac && (ac->m_numSkeletons > 0) ) MessageBox( NULL,L"You got the skeleton",L"Error", MB_OK ); else MessageBox( NULL,L"No skeleton loaded",L"Error", MB_OK ); m_skeleton = ac->m_skeletons[0];
}
It always crashes here: hkaAnimationContainer* ac = reinterpret_cast<hkaAnimationContainer*>( container->findObjectByType( hkaAnimationContainerClass.getName() ));
even though the app reports that the container is loaded properly...
I believe that the source from the demos might be outdated because in the source it loads hkRig.hkx but that file doesnt exist in the resources folder. I tried to substitute hkRig_L4101.hkx instead but i still get the crash.
Any help would be appreciated ;).
Edit: I figured the demo(Api/Playback/SkeletonDemo) would be the easiest place to start for animation since all it does is load a skeleton but if anyone has an tips on a simpler example i would be glad to know.
| |
Re: Crash when loading skeleton
Hey jchmack,
Looking over your code, I don't see anything immediately wrong. If the container is not null after the m_loader->load() then it found the asset on disk. As for the discrepancy between hkRig.hkx and hkRig_L4101.hkx, you'll notice the demos call a hkAssetManagementUtil::getFilePath(assetFile) which appends on the extra "_L4101" bit.
Maybe we can narrow down what's causing the issue: Is you container not null at the time it crashes? Are you running in debug, and if so - can you tell if it's full on crashing or is it an assert?
It might be useful to see the callstack when you hit the crash, if you don't get it figured out, could you post your callstack when it crashes?
Let me know how it goes!
Pete
Developer Support Engineer
Havok
www.havok.com | |
Re: Crash when loading skeleton
Hey jchmack,
Looking over your code, I don't see anything immediately wrong. If the container is not null after the m_loader->load() then it found the asset on disk. As for the discrepancy between hkRig.hkx and hkRig_L4101.hkx, you'll notice the demos call a hkAssetManagementUtil::getFilePath(assetFile) which appends on the extra "_L4101" bit.
Maybe we can narrow down what's causing the issue: Is you container not null at the time it crashes? Are you running in debug, and if so - can you tell if it's full on crashing or is it an assert?
It might be useful to see the callstack when you hit the crash, if you don't get it figured out, could you post your callstack when it crashes?
Let me know how it goes!
Thank you for the quick reply =); The explanation of the _L4101 discrepancy makes things alot clearer. Thank you.
I wasnt running it in debug before but I did so and the crash moved to the container loading process:
hkRootLevelContainer* container = m_loader->load( JWStringToString(FinalFileName).c_str() );
I believe that the container IS null still.
- container 0xcccccccc {m_namedVariants=??? m_numNamedVariants=??? } hkRootLevelContainer * m_namedVariants CXX0030: Error: expression cannot be evaluated m_numNamedVariants CXX0030: Error: expression cannot be evaluated - m_loader 0x0322cb80 {m_loadedData={...} } hkLoader * + hkReferencedObject {m_memSizeAndFlags=20 m_referenceCount=1 } hkReferencedObject + m_loadedData {m_data=0x00000000 m_size=0 m_capacityAndFlags=-2147483648 } hkArray<hkPackfileData *>
Here is the call stack:
game6.exe!hkBinaryPackfileReader::finishLoadedObjects(const hkTypeInfoRegistry & finishObjects={...}) Line 1289 C++ game6.exe!hkBinaryPackfileReader::getContentsWithRegistry(const char * expectedClassName=0x009320d4, const hkTypeInfoRegistry * finishRegistry=0x0323b220) Line 905 + 0xc bytes C++ game6.exe!hkLoader::load(hkStreamReader * streamIn=0x0323cbe0, const hkClass & expectedClass={...}, hkTypeInfoRegistry * finish=0x0323b220, hkVersionRegistry * version=0x0323b650) Line 124 + 0x16 bytes C++ game6.exe!hkLoader::load(const char * filename=0x0323ff48, const hkClass & expectedClass={...}, hkTypeInfoRegistry * finish=0x0323b220, hkVersionRegistry * version=0x0323b650) Line 87 + 0x2f bytes C++ game6.exe!hkLoader::load(const char * filename=0x0323ff48, hkTypeInfoRegistry * finish=0x0323b220, hkVersionRegistry * version=0x0323b650) Line 59 C++ game6.exe!hkLoader::load(const char * filename=0x0323ff48) Line 46 + 0x23 bytes C++
| |
Re: Crash when loading skeleton
Just to make sure I was correctly entering the directory I manually entered the filename and am pretty much left with this:
m_loader = new hkLoader(); hkRootLevelContainer* container = m_loader->load( "../../Media/Resources/Animation/HavokGirl/hkRig_L4101.hkx" );
and it still crashes on the second line in debug.
Im betting that its not finding the file but I see no reason why lol.
| |
Re: Crash when loading skeleton
Lets see for sure if it can or can't find the file - trying entering the absolute path start from your root drive, a la:
hkRootLevelContainer* container = m_loader->load("c:/so on/so forth/blah blah/Media/Resources/Animation/HavokGirl/hkRig_L4101.hkx");
Next, single step through your code in debug and after this line executes, check if container is null. If it's null, the file couldn't be found, and it's a path issue (re check your path, copy and paste the path from windows explorer if you have to). If the container IS valid after this line, let me know if it still crashes.
Pete
Developer Support Engineer
Havok
www.havok.com | |
Re: Crash when loading skeleton
Lets see for sure if it can or can't find the file - trying entering the absolute path start from your root drive, a la:
hkRootLevelContainer* container = m_loader->load("c:/so on/so forth/blah blah/Media/Resources/Animation/HavokGirl/hkRig_L4101.hkx");
Next, single step through your code in debug and after this line executes, check if container is null. If it's null, the file couldn't be found, and it's a path issue (re check your path, copy and paste the path from windows explorer if you have to). If the container IS valid after this line, let me know if it still crashes.
Okay i tried to give load an obviously wrong filepath: hkRootLevelContainer* container = m_loader->load("THIS IS WRONG");
the crash is gone and in my console havok reports: ./util/hkloader.cpp - unable to load file THIS IS WRONG
Then i tried what you said and copy pasted the name: hkRootLevelContainer* container = m_loader->load( "C:UsersDesktopGame Developmentgame6MediaResourcesAnimationHavokGirlhkRig_L4101.hkx" );
which is also unable to find the file because the compiler gets rid of the slashes:
1>c:usersjulius abelladesktopgame developmentgame6game6skeleton.cpp(26) : warning C4129: 'J' : unrecognized character escape sequence ...
so i switched them to an acceptable sequence:
hkRootLevelContainer* container = m_loader->load( "C:/Users/Julius Abella/Desktop/Game Development/game6/Media/Resources/Animation/HavokGirl/hkRig_L4101.hkx" ); and the container is null:
- container 0xcccccccc {m_namedVariants=??? m_numNamedVariants=??? } hkRootLevelContainer * m_namedVariants CXX0017: Error: symbol "" not found m_numNamedVariants CXX0030: Error: expression cannot be evaluated
So basically if it doesnt find the file it correctly reports it but for some reason crashes when it does. I cannot specify any further where it crashes because i dont have the source for m_loader->load().
edit: the stack reports the crash in: > game6.exe!hkBinaryPackfileReader::getPackfileData() Line 432 + 0x6b bytes C++
i also tried to change the file to hkIdle_L4101.hkx in case it was a file error and i get the same results
| |
Re: Crash when loading skeleton
Hrm, lets make sure nothing's wrong with your .hkx file. It's strange that it would fail especially after trying the full absolute path. Can you post and attach your .hkx file and I'll take a look on my end?
Pete
Developer Support Engineer
Havok
www.havok.com | |
Re: Crash when loading skeleton
Hrm, lets make sure nothing's wrong with your .hkx file. It's strange that it would fail especially after trying the full absolute path. Can you post and attach your .hkx file and I'll take a look on my end?
The files I used were straight out of the havok sdk but here is an upload: http://www.mediafire.com/file/zymmdnj2yrj/hkRig_L4101.hkx http://www.mediafire.com/file/myzzt4xikxn/hkIdle_L4101.hkx
edit: although the debug build crashes and gives me no info the release gives me this warning:
.packfilehpackfilereader.cpp(118) [0x7AEF6C06] - warning havok data contains version havok-3.1.0 current version is havok-6.5.0-r1 did you call hkversionutil::updatetocurrentversion() to current version? or did it fail?
any info on how to use the hkversionutil::updatetocurrentversion() thing? because i cannot find it anywhere.
| |
Re: Crash when loading skeleton
Hey jchmack,
I took a look at the .hkx file and it's ok. I've been investigating some more and I've got another question. In your main.cpp file (or where ever you're setting up havok), are you registering all the class types? The code snippet should look something like this:
#include <Common/Base/KeyCode.h>
#define HK_CLASSES_FILE <Common/Serialize/ClassList/hkKeyCodeClasses.h>
#include <Common/Serialize/Util/hkBuiltinTypeRegistry.cxx>
This is in the docs under: Common Havok Components -> Serialization -> Type Registration -> 7.2 Register All Types
Let me know if you've got this already - and if not, try adding it. This code essentially tells havok about the types of classes it can load, and if you don't have it, it could explain the crash on load. Hope this helps!
Pete
Developer Support Engineer
Havok
www.havok.com | |
Re: Crash when loading skeleton
I believe that this may be the problem. I have this in a .h file included into my main:
#ifndef HavokRegistries_H #define HavokRegistries_H
// Keycode #include <Common/Base/keycode.cxx>
#if !defined USING_HAVOK_PHYSICS #error Physics is needed to build this demo. It is included in the common package for reference only. #endif
// Classlists #define INCLUDE_HAVOK_PHYSICS_CLASSES #define HK_CLASSES_FILE <Common/Serialize/Classlist/hkClasses.h> #include <Common/Serialize/Util/hkBuiltinTypeRegistry.cxx>
// Generate a custom list to trim memory requirements #define HK_COMPAT_FILE <Common/Compat/hkCompatVersions.h> #include <Common/Compat/hkCompat_None.cxx>
#endif
It is basically copy pasted from the stand alone demo. I think it includes the physics classes but not the animation. How do I add this?
| |
Re: Crash when loading skeleton
Cool, glad we're making progress. To add animation to the type registry, you'll want to add this line after the INCLUDE_HAVOK_PHYSICS_CLASSES:
#define INCLUDE_HAVOK_ANIMATION_CLASSES
Thus, your code should look like this
// Classlists #define INCLUDE_HAVOK_PHYSICS_CLASSES #define INCLUDE_HAVOK_ANIMATION_CLASSES // Add this line here! #define HK_CLASSES_FILE <Common/Serialize/Classlist/hkClasses.h> #include <Common/Serialize/Util/hkBuiltinTypeRegistry.cxx>
Let me know if this works!
Pete
Developer Support Engineer
Havok
www.havok.com | | |