An AI consists of 6 Models

From The DarkMod Wiki
Jump to: navigation, search

Originally written by Ishtvan on http://forums.thedarkmod.com/topic/2513

This may be common knowledge to modelers, but it's news to me, so figured I'd post it just in case.

In all of Id's AI, the body and head appear to be separate models. That's how they can get away with using simple boxes for some collisions, by detecting the head and rest of body separately. Otherwise the area just above the AI's shoulders would be solid. Beyond that, each of these models, head and body, actually has three internal models as seen by D3.

Id calls them: model (visual model + collision model), combat model, ragdoll

Model (Visual and Collision Model)

Actually two models, visual model and simple collision model.

This is actually more like two models, because it contains the visual model that you see, but also an invisible box used for the collision model. This basic collision model determines whether the AI bumps into stuff when walking around, how big an opening it can fit through, etc.

For other objects, you can define your own collision model (see below). For AI, I believe D3 always uses a box, which is defined in the def file with "mins" and "maxs" spawn args. These store two points that are the opposite corners of the box, relative to the origin. (So it could be the back lower left corner and the front upper right corner).

It's important that the two points in the def file are relative to the origin, because if your model origin is in some weird place (ie, not centered), you will have to calculate where to place the mins and maxs points so that the bounding box is actually centered on your AI. I'd recommend putting the model origin between the AI's feet in XY and on the floor in Z.

Important for physical objects (not AI): If you don't put in your own collision model with surf_clip, D3 will automatically generate one for you, based on the visual model. It may not be what you want. [For example, that's the arrow in our mod goes too far into the wall, because the auto-generated collision model sucks].

Combat Model

This is used for more detailed detection of collisions when projectiles hit the AI. You don't ever have to actually make this model. What happens is D3 does 1 of 2 things, based on the spawnarg "use_combat_bbox" in the def file.

If use_combat_bbox is set to "1" (true), D3 uses the simple box that you established with your surf_clip invisible surfaces in the visual model. Basically, projectile collisions are no more detailed than any other collisions if you set "use_combat_bbox" to "1".

If use_combat_bbox is set to "0" (false), D3 calculates projectile collisions with the actual visual model. In other words, the visual bounds that you can see become the bounds of the combat model.

Additionally, there is a "big_monster" spawnarg. If this is set to true, I believe D3 also uses the visual model as the combat model.

Ragdoll

This gets switched in when the AI dies. It is an AF model. This one is well documented in other places, so I'm not going to bother talking about it here. One thing to mention is that I think you still have to use surf_clip brushes to define the collision for each 'limb' or body of the AF. Otherwise, D3 will generate the collision model for you and it may suck.

Note: You can visualize the collision models by seting "g_showcollisionmodels" to "1" in the console.

Note by BlackThief: collision models are REALLY important, not only for character models! I noticed that in my map. there's one part of the room that is a static mesh with about 4k tris. that's not much for the renderer, but as soon as you put in some zombies you get a big performance drop. so I created a simple collision model for the room with a few hundret tris and now there's no performance drop at all.