Update lib name and implement basis of lib interface
This commit is contained in:
parent
8da3b4bd43
commit
5922c3ec6a
@ -26,8 +26,8 @@ SOURCE_GROUP("Source Files" FILES ${RSE_MOD_SOURCES})
|
|||||||
|
|
||||||
|
|
||||||
# Building instructions for RSE-Model
|
# Building instructions for RSE-Model
|
||||||
if(DEFINED ENV{RSE-WS})
|
if(DEFINED ENV{CI})
|
||||||
set(CMAKE_BUILD_TYPE DEBUG)
|
set(CMAKE_BUILD_TYPE RELEASE)
|
||||||
endif()
|
endif()
|
||||||
add_executable(rse-model ${RSE_MOD_SOURCES})
|
add_executable(rse-model ${RSE_MOD_SOURCES})
|
||||||
set_property(TARGET rse-model PROPERTY C_STANDARD 90)
|
set_property(TARGET rse-model PROPERTY C_STANDARD 90)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
#include <errors_types.h>
|
#include <RSPLib_errors.h>
|
||||||
#include <hob_struct.h>
|
#include <hob_struct.h>
|
||||||
#include <hob_parser.h>
|
#include <hob_parser.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errors_types.h>
|
|
||||||
#include <hob_struct.h>
|
#include <hob_struct.h>
|
||||||
|
#include <RSPLib_errors.h>
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "rlk/obj.h"
|
#include "rlk/obj.h"
|
||||||
#include "obj_exporter.h"
|
#include "obj_exporter.h"
|
||||||
|
@ -15,21 +15,21 @@ include(CheckIncludeFile)
|
|||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
|
|
||||||
# Push compile infos to source
|
# Push compile infos to source
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h @ONLY)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/config.h @ONLY)
|
||||||
|
|
||||||
|
|
||||||
# Define src/headers files
|
# Define src/headers files
|
||||||
FILE(GLOB_RECURSE RSP_MOD_SOURCES ./*.c)
|
FILE(GLOB_RECURSE RSP_MOD_SOURCES ./src/*.c)
|
||||||
SOURCE_GROUP("Source Files" FILES ${RSP_MOD_SOURCES})
|
SOURCE_GROUP("Source Files" FILES ${RSP_MOD_SOURCES})
|
||||||
|
|
||||||
|
|
||||||
# Building instructions for RSE-Model
|
# Building instructions for RSE-Model
|
||||||
if(DEFINED ENV{RSE-WS})
|
if(DEFINED ENV{CI})
|
||||||
set(CMAKE_BUILD_TYPE DEBUG)
|
set(CMAKE_BUILD_TYPE RELEASE)
|
||||||
endif()
|
endif()
|
||||||
add_library(rsp-model-lib ${RSP_MOD_SOURCES})
|
add_library(rsp-model-lib ${RSP_MOD_SOURCES})
|
||||||
set_property(TARGET rsp-model-lib PROPERTY C_STANDARD 90)
|
set_property(TARGET rsp-model-lib PROPERTY C_STANDARD 90)
|
||||||
target_include_directories(rsp-model-lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(rsp-model-lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
set_target_properties(rsp-model-lib PROPERTIES OUTPUT_NAME ${RSP_MODEL_LIB_NAME})
|
set_target_properties(rsp-model-lib PROPERTIES OUTPUT_NAME ${RSP_MODEL_LIB_NAME})
|
||||||
# Link externals libraries to the linker
|
# Link externals libraries to the linker
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -1 +0,0 @@
|
|||||||
#define VERSION "1.0.0"
|
|
@ -1 +0,0 @@
|
|||||||
#define VERSION "@PROJECT_VERSION@"
|
|
@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* errors_types.h
|
|
||||||
*
|
|
||||||
* Created on: 26 juil. 2022
|
|
||||||
* Author: JackCarterSmith
|
|
||||||
*/
|
|
||||||
|
|
||||||
//#include "error.h" //TODO: use it as base for error ID
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef SRC_ERRORS_TYPES_H_
|
|
||||||
#define SRC_ERRORS_TYPES_H_
|
|
||||||
|
|
||||||
#ifdef NO_ERROR
|
|
||||||
#undef NO_ERROR
|
|
||||||
#endif
|
|
||||||
#define NO_ERROR 0
|
|
||||||
#define ERROR_GENERIC 1
|
|
||||||
#define ERROR_MEMORY 2
|
|
||||||
#define ERROR_IO 3
|
|
||||||
#define ERROR_PROCESS 4
|
|
||||||
|
|
||||||
#define ERROR_ARGS_NULL 10
|
|
||||||
#define ERROR_ARGS_RANGE 11
|
|
||||||
|
|
||||||
#define ERROR_REALITY_BROKED -1
|
|
||||||
|
|
||||||
#endif /* SRC_ERRORS_TYPES_H_ */
|
|
82
RSPModelLib/include/RSPModel.h
Normal file
82
RSPModelLib/include/RSPModel.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/**
|
||||||
|
* @file RSPModel.h
|
||||||
|
* @date 11/08/2022
|
||||||
|
* @author JackCarterSmith
|
||||||
|
* @copyright GPL-v3.0
|
||||||
|
* @brief Rogue Squadron Parser model library, used to decode decode datas
|
||||||
|
* from original game file and access them through public interface.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "RSPModel_datatypes.h"
|
||||||
|
|
||||||
|
#ifndef RSPMODEL_H_
|
||||||
|
#define RSPMODEL_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Library's functions declaration
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the current library version.
|
||||||
|
* @return Char array of the version, escape char included.
|
||||||
|
*/
|
||||||
|
char* RSPModel_getVersion( void );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Run model parser for the specified file in file system.
|
||||||
|
* @details Model library can process HOB file from file system. It's a easy
|
||||||
|
* approach using this library for debugging purpose.
|
||||||
|
*
|
||||||
|
* @param[out] hob HOB structure to be filled with parsed datas.
|
||||||
|
* @param[in] filePath Path to the HOB file in system.
|
||||||
|
*
|
||||||
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
||||||
|
*/
|
||||||
|
unsigned short RSPModel_processHOBFileMemory( T_RSPMODEL_HOB* hob, const char* const filePath );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Run model parser for the specified file in memory.
|
||||||
|
* @details Model library can process HOB 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] hob HOB 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.
|
||||||
|
*
|
||||||
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
||||||
|
*/
|
||||||
|
unsigned short RSPModel_processHOBFile( T_RSPMODEL_HOB* hob, const void* const memFilePtr, const long memFileSize );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert HOB's object datas to GL compatible format.
|
||||||
|
* @note Only available if GL module as specified at compilation.
|
||||||
|
*
|
||||||
|
* @param[in] objStruct Object datas from previously parsed HOB file.
|
||||||
|
* @param[out] glObj GL structure.
|
||||||
|
*
|
||||||
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
||||||
|
*/
|
||||||
|
unsigned short RSPModel_objectToGL( const T_RSPMODEL_OBJECT* objStruct, void* glObj );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Convert HOB's object datas to Direct3D compatible format.
|
||||||
|
* @note Only available if D3D module as specified at compilation.
|
||||||
|
*
|
||||||
|
* @param[in] objStruct Object datas from previously parsed HOB file.
|
||||||
|
* @param[out] D3DObj Direct3D structure.
|
||||||
|
*
|
||||||
|
* @return Error status, return RSPLIB_SUCCESS in nominal case.
|
||||||
|
*/
|
||||||
|
unsigned short RSPModel_objectToD3D( const T_RSPMODEL_OBJECT* objStruct, void* D3DObj );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RSPMODEL_H_ */
|
104
RSPModelLib/include/RSPModel_datatypes.h
Normal file
104
RSPModelLib/include/RSPModel_datatypes.h
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* @file RSPModel_datatypes.h
|
||||||
|
* @date 11/08/2022
|
||||||
|
* @author JackCarterSmith
|
||||||
|
* @copyright GPL-v3.0
|
||||||
|
* @brief RSP Model workflow structures definitions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RSPMODEL_DATATYPES_H_
|
||||||
|
#define RSPMODEL_DATATYPES_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Lib's structure definitions
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef unsigned int T_RGBA;
|
||||||
|
|
||||||
|
typedef struct vector3 { float x,y,z; } T_VECTOR3;
|
||||||
|
|
||||||
|
typedef struct vertex { short x,y,z,w; } T_VERTEX;
|
||||||
|
|
||||||
|
typedef struct tex_coord { unsigned short u,v; } T_TEXCOORD;
|
||||||
|
|
||||||
|
typedef struct face_flags {
|
||||||
|
unsigned int fUnknown0:1;
|
||||||
|
unsigned int fUnknown1:1;
|
||||||
|
unsigned int fHasTexture:1;
|
||||||
|
unsigned int fIsQuad:1;
|
||||||
|
unsigned int fSeparateColorVertex:1;
|
||||||
|
unsigned int fHasColor:1;
|
||||||
|
unsigned int fHasExtraBytesBeforeColor:1;
|
||||||
|
unsigned int fUnknown7:1;
|
||||||
|
unsigned int fUnknown8:1;
|
||||||
|
unsigned int fUnknown9:1;
|
||||||
|
unsigned int fUnknown10:1;
|
||||||
|
|
||||||
|
unsigned int reserved:21;
|
||||||
|
} FACE_FLAGS;
|
||||||
|
|
||||||
|
typedef struct hob_face {
|
||||||
|
union {
|
||||||
|
unsigned int flags;
|
||||||
|
FACE_FLAGS flags_bits;
|
||||||
|
};
|
||||||
|
unsigned char b1;
|
||||||
|
unsigned char b2;
|
||||||
|
unsigned char b3;
|
||||||
|
unsigned char bsize;
|
||||||
|
unsigned short material_index;
|
||||||
|
unsigned short indices[4];
|
||||||
|
T_RGBA vertex_colors[4]; //TODO: convert in R:8_G:8_B:8_A:8 format? Caution with BE/LE conversion
|
||||||
|
T_TEXCOORD tex_coords[4];
|
||||||
|
} T_HOB_FACE;
|
||||||
|
|
||||||
|
typedef struct hob_face_group {
|
||||||
|
unsigned int meshdef1_offset;
|
||||||
|
|
||||||
|
unsigned int face_block_end_offset;
|
||||||
|
unsigned int face_block_offset;
|
||||||
|
unsigned int vertex_block_offset;
|
||||||
|
|
||||||
|
unsigned int id;
|
||||||
|
T_VECTOR3 transform;
|
||||||
|
|
||||||
|
unsigned int face_count;
|
||||||
|
T_HOB_FACE* faces;
|
||||||
|
|
||||||
|
unsigned int vertex_count;
|
||||||
|
T_VERTEX* vertices;
|
||||||
|
} T_HOB_FACE_GROUP;
|
||||||
|
|
||||||
|
typedef struct rspmodel_object {
|
||||||
|
char name[16];
|
||||||
|
unsigned int face_group_offset;
|
||||||
|
unsigned int object_part_header_offset;
|
||||||
|
unsigned int face_group_header_offset;
|
||||||
|
|
||||||
|
unsigned int object_part_count;
|
||||||
|
unsigned int face_group_count;
|
||||||
|
|
||||||
|
T_HOB_FACE_GROUP* object_parts;
|
||||||
|
} T_RSPMODEL_OBJECT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Model-Extractor HOB structure of an HOB file content.
|
||||||
|
* @details Used with malloc to create a clean method of bufferized
|
||||||
|
* model datas before saving it.
|
||||||
|
* @todo Export format to use it directly in other program.
|
||||||
|
*/
|
||||||
|
typedef struct rspmodel_hob {
|
||||||
|
unsigned int obj_count;
|
||||||
|
T_RSPMODEL_OBJECT* objects;
|
||||||
|
} T_RSPMODEL_HOB;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RSPMODEL_DATATYPES_H_ */
|
43
RSPModelLib/include/RSPModel_errordefs.h
Normal file
43
RSPModelLib/include/RSPModel_errordefs.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* \file RSPModel_errordefs.h
|
||||||
|
* \date 26/07/2022
|
||||||
|
* \author JackCarterSmith
|
||||||
|
* \copyright GPL-v3.0
|
||||||
|
* \brief Errors type definition file. Used mostly by methods in this project.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef RSPMODELLIB_ERRORS_H_
|
||||||
|
#define RSPMODELLIB_ERRORS_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Errors types definitions
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef NO_ERROR
|
||||||
|
#define NO_ERROR 0 // In case of dual declaration by GCC
|
||||||
|
#endif
|
||||||
|
#define RSPLIB_SUCCESS NO_ERROR //!< All is running good!
|
||||||
|
|
||||||
|
#define RSPLIB_ERROR_GENERIC 1 //!< Misuse of the program
|
||||||
|
#define RSPLIB_ERROR_MEMORY 2 //!< Memory de/allocation failure
|
||||||
|
#define RSPLIB_ERROR_IO 3 //!< File system access failure
|
||||||
|
#define RSPLIB_ERROR_PROCESS 4 //!< Internal processing failure
|
||||||
|
|
||||||
|
#define RSPLIB_ERROR_ARGS_NULL 16 //!< Method not NULL input expected
|
||||||
|
#define RSPLIB_ERROR_ARGS_RANGE 17 //!< Method input out of expected range
|
||||||
|
|
||||||
|
#define RSPLIB_ERROR_MOD_DISABLED 64 //!< A necessary module hasn't been activated during compilation time
|
||||||
|
|
||||||
|
#define RSPLIB_ERROR_REALITY_BRK -1 //!< This error can only appear in alternate reality
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RSPMODELLIB_ERRORS_H_ */
|
42
RSPModelLib/src/RSPModel.c
Normal file
42
RSPModelLib/src/RSPModel.c
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* \file RSPModel.c
|
||||||
|
* \date 11/08/2022
|
||||||
|
* \author JackCarterSmith
|
||||||
|
* \copyright GPL-v3.0
|
||||||
|
* \brief HOB model parser and export to Waveform OBJ format.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "RSPModel_errordefs.h"
|
||||||
|
#include "RSPModel.h"
|
||||||
|
|
||||||
|
char* RSPModel_getVersion( void ) {
|
||||||
|
return PRG_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short RSPModel_processHOBFileMemory( T_RSPMODEL_HOB* hob, const char* const filePath ) {
|
||||||
|
return RSPLIB_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short RSPModel_processHOBFile( T_RSPMODEL_HOB* hob, const void* const memFilePtr, const long memFileSize ) {
|
||||||
|
return RSPLIB_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short RSPModel_objectToGL( const T_RSPMODEL_OBJECT* objStruct, void* glObj ) {
|
||||||
|
#ifndef GL_SUPPORT
|
||||||
|
return RSPLIB_ERROR_MOD_DISABLED;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return RSPLIB_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short RSPModel_objectToD3D( const T_RSPMODEL_OBJECT* objStruct, void* D3DObj ) {
|
||||||
|
#ifndef D3D_SUPPORT
|
||||||
|
return RSPLIB_ERROR_MOD_DISABLED;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return RSPLIB_SUCCESS;
|
||||||
|
}
|
6
RSPModelLib/src/config.h
Normal file
6
RSPModelLib/src/config.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef CONFIG_H_
|
||||||
|
#define CONFIG_H_
|
||||||
|
|
||||||
|
#define PRG_VERSION "1.0.0"
|
||||||
|
|
||||||
|
#endif /* CONFIG_H_ */
|
6
RSPModelLib/src/config.h.in
Normal file
6
RSPModelLib/src/config.h.in
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef CONFIG_H_
|
||||||
|
#define CONFIG_H_
|
||||||
|
|
||||||
|
#define PRG_VERSION "@PROJECT_VERSION@"
|
||||||
|
|
||||||
|
#endif /* CONFIG_H_ */
|
@ -9,13 +9,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "errors_types.h"
|
#include "RSPModel_errordefs.h"
|
||||||
|
#include "RSPModel_datatypes.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "hob_struct.h"
|
#include "hob_struct.h"
|
||||||
#include "hob_parser.h"
|
#include "hob_parser.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_HOB* hob_struct, T_PROG_OPTIONS* p_opts) {
|
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_RSPMODEL_HOB* hob_struct, T_PROG_OPTIONS* p_opts) {
|
||||||
unsigned char err = NO_ERROR;
|
unsigned char err = NO_ERROR;
|
||||||
long fileSize;
|
long fileSize;
|
||||||
FILE* fStream = NULL;
|
FILE* fStream = NULL;
|
||||||
@ -47,7 +48,7 @@ unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_HOB* hob_struct,
|
|||||||
|
|
||||||
if (hob_struct->obj_count > 0) {
|
if (hob_struct->obj_count > 0) {
|
||||||
// Populate HOB structure with object descriptor
|
// Populate HOB structure with object descriptor
|
||||||
hob_struct->objects = calloc(hob_struct->obj_count, sizeof(T_HOB_OBJECT));
|
hob_struct->objects = calloc(hob_struct->obj_count, sizeof(T_RSPMODEL_OBJECT));
|
||||||
for ( i = 0; i < hob_struct->obj_count; i++ ) {
|
for ( i = 0; i < hob_struct->obj_count; i++ ) {
|
||||||
if (p_opts->debug_mode) printf("\n-=====================-Begin of Object part-======================-\n");
|
if (p_opts->debug_mode) printf("\n-=====================-Begin of Object part-======================-\n");
|
||||||
|
|
||||||
@ -401,7 +402,7 @@ unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_HOB* hob_struct,
|
|||||||
free(offset_index);
|
free(offset_index);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = ERROR_GENERIC;
|
err = RSPLIB_ERROR_GENERIC;
|
||||||
printf("[INFO] Can't process empty file!\n");
|
printf("[INFO] Can't process empty file!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,14 +410,14 @@ unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_HOB* hob_struct,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
fclose(fStream);
|
fclose(fStream);
|
||||||
err = ERROR_MEMORY;
|
err = RSPLIB_ERROR_MEMORY;
|
||||||
if (p_opts->verbose_mode) printf("[ERR] Can't allocate enough memory for file processing!\n");
|
if (p_opts->verbose_mode) printf("[ERR] Can't allocate enough memory for file processing!\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = ERROR_IO;
|
err = RSPLIB_ERROR_IO;
|
||||||
if (p_opts->verbose_mode) printf("[ERR] Input file %s not found!\n", fileName);
|
if (p_opts->verbose_mode) printf("[ERR] Input file %s not found!\n", fileName);
|
||||||
}
|
}
|
||||||
} else err = ERROR_ARGS_NULL;
|
} else err = RSPLIB_ERROR_ARGS_NULL;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
@ -7,12 +7,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "hob_struct.h"
|
#include "RSPModel_datatypes.h"
|
||||||
|
|
||||||
|
|
||||||
#ifndef SRC_HOB_PARSER_H_
|
#ifndef SRC_HOB_PARSER_H_
|
||||||
#define SRC_HOB_PARSER_H_
|
#define SRC_HOB_PARSER_H_
|
||||||
|
|
||||||
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_HOB* hob_struct, T_PROG_OPTIONS* p_opts);
|
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_RSPMODEL_HOB* hob_struct, T_PROG_OPTIONS* p_opts);
|
||||||
|
|
||||||
#endif /* SRC_HOB_PARSER_H_ */
|
#endif /* SRC_HOB_PARSER_H_ */
|
@ -1,12 +1,14 @@
|
|||||||
/*
|
/**
|
||||||
* hob_struct.h
|
* \file hob_struct.h
|
||||||
|
* \date 26/07/2022
|
||||||
|
* \author JackCarterSmith
|
||||||
|
* \copyright GPL-v3.0
|
||||||
|
* \brief HOB file mapping definition.
|
||||||
*
|
*
|
||||||
* Created on: 26 juil. 2022
|
|
||||||
* Author: JackCarterSmith
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SRC_HOB_STRUCT_H_
|
#ifndef RSPMODELLIB_HOB_STRUCT_H_
|
||||||
#define SRC_HOB_STRUCT_H_
|
#define RSPMODELLIB_HOB_STRUCT_H_
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -22,90 +24,6 @@
|
|||||||
#define PACK __attribute__((packed))
|
#define PACK __attribute__((packed))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// HOB file structure
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
typedef unsigned int T_RGBA;
|
|
||||||
|
|
||||||
typedef struct vector3 { float x,y,z; } T_VECTOR3;
|
|
||||||
|
|
||||||
typedef struct vertex { short x,y,z,w; } T_VERTEX;
|
|
||||||
|
|
||||||
typedef struct tex_coord { unsigned short u,v; } T_TEXCOORD;
|
|
||||||
|
|
||||||
typedef struct face_flags {
|
|
||||||
unsigned int fUnknown0:1;
|
|
||||||
unsigned int fUnknown1:1;
|
|
||||||
unsigned int fHasTexture:1;
|
|
||||||
unsigned int fIsQuad:1;
|
|
||||||
unsigned int fSeparateColorVertex:1;
|
|
||||||
unsigned int fHasColor:1;
|
|
||||||
unsigned int fHasExtraBytesBeforeColor:1;
|
|
||||||
unsigned int fUnknown7:1;
|
|
||||||
unsigned int fUnknown8:1;
|
|
||||||
unsigned int fUnknown9:1;
|
|
||||||
unsigned int fUnknown10:1;
|
|
||||||
|
|
||||||
unsigned int reserved:21;
|
|
||||||
} FACE_FLAGS;
|
|
||||||
|
|
||||||
typedef struct hob_face {
|
|
||||||
union {
|
|
||||||
unsigned int flags;
|
|
||||||
FACE_FLAGS flags_bits;
|
|
||||||
};
|
|
||||||
unsigned char b1;
|
|
||||||
unsigned char b2;
|
|
||||||
unsigned char b3;
|
|
||||||
unsigned char bsize;
|
|
||||||
unsigned short material_index;
|
|
||||||
unsigned short indices[4];
|
|
||||||
T_RGBA vertex_colors[4]; //TODO: convert in R:8_G:8_B:8_A:8 format? Caution with BE/LE conversion
|
|
||||||
T_TEXCOORD tex_coords[4];
|
|
||||||
} T_HOB_FACE;
|
|
||||||
|
|
||||||
typedef struct hob_face_group {
|
|
||||||
unsigned int meshdef1_offset;
|
|
||||||
|
|
||||||
unsigned int face_block_end_offset;
|
|
||||||
unsigned int face_block_offset;
|
|
||||||
unsigned int vertex_block_offset;
|
|
||||||
|
|
||||||
unsigned int id;
|
|
||||||
T_VECTOR3 transform;
|
|
||||||
|
|
||||||
unsigned int face_count;
|
|
||||||
T_HOB_FACE* faces;
|
|
||||||
|
|
||||||
unsigned int vertex_count;
|
|
||||||
T_VERTEX* vertices;
|
|
||||||
} T_HOB_FACE_GROUP;
|
|
||||||
|
|
||||||
typedef struct hob_object {
|
|
||||||
char name[16];
|
|
||||||
unsigned int face_group_offset;
|
|
||||||
unsigned int object_part_header_offset;
|
|
||||||
unsigned int face_group_header_offset;
|
|
||||||
|
|
||||||
unsigned int object_part_count;
|
|
||||||
unsigned int face_group_count;
|
|
||||||
|
|
||||||
T_HOB_FACE_GROUP* object_parts;
|
|
||||||
} T_HOB_OBJECT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Model-Extractor HOB structure of an HOB file content.
|
|
||||||
* \details Used with malloc to create a clean method of bufferized
|
|
||||||
* model datas before saving it.
|
|
||||||
* \todo Export format to use it directly in other program.
|
|
||||||
*/
|
|
||||||
typedef struct hob {
|
|
||||||
unsigned int obj_count;
|
|
||||||
T_HOB_OBJECT* objects;
|
|
||||||
} T_HOB;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Declaration of Memory Mapped Structure
|
// Declaration of Memory Mapped Structure
|
||||||
// Caution: the place of variable is important for correct mapping!
|
// Caution: the place of variable is important for correct mapping!
|
||||||
@ -289,4 +207,4 @@ typedef struct PACK hobfile_vertex {
|
|||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* SRC_HOB_STRUCT_H_ */
|
#endif /* RSPMODELLIB_HOB_STRUCT_H_ */
|
Loading…
x
Reference in New Issue
Block a user