Problem with hkxSparselyAnimatedEnum - m_enum is NULL?

Problem with hkxSparselyAnimatedEnum - m_enum is NULL?

Hi. I'm still in the process of converting from Havok 6.0.0 to Havok 7.1.0.
The game is running and I'm able to load our models and animations just fine.

However, we have a custom attribute for material ID. We were using the following code in 6.0.0:

const hkVariant* pValue = attribGroup.findAttributeVariantByName ( MATERIAL_ID_ATTRIBUTE_NAME );

if ( pValue )

{

// is the material ID an enum value?

if ( pValue->m_class == &hkxSparselyAnimatedEnumClass )

{

hkxSparselyAnimatedEnum* pEnum = (hkxSparselyAnimatedEnum*) pValue->m_object;

if ( pEnum )

{

if ( pEnum->m_numInts > 0 )

{

int nEnumItemIndex = pEnum->m_ints[0];

const hkClassEnum* pEnumType = pEnum->m_type;

if ( pEnumType )

{

// found the material ID name, get it and break out of loop

// then we will use this name to get the material ID value

const hkClassEnum::Item item = pEnumType->getItem ( nEnumItemIndex );

szMaterialName = (LPCTSTR)item.getName();

break;

}

}

}

}

}

I have converted this to the following:

hkRefVariant& attribVar = attribGroup.findAttributeVariantByName ( MATERIAL_ID_ATTRIBUTE_NAME );

// is the material ID an enum value?

if ( attribVar.getClass() == &hkxSparselyAnimatedEnumClass )

{

hkxSparselyAnimatedEnum* pEnum = static_cast(attribVar.val());

if ( pEnum )

{

if ( pEnum->m_ints.getSize() > 0 )

{

int nEnumItemIndex = pEnum->m_ints[0];

hkRefPtr pClassEnum = pEnum->m_enum;

if ( pClassEnum )

{

// found the material ID name, get it and break out of loop

// then we will use this name to get the material ID value

pClassEnum->getNameOfValue ( nEnumItemIndex, &szMaterialName );

break;

}

}

}

}

The problem is that m_enum is always NULL.

Is there a different way to get the value of the attribute as a string? I used to just get the value and then use the enum to get the string value. I'm not sure what to do here, since the m_enum ptr is NULL.

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

I'm trying to get the string value of the enum that corresponds to the numeric value of the attribute. Is there a newer/better way to do this than what I'm doing here?

I'm still having trouble with this.
Is there anything you can suggest?

Thanks

Hi jbrindle,

Your code looks just fine, I'm not sure why m_enum would be null, maybe something is wrong with the asset? Can you tell me a little bit more about the source asset, what version of havok it was exported using, how you're loading it, etc?

Thanks!

Pete Developer Support Engineer Havok www.havok.com

The asset was exported with Havok 6.0.0r1.
We are loading it using Havok 7.1.0r1 now, using the hkBinaryPackfileReader. We also call updateToCurrentVersion on it.

It worked when we were using Havok 6.0.0, but using the same asset file with the new Havok 7.0.0r1 and while the model looks like it loaded fine (the geometry and skeleton are all there intact) the enum is NULL.

If it would help, I could send you one of the problematic model files. Just let me know where to send it.

EDIT: More information
We have custom attributes that we assign in Maya for the material ID. We have a dropdown with an enum in it. This is the enum we're trying to get access to in code.

Thanks.

Hi jbrindle,

Can you try re-exporting the asset using Havok 7.1, load it up, and see if the enum is still null? I'm thinking maybe something went wrong versioning the file up to 7.1.

Let me know how it goes!

Pete Developer Support Engineer Havok www.havok.com

When I export one of the models with 7.1.0's exporter it is able to get the enum. This is a bit scary for us, because we have at least 1700assets that were created with Havok 6.0.0.

If we export just the mesh and skeleton, the game is able to load and render it just fine. Once we try to use an animation that was exported with 7.1.0, I start getting asserts:

HAVOK: .\Math\Quaternion\hkQuaternion.cpp(84): [0x70DC41CB] Assert : isOk()

