Still confused about models.

Still confused about models.

So I have figured out how to use basic objects in Havok but I have spent multiple days trying to figure out how to import a 3d model from either blender, Maya, or whatever into my C++ havok world. Now I am having problems exporting some of the models but what I really want to know now is how do I code that and add it to my physics world so I can see the model in my Visual debugger

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

Hey fatttonyisfat555!

There are two (and maybe three) parts to this question:

1. How do I get physics information (ragdolls, objects,
constraints, etc) out of Max/Maya?

2. How do I create a physics world from this data?

And maybe you were also wondering:

3. How do I get my graphics/mesh/character skins in to
Havok?

For the first problem:

The first step is to read up on the Havok Content Tools
which help export rigid body physics information from Maya and Max. I would
recommend going to the Docs folder in the download you got from Havok.com and
open the user guide. There are a lot of great tutorials that got installed when
you installed the Max/Maya content tools, and by working your way through
"3ds Max Physics Tools" (or Maya...) you will learn how to export
physics bodies using the Havok exporter tool.

Check out "Havok_Physics_Animation_2011-3-0_Pc_Xs_User_Guide" and go to

Havok Content Tools > 3ds Max Tools > 3ds Max: Physics Tools

Once you are able to work your way through that you should know enough to get the data out of Max/Maya.

The exporter exports physics information as ".hkt"
tagfiles or ".hkx" packfiles, although tagfiles are the preferred
format. These are xml (human and computer readable, but big) or binary (not
human readable, but small) files that can be opened at runtime and converted in
to rigid bodies, animations, entire physics "worlds" or a combination
of all these things. This is known as "serializing" the physics
scene. You are turning all the objects defined in Max/Maya in to a format that
can be turned in to code objects at runtime. The output file contains an
instance of "hkpPhysicsData", which contains a hkpWorldCinfo and an
array of hkpPhysicsSystems (which themselves are either rigid bodies or
collections of rigid bodies with constraints).

For now, concentrate on exporting simple rigid bodies with
simple constraints and worry about the more complex animation stuff later.

For the second problem:

The demos, as usual, will show you the way! Start with this
one:

Common > Api > Serialize > SimpleLoad

This demo shows the simplest possible method of opening a
serialized file and recreating a physics world from it. You can also take a
look at hkpHavokSnapshot for quickly saving and reloading physics worlds.

For the third problem:

In general, Havok isn't used that way. Havok does have
some internal systems for loading art assets like character meshes, but only
for demo purposes. There are other, better tools for handling the
graphics. For example, if you are using Ogre, there are a number of Ogre
exporters that will export your graphics assets to your game.

I hope this helps. Good luck!

-Josh

Josh
Developer Support Engineer
Havok
www.havok.com

This was very helpful. I am going through those items right now. Thank you.

So I borrowed some of the code from the SimpleLoadDemo.cpp but now If I use most of the HKX files from the "Resources" folder it gives me an error at

1
A." HK_ASSERT3(0xa6451543, m_loadedData != HK_NULL, "Could not load file. The error is:\n" << loadError.defaultMessage.cString() );"saying"ackfile versioning support is no linked. Versioning packefiles at runtime was deprecated in Hacok-7.0.0 ..... Alternatively you can use Tools/PackfileConvert/AsseetCc2 to convert your packfiles the the latest version before loading."I couldn't find the packfileConvert. I just wanted to test that I can import a correctly exported model in my "game".

I used the following as my model though I tried multiple ones

hkStringBuf path("//HL/Profiles/Fat/Documents/BlahBlah/Concaves/farmhouse_L4101.HKX");

B. Is there an updated model or HKX file that I can use to test that I am importing model correctly?
2. If I use the random items I exported from Maya. I get an error caught at"
HK_ASSERT2(0xa6451535, physicsData->getWorldCinfo() != HK_NULL, "No physics cinfo in loaded file - cannot create a hkpWorld" );". Did I export my Maya model worng?

Thanks again for the help.

