1 /*
2   Pacman Arena
3   Copyright (C) 2003 Nuno Subtil
4 
5   This program is free software; you can redistribute it and/or
6   modify it under the terms of the GNU General Public License
7   as published by the Free Software Foundation; either version 2
8   of the License, or (at your option) any later version.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19 
20 /* $Id: object.h,v 1.2 2003/11/22 17:32:10 nsubtil Exp $ */
21 
22 #ifndef _OBJECT_H
23 #define _OBJECT_H
24 
25 #define X 0
26 #define Y 1
27 #define Z 2
28 #define W 3
29 
30 #define R 0
31 #define G 1
32 #define B 2
33 #define A 3
34 
35 struct face_tri
36 {
37 	/* v�rtices */
38 	float *a, *b, *c;
39 	/* normais */
40 	float na[3], nb[3], nc[3];
41 
42 	/* cor da face */
43 	float color[4];
44 	/* tag de cor */
45 	int color_tag;
46 };
47 
48 struct object
49 {
50 	/* num de faces */
51 	int num_fc;
52 	/* lista de faces */
53 	struct face_tri **fc_list;
54 
55 	/* display list deste objecto para pol�gonos de cor fixa*/
56 	GLuint dlist_color;
57 	/* pol�gonos de cor vari�vel */
58 	GLuint dlist_nocolor;
59 
60 	struct object *next;
61 };
62 
63 /* caches */
64 struct ocache_entry
65 {
66 	char *name;
67 	struct object *objs;
68 	int n_objs;
69 
70 	struct ocache_entry *next;
71 };
72 
73 int object_hash_vertex(float vx[3]);
74 int object_hash_face(struct face_tri *face);
75 void object_add_face(struct object *obj, struct face_tri *face);
76 struct object *object_cache_find_file(char *fname, int *n_objs);
77 void object_cache_add_file(char *fname, struct object *objs, int n_objs);
78 int object_face_equal(struct face_tri *f1, struct face_tri *f2);
79 int object_get_vertex_index(float **vx_list, int num_vx, float vec[3]);
80 int object_get_face_index(struct face_tri **fc_list, int num_fc, struct face_tri *fc);
81 void object_write_file(char *fname, struct object *objs, int n_objs);
82 struct object *object_read_file(char *fname, int *n_objs);
83 void object_release_dlists(void);
84 void object_recompile_dlists(void);
85 
86 #endif
87