UFO:Alien Invasion

Development => Newbie Coding => Topic started by: ShipIt on March 09, 2014, 03:57:23 pm

Title: extracting surface parameters from .map files
Post by: ShipIt on March 09, 2014, 03:57:23 pm
In order to bring the material files up-to-date, I have some script to find out what textures are used in the maps. But of course some textures are rarely used and not worth an entry in the material file, while others are very important. So I want to compute on how many 'square units' each texture is used.
In the map files a brush is defined like that:
Quote
// brush 0
{
( 128 192 4 ) ( 128 0 4 ) ( 0 192 4 ) tex_nature/desert001 0 0 0 0.25 0.25 65280 0 0
( 128 192 128 ) ( 0 192 128 ) ( 128 192 0 ) tex_nature/flower 0 0 0 0.25 0.25 65280 0 0
( 128 192 128 ) ( 128 192 0 ) ( 128 0 128 ) tex_nature/dirt_se01 0 0 0 0.25 0.25 65280 0 0
( 0 0 0 ) ( 128 0 0 ) ( 0 192 0 ) tex_common/nodraw 0 0 0 0.25 0.25 65280 0 0
( 0 0 0 ) ( 0 0 128 ) ( 128 0 0 ) tex_nature/dirt002 0 0 0 0.25 0.25 65280 0 0
( 0 0 0 ) ( 0 192 0 ) ( 0 0 128 ) tex_nature/desert009 0 0 0 0.25 0.25 65280 0 0
}

I have no problems to extract the coords, texture IDs and the properties from that. But I am lost on computing the info I want from the given vertices. Why there are only three coordinates, even if the face has four or even more? Maybe someone can explain this to me?
Title: Re: extracting surface parameters from .map files
Post by: Sandro on March 09, 2014, 06:28:31 pm
Those are not vertices; those are clipping planes for convex polytopes called brushes.
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 09, 2014, 06:55:58 pm
So computing the surface area for each plane from those numbers is not possible ? Or just very hard to do?
Title: Re: extracting surface parameters from .map files
Post by: Sandro on March 09, 2014, 08:26:46 pm
Possible, but will requre some serious math. Or you can use the processed data from .bsp files.
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 10, 2014, 06:23:13 am
Unfortunately I am unable to do serious math nor do I know how to access the data in the bsp files. So any hint would be welcome.

Title: Re: extracting surface parameters from .map files
Post by: Duke on March 10, 2014, 08:13:41 am
Can your script already count the number of occurrences for each texture ?
That would be a start...
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 10, 2014, 12:17:23 pm
I started simple by counting the number of faces each texture is used on.
But I found this to be misleading often, because a texture used on a single big plane needs a material entry more than a texture used on lots of very small surfaces.
Title: Re: extracting surface parameters from .map files
Post by: Sandro on March 10, 2014, 02:11:54 pm
Please clarify what exactly you want to accomplish? Remove textures which are almost always not seen by player? Or, optimize memory usage? Second one would not work -- texture is always loaded in it's entiriety.
Title: Re: extracting surface parameters from .map files
Post by: Duke on March 10, 2014, 02:16:12 pm
Sandro,
he is talking about material entries for textures, not the textures themselves.

ShipIt,
how many percent of your list currently lack a material entry ?
Is there a limit for material entries ?
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 10, 2014, 05:29:23 pm
Please clarify what exactly you want to accomplish? Remove textures which are almost always not seen by player? Or, optimize memory usage? Second one would not work -- texture is always loaded in it's entiriety.

I check out what textures are used within a map to update its material file.

RMAs use more than 100 different textures. Now I seek a way to figure out which textures are worth a material definition. For this I thought it would be nice to know how many square units each texture uses within the map.

So basically, I want to compute the surface size of each face in a .map file.

Title: Re: extracting surface parameters from .map files
Post by: Sandro on March 10, 2014, 08:14:32 pm
.bsp will be better since it got the final geometry. It is quite simple, actually, all the needed data is provided in the plain way. Vertices, edges, polygons -- everything is right there.
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 11, 2014, 06:39:23 am
Even if I was (and I am not) able to access the data from the .bsp files, the math would still be beyond me.
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 11, 2014, 06:46:12 am
ShipIt,
how many percent of your list currently lack a material entry ?
Is there a limit for material entries ?

Not sure if I get the question right. What list you are thinking about?
I can extract the used textures for each map and auto-generate a .mat file for it. But making 100+ entries in ~70 files? Some of the textures are so tiny in the map, they are just not worth it imo.
Title: Re: extracting surface parameters from .map files
Post by: Duke on March 11, 2014, 03:36:31 pm
Sorry, I was under the impression that we have only one material file for all the textures that need a material entry. Now I looked at the /material dir the first time. Quite a lot redundancy :(
So forget about my above question.

ufo2map seems to have a material file generation feature. Have you tried that ?
Title: Re: extracting surface parameters from .map files
Post by: Sandro on March 11, 2014, 09:10:02 pm
Indeed. IMHO maps should refer to materials, not textures
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 12, 2014, 07:26:41 am
ufo2map seems to have a material file generation feature. Have you tried that ?

I did. But, using this for the tiles of an RMA it generates a file for each tile, e.g. iterating over +mansion gives 29 new .mat files. For some reason it always only adds exactly one entry to the file. Therefore, it uses some hardcoded values that are not the best imo.
Also, it doesn´t check whether an entry already existst or not, so it is not usable for maintenance.
Title: Re: extracting surface parameters from .map files
Post by: Duke on March 12, 2014, 09:42:16 am
Set aside the 'only one entry per file' and '1 file per tile' problems (that could be fixed/changed):

Can the values in the mat file *only* be entered there or can they be entered elsewhere (eg. radiant) ?
I.o.w.: does ufo2map at least have a chance to extract the wanted values from the map file ?
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 12, 2014, 02:53:29 pm
The material settings for the textures are not stored in the map. Afaik the only chance to set material parameters for textures is the material file.
Title: Re: extracting surface parameters from .map files
Post by: Duke on March 12, 2014, 03:35:08 pm
There is also something in the UI called 'material_editor'. Not sure if that is just unfinished business. Do you know anything about that ?
(ui_push material_editor at the game console shows the window at least)
Title: Re: extracting surface parameters from .map files
Post by: ShipIt on March 12, 2014, 08:28:54 pm
There is also something in the UI called 'material_editor'. Not sure if that is just unfinished business. Do you know anything about that ?
(ui_push material_editor at the game console shows the window at least)

It is possible to open an editor and edit the material file out of radiant.