project-navigation
Personal tools

Author Topic: extracting surface parameters from .map files  (Read 14371 times)

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
extracting surface parameters from .map files
« 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?

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: extracting surface parameters from .map files
« Reply #1 on: March 09, 2014, 06:28:31 pm »
Those are not vertices; those are clipping planes for convex polytopes called brushes.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: extracting surface parameters from .map files
« Reply #2 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?

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: extracting surface parameters from .map files
« Reply #3 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.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: extracting surface parameters from .map files
« Reply #4 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.


Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: extracting surface parameters from .map files
« Reply #5 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...

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: extracting surface parameters from .map files
« Reply #6 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.

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: extracting surface parameters from .map files
« Reply #7 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.

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: extracting surface parameters from .map files
« Reply #8 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 ?

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: extracting surface parameters from .map files
« Reply #9 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.

« Last Edit: March 10, 2014, 05:33:37 pm by ShipIt »

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: extracting surface parameters from .map files
« Reply #10 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.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: extracting surface parameters from .map files
« Reply #11 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.

Offline ShipIt

  • Project Artist
  • Captain
  • ***
  • Posts: 906
    • View Profile
Re: extracting surface parameters from .map files
« Reply #12 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.

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: extracting surface parameters from .map files
« Reply #13 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 ?

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: extracting surface parameters from .map files
« Reply #14 on: March 11, 2014, 09:10:02 pm »
Indeed. IMHO maps should refer to materials, not textures