Proposals/MapUtils
From UFO:AI
I have started to write a utility to automate some of the more tedious tasks in mapping. I am aware of the -fix option fo ufo2map. I am more ambitious. I am writing this in java simply because i can code 100 times faster in java. in the future, when i have developed the algorithms here, i may integrate them into ufo2map.
I am writing this now, as my java package has just reached the point were it does something useful - sets brush levelflags automatically based on the vertex coordinates.
Contents |
usage
to see it do something
java -jar maputils.jar -lvlflags mymap.map
It will change your map file if you use -fix. for up-to-date usage
java -jar maputils.jar -h
the plan
- set level flags automatically
- [done] for brushes in worldspawn
- [WIP] for func_breakable, misc_model, misc_particle
- check for z-fighting
- check for intersecting brushes (related to z-fighting) give them an error texture so you can find them in GTKRadiant.
- align actorclips with the grid
- reduction of exposed faces
- find broken brushes.
- align info_.+?_start to grid
- snap brushes to grid (not sure if this is a good idea...)
- convert null textures to nodraw textures
- assign nodraw to faces that are never exposed, taking account of;
- transparent brushes (trans33 and trans66 surfaceflags)
- faces that are exposed when the player looks at different levels.
- rotating brushes and doors
- brushes in a func_breakable
nodraw algorithm
my java seems to work now. here is a description of the algorithm is uses. TODO: leave change actorclip, weaponclip, stepon alone
- calculate and store the Hessian normal form of the plane of the face of each brush. http://mathworld.wolfram.com/HessianNormalForm.html. the points defining the faces in the map files are arranged such that when you look at the brush from the outside the 3 points go anticlockwise. i converted this to Hessian using the convention that unit normals should point out of the brush.
- make a list of all brushes in worldspawn and func_group entities. (this step excludes func_breakable, doors, ...). exclude any brushes with any transparent faces (trans33, trans66 surfaceflags). exclude any actorclip, weaponclip, or stepon.
- for each brush in the list make a list of brushes which might possibly touch this brush. to do this look at the bounding boxes of the brushes. exclusions: a brush will not be put in its own interaction list, brushes with different levelflags.
- note: this list of lists should be useful for other optimisations, eg rearranging brushes to reduce number of exposed faces.
- consider each face, FL, of each brush on the list
- consider each face, FI, of each brush on the possible interaction list
- set nodraw on FL if FI obscures it.
- conditions (various epsilons for distances and angles used throughout)
- FL and FI face each other (unit normals are antiparallel)
- FL and FI are touching.
- all vertices of FL are within epsilon distance of being inside the brush of which FI is a member.
once a nodraw is identifed from the geometry, it should report
- faces with nodraw flag & texture already set;
- faces with flag only set;
- faces with texture only set;
- faces without any of these that are going to be transformed.
Some of the stuff is already ported and included in ufo2map - here's a patch http://mattn.ninex.info/patches/ufo2map_nodraw.diff
Note: This is not yet working in ufo2map. More patches are welcome
other stuff
- Richlv mentioned this case: faces obscured by more than one face, which cannot be solved by combining brushes.
1. differing textures;
2. uneven other ends of the brushes to form some structure.
for example :
in first case, both brushes hiding the single face would have different textures, so merging them is not possible; in the second case, brushes can't be merged, because the other corners form a more complex strcture than a simple rectangular brush; in the third case, i tried to depict a very common feature in our maps - wall ending faces are pushed one against other, but one or both walls consist of several brushes because of some feature in the wall (doors, windows, holes...)
Here's an in-gtkradiant screenshot of the third problem depicted above :
- BTAxis mentioned: faces that are never seen because the angle of view is limited and there are other brushes (eg floor, ground) above them. This would require a completely different algorithm , so i will leave it for now.

