1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #ifndef _LOADOBJ_
- #define _LOADOBJ_
- #include <vector>
- #include "vec3.h"
- /* Loads a .obj file (it's a toy parser - it's not complete)
- * gets object's vertices and calculate's its boundbox
- */
- bool loadOBJ(
- const char *path,
- std::vector<vec3> &out_vertices,
- vec3 *bound,
- unsigned char mirror);
- /* Loads a .ply file (it's a toy parser - it's not complete)
- * gets object's vertices and vertex colors and calculate's its boundbox
- * mirror makes the object mirrored on x/y/z
- * x = 0b1 | y = 0b10 | z = 0b100
- */
- bool loadPLY(
- const char *path,
- std::vector<vec3> &out_vertices,
- std::vector<vec3> &out_color,
- vec3 *out_bound,
- unsigned char mirror);
- /* Experiment to improve importing */
- // Hold all data that are extracted by a file (that the game uses)
- struct mesh_data
- {
- unsigned int vcount;
- float *pos;
- float *col;
- vec3 pbound, nbound;
- };
- struct property
- {
- unsigned int flag;
- unsigned char format;
- };
- // Flags of what data to parse
- #define FLG_V_POS_X 1
- #define FLG_V_POS_Y 2
- #define FLG_V_POS_Z 4
- #define FLG_V_POS_MIRROR_X 8
- #define FLG_V_POS_MIRROR_Y 16
- #define FLG_V_POS_MIRROR_Z 32
- #define FLG_V_COL_R 64
- #define FLG_V_COL_G 128
- #define FLG_V_COL_B 256
- #define FLG_F_VINDICES 512
- //Formats
- #define PLY_UNSUPPORTED 0
- #define PLY_CHAR 1
- #define PLY_UCHAR 2
- #define PLY_SHORT 3
- #define PLY_USHORT 4
- #define PLY_INT 5
- #define PLY_UINT 6
- #define PLY_FLOAT 7
- #define PLY_DOUBLE 8
- /* Load a .ply file, and return a struct with mesh data
- * path is filepath
- * flags declare what data to parse and how (mirroring)
- */
- mesh_data *loadPly(const char *path, int flags);
- unsigned char form_to_num( char *format );
- unsigned int flag_to_num( char *flag );
- char *flagstr( unsigned int flag );
- char *formatstr( char format );
- #endif
|