hkRotation used for hkQuaternion construction is invalid. hkQuaternion is not normalized/invalid!

HAVOK: f:\projects\elemental\elementalbuild\external\havok\hk710r1\source\common\base\math\quaternion\hkquaternion.inl(55): [0x1ADAAD0E] Assert : isOk()

hkQuaternion components were not normalized.

HAVOK: .\Math\Matrix\hkRotation.cpp(114): [0x1FF88F0E] Assert : qi.isOk()

hkQuaternion not normalized/invalid!

After updating the animation, the transforms are copied into a format that our game engine uses and this is where we're getting these asserts.

This code used to work with Havok 6. If you have any ideas why this data might not be normalized or valid, please let me know.

I will continue to dig and see what I can find.

More information:

After updating the animation using stepDeltaTime, and sampleAndCombineAnimations, I use this to get the bone transform:

const hkTransform& boneFromSkinMeshTransform = m_pHavokMeshBinding->m_boneFromSkinMeshTransforms[ulIndex];

Then I use the following code to copy the rotation out of that hkTransform:

CAnimationQuaternion::CAnimationQuaternion ( const hkRotation& hkRotationIn )

{

m_qQuat = hkQuaternion ( hkRotationIn );

}

m_qQuat is a hkQuaternion. DidhkTransform have a hkQuaternion instead of hkRotation in ver 6.0.0?
Is there a way to convert the rotation data to a quaternion? This code used to work in the older version, and that's the only thing I can think of right now that might have caused this conflict.

Our engine is using the CAnimationQuaternion class so if you could help us to figure out how to get quaternion data from the hkTransform that'd be great.

I think in the old version hkTransform did use hkRotation.

hkQuaternion has a constructor that takes an hkRotation and that's what we were using.

Here is an hkRotation that is causing the problem:

m_col0 ( 0.50297964, 0.94342858, -0.28640836, 0.0 )
m_col1 ( -0.70510066, 0.57105249, -0.62822777, 0.0 )
m_col2 ( -0.33273506, 0.10925776, 1.0465603, 0.0 )

Is this just bad data coming back from the m_boneFromSkinMeshTransforms array?
If so, what could be going wrong?

EDIT: I've tried using a mesh, skeleton, and animation (all 3 exported using just Havok Content Tools - no custom filters) ) and still get this problem.

Here's the first transformI get the problem with.

- transform
- m_rotation {...} hkRotation

- m_col0 {x=0.0070275632 y=-1.5994433e-016 z=-0.71681142, 0.0 } hkVector4

- m_col1 {x=0.71681142 y=-7.8021628e-017 z=0.0070275632, 0.0 } hkVector4

- m_col2 {x=-7.8021624e-019 y=-0.71684593 z=7.9582054e-017, 0.0 } hkVector4

- m_translation

- x -33.061012 float

- y 3.5914684e-015 float

- z -0.35597131 float

- w 1.0000000 float

Do you need any other data?

Well, it turns out that model and animation I was testing was a new asset that hadn't been tested under havok 6.

I've now taken a mesh, skeleton, and animation from havok 6, re-exported it to 7.1, and am able to load it in the game without all these asserts, and it all works ok.

However, we still do need to use this new asset.
Any ideas what could be going on?

We're using the same exporter filters that we used to re-export the old asset.
The mesh and skeleton works fine, but the animation causes the asserts.

We've done some more testing with this new asset (called asset A).

When we export it as-is with a mesh, skeleton, and animation we get the problems described above.

We have exported another model (asset B) that uses the same skeleton and applied the same animation that was applied to asset A. This works just fine.

Then, in Maya 8.5, we took the skeleton from asset B, and bound asset A to it. We re-exported asset A with this skeleton and applied the animation again. This now works.

So there seems to be an issue with the skeleton in Maya. We are unable to determine what is different between the two versions. Looking at the data we've shown you, is there anything that you can suggest might be happening? Although the asset is now working, we would like to know the original problem so we can avoid it in the future.

Again, both assets are using the same skeleton, but are in two different Maya files. One works and the other does not.

Would it be helpful for us to send you our asset files?

Login to leave a comment.