cannot call fs_seek or trap_fs_seek function for file manipu


(rtt) #1

Ive searched evrywhere i could think of including this forum and could not find out how to call this function. I see a reference to fs_seek in botlib.h but cannot call it. It seems there is no reference to it other than in that header file. I would like to use the engine file manip functions because i am accessing the pk3 files. any help would be greatly appreciated.

p.s. As u prolly can tell iam kinda new to modding.

Thanks rtt :???:


(jaybird) #2

What exactly are you trying to do?


(rtt) #3

Iam trying to extract vertex info from the .bsp file. Ive tried to use fs_read but to go back and forth within the file u have to close and reopen the file which is becoming a pain. I havent seen any use of fs_seek by the original code so I don’t know if i can even call it.


(kamikazee) #4

I believe the vertex data is only used by the engine, so I don’t know what you’re up to…
Is there no way of simply asking for a specific vertex from the engine so you don’t need to clutter with the .bsp files themself?


(rtt) #5

I couldn’t find any way of accessing that info other than reading the bsp file. I can read the file fine but u have to read it in sequence and there is no going backwards without reopening the file. I need all the vertices for all collidable objects in the map. I am “ATTEMPTING” to add real driveable vehicles to the game without relying on the mapper to supply the collision info. This is just an attempt. It may not even be possible. using fs_seek would make reading the data a whole lot easier. Try not to laugh too hard at my attempt. lol

thanks
rtt


(SCDS_reyalP) #6

I have a vague memory of a comment somewhere that you can’t seek backwards in .pk3 files. code/qcommon/files.c FS_Seek in the quake3 engine source looks to be the point of interest. Hrm, I don’t even see a trap_FS_Seek in ET, althought it does exist in q3.

My suggestion would be to either read through the whole .bsp, or at least the lumps of interest discarding the bits you don’t need, and grabbing the ones you want, or write an external program that harvests the data you need out of the .bsp. The latter might be useful if you have to massage the data in singificant ways.

As an aside, you might want to use the collision brushes in the .bsp rather than the meshverts. Or use trap_trace if you can kludge that to match you needs.

If you want a truely hacky option, find out where in memory et loads the .bsp data, and use that directly :moo:


(rtt) #7

I can get the data out but only in the order in which it’s saved within the file. I need to then arrange the data differently which would take time due to all the looping involved for approx 39,714 vertices. The test map is small by comparison to other maps I’ve seen, the file is only about 4.6 MB. for a large map this would be very time consuming as well as a pain in the butt.

I saw the trap_fs_seek function in q3a 1.17 referenced in g_syscalls.c. I wonder if I could use that in some way, maybe compile a lib and use it that way.
what do u think. I’m just guessing.

Thanks

rtt


(SCDS_reyalP) #8

This would be an argument for using a separate pre-process to get the data you need.

I saw the trap_fs_seek function in q3a 1.17 referenced in g_syscalls.c. I wonder if I could use that in some way, maybe compile a lib and use it that way.
what do u think. I’m just guessing.

Well, it doesn’t seem to be in the ET syscalls, which means you are pretty much SOL. Since the low level zip file functions are also not available to gamecode, you’d have to do the entire thing yourself.


(rtt) #9

This is what i saw in botlib.h. If anyone can see a way of calling this function it would be great. I can get the data it’s just gonna take a bit of work to do with the other fuctions available to me. Map load time will be long also.

//bot AI library exported functions
typedef struct botlib_import_s
{
//print messages from the bot library
void (QDECL *Print)(int type, char *fmt, …);
//trace a bbox through the world
void (*Trace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask);
//trace a bbox against a specific entity
void (*EntityTrace)(bsp_trace_t *trace, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask);
//retrieve the contents at the given point
int (*PointContents)(vec3_t point);
//check if the point is in potential visible sight
int (*inPVS)(vec3_t p1, vec3_t p2);
//retrieve the BSP entity data lump
char *(*BSPEntityData)(void);
//
void (*BSPModelMinsMaxsOrigin)(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);
//send a bot client command
void (*BotClientCommand)(int client, char *command);
//memory allocation
void *(*GetMemory)(int size);
void (*FreeMemory)(void *ptr);
void (*FreeZoneMemory)(void);
void *(*HunkAlloc)(int size);
//file system access
int (*FS_FOpenFile)( const char *qpath, fileHandle_t *file, fsMode_t mode );
int (*FS_Read)( void *buffer, int len, fileHandle_t f );
int (*FS_Write)( const void *buffer, int len, fileHandle_t f );
void (*FS_FCloseFile)( fileHandle_t f );


int			(*FS_Seek)( fileHandle_t f, long offset, int origin );

//debug visualisation stuff
int			(*DebugLineCreate)(void);
void		(*DebugLineDelete)(int line);
void		(*DebugLineShow)(int line, vec3_t start, vec3_t end, int color);
//
int					(*DebugPolygonCreate)(int color, int numPoints, vec3_t *points);
bot_debugpoly_t*	(*DebugPolygonGetFree)(void);
void				(*DebugPolygonDelete)(int id);
void				(*DebugPolygonDeletePointer)(bot_debugpoly_t* pPoly);
//
// Ridah, Cast AI stuff
qboolean	(*BotVisibleFromPos)(	vec3_t srcpos, int srcnum, vec3_t destpos, int destnum, qboolean updateVisPos );
qboolean	(*BotCheckAttackAtPos)(	int entnum, int enemy, vec3_t pos, qboolean ducking, qboolean allowHitWorld);
// done.
// Gordon: ability for botlib to check for singleplayer
// Arnout: removed again, botlibsetup already has a parameter 'singleplayer'
//qboolean	(*BotGameIsSinglePlayer) ( void );


// Gordon: direct hookup into rendering, stop using this silly debugpoly faff
void		(*BotDrawPolygon)(int color, int numPoints, float *points);

} botlib_import_t;

Thanks for all your input and happy moddding to all

rtt


(rtt) #10

after much playing around i found i can get the data i want, its just not in the right order. here’s what i did:

extracted the lumps from the bsp file

read in the verices for the level

now i need to create 2 array one say array[60000] for the verts and one say array[60000][3] for the indices;

where do i get the indices - from the meshverts lump and or the faces vertexindex and numofverts and or the brush info.

I got info on the bsp format from Gametutorials.com http://www.cs.uwec.edu/~stevende/cs455/programs/GameTutorials%20-%20Quake%203%20BSP%20Format.htm
and the unofficial q3map format pages


(SCDS_reyalP) #11

I still suggest that if you want collision detection, you may want to use the leafbrushes, and not deal with vertexes or faces at all. That’s what they are there for. You can look at the code for trap_trace in the quake3 engine code for some examples.

If you really want to use vertexes, the faces lump tells you which vertices belong to each face. Note that there are several face types, and the meanings of the fields are different between each type. Also note that the ‘faces’ lump is called the surfaces lump in id code, which is probably a more descriptive name. The individual entries often correspond to more than one face. the surfaces lump refers to the vertexes lump and the meshverts lump (which is a list of offsets into the vertexes).

You can find quite a bit of example code for dealing with the .bsp file in the q3map2 (get with SVN from zerowing.idsoftware.com ) via source and quake3 engine source ftp://ftp.idsoftware.com/idstuff/source/


(rtt) #12

Thanks for that info. the reason i have to use vertexes is iam using a third party dynamics engine for the vehicles which takes vertices. trap_trace only uses an aabb which is not good for realistic vehicle physics. (i.e health packs don’t sit flat on the terrain). If i was a math wizard maybe i could make it work but iam not.

I suppose i need both the faces and the meshverts to get all the verts correct?

rtt