Writing skinning code

Writing skinning code

Hi, I've read the user guide and made sure I understand the concepts fully, but I'm not so sure what the hkg objects do, for example, I'm wondering when / where I would need my own version of a hkgReferencedObject in my game code, and why it's useful.

When importing the skinning data at runtime in the CharacterAnimationDemo, this line is used:

// Make graphics output buffers for the skins
env->m_sceneConverter->convert( scene );

Does this just store them in memory? I was wondering how games like BioShock would have done this for example. Just wanted to be pointed in the right direction, I think I've got the idea, kind of.

And then this line:

// Find the vertex buffer for display that corresponds to this loaded vertex buffer
const int ivOut = hkgAssetConverter::findMapping( graphicsScene.m_vertexBuffers, vIn );

Looks like it finds the index of that object vIn, by looking in graphicsScene.m_vertexBuffers. Also I wanted to know if the Havok engineers advised devs working on commercial titles, to use Havok arrays (hkArray) in their games / game engines.

Thanks.

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

A quick question, I'm looking at using:

scene->m_meshes[0]->m_sections[0]->m_vertexBuffer

Can I evaluate the count of elements at all?

Thanks.

Hi Sorlaize,

While hkg can be used for your game's graphics, it it not necessarily recommended. Typically people have their own rendering solutions and pipelines. Some of our rendering code is not fully optimized, like skinning, and was just written for use in our demos. So it would be best to use your own skinning solution.

That being said, inheriting from hkgReferencedObject allows the object to be reference counted and handled by our memory management system. This one is used for graphics objects, but the parent class hkReferencedObject is used throughout the SDK. You need to inherit from this if you want an object to be used by Havok memory managers.

env->m_sceneConverter->convert( scene ); converts the scene and stores the different pieces of the scene internally. It will add objects to the world also.

const int ivOut = hkgAssetConverter::findMapping( graphicsScene.m_vertexBuffers, vIn ); looks where vIn buffer is stored in the graphicsScene and returns the index. Seems like you know what is going on there.

There isn't any real reason why you can use hkArrays outside of the Havok portions of your game, but make sure yu know when to use hkArray and hkObjectArray and note that it is not necessarily a replacement for stl.

Can I evaluate the count of elements at all? I'm not sure what you mean by this, but the vertex buffer has a m_numVertexData member. Is that what you are looking for?

Let me know how it goes.

Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Quoting - sean.thurston

Hi Sorlaize,

While hkg can be used for your game's graphics, it it not necessarily recommended. Typically people have their own rendering solutions and pipelines. Some of our rendering code is not fully optimized, like skinning, and was just written for use in our demos. So it would be best to use your own skinning solution.

That being said, inheriting from hkgReferencedObject allows the object to be reference counted and handled by our memory management system. This one is used for graphics objects, but the parent class hkReferencedObject is used throughout the SDK. You need to inherit from this if you want an object to be used by Havok memory managers.

env->m_sceneConverter->convert( scene ); converts the scene and stores the different pieces of the scene internally. It will add objects to the world also.

const int ivOut = hkgAssetConverter::findMapping( graphicsScene.m_vertexBuffers, vIn ); looks where vIn buffer is stored in the graphicsScene and returns the index. Seems like you know what is going on there.

There isn't any real reason why you can use hkArrays outside of the Havok portions of your game, but make sure yu know when to use hkArray and hkObjectArray and note that it is not necessarily a replacement for stl.

Can I evaluate the count of elements at all? I'm not sure what you mean by this, but the vertex buffer has a m_numVertexData member. Is that what you are looking for?

Let me know how it goes.

Thanks,
Sean

Yeah, thanks, that cleared it up for me. One thing though, there isn't much documentation on the hkxMesh and what it contains, I'm not sure how to go about drawing a mesh, the hkxMesh has multiple hkxVertexBuffers but for each hkxVertexBuffer there can be multiple hkxIndexBuffers..I'm used to having one vertex buffer and one index buffer. How can I iterate through the mesh data to draw it, assuming I've already got the matrix pallette(s)?

Thanks.

Quoting - Sorlaize

Yeah, thanks, that cleared it up for me. One thing though, there isn't much documentation on the hkxMesh and what it contains, I'm not sure how to go about drawing a mesh, the hkxMesh has multiple hkxVertexBuffers but for each hkxVertexBuffer there can be multiple hkxIndexBuffers..I'm used to having one vertex buffer and one index buffer. How can I iterate through the mesh data to draw it, assuming I've already got the matrix pallette(s)?

Thanks.

Actually I think I've got it now, just need to find the best way to convert from a hkMeshVertexBuffer to xna's format.

Hi Sorlaize,

That's great. How have you decided to do it?

Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Well I need an efficient way to get the vertices and so on from the hkxVertexBuffers in the hkxMeshSections in all of the runtime-loaded assets, and then I'll use the skinning transforms to deform the xna meshes in the shader.

I was thinking of using the hkPackfileReader directly but I think it's easier to load the assets [meshes] into memory and copy the data over to the xna Model class' format.

I can't seem to find how the hkxVertexBuffers work though.. I've seen hkMeshVertexBuffer and hkMultipleVertexBuffer so I can see how they would be used, but hkxVertexBuffer doesn't have the hkMeshVertexBuffer implementation. What do I have to do to get access to the members like virtual hkMeshVertexBuffer* clone() as with those other two classes?

Thanks.

Does anyone know how to go about doing this? I need to be able to extract the vertex element struct and similar things as well. Thanks.

Hi Sorlaize,

I just wanted to point you to the AnimationUtils::drawVertices() method (Part of the DemoCommon Utilities). It shows pretty well how to use the hkxVertexBuffer.

Hopefully that will help you get that going.

Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Leave a Comment

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