167 lines
5.4 KiB
C
167 lines
5.4 KiB
C
/**
|
|
* @file RSPTerrain.h
|
|
* @date 22/08/2022
|
|
* @author JackCarterSmith
|
|
* @copyright GPL-v3.0
|
|
* @brief Rogue Squadron Parser terrain library, used to decode decode datas
|
|
* from original game file and access them through public interface.
|
|
*
|
|
*/
|
|
|
|
#include "RSPTerrain_datatypes.h"
|
|
|
|
#ifndef RSPTERRAINLIB_H_
|
|
#define RSPTERRAINLIB_H_
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
# define RSPTERRAIN_ABI_EXPORT __declspec(dllexport)
|
|
# define RSPTERRAIN_ABI_IMPORT __declspec(dllimport)
|
|
#elif __GNUC__ >= 4
|
|
# define RSPTERRAIN_ABI_EXPORT __attribute__ ((visibility("default")))
|
|
# define RSPTERRAIN_ABI_IMPORT __attribute__ ((visibility("default")))
|
|
#else
|
|
# define RSPTERRAIN_ABI_EXPORT
|
|
# define RSPTERRAIN_ABI_IMPORT
|
|
#endif
|
|
|
|
#if defined(RSPTERRAIN_DLL)
|
|
# if defined(WIN32)
|
|
# if defined(RSPTERRAIN_DLLBUILD)
|
|
# define RSPTERRAIN_EXTERN extern RSPTERRAIN_ABI_EXPORT
|
|
# else
|
|
# define RSPTERRAIN_EXTERN extern RSPTERRAIN_ABI_IMPORT
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
#ifndef RSPTERRAIN_EXTERN
|
|
# define RSPTERRAIN_EXTERN extern
|
|
#endif
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// Library's functions declaration
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
* @brief Get the current library version.
|
|
* @return Char array of the version, escape char included.
|
|
*/
|
|
RSPTERRAIN_EXTERN char* RSPTerrain_getVersion( void );
|
|
|
|
/**
|
|
* @brief Run terrain parser for the specified file in file system.
|
|
* @details Model library can process HMP file from file system. It's a easy
|
|
* approach using this library for debugging purpose.
|
|
*
|
|
* @param[out] hmpStruct HMP terrain structure to be filled with parsed datas.
|
|
* @param[in] filePath Path to the HMP file in system.
|
|
* @param[in] params Parser options. See RSPTERRAIN_PARAMETERS.
|
|
*
|
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
|
*/
|
|
RSPTERRAIN_EXTERN unsigned short RSPTerrain_processHMPFile(
|
|
T_RSPTERRAIN_HMP* hmpStruct, const char* const filePath,
|
|
const RSPTERRAIN_PARAMETERS params
|
|
);
|
|
|
|
/**
|
|
* @brief Run terrain parser for the specified file in memory.
|
|
* @details Model library can process HMP file directly stored in RAM memory,
|
|
* you must load the file beforehand through a malloc/memcpy call.
|
|
* @warning No controls routines are implemented to verify file length!
|
|
*
|
|
* @param[out] hmpStruct HMP terrain structure to be filled with parsed datas.
|
|
* @param[in] memFilePtr Pointer to the beginning of the file in memory.
|
|
* @param[in] memFileSize Size of the file in bytes.
|
|
* @param[in] params Parser options. See RSPTERRAIN_PARAMETERS.
|
|
*
|
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
|
*/
|
|
RSPTERRAIN_EXTERN unsigned short RSPTerrain_processHMPFileMemory(
|
|
T_RSPTERRAIN_HMP* hmpStruct, const void* const memFilePtr, const long memFileSize,
|
|
const RSPTERRAIN_PARAMETERS params
|
|
);
|
|
|
|
/**
|
|
* @brief Convert terrain tilesmap into fullframe heightmap.
|
|
* @details Height values are placed in a two dim array for easy access.
|
|
*
|
|
* @param[out] heightmap 2D array type heightmap structure.
|
|
* @param[in] hmpStruct HMP terrain datas from previously parsed HMP file.
|
|
*
|
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
|
*/
|
|
RSPTERRAIN_EXTERN unsigned short RSPTerrain_terrainToHeightmap(
|
|
T_RSPTERRAIN_HEIGHTMAP* heightmap, const T_RSPTERRAIN_HMP* hmpStruct
|
|
);
|
|
|
|
/**
|
|
* @brief Convert terrain tilesmap into vertices mesh for 3D purpose.
|
|
* @details Vertex have a X,Y,Z format. Vertices are placed in a row.
|
|
*
|
|
* @param[out] mesh Mesh of vertices heightmap type.
|
|
* @param[in] hmpStruct HMP terrain datas from previously parsed HMP file.
|
|
* @param[in] scale X/Z map mesh scale factor (default: 0.1).
|
|
*
|
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
|
*/
|
|
RSPTERRAIN_EXTERN unsigned short RSPTerrain_terrainToMesh(
|
|
T_RSPTERRAIN_MESH* mesh, const T_RSPTERRAIN_HMP* hmpStruct, const float scale
|
|
);
|
|
|
|
/**
|
|
* @brief Convert terrain to GL compatible format.
|
|
* @note Only available if GL module as specified at compilation.
|
|
*
|
|
* @param[out] glTerrainObj GL structure.
|
|
* @param[in] hmpStruct HMP terrain datas from previously parsed HMP file.
|
|
*
|
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
|
*/
|
|
RSPTERRAIN_EXTERN unsigned short RSPTerrain_terrainToGL(
|
|
void* glTerrainObj, const T_RSPTERRAIN_HMP* hmpStruct
|
|
);
|
|
|
|
/**
|
|
* @brief Convert terrain to Direct3D compatible format.
|
|
* @note Only available if D3D module as specified at compilation.
|
|
*
|
|
* @param[out] D3DTerrainObj Direct3D structure.
|
|
* @param[in] hmpStruct HMP terrain datas from previously parsed HMP file.
|
|
*
|
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
|
*/
|
|
RSPTERRAIN_EXTERN unsigned short RSPTerrain_terrainToD3D(
|
|
void* D3DTerrainObj, const T_RSPTERRAIN_HMP* hmpStruct
|
|
);
|
|
|
|
/**
|
|
* @brief Clean HMP object and it's childrens from memory.
|
|
* @param[in] hmpStruct Pointer to data to be cleaned up.
|
|
*/
|
|
RSPTERRAIN_EXTERN void RSPTerrain_freeHMP( T_RSPTERRAIN_HMP* hmpStruct );
|
|
|
|
/**
|
|
* @brief Clean heightmap object and it's childrens from memory.
|
|
* @param[in] heightmap Pointer to data to be cleaned up.
|
|
*/
|
|
RSPTERRAIN_EXTERN void RSPTerrain_freeHeightmap( T_RSPTERRAIN_HEIGHTMAP* heightmap );
|
|
|
|
/**
|
|
* @brief Clean mesh object and it's childrens from memory.
|
|
* @param[in] mesh Pointer to data to be cleaned up.
|
|
*/
|
|
RSPTERRAIN_EXTERN void RSPTerrain_freeMesh( T_RSPTERRAIN_MESH* mesh );
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* RSPTERRAINLIB_H_ */
|