WMB7 BSP

Posted By: sheefo

WMB7 BSP - 01/05/11 12:32

Hi. I was wondering if you could document the BSP data in the WMB7 file format.
I am not asking for a BSP implementation or any trade secrets, just how to interpret the data for use with my BSP tree for a project I am working on which I hope will benefit many 3DGS users.

I am using the "WMB7 Simple Level format" documented in the manual. The lists I am looking for are:
Quote:
bsp_leafs
bsp_nodes
aabb_hulls
bsp_blocks
pvs

Thanks.
Posted By: jcl

Re: WMB7 BSP - 01/07/11 11:13

The BSP structures are harder to document and explain, that's why we documented the Simple Format only. Even worse, I had to do it as such documentation is my job. But when I have some time in the next months I'll document the BSP structures.
Posted By: sheefo

Re: WMB7 BSP - 01/10/11 12:44

Thanks.

I have a few other questions about the WMB7 file format.
How are the number of lightmaps calculated? The code I use only works for lightmaps compiled at the highest setting.
Code:
DWORD dwNumLightmaps = header.lightmaps.length / (1024 * 1024 * 3);



Also, why was path.num_edges encoded like so? Took me a while to crack.
Code:
DWORD dwNumPoints = (DWORD)path.fNumPoints;
DWORD dwNumEdges = (path.num_edges - (dwNumPoints * 3)) / 2;


Posted By: jcl

Re: WMB7 BSP - 01/11/11 12:22

The lightmap size is optimized for minimum file size. When the total lightmap length is above 1024*1024*3, they a calculated like in our code, otherwise divide the length by 512*512*3 or by 256*256*3, whichever gives the smallest size.

The strange path format has historical reasons, it had to be compatible to an earlier path format where a node always had two edges.
Posted By: sheefo

Re: WMB7 BSP - 01/14/11 21:41

Thanks for the help so far. Just a few more questions.
Is sequential reading of the WMB file recommended? I know that there are offsets specified in the header but for speed reasons I would prefer to read sequentially.

This is the order I have discovered so far. I don't know what data legacy7 and legacy1 contain, but they are not empty.
Would it be possible to tell me where the remaining structures fit in the sequence so in case they are not empty I can tell my parser to skip the length of those blocks?
Quote:
header
legacy7
legacy1
blocks
materials
textures
palettes
lightmaps
lightmaps_terrain
bsp_leafs
bsp_nodes
aabb_hulls
bsp_blocks
pvs
objects


PS: Sorry for attempting to "rape" the WMB7 file format.
Posted By: sheefo

Re: WMB7 BSP - 02/10/11 20:18

I was considering upgrading to the new A8 engine but I have a few questions regarding the implications this may have on my project.

First off, will the file format currently used (WMB7) become obsolete? Will there be any changes in the A8 engine that I need to know about so my code can parse the newer WMB files generated by the A8 engine.

Secondly, is PVS data still only avaliable for Pro version? Since I own A7 Comm I cannot use this data anyway. I really only need to know how the BSP data is stored so I can generate my own BSP tree for my project.

Lastly, the question from my last post; Is sequential reading of the WMB file recommended? If so could you give me the order of the structures.

Thank You Very Much! I look forward to upgrading to A8 very soon!

PS: I hope you haven't forgotten about me wink
Posted By: jcl

Re: WMB7 BSP - 02/11/11 12:42

All Gamestudio file formats can change anytime. A change of the WMB7 format is not planned at the moment, but it can happen during the lifetime of A8.

Yes, PVS and BSP data are used by Pro only.

Reading the WMB file sequential or not has probably no effect on speed. The engine does not read the file sequentially. In any case you can skip the legacy chunk and all other chunks that you don't need.
Posted By: _cash_

Re: WMB7 BSP - 03/15/11 15:42

what is lightmap format? (bitmap or vector)
how i view lightmap data?

thanks.
Posted By: Damocles_

Re: WMB7 BSP - 03/15/11 19:56

according to the manual:

Quote:
The lightmaps list is just an array of quadratic lightmaps with 3 bytes per pixel (blue, green, red) and a size of 1024x1024 pixels each


So when you can calcualte the offset, and retreive the lightmap-bytes from the WMB, you could tranfrom it into a 1024x1024 RGB Bitmap.

Posted By: _cash_

Re: WMB7 BSP - 03/21/11 17:48

in help,
they say lContent is always 0,

////////////////////
typedef struct {
float fMins[3]; // bounding box
float fMaxs[3]; // bounding box
long lContent; // always 0
long lNumVerts; // number of VERTEX structs that follow
long lNumTris; // number of TRIANGLE structs that follow
long lNumSkins; // number of SKIN structs that follow
} BLOCK;
/////////////////////

but i check some wmb7 file,
lContent is set -80 or -128 or 0

whats meaning of this parameter?
Posted By: jcl

Re: WMB7 BSP - 03/23/11 12:29

