1 /*
2 Copyright (C) 2003 Cedric Cellier, Dominique Lavault
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 */
18 #ifndef DATA_H
19 #define DATA_H
20 #include "opengl.h"
21 #include "hash.h"
22 #include "slist.h"
23 #include "system.h"
24 
25 /* position */
26 
27 #define NB_MAX_SUBPOSITION 30 //6	/* TODO : fix root so that its no more used nor loaded */
28 #define NB_MAX_MESHES_IN_POSITION 16
29 struct mesh_s;
30 
31 struct position_s {
32 	GLfloat c[16];
33 	struct position_s *relative_to;
34 	unsigned nb_sons;
35 	char *name;
36 	unsigned nb_meshes;
37 	struct mesh_s *meshes[NB_MAX_MESHES_IN_POSITION];
38 	struct position_s *sons[NB_MAX_SUBPOSITION];
39 };
40 typedef struct position_s position;
41 
42 /* primitive */
43 
44 #define ROT_X_45 1
45 #define ROT_X_90 2
46 #define ROT_Y_45 4
47 #define ROT_Y_90 8
48 #define ROT_Z_45 16
49 #define ROT_Z_90 32
50 
51 /* meshes */
52 
53 typedef struct {
54 	char *name;
55 	GLuint binding;
56 } texture;
57 
58 struct primitive_s {
59 	unsigned nb_points, nb_faces;
60 	GLfloat *points, *norms;
61 	GLuint *faces;
62 	unsigned nb_points_light, nb_faces_light;
63 	GLfloat *points_light, *norms_light;
64 	GLuint *faces_light;
65 	unsigned symmetry;	/* combinaison of ROTs */
66 	float size_x, size_y, size_z;
67 	char *name;
68 };
69 typedef struct primitive_s primitive;
70 extern GLTV_HASH enigm_meshes;	/* meshes usables for csg */
71 
72 typedef struct {
73 	GLfloat *c;
74 	char *name;
75 } uv_coords;
76 
77 /* severall instance of a mesh can be created, in wich case coord_uv, prims, name & texture, are merged, and position cleared */
78 struct mesh_s {
79 	texture *texture;
80 	primitive *prim;	/* c'est l� dessus que se fait la gestion d'evenements */
81 	uv_coords *uv_coord;
82 	position *pos;
83 	char *name;
84 };
85 typedef struct mesh_s mesh;
86 
87 /* enigms */
88 
89 typedef struct {
90 	unsigned nb_bricks;
91 	mesh **bricks;
92 	char *solution;
93 	GLfloat (*solution_pos)[16];
94 	unsigned score;
95 	char *name;
96 	struct csg_node_s *root;
97 } enigm;
98 
99 extern GLTV_SLIST enigms, editable_enigms;	/* sorted by score */
100 
101 /* calls */
102 
103 extern void data_read_all();
104 extern void data_read_userland();
105 extern texture *data_load_texture(const char *);
106 extern mesh *data_load_mesh(const char *, int);
107 extern void data_bind_mesh(position *, mesh *);
108 extern position *data_get_named_position(const char *);
109 extern primitive *data_load_primitive(const char *, int);
110 extern enigm *data_enigm_full_new(char *);
111 extern void data_enigm_finalize(enigm *, char *);
112 extern void data_enigm_save(enigm *);
113 extern void data_enigm_add(enigm *);
114 extern void data_enigm_del(enigm *);
115 extern enigm *data_load_enigm(const char *);
116 
117 #endif
118