Model collision (*.hkx) guideline

Game physics modding and related tasks.

Moderator: Oleg

Model collision (*.hkx) guideline

Postby Oleg » Tue Jan 06, 2015 10:36 am

*.hkx files guideline.
Your mods should utilize original physics and collisions (*.hkx file), that bounds you to a need to locate a proper base model as a donor for the mod. Each original model part (door, hood, frame and trunk) should be somewhat alike to respective part of your modded vehicle. Headlights, windscreen, glass and taillights should be located in the similar areas, so shooting or smashing them would behave properly on a modded geometry. These are not about to retain the shape, when you shot the taillight, the original collision volume is checked - once hit is detected, your geometry will show damages properly. The same applies to collision volumes of the doors, bonnet, etc. These are not needed to match perfectly, but it would be good to see objects falling to your hood and laying properly instead of falling through or hovering in an air above the object visual shape.

This is particularly important for bullet holes that appear on a model when you shot: the game performs collision volume hit-test and lays bullet shells on your geometry when original collision volume is hit. That is why, the close original *.hkx to your modded model, the better result you will get.

Beside collision volume, *.hkx contains a model-specific damage definitions in a file too. These are, in particular, smashable windscreen, rear, side and door windows. Also, a headlight/taillight glass on some models can take visual damage too. The model file should keep damage on such an objects in synch, so shooting the windscreen should affect an entire object. The game does this by "marking" geometry fragments as to be a damageable part #1, #2 etc. These parts are stored in *.hkx file too, so your model should respect object <-> damage_part relation too. This is retained on material's user-defined property named "Damage" where objects names are listed in a comma-separated way.
For example, a material Vehicle_Global_LightGlass has a "Damage" property ,,,,TailLight_R,TailLight_L,HeadLight_L,HeadLight_R,TailLight_M. See the missing part names and 4 commas in the beginning? This property is evaluated to "TailLight_R" is damage part #5, TailLight_L is damage part #6, and so on.
Since you can not change "damage parts" inside *.hkx file, you should write down object names listed in properties of such a materials and reproduce this property on your materials (if you create any).

Additionally, *.hkx file (may be it's stored somewhere else, not sure) contains an indices of "emissive mesh lights", so each shining fragment has it's own index. For example, left brake light could be #1, left idle light could be #2, left reverse light could be #3 and like this. As these indices should be retained on modded vehicle, you can write down original model indices to reproduce these indices on your modded vehicle. These indices are assigned to polygon's IDs, so the game will light-up respective polygons while rendering a specific state (e.g. when car is reversing, the game will light rendering on "reverse light"-marked polygons only). Of cause, the game will respect damage state of respective light, so the broken lights will not shine. Emissive mesh lights are adjusted by specific material settings, so IDs on polygons are not the only thing to set up.
User avatar
Site Admin
Posts: 7390
Joined: Fri Feb 06, 2004 3:54 am

Return to Physics and collisions

Who is online

Users browsing this forum: No registered users and 1 guest