I believe it codes for special block contents such as Passable, Invisible, and so on. It is not used by the engine AFAIK, so it can normally be 0.
Posted By: sheefo

Re: WMB7 BSP - 04/02/11 14:17

Hi. I was just wondering if you still plan on documenting the BSP data? All I really need to know is how to interpret the data stored in the file. Thanks!
Posted By: sheefo

Re: WMB7 BSP - 05/01/11 17:17

I know a bit about BSP and have been trying to hack the format you have used to serialize them in the WMB7 file format.
I could use a little help. So far I have identified structures, now all I need is to [figure out/be told] what variable means what?
Posted By: jcl

Re: WMB7 BSP - 05/02/11 13:19

You can post the structures and variables in question here and I'll try to help.
Posted By: sheefo

Re: WMB7 BSP - 05/03/11 00:27

This code was taken from a TXT file I backup A LONG TIME AGO so if it embaresses me by looking retarded, just remember that PLEASE.
I don't have access to my current version of my source code and will not for at least a week. To be honest I havent touched the source code in a few months (she must be gagging for it) due to the lack of information of the data structures.
Remember; this will benefit the community (without compromising the integrity of the engines best kept secrets).

NOTE: I have since forgotten the meaning behind some data, such as bsp_blocks, which is just (in my case) and array of 20 32-bit integers.
NOTE: I do remember that this map only had 5 regions.
NOTE: I did my best using the manual.

Code:
////////////////////////////////////////////////////////////////
	// bsp_leafs
	typedef struct {
		unsigned long type; // root = 0xFFFFFF80, child = 0xFFFFFF00
		long  region;
		float plane[4];
		long  _unused_;
		long  lBlockIndex; // x = block offset
		long  lNumBlocks; // y = num blocks
	} WMB7_BSP_LEAFS;
	// NOTE: x+y = next leaf x
	// x = block offset
	// y = num blocks
	WMB7_BSP_LEAFS bsp_leafs[5];
	// NOTE: Number of leafs = Number of regions
	// Each leaf is 36 bytes. There is always one leaf (the root) even without BSP.
	file.Seek(header.bsp_leafs.offset);
	file.Read(&bsp_leafs, header.bsp_leafs.length);
	////////////////////////////////////////////////////////////////
	// bsp_blocks
	typedef struct {
		long a;
		long unused0; // 0
		float c[3];
		long unused1; // 0
		long next; // ?
		long prev; // ?
		long lSurfaceOffset; // ?
		long lVisibleSurfaces; // ?
	} WMB7_BSP_NODES;
	WMB7_BSP_NODES bsp_nodes[15];
	file.Seek(header.bsp_nodes.offset);
	file.Read(&bsp_nodes, header.bsp_nodes.length);
	////////////////////////////////////////////////////////////////
	// aabb_hulls
	file.Skip(header.aabb_hulls.length);
	////////////////////////////////////////////////////////////////
	// bsp_blocks
	unsigned long bsp_blocks[20];
	file.Seek(header.bsp_blocks.offset);
	file.Read(&bsp_blocks, header.bsp_blocks.length);
	////////////////////////////////////////////////////////////////
	// pvs
	file.Skip(header.pvs.length);
	////////////////////////////////////////////////////////////////
	// objects
	file.Skip(header.objects.length);
	////////////////////////////////////////////////////////////////



Many, many thanks!
Posted By: jcl

Re: WMB7 BSP - 05/06/11 15:14

Ok, here are the same structs in the engine source:

Code:
typedef struct BSP_LEAF {
	int   type;
	int   nRenderFrame;	// was leaf already rendered?
	float minmaxs[6]; // bounding box
	BSP_NODE  *parent;
	byte  *PVS;
	BSP_SURFACE **surfacelist;
	int   numSurfaces;
	int   nLeaf;
} BSP_LEAF;

typedef struct BSP_NODE {
	int   type;
	int   nRenderFrame;	// was node already rendered?
	float minmaxs[6]; // bounding box
	BSP_NODE  *parent;
	BSP_PLANE *plane;
	BSP_NODE  *child[2];
	int   nSurface;
	int   numSurfaces;
} BSP_NODE;


Posted By: txesmi

Re: WMB7 BSP - 03/02/20 09:36

Hi @jcl,
Would you be so kind as to show us here the data structures of the region object, which is not documented in the manual?
It is the only data missing to complete the simple scenarios.

Thank you in advance.
Txes.
Posted By: jcl

Re: WMB7 BSP - 03/13/20 11:22

Code
typedef struct {
	long	type;       // 8 = Region
	float	mins[3],maxs[3];  // Bounding Box
	void*	event;    	// Trigger-Aktion
	long	flags;
	char	name[ENT_NAMESIZE];
} E_REGION;
Posted By: txesmi

Re: WMB7 BSP - 03/13/20 16:33

Thank you very much!
© 2024 lite-C Forums