Loading assets in QX from BAR | developer.brewmp.com Loading assets in QX from BAR | developer.brewmp.com

Developer

Loading assets in QX from BAR

Forums:

I have been using QXResourceMgr_GetResourceByName successfully. However, I need to know how loading a model from the BAR would work using QX.

I understand the qxm file references the textures and animations by name. How would I apply a texture to a model using a BAR id??

I see QXResourceMgr_GetResourceByID but I don't understand how this would know where the textures are or if this is even for the BAR id.

Hello Brian,
QX does not directly support BAR files out of the box. However, it can be extended to do so by writing a QXFileManager extension. You can do this by building a structure that conforms to QXFileMgr (QXFileManager.h):
typedef struct _QXFileMgr
{
PFN_QXFileMgr_Open pfn_Open;
PFN_QXFileMgr_Read pfn_Read;
PFN_QXFileMgr_GetSize pfn_GetSize;
PFN_QXFileMgr_Write pfn_Write;
PFN_QXFileMgr_Close pfn_Close;
void* pData;
} QXFileMgr;
There is documentation in the reference CHM and QXFileManager.h as to which functions are mandatory and what their parameters should contain. You can then mount your BAR and redirect load calls to read from the BAR instead of from EFS. To override the default file manager you can call: QXState_SetFileManager at startup and pass in your overloaded structure. To maintain state data that you may need you can either use the void* pData pointer or just have a bigger structure and cast it down to QXFileMgr.
As you mentioned, texture file names are stored within the QXM file so in order to trap those properly you will want to capture the .qxt files when you receive an Open call and have a mapping function that maps that to a BAR resource name. Also note that texture paths are pre-pended with whatever string is passed into QXResourceMgr_SetReferenceBaseDirectory. You may want to remove the default “data/” string with something that makes sense for your app.
- Baback

Hello Brian,
QX does not directly support BAR files out of the box. However, it can be extended to do so by writing a QXFileManager extension. You can do this by building a structure that conforms to QXFileMgr (QXFileManager.h):
typedef struct _QXFileMgr
{
PFN_QXFileMgr_Open pfn_Open;
PFN_QXFileMgr_Read pfn_Read;
PFN_QXFileMgr_GetSize pfn_GetSize;
PFN_QXFileMgr_Write pfn_Write;
PFN_QXFileMgr_Close pfn_Close;
void* pData;
} QXFileMgr;
There is documentation in the reference CHM and QXFileManager.h as to which functions are mandatory and what their parameters should contain. You can then mount your BAR and redirect load calls to read from the BAR instead of from EFS. To override the default file manager you can call: QXState_SetFileManager at startup and pass in your overloaded structure. To maintain state data that you may need you can either use the void* pData pointer or just have a bigger structure and cast it down to QXFileMgr.
As you mentioned, texture file names are stored within the QXM file so in order to trap those properly you will want to capture the .qxt files when you receive an Open call and have a mapping function that maps that to a BAR resource name. Also note that texture paths are pre-pended with whatever string is passed into QXResourceMgr_SetReferenceBaseDirectory. You may want to remove the default “data/” string with something that makes sense for your app.
- Baback

Thanks a lot baback. That all makes sense. I will look into this soon.

Thanks a lot baback. That all makes sense. I will look into this soon.