a problem that has me stumped!

tigital tigital at mac.com
Fri Aug 23 21:58:22 EDT 2002


hiya,

...after jumping the gun and releasing an OS X diff, I'm trying to 
move ahead with the port and get the byteswapping to work with model 
loading...fortunately, most of the that is done, but I'm now stuck on 
what to do with a coupla struct data fields...

the polymodel struct has an element "*submodel" of type bsp_info, 
which is another struct...this bsp_info has a ubyte *bsp_data, which 
is specifically passed to many model functions, which then use a 
series of dereferencing define's to access certain fields:

#define w(p) (*((int *) (p)))
#define vp(p) ((vector *)(p))
#define fl(p) (*((float *)(p)))


...unfortunately, the fields are offsets from the beginning of the 
"ubyte *bsp_data", so, as an example, with Textured poly's the 
following offsets apply:

+0	int	id
+4	int	size
+8	vector	normal
+20	vector	center
+32	float	radius
+36	int	nverts
+40	int	tmap_num
+44	nverts*(model_tmap_vert)	vertlist (n,u,v)

...so, the code uses vp(p+8) and vp(p+20) to access the vector 
fields...so far I've been able to byteswap the w(p) and fl(p) 
functions at the point of their calling(ex. chunk_size = 
SDL_SwapLE32( w(p+4));), but I'm unsure how to access the vector 
elements...a vector is as follows:

typedef struct vector {
	union {
		struct{
			float x,y,z;
		}xyz;
		float a1d[3];
	};
} vector;

...anyone think they can shed some insight?

tanx,

jamie



More information about the freespace2 mailing list