Structure for exporting
This commit is contained in:
parent
e5b3058999
commit
e0c9f2c7d8
@ -23,8 +23,8 @@ include(CheckCSourceCompiles)
|
||||
|
||||
# needed packages
|
||||
|
||||
find_package(GLEW REQUIRED)
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
#find_package(GLEW REQUIRED)
|
||||
#include_directories(${GLEW_INCLUDE_DIR})
|
||||
|
||||
# define src/headers files
|
||||
|
||||
@ -45,7 +45,7 @@ if(MSVC)
|
||||
set_target_properties(rse-model PROPERTIES PREFIX "lib")
|
||||
set_target_properties(rse-model PROPERTIES IMPORT_PREFIX "lib")
|
||||
endif()
|
||||
target_link_libraries(rse-model ${GLEW_LIBRARIES})
|
||||
target_link_libraries(rse-model m)
|
||||
|
||||
# add GPG signature command
|
||||
#add_custom_command(
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "options.h"
|
||||
#include "hob_struct.h"
|
||||
#include "hob_parser.h"
|
||||
//#include "rlk/obj.h"
|
||||
#include "obj_exporter.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -72,6 +72,7 @@ int main(int argc, char *argv[]) {
|
||||
static unsigned int mainProcess(int args_cnt, char *args_value[]) {
|
||||
unsigned short file_index;
|
||||
T_HOB* hobStruct = NULL;
|
||||
int i;
|
||||
|
||||
// Manage multiple inputs files
|
||||
for (file_index=(_options >> 8) & 0xFF; file_index < args_cnt; file_index++)
|
||||
@ -84,16 +85,21 @@ static unsigned int mainProcess(int args_cnt, char *args_value[]) {
|
||||
free(hobStruct);
|
||||
return ERROR_PROCESS;
|
||||
}
|
||||
|
||||
if (hobStruct->obj_count > 0) {
|
||||
if (_options & OUTPUT_DIR) createSubDir(args_value[file_index]);
|
||||
|
||||
for ( i = 0; i < hobStruct->obj_count; i++ ) {
|
||||
if (exportOBJModel(&(hobStruct->objects[i]), args_value[file_index]) != NO_ERROR)
|
||||
printf("[ERR] Failed to export %s object in OBJ format!\n", hobStruct->objects[i].name);
|
||||
else
|
||||
printf("[INFO] Successfully exported %s object in OBJ format.\n", hobStruct->objects[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanUpMemory(hobStruct);
|
||||
|
||||
|
||||
/*
|
||||
if (exportTextures(hmt_fdatas, argv[file_index]) == EXIT_FAILURE) return EXIT_FAILURE;
|
||||
purgeHMTFromMemory(hmt_fdatas); // Clean up memory (because I'm a good boy)
|
||||
*/
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ typedef struct hob_face_group {
|
||||
} T_HOB_FACE_GROUP;
|
||||
|
||||
typedef struct hob_object {
|
||||
unsigned char name[16];
|
||||
char name[16];
|
||||
unsigned int face_group_offset;
|
||||
unsigned int face_group_header_offset;
|
||||
unsigned int face_group_header2_offset;
|
||||
|
46
src/obj_exporter.c
Normal file
46
src/obj_exporter.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* obj_exporter.c
|
||||
*
|
||||
* Created on: 27 juil. 2022
|
||||
* Author: JackCarterSmith
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "errors_types.h"
|
||||
#include "options.h"
|
||||
#include "hob_struct.h"
|
||||
#include "rlk/obj.h"
|
||||
#include "obj_exporter.h"
|
||||
|
||||
|
||||
unsigned char exportOBJModel(T_HOB_OBJECT* hob_objects, const char *out_path) {
|
||||
char export_path[128];
|
||||
obj* objConstruct = NULL;
|
||||
|
||||
if (hob_objects == NULL || out_path == NULL)
|
||||
return ERROR_ARGS_NULL;
|
||||
|
||||
if (_options & OUTPUT_DIR) {
|
||||
strcpy(export_path, out_path);
|
||||
#ifdef _WIN32
|
||||
strcat(export_path, "-out\\");
|
||||
#else
|
||||
strcat(export_path, "-out/");
|
||||
#endif
|
||||
strcat(export_path, hob_objects->name);
|
||||
} else {
|
||||
strcpy(export_path, hob_objects->name);
|
||||
}
|
||||
strcat(export_path, ".obj");
|
||||
|
||||
objConstruct = obj_create(NULL);
|
||||
|
||||
//TODO: Write datas to obj file!
|
||||
|
||||
obj_write(objConstruct, hob_objects->name, export_path, 8);
|
||||
obj_delete(objConstruct);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
13
src/obj_exporter.h
Normal file
13
src/obj_exporter.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* obj_exporter.h
|
||||
*
|
||||
* Created on: 27 juil. 2022
|
||||
* Author: JackCarterSmith
|
||||
*/
|
||||
|
||||
#ifndef SRC_OBJ_EXPORTER_H_
|
||||
#define SRC_OBJ_EXPORTER_H_
|
||||
|
||||
unsigned char exportOBJModel(T_HOB_OBJECT* hob_objects, const char *out_path);
|
||||
|
||||
#endif /* SRC_OBJ_EXPORTER_H_ */
|
Loading…
x
Reference in New Issue
Block a user