Thursday, January 1, 2009

Using models

An introduction to misc models

Misc models, also known as mapobject are models external to your MAP file. You can add a misc model by right-clicking on one of your 2D view in Radiant, and by choosing in the contextual menu: misc>misc_model. You can use two kind of models: ASE and MD3.

Note that misc models are compiled by q3map2 into a your BSP file. They are external only at editing stage (there are not in the MAP file), but then they are fully incorporated in the BSP file. This mean that you don't have to include your ASE models and MD3 models in your pk3 when you release your level.

Also, the first time you will use MD3 models as mapobject, you will confuse a bit, cause MD3 are ordinary used for dynamic models too. So let's clear something right now: misc models can't be animated, even if you use an MD3 that has animation frame (in this case the first frame will be used, and the others will be ignored). And if you update an MD3, you will not see any change on your level, as long as you don't recompile your MAP file (and remember that you don't need them to be present at runtime). However, while dynamic models receive light from the lightgrid, misc models use vertex-lighting (you can make lightmap'ed models too, we will see that on another blog post).



Brushwork VS misc models

Brushwork is the base of mapping. A brush is a volume, limited by clipping plane. So a brush is a convex form (i.e. without cavity). This property ensure that for every clipping plane, the entire volume is on the same side, and that the other side is outside. So brush are very interesting for game, because of physics: you know if you are in a brush (or collide with it) if you are inside for all the clipping plane of the brush. Faceq of a brush are just the result of intersecting plane, leaving out parts of the plane that are outside. So faces are not limited to 3-sided polygone (tris), but can be 4-sided (quad), or even n-sided polygone. Of course q3map2 transform them into tris, for the renderer, but keep the brush structure for the physical engine.

A model is simply a collection of 3-sided faces. Physical engine doesn't care of them, they are unexistant for it. If you want to make them solid, you have to make a brush inside of it, with the player clip texture (block players) or the weapon clip texture (block weapons and players), the renderer just ignore those textures, only the physical engine care of it. There are some others ways to clip a model without adding clipping brush, using autoclipping, we will see that on another blog post. And of course, models are not structural, and not VIS-blocker.

Brushwork is good for:
  • physical clipping
  • big structural stuff, like wall, house, corridor, ground, and so on... anything big and simple is best using brushwork
  • curves!!! (yes, curves are not brush, but they are directly inside the MAP format and are created with Radiant) they can sometime replace a model
Brushwork is bad for:
  • texture coordinate are just weird axial projection, and Radiant's texturing interface just suck
  • arbitrary rotation just break the whole thing, if you have made something fine, you just can't re-use it at another angle except 90°, 180° and 270° degrees... (by the way q3map2 can turn your brushwork into an ASE model, if you invoke it with the right option)
  • you can't rescale a brushwork
  • generated tris used by the renderer are weird too, and the T-Junction fix pass of q3map2 generate even more poly, except if you have great mapping skills and a lot of patience (but most of time, optimizing for the renderer make things more difficult for the physical engine)
  • sometime doing complex stuff with brushwork, like a chariot's wheel, needs too much brush, so the physical engine will have too many test to perform, and it will hit performance when people try to interact with that (jumping on, shooting at, ...)
Models are good for:
  • small objects, object that need great precision
  • object with complex geometry
  • advanced texturing (only if you are using MD3)
  • things that are present on your level at various and non-axial angles, and at various scale
  • freedom!!! you can do everything with models, whithout dealing with brush (and Radiant) limitation/annoyance (again, only if you are using MD3)
  • optimizing polycount, because you have full control over it (MD3 only)
Models are bad for:
  • func entities... most of func entities (like func_train, func_pendulum, ...) accept a key named model2 but doesn't give great flexibility there (for example, you can't group many models into the same entity)
  • physical engine... autoclip'ed models have to create brush for the game's physics, so it creates one brush per tris!!! For example, a simple autoclip'ed cube-box model will generate 12 brush, while only one is needed if you do it by yourself. Of course this is the worst case, most of time you will get 3 or 4 times more (in some special case you can even have less brush generated, if you are not using the autoclip spawnflag but a special autoclip shader that cover roughly your geometry)... Never use the autoclip spawnflags on small or high polycount object...
  • big structure... since they can't be structural nor VIS-blocker, if you want to use them for big structure you have to seal the area with caulk... you can use them anyway, for terrain for example, but do it only if you can't make it with brushwork or an indexed terrain
  • light: models are basicly using vertex-lighting that isn't very good-looking (except for small and/or high polycount object)... you can turn them into lightmap'ed models, sometime it does it well, sometime not too much



MD3 models VS ASE models

You will soon realize that I'm a big fan of MD3, and almost never use ASE models. First because ASE are made with Radiant, so you lose most of advantage using models. And to be honest, I'm not fond of Radiant, too much bug, not very user-friendly, and lot of stuff are definitively bad (like editing texture coordinate or moving vertex).

ASE models:
  • are made using Radiant, then compiled with q3map2 with special option (first with bsp -meta -patchmeta -subdivisions 6 then with bsp -convert [your_bsp])
  • are usefull if you have done some brushwork, then realize that you need to duplicate it with a random angle and a random scale
MD3 models:
  • are made using a 3D modeling software (couldn't be done with Radiant), many software support it
  • you don't have to lose your nerve because of Radiant bugs/limitations/weirdness
  • can use true UV texturing instead of weird axial projection
  • great control over the geometry

A little limitation with MD3: you can't make it to big. Not a big deal, you have to scale down your md3, and scale it up in Radiant (entity special key: modelscale).



Spawnflags of a model entity

In radiant, select your model and enter the entity menu ('n').
If you want your model to be lightmapped (most of time it give you a better lighting effect), create a new key named spawnflags and give it the value of 4.
If you want your model to be autoclipped (I should warn you again that this is generally a bad idea), assign the value of 2 to this key.
Because this key works as bit-flags, if you want your model to be lightmapped and autoclipped, assign to spawnflags the value of 6 (4+2).



Next time I will explain how to use an autoclip shader to fine clip a model without hurting performance.

2 comments:

  1. Hi,

    .ASE models arent always made with Radiant :) You can also make them with 3D Studio Max for example

    ReplyDelete
  2. is it possible to have animated model in the map which is not a player nor a monster but just part of the map but animated?

    ReplyDelete