Hey fattonyisfat5555!

For part A:
Some of the demo assets are quite old and out of sync with the current source version. The demos make this work by including code to patch the various resources before they use them. Another person was having a similar problem:
http://software.intel.com/en-us/forums/showthread.php?t=97534
For part B:
I think you may have exported your physics scene incorrectly. You probably want to read how the Havok Filter works. Take a look in the User Guide at:
Havok Content Tools > The Havok Filter Pipeline
Essentially you tell the Havok Content Tools what data you want saved from the Maya scene. For example, you might say:
Scene Transform (SCALE_INCHES_TO_METERS, as Havok expects meters)Create Rigid Bodies (adds the rigid bodies you defined in the scene to the output file)Create Constraints (if you have constraints between bodies this is needed)Write to Platform (and this is how you get the file out)View XML (is pretty useful. The file is human readable, and will give you a sense for what is coming out of Havok Content Tools)
Try playing around with the exporter and see if you can export a simple body that can be loaded by the SimpleLoad demo. This should show you how to get the Content Tools working.
-Josh

Josh
Developer Support Engineer
Havok
www.havok.com

I still can't get it to work. It keeps throwing the

HK_ASSERT2(0xa6451535, physicsData->getWorldCinfo() != HK_NULL, "No physics cinfo in loaded file - cannot create a hkpWorld" );
error.I have read the User manual.I have tried to create multiple bodies connected via a constraint and I have tried to create a simple box. I have changed the Scale_Inches_to_meters besides identity now in the Transform Scene. I have tried using the Tagfile and the Packfile.
I am trying to run only

Scene Transform (SCALE_INCHES_TO_METERS, as Havok expects meters)Create Rigid Bodies (adds the rigid bodies you defined in the scene to the output file)Create Constraints (if you have constraints between bodies this is needed)Write to Platform (and this is how you get the file out)View XML (is pretty useful. The file is human readable, and will give you a sense for what is coming out of Havok Content Tools)Here is what I am doing step by step.1. going to create in Maya and selecting "Polygon Primities -> Sphere".2. I go to "Havok Content Tools->physics->Create ridged body" while the Sphere is selected.3. I create a cube using the "Polygon Primities"http://img59.imageshack.us/img59/1008/havokhelp4.jpg4. I also make it a ridge body5. I make sure each of them has a mass.6.Highlight both of them and create a stiff spring constraint.7. click on exporthttp://img9.imageshack.us/img9/3506/havokhelp1.jpg

http://img716.imageshack.us/img716/6449/havokhelp2.jpgI only changed the Transform scene and kept the Write Platform the same.8. I click run Confighttp://img715.imageshack.us/img715/4373/havokhelp3.jpgThen I update everything and I get that erorr again.

Am I missing a step? I have been beating my head against this for days so any help would be great.I can post more info too if that helps.

**********************Also if it helps anyone, in order to run the SimpleLoadDemo in your program make sure you do NOT include these files////#define HK_EXCLUDE_FEATURE_SerializeDeprecatedPre700//#define HK_EXCLUDE_FEATURE_RegisterVersionPatches

I am now able to load the included/simple.hkt file

Hey fattonyisfat5555:First:To clarify, you ARE able to load the demo assets but ARE NOT able to load your own assets, correct?Second:After looking over your screenshots and the code in the SimpleDemo, I notice that you do not use the "Create World" filter when you export. Because the demo code you are using recreates the world from the file (rather than just a rigid body or something) you need to add that filter to your Filter Manager. I duplicated the problem you were seeing with the SimpleDemo and left out a Create World filter. I saw the problem you had. I then added the filter back in and the demo started working.Third:The #defines you mentioned#define HK_EXCLUDE_FEATURE_SerializeDeprecatedPre700#define HK_EXCLUDE_FEATURE_RegisterVersionPatchesTell the compiler to EXCLUDE the "patching" code that allows it to update old assets. This is provided as a feature because the patching code can be sizeable and most projects would use up-to-date resources and not need that extra code which they were not going to use. Becuse you are using old assets, you need your project to include the patching functionality.Fourth:I know it can be frustrating, but I think you are getting really close. Good luck!-Josh

