/* Project Ovejota, by Alejandro Valenzuela Roca (lanjoe9 mexinetica com) http://mexinetica.com/~lanjoe9/proyectos/ovejota Project Ovejota is an attempt to produce a free (as in freedom) library capable of viewing .OBJ files using OpenGL drawing instructions in C, for use in free software projects. This file is part of Project Ovejota. Project Ovejota is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. Project Ovejota is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License (LICENSE.TXT) along with this program. If not, please see . This program was made possible by documentation found in: http://people.scs.fsu.edu/~burkardt/txt/obj_format.txt */ #ifndef OVEJOTA_H #define OVEJOTA_H #include "support.h" #include "data_structs.h" #include "textures.h" #ifndef NINTENDO_DS #ifndef NINTENDO_WII // FIXME: FTBFS in Nintendo DS #ifdef VISUAL_STUDIO #include #endif #include #include #include #include enum parse_status{PARSE_NEUTRAL, PARSE_MTLLIB, PARSE_ELEMENT, PARSE_VERTEX, PARSE_TEXV, PARSE_NORMAL, PARSE_COMMENT, PARSE_WHITESPACE, PARSE_INT, PARSE_FLOAT, PARSE_NAME, PARSE_FACE, PARSE_KA, PARSE_KD, PARSE_KS, PARSE_D, PARSE_TR, PARSE_NS, PARSE_ILLUM, PARSE_MAP_KA, PARSE_MODEL, PARSE_OBJ, PARSE_PATH, PARSE_ITEM, PARSE_MODELCONFIG}; enum ovejota_actions{DRAW_FACELIST,CHANGE_MTL}; enum ovejota_clones{OVJ3D_ANY_CLONE, OVJ3D_MODEL, OVJ3D_OBJ, OVJ3D_PK3, OVJ3D_ITEM, OVJ3D_CHARACTER}; typedef struct{ vector3 * v; vector2 * vt; vector3 * vn; } ovj3d_face_data; typedef struct { list_header face_data; } ovj3d_face; typedef struct { int ID; list_header groups; list_header vertices; list_header normals; list_header faces; list_header texvs; list_header instructions; list_header materials; char * mtllib; char * path; char * resource_path; vector3 bb[3]; float bsradius; char bsradius_axis; } ovj3d_obj; typedef struct{ ovejota_clones type; ovj3d_obj * obj; char * model_name; char * alias; //ovj3d_pk3 * pk3; vector3 pos; vector3 rot; vector3 scale; } ovj3d_clone; typedef struct{ char * name; vector3 ka; vector3 kd; vector3 ks; float d; float tr; float ns; int illum; char * map_ka; GLuint gl_texture; //bool has_gl_texture; } ovj3d_mtl; #define OVJ_MAX_LINE_LENGTH 1024 #define MTL_ka_def 0.55 #define MTL_kd_def 0.8 #define MTL_ks_def 1.0 #define MTL_d_def 1.0 #define MTL_tr_def 1.0 #define MTL_ns_def 0.0 #define MTL_illum_def 1 void load_clone_file(char * path, list_header * clones); int draw_obj(ovj3d_obj * obj, bool normals); void init_obj(ovj3d_obj * obj); void load_obj_from_file(ovj3d_obj * obj); //void paint_face(ovj3d_face &f); int parse_obj_line(char * line, ovj3d_obj * obj); //void ideal_viewer_pos(ovj3d_obj & obj, vector3 * viewer); ovj3d_mtl * ovj3d_new_mtl(char * name); int parse_mtl_line(char * line, ovj3d_obj * obj, ovj3d_mtl ** current_mtl); int link_obj_instructions(ovj3d_obj * obj); ovj3d_mtl * ovj3d_mtl_by_name(char * name, list_header * materials); int load_obj_textures(ovj3d_obj * obj); void init_clone(ovj3d_clone * clone); ovj3d_clone * parse_clone_line(char * line, ovj3d_clone * clone); void link_clones_to_models(list_header * clones); ovj3d_clone * find_clone_by_name(char * name, ovejota_clones type, list_header * clones); //int link_clones(); void calculateBB_BS(vector3 * bb, float * bsradius, char * bsradius_axis); #endif #else #include #endif #endif