Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

How does the source engine do it?

This topic is 3582 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do they construct the collision data in the MDL files? I know they use some type of script that came from the quake engine and they construct the MDLs form SMD meshes. So I'm guessing that the reason for this is to add collision data, basically what I want to know is how are they setting up the physics data? If it's a script as I'm imagining can someone show me a sample of it so I can get a better idea of what they are doing?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by CodaKiller
How do they construct the collision data in the MDL files? I know they use some type of script that came from the quake engine and they construct the MDLs form SMD meshes. So I'm guessing that the reason for this is to add collision data, basically what I want to know is how are they setting up the physics data? If it's a script as I'm imagining can someone show me a sample of it so I can get a better idea of what they are doing?


HL2 model files contain a lot of data. There's the visual meshes, for various LOD levels. There's also the collision mesh. And animation data, prop data (weight, type, etc.) and various other bits and pieces. The collision data can be generated from the visual meshes, but it's also possible to create a mesh for it specifically. The model compile tools will take the meshes, animation data and prop data and generate model files from them.

The game then loads these files into memory and uses the data appropriately. HL2 uses the Havok physics engine for it's physics, which needs to be licensed, so at that point you'll have to find another solution. I believe there are a few free physics libraries, so you may want to do some research there.

Share this post


Link to post
Share on other sites
Quote:
Original post by Captain P
Quote:
Original post by CodaKiller
How do they construct the collision data in the MDL files? I know they use some type of script that came from the quake engine and they construct the MDLs form SMD meshes. So I'm guessing that the reason for this is to add collision data, basically what I want to know is how are they setting up the physics data? If it's a script as I'm imagining can someone show me a sample of it so I can get a better idea of what they are doing?


HL2 model files contain a lot of data. There's the visual meshes, for various LOD levels. There's also the collision mesh. And animation data, prop data (weight, type, etc.) and various other bits and pieces. The collision data can be generated from the visual meshes, but it's also possible to create a mesh for it specifically. The model compile tools will take the meshes, animation data and prop data and generate model files from them.

The game then loads these files into memory and uses the data appropriately. HL2 uses the Havok physics engine for it's physics, which needs to be licensed, so at that point you'll have to find another solution. I believe there are a few free physics libraries, so you may want to do some research there.


So how do they do ragdolls? PhysX which is what I'm using can't bend a collision mesh and you have to joint together actors to make ragdolls. I would guess that Havok also does it that way, am I correct? Does anyone have a sample of the code used to compile a MDL file?

EDIT: Found a sample of QC and it makes sense now but I need to know what Havok is doing, I'm not sure I can create the same effect with PhysX. Can someone explain how the ragdolls work in Havok? Is it using the weight and bone data inside the mesh to create the ragdoll?

If thats the case then I need to switch to Havok because thats crazy powerful, does anyone know if you are still allowed to enter your game in to the IGF without a commercial license?

[Edited by - CodaKiller on December 26, 2008 2:21:40 AM]

Share this post


Link to post
Share on other sites
This one might be of interest for you (Lesson 404):

http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=17669

Its not too hard to find tutorials in that area. Doesn't PhysX also come with samples?

Share this post


Link to post
Share on other sites
Quote:
Original post by J-Fox
This one might be of interest for you (Lesson 404):

http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=17669

Its not too hard to find tutorials in that area. Doesn't PhysX also come with samples?


Yeah I know how to use it but there are 2 reasons why I believe you would not be able to create a ragdoll from a mesh:

1. Convex meshes are limited to 256 vertices and indices.

2. I do not believe you can bend parts of the convex mesh to line up with the bones of a mesh.

The only way I can figure that you would be able to create a ragdoll is by jointing together actors like spheres, boxes and convex meshes. So you would not be able to create a command that converts a mesh to a ragdoll. I know the triangle meshes also can not be used since they can not have a body and so they can not be moved once set.

So how does the Half Life 2 source engine create ragdolls from meshes? Does Havok have that ability?

Share this post


Link to post
Share on other sites
I think most people manually build a ragdoll body out of simple primitives, as you suggested. One possible method for autogenerating a ragdoll from a skeletal mesh is to build an OBB (or capsule or convex hull or whatever) for each bone containing the vertices influenced by that bone. The results may or may not be acceptable depending on your application and the complexity of the mesh.

Share this post


Link to post
Share on other sites
Quote:
Original post by FluxCapacitor
I think most people manually build a ragdoll body out of simple primitives, as you suggested. One possible method for autogenerating a ragdoll from a skeletal mesh is to build an OBB (or capsule or convex hull or whatever) for each bone containing the vertices influenced by that bone. The results may or may not be acceptable depending on your application and the complexity of the mesh.


Thats what I thought but does the source engine create a ragdoll directly from a mesh or do they use the QC code to create each actor then joint them together? Can someone show me the QC code that would create a ragdoll? That would help explain what it is doing.

EDIT: Found a tutorial on ragdolls for the source engine and it appears that they are jointing together shapes, I have an idea that I think will work quite well!

Since 3DS Max uses meshes for bones I will use them as the convex objects and the connections as the joints, it should be pretty easy to do. This was my idea all along but I didn't want to work on something that would be inferior to what the source engine was doing.

[Edited by - CodaKiller on December 26, 2008 1:24:49 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!