Josh
Developer Support Engineer
Havok
www.havok.com

1.Yes. I loaded simple.hkt
2. I now have "create world" after create constraints and before write to Platform. It runs now with the code but I never see my objects. Is it because I have 2 worlds now? One I created via c++ and one that is created by the .HKX file? Why can't I see the Sphere and cube? I try to put it above my simple floor I created via c++

Hphys.addFixedSurface(hkVector4(0.0,0.0,0.0,0.0), hkVector4(30.0,1.0,30.0,1.0));a bouncy ballbodyCinfo.m_position = hkVector4(0.0,15.0,0.0,0.0);I have my Maya created shpere at translate X= -.0459; Translate Y 25; Translate Z -1.776and the cube (which stayed connected due to its constraint so it appears to be the same distance visually though not Translated wise) at T X = .352, T Y=1.082, T Z= 4.435.

3. Good to know.

4. Thank you so much for your continued help and yes it can be very frustrating.

Hey fattonyisfat5555,

In short, yes, this is because you have two worlds. Although
Havok supports more than one physics world, I recommend you don't for your demo
as it adds unnecessary complexity.

As I understand things, you are creating one physics world
with a fixed rigid body for the floor, and loading in another physics world
with the sphere and box you created in Maya. There are two ways you can
consolidate this into one world:

1) Load in the .hkt file which should load in a hkpWorld
with two rigid bodies in it, and then add the fixed floor rigid body to the
world you loaded.

2) Create a hkpWorld via C++ code and then load in only the
sphere and box rigid bodies from the .hkt file.

With the second method you would no longer need to use the
"Create World" filter when exporting from Maya as you are no longer
trying to load in a physics world.

For this demo I would say method 1 is simpler, but less
extendable if you want to load in several asset files.

Let me know if this helps!

-Nick

Nick S.
Developer Support Engineer
Havok
www.havok.com

i am also confused with this if you get answer for this than let me know

I have the similar problem using "project anarchy". I load the sample from .vscene file and after that try to add some rigid bodies from the hkt-file. Enumeration of objects in the world shows that all bodies was successfully added; old objects in the world was listed too. But I still can't see new objects in the rendered scene, only the old objects are visible. Why?

   hkpWorld* w = vHavokPhysicsModule::GetInstance()->GetPhysicsWorld();
   w->markForWrite();
   const hkArray<hkpPhysicsSystem*>& arr = physicsData->getPhysicsSystems();
   for (INT i = 0; i<arr.getSize(); i++)
    { hkpPhysicsSystem* psys = arr[i]->clone(hkpPhysicsSystem::CLONE_DEFAULT);
      w->addPhysicsSystem(psys);
      const hkArray<hkpRigidBody*>& bodies = psys->getRigidBodies();
      for (INT j = 0; j<bodies.getSize(); j++)
       { hkpRigidBody* b = bodies[j];
         b->setPosition(hkVector4(100.0, 100.0, 100.0, 0));
         b->setMass(10.0);
         b->setMotionType(hkpMotion::MOTION_FIXED);
         dbg_printf("detected %s world:%08Xn",b->getName(), b->getWorld());
       }
    }
   w->unmarkForWrite();

Visual Debugger shows that objects are successfully added to the world. But they are invisible in my scene. What the reason? How can I make them visible?

Hi Mikhail,

I'm sorry but Havok PCXS (the free Physics and Animation package that this forum supports) does not control what or how objects are rendered in your scene. PCXS users should control how their objects are rendered in their applications.

If this is a problem with how Anarchy is rendering your objects you should post this problem on the Project Anarchy forums (http://forum.projectanarchy.com/forum.php) as this forum does not support Project Anarchy.

Amy Developer Support Engineer Havok www.havok.com

Leave a Comment

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