Final review
This commit is contained in:
parent
12d7409767
commit
f2dc04a991
4
Jenkinsfile
vendored
4
Jenkinsfile
vendored
@ -44,10 +44,10 @@ pipeline {
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
dir("zip_linux") {
|
||||
sh 'cp -R ../linux/build/bin ../linux/build/lib ../linux/RSPTerrainLib/include .'
|
||||
sh 'cp -R ../linux/build/bin ../linux/build/lib ../linux/RSPModelLib/include .'
|
||||
}
|
||||
dir("zip_win") {
|
||||
sh 'cp -R ../windows/build/bin ../windows/build/lib ../windows/RSPTerrainLib/include .'
|
||||
sh 'cp -R ../windows/build/bin ../windows/build/lib ../windows/RSPModelLib/include .'
|
||||
}
|
||||
zip archive: false, dir: 'zip_linux', exclude: '', glob: '', zipFile: 'linux_x64.zip'
|
||||
sh 'mv linux_x64.zip ${CI_OUTPUT_NAME}_${CI_VERSION}.${BUILD_NUMBER}_Linux_x86_64.zip'
|
||||
|
@ -19,8 +19,7 @@
|
||||
#include "options.h"
|
||||
#include <RSPModel.h>
|
||||
#include <RSPModel_errordefs.h>
|
||||
#include "obj_exporter.h"
|
||||
|
||||
#include "model_export.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -29,8 +28,7 @@
|
||||
|
||||
static unsigned int mainProcess(int args_cnt, char* args_value[], T_PROG_OPTIONS* opt_ptr);
|
||||
static void createSubDir(char *dirName);
|
||||
static unsigned char checkInputArgs(T_PROG_OPTIONS* opt_ptr, int p_arg_nbr, char* p_args[]);
|
||||
static void cleanUpMemory(T_RSPMODEL_HOB* hobStruct);
|
||||
static unsigned short checkInputArgs(T_PROG_OPTIONS* opt_ptr, int p_arg_nbr, char* p_args[]);
|
||||
static void dispHelp();
|
||||
|
||||
|
||||
@ -42,7 +40,7 @@ int main(int argc, char *argv[]) {
|
||||
unsigned char p;
|
||||
|
||||
// Hello world!
|
||||
printf("\n*** RogueSquadron Extractor (RSE) - MODEL module - RSPModelLib v%s ***\n", RSPModel_getVersion());
|
||||
printf("\n*~[ Rogue Squadron Extractor (RSE) - RSPModelLib v%s ]~*\n", RSPModel_getVersion());
|
||||
|
||||
// Check for arguments
|
||||
if (argc < 2) {
|
||||
@ -76,32 +74,37 @@ static unsigned int mainProcess(int args_cnt, char* args_value[], T_PROG_OPTIONS
|
||||
for ( file_index = p_opts->input_files_cnt; file_index < args_cnt; file_index++)
|
||||
{
|
||||
printf("\n=============================================\n[INFO] - Parsing file: %s ...\n", args_value[file_index]);
|
||||
|
||||
// Allocate T_RSPMODEL_HOB structure to store extracted datas.
|
||||
hobStruct = calloc(1, sizeof(T_RSPMODEL_HOB));
|
||||
// Parse data from HOB file and put in T_HOB structure.
|
||||
if (RSPModel_processHOBFile(hobStruct, args_value[file_index], libParams) != RSPLIB_SUCCESS) {
|
||||
printf("[ERR] Failed to parse datas from %s\n", args_value[file_index]);
|
||||
free(hobStruct);
|
||||
return RSPLIB_ERROR_PROCESS;
|
||||
}
|
||||
if (hobStruct) {
|
||||
// Parse data from HOB file and put in T_RSPMODEL_HOB structure.
|
||||
if (RSPModel_processHOBFile(hobStruct, args_value[file_index], libParams) != RSPLIB_SUCCESS) {
|
||||
printf("[ERR] Failed to parse datas from %s\n", args_value[file_index]);
|
||||
RSPModel_freeHOB(hobStruct);
|
||||
return RSPLIB_ERROR_PROCESS;
|
||||
}
|
||||
} else return RSPLIB_ERROR_MEMORY;
|
||||
|
||||
if (hobStruct->obj_count > 0) {
|
||||
// Create output folders structure.
|
||||
if (p_opts->output_dir) createSubDir(args_value[file_index]);
|
||||
|
||||
for ( i = 0; i < hobStruct->obj_count; i++ ) {
|
||||
if (exportOBJModel(&(hobStruct->objects[i]), args_value[file_index], p_opts) != RSPLIB_SUCCESS)
|
||||
printf("[ERR] Failed to export %s object in OBJ format!\n", hobStruct->objects[i].name);
|
||||
else
|
||||
if (exportOBJModel(&(hobStruct->objects[i]), args_value[file_index], p_opts) == RSPLIB_SUCCESS)
|
||||
printf("[INFO] Successfully exported %s object in OBJ format.\n", hobStruct->objects[i].name);
|
||||
else
|
||||
printf("[ERR] Failed to export %s object in OBJ format!\n", hobStruct->objects[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanUpMemory(hobStruct);
|
||||
RSPModel_freeHOB(hobStruct);
|
||||
|
||||
return RSPLIB_SUCCESS;
|
||||
}
|
||||
|
||||
static unsigned char checkInputArgs(T_PROG_OPTIONS* opt_ptr, int p_arg_nbr, char* p_args[]) {
|
||||
static unsigned short checkInputArgs(T_PROG_OPTIONS* opt_ptr, int p_arg_nbr, char* p_args[]) {
|
||||
char test[256];
|
||||
int i;
|
||||
|
||||
@ -159,23 +162,6 @@ static void createSubDir(char *dirName) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cleanUpMemory(T_RSPMODEL_HOB* hobStruct) {
|
||||
int i,j;
|
||||
|
||||
for ( i=0; i<hobStruct->obj_count; i++ ) {
|
||||
for ( j=0; j<hobStruct->objects[i].face_group_count; j++ ) {
|
||||
|
||||
free(hobStruct->objects[i].object_parts[j].faces);
|
||||
free(hobStruct->objects[i].object_parts[j].vertices);
|
||||
}
|
||||
|
||||
free(hobStruct->objects[i].object_parts);
|
||||
}
|
||||
|
||||
free(hobStruct->objects);
|
||||
free(hobStruct);
|
||||
}
|
||||
|
||||
static void dispHelp() {
|
||||
printf("\n");
|
||||
printf("Options:\n -h Print this message\n");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file obj_exporter.c
|
||||
* @file model_export.c
|
||||
* @date 27/07/2022
|
||||
* @author JackCarterSmith
|
||||
* @copyright GPL-v3.0
|
||||
@ -14,11 +14,11 @@
|
||||
#include <RSPModel_datatypes.h>
|
||||
#include <RSPModel_errordefs.h>
|
||||
#include "obj/obj.h"
|
||||
#include "obj_exporter.h"
|
||||
#include "model_export.h"
|
||||
|
||||
|
||||
unsigned char exportOBJModel(T_RSPMODEL_OBJECT* hob_objects, const char *out_path, T_PROG_OPTIONS* p_opts) {
|
||||
char exportPath[1024];
|
||||
char export_path[1024];
|
||||
char objExport_name[128];
|
||||
char mtlExport_name[128];
|
||||
obj* objConstruct = NULL;
|
||||
@ -32,9 +32,9 @@ unsigned char exportOBJModel(T_RSPMODEL_OBJECT* hob_objects, const char *out_pat
|
||||
return RSPLIB_ERROR_ARGS_NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
snprintf(exportPath, 1024, "%s-out\\", out_path);
|
||||
snprintf(export_path, 1024, "%s-out\\", out_path);
|
||||
#else
|
||||
snprintf(exportPath, 1024, "%s-out/", out_path);
|
||||
snprintf(export_path, 1024, "%s-out/", out_path);
|
||||
#endif
|
||||
snprintf(objExport_name, 128, "%s.obj", hob_objects->name);
|
||||
snprintf(mtlExport_name, 128, "%s.mtl", hob_objects->name);
|
||||
@ -101,12 +101,12 @@ unsigned char exportOBJModel(T_RSPMODEL_OBJECT* hob_objects, const char *out_pat
|
||||
|
||||
if (p_opts->export_mtl) {
|
||||
if (p_opts->output_dir)
|
||||
obj_write(objConstruct, objExport_name, mtlExport_name, exportPath, 8);
|
||||
obj_write(objConstruct, objExport_name, mtlExport_name, export_path, 8);
|
||||
else
|
||||
obj_write(objConstruct, objExport_name, mtlExport_name, NULL, 8);
|
||||
} else {
|
||||
if (p_opts->output_dir)
|
||||
obj_write(objConstruct, objExport_name, NULL, exportPath, 8);
|
||||
obj_write(objConstruct, objExport_name, NULL, export_path, 8);
|
||||
else
|
||||
obj_write(objConstruct, objExport_name, NULL, NULL, 8);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file obj_exporter.h
|
||||
* @file model_export.h
|
||||
* @date 27/07/2022
|
||||
* @author JackCarterSmith
|
||||
* @copyright GPL-v3.0
|
||||
@ -7,8 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SRC_OBJ_EXPORTER_H_
|
||||
#define SRC_OBJ_EXPORTER_H_
|
||||
#ifndef MODEL_EXPORT_H_
|
||||
#define MODEL_EXPORT_H_
|
||||
|
||||
|
||||
typedef struct t_material {
|
||||
@ -19,4 +19,4 @@ typedef struct t_material {
|
||||
|
||||
unsigned char exportOBJModel(T_RSPMODEL_OBJECT* hob_objects, const char *out_path, T_PROG_OPTIONS* p_opts);
|
||||
|
||||
#endif /* SRC_OBJ_EXPORTER_H_ */
|
||||
#endif /* MODEL_EXPORT_H_ */
|
@ -20,7 +20,7 @@ typedef union u_prog_options {
|
||||
unsigned char output_dir:1; //!< Export extracted datas to a sub-directory.
|
||||
unsigned char export_mtl:1; //!< Export materials datas with object.
|
||||
|
||||
unsigned short reserved0:11; //!< For future use.
|
||||
unsigned short reserved0:11; //!< For future use.
|
||||
|
||||
unsigned short input_files_cnt; //!< Internal files counters.
|
||||
};
|
||||
|
@ -114,6 +114,12 @@ RSPMODEL_EXTERN unsigned short RSPModel_objectToD3D(
|
||||
const T_RSPMODEL_OBJECT* objStruct, void* D3DObj
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Clean HOB object and it's childrens from memory.
|
||||
* @param[in] hobStruct Pointer to data to be cleaned up.
|
||||
*/
|
||||
RSPMODEL_EXTERN void RSPModel_freeHOB( T_RSPMODEL_HOB* hobStruct );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -7,11 +7,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "RSPModel_errordefs.h"
|
||||
#include "RSPModel_datatypes.h"
|
||||
#include "hob_parser.h"
|
||||
#include "RSPModel.h"
|
||||
|
||||
@ -55,3 +56,28 @@ unsigned short RSPModel_objectToD3D( const T_RSPMODEL_OBJECT* objStruct, void* D
|
||||
|
||||
return RSPLIB_SUCCESS;
|
||||
}
|
||||
|
||||
void RSPModel_freeHOB( T_RSPMODEL_HOB* hobStruct ) {
|
||||
int i,j;
|
||||
|
||||
if (hobStruct == NULL) return;
|
||||
|
||||
if (hobStruct->objects) {
|
||||
for ( i=0; i<hobStruct->obj_count; i++ ) {
|
||||
if (hobStruct->objects[i].object_parts) {
|
||||
for ( j=0; j<hobStruct->objects[i].face_group_count; j++ ) {
|
||||
|
||||
if (hobStruct->objects[i].object_parts[j].faces)
|
||||
free(hobStruct->objects[i].object_parts[j].faces);
|
||||
|
||||
if (hobStruct->objects[i].object_parts[j].vertices)
|
||||
free(hobStruct->objects[i].object_parts[j].vertices);
|
||||
}
|
||||
free(hobStruct->objects[i].object_parts);
|
||||
}
|
||||
}
|
||||
free(hobStruct->objects);
|
||||
}
|
||||
|
||||
free(hobStruct);
|
||||
}
|
||||
|
@ -20,18 +20,18 @@
|
||||
// Private functions declarations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static unsigned int ExtractObjects(T_RSPMODEL_HOB*, const MEMFILE, const RSPMODEL_PARAMETERS*);
|
||||
static unsigned int ExtractObjParts(T_RSPMODEL_OBJECT*, const MEMFILE, const RSPMODEL_PARAMETERS*);
|
||||
static unsigned int ExtractObjParts_faces(T_RSPMODEL_OBJ_PARTS*, const MEMFILE, const RSPMODEL_PARAMETERS*);
|
||||
static inline unsigned int ExtractObjpart_Face_Colors(T_RSPMODEL_FACE*, const char*);
|
||||
static inline unsigned int ExtractObjpart_Face_UVMaps(T_RSPMODEL_FACE*, const char*);
|
||||
static unsigned short ExtractObjects(T_RSPMODEL_HOB*, const MEMFILE, const RSPMODEL_PARAMETERS*);
|
||||
static unsigned short ExtractObjParts(T_RSPMODEL_OBJECT*, const MEMFILE, const RSPMODEL_PARAMETERS*);
|
||||
static unsigned short ExtractObjParts_faces(T_RSPMODEL_OBJ_PARTS*, const MEMFILE, const RSPMODEL_PARAMETERS*);
|
||||
static unsigned short ExtractObjpart_Face_Colors(T_RSPMODEL_FACE*, const char*);
|
||||
static unsigned short ExtractObjpart_Face_UVMaps(T_RSPMODEL_FACE*, const char*);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Public functions definition
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
unsigned char RSP_ModelLib_ParseHOBMemFile(const MEMFILE pMemFile, T_RSPMODEL_HOB* hobStruct, const RSPMODEL_PARAMETERS* pParams) {
|
||||
unsigned short RSP_ModelLib_ParseHOBMemFile(const MEMFILE pMemFile, T_RSPMODEL_HOB* hobStruct, const RSPMODEL_PARAMETERS* pParams) {
|
||||
unsigned char err = RSPLIB_SUCCESS;
|
||||
|
||||
if (hobStruct != NULL && pMemFile != NULL) {
|
||||
@ -42,7 +42,7 @@ unsigned char RSP_ModelLib_ParseHOBMemFile(const MEMFILE pMemFile, T_RSPMODEL_HO
|
||||
return err;
|
||||
}
|
||||
|
||||
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_RSPMODEL_HOB* hobStruct, const RSPMODEL_PARAMETERS* pParams) {
|
||||
unsigned short RSP_ModelLib_ParseHOBFile(const char* fileName, T_RSPMODEL_HOB* hobStruct, const RSPMODEL_PARAMETERS* pParams) {
|
||||
unsigned char err = RSPLIB_SUCCESS;
|
||||
long fileSize;
|
||||
FILE* fStream = NULL;
|
||||
@ -94,11 +94,11 @@ unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName, T_RSPMODEL_HOB* ho
|
||||
*
|
||||
* @param[in|out] pHobStruct Take root hob structure to get the T_RSPMODEL_OBJECT buffer and header datas.
|
||||
* @param[in] pMemfile Pointer to an in-memory file location.
|
||||
* @param[in] verbose
|
||||
* @param[in] pParams Program option, used to tune parser features.
|
||||
*
|
||||
* @return Error code, RSPLIB_SUCCESS when no error.
|
||||
*/
|
||||
static unsigned int ExtractObjects(T_RSPMODEL_HOB* pHobStruct, const MEMFILE pMemfile, const RSPMODEL_PARAMETERS* pParams) {
|
||||
static unsigned short ExtractObjects(T_RSPMODEL_HOB* pHobStruct, const MEMFILE pMemfile, const RSPMODEL_PARAMETERS* pParams) {
|
||||
unsigned int i;
|
||||
|
||||
if (pHobStruct == NULL || pMemfile == NULL) return RSPLIB_ERROR_ARGS_NULL;
|
||||
@ -167,11 +167,11 @@ static unsigned int ExtractObjects(T_RSPMODEL_HOB* pHobStruct, const MEMFILE pMe
|
||||
*
|
||||
* @param[in|out] pObject Take object structure to get the T_RSPMODEL_OBJ_PARTS buffer and object datas.
|
||||
* @param[in] pMemfile Pointer to an in-memory file location.
|
||||
* @param[in] verbose
|
||||
* @param[in] pParams Program option, used to tune parser features.
|
||||
*
|
||||
* @return Error code, RSPLIB_SUCCESS when no error.
|
||||
*/
|
||||
static unsigned int ExtractObjParts(T_RSPMODEL_OBJECT* pObject, const MEMFILE pMemfile, const RSPMODEL_PARAMETERS* pParams) {
|
||||
static unsigned short ExtractObjParts(T_RSPMODEL_OBJECT* pObject, const MEMFILE pMemfile, const RSPMODEL_PARAMETERS* pParams) {
|
||||
unsigned int i, subpart_offset = 0;
|
||||
|
||||
if (pObject == NULL || pMemfile == NULL) return RSPLIB_ERROR_ARGS_NULL;
|
||||
@ -248,11 +248,11 @@ static unsigned int ExtractObjParts(T_RSPMODEL_OBJECT* pObject, const MEMFILE pM
|
||||
*
|
||||
* @param[in|out] pObjPart Take object sub-part structure to get the T_RSPMODEL_FACE buffer and object sub-part datas.
|
||||
* @param[in] pMemfile Pointer to an in-memory file location.
|
||||
* @param[in] verbose
|
||||
* @param[in] pParams Program option, used to tune parser features.
|
||||
*
|
||||
* @return Error code, RSPLIB_SUCCESS when no error.
|
||||
*/
|
||||
static unsigned int ExtractObjParts_faces(T_RSPMODEL_OBJ_PARTS* pObjPart, const MEMFILE pMemfile, const RSPMODEL_PARAMETERS* pParams) {
|
||||
static unsigned short ExtractObjParts_faces(T_RSPMODEL_OBJ_PARTS* pObjPart, const MEMFILE pMemfile, const RSPMODEL_PARAMETERS* pParams) {
|
||||
unsigned int i, facesExtraOffset = 0;
|
||||
|
||||
if (pObjPart == NULL || pMemfile == NULL) return RSPLIB_ERROR_ARGS_NULL;
|
||||
@ -390,7 +390,7 @@ static unsigned int ExtractObjParts_faces(T_RSPMODEL_OBJ_PARTS* pObjPart, const
|
||||
*
|
||||
* @return The size of processed data. Used to count new offset between each face in object sub-part.
|
||||
*/
|
||||
static inline unsigned int ExtractObjpart_Face_Colors(T_RSPMODEL_FACE* pFace, const char* pFaceMemFileOffset) {
|
||||
static unsigned short ExtractObjpart_Face_Colors(T_RSPMODEL_FACE* pFace, const char* pFaceMemFileOffset) {
|
||||
unsigned int dynOffset = 0;
|
||||
|
||||
if (pFace->flags_bits.fSeparateColorVertex) {
|
||||
@ -423,7 +423,7 @@ static inline unsigned int ExtractObjpart_Face_Colors(T_RSPMODEL_FACE* pFace, co
|
||||
*
|
||||
* @return The size of processed data. Used to count new offset between each face in object sub-part.
|
||||
*/
|
||||
static inline unsigned int ExtractObjpart_Face_UVMaps(T_RSPMODEL_FACE* pFace, const char* pFaceMemFileOffset) {
|
||||
static unsigned short ExtractObjpart_Face_UVMaps(T_RSPMODEL_FACE* pFace, const char* pFaceMemFileOffset) {
|
||||
unsigned int dynOffset = 0;
|
||||
|
||||
pFace->tex_coords[0] = ((T_HOBFILE_FACES_VERTEX_TEXTURE *)(pFaceMemFileOffset))->v1_texcoord;
|
||||
|
@ -26,7 +26,7 @@
|
||||
*
|
||||
* @return Processing error code, RSPLIB_SUCCESS if no error.
|
||||
*/
|
||||
unsigned char RSP_ModelLib_ParseHOBMemFile(const MEMFILE pMemFile,
|
||||
unsigned short RSP_ModelLib_ParseHOBMemFile(const MEMFILE pMemFile,
|
||||
T_RSPMODEL_HOB* hobStruct, const RSPMODEL_PARAMETERS* pParams);
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ unsigned char RSP_ModelLib_ParseHOBMemFile(const MEMFILE pMemFile,
|
||||
*
|
||||
* @return Processing error code, RSPLIB_SUCCESS if no error.
|
||||
*/
|
||||
unsigned char RSP_ModelLib_ParseHOBFile(const char* fileName,
|
||||
unsigned short RSP_ModelLib_ParseHOBFile(const char* fileName,
|
||||
T_RSPMODEL_HOB* hobStruct, const RSPMODEL_PARAMETERS* pParams);
|
||||
|
||||
#endif /* RSPMODELLIB_HOB_PARSER_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user