All pastes #587094 Raw Edit

Mine

public text v1 · immutable
#587094 ·published 2007-06-24 08:17 UTC
rendered paste body
VMaps (the better line of sight)

Did you ever have the problem being seen by a mob through a wall? NOT ANYMORE! With some additional vector map information (about 1 GB) and some additional logic mangos can be enhanced to do a proper "line of sight" or “height" calculation within buildings, instances or cities. Using "blink" within a city is possible now without finding yourself under city walls.

We are running this enhancement on our server for some days now and everything seems to run smooth.

This is the way to enhance mangos:

1. You have to extract some raw vector data of buildings, trees, fences, instance ... You will find a good source for that :-). I modified a world viewer to extract all necessary data. My source had the version number 2.0.6. Is works with newer versions as well (last tested 2.0.12). The extract program is a dirty hack, but it will only run once, so never mind. It will create a sub directory "buildings" witch will hold all model, placement, scaling and rotation information (about 400MB). The extract process will take some time (more than one hour) so be patient.

If you want to compile the extractor yourself define _MAP_EXTRACTOR_ONLY. Otherwise you will get the standard word map viewer.

Animated objects are not extracted jet. Therefore do not try to hide behind an animated object like fountain or bellow. You will be seen there. ADD: They are in now.

2. The raw data has to be converted into balanced octrees (axis aligned bsp-trees) to be able to calculate line of sight. This is done in the second step. The aabsp-trees consume more space than the raw data, because one tree for instance is placed several times within one map. To calculate line of sight we need to pre calculated maps with all the position, scale and rotation information already resolved. Otherwise it would be much to slow. To save space I only use a fixed point 16 bit representation for vectors which are relative to a base vector represented as a float value. Some cities and other objects are large and cover more than one map tile. Therefore we need a directory file for each map tile that describes with model files have to be loaded. A huge object, like a city, will than be loaded only once, because multiple tiles will only point to the one city instance file.

The conversion process creates the vmaps (static balanced aa bsp trees) and directory files. You will need about 1 GB for the vmaps and it will take some time to convert them (be patient).

Create a vmaps directory in your data directory of your mangos instance and copy the maps there.

3. Build mangos with vmap support.

To create the balanced bsp trees, for visual debugging and for the mathematics I used G3D as the underlying library. To simplify the merge to mangos Alora striped down G3D and he included the necessary parts in a sub directory g3dlite (thanks for that). You do not have to include any original G3D stuff or link against G3D or SDL.

The communication between mangos and the VMapManger is through a tiny interface created by a factory.

Copy the vmap source to dep\src\vmap. The project file tries to find it there.

To really use vmaps you have to compile with the definition: MANGOS_USE_VMAPS. This will activate the loading and unloading of maps and the line of sight calculation.

I also provide a much better height calculation based on the vmaps. This can be activated by using the define: MANGOS_USE_VMAP_HEIGHT.

Under windows you nearly get no warning. Using gcc4 under Linux will create some warnings. You can ignore them. ADD: This is fixed now.

Enabling vmaps will consume memory and processor power. Have a watchful eye on that.

We are using the code on a 64 32 Bit Linux and on Windows using VC7 , so it should work for you as well. The makefiles and the VC7 project files might be a bit smarter, but that could be your job fulfill :-) ADD: this is done.

The attached archive contains all you need and a patch against mangos 3462 (I know that is not the current version, but the one we are running right now.)

contrib contains the extract and convert progs.
In dep you will find the mangos extension source code
win holds the VC7 project files.

Have fun. All Comments are welcome.

Ralf


PS: My previous little patch suggestions did not find there way into the core jet. Maybe you find that one more helpful. ADD: They are partly in and the rest comes with student1's rouge patch.


Update 070608: New version for 3839, SD2_54, 16:00
New patch for 3839, SD2 54
* Fixed extractor
* Modified debugger
* Modified assembler
New path for 3763, SD2 46, Thanks to ab2cd4
*
New in version 3726:
* Thanks to Chris K and Leathude for their patches.
* new patch for the current mangos, SD2 version.
* As suggested by Niobium and Alora I included the patch to prevent mobs seeing the player through walls when helping other mobs. If you don’t like that one, just comment out the isInLineOfSight() call in file:src/game/SpellEffects.cpp, method:Spell::EffectDummy().

DOWNLOAD NOW!

Here you find a step by step description with many screenshots. I used VC71 but it should work with VC80 as well.
The tutorial is a rtf file, so you should all be able to open it.
How to build mangos with vmaps on Windows