2 goat3d - 3D scene, and animation file format library.
3 Copyright (C) 2013-2023 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef GOAT3D_SCENE_H_
19 #define GOAT3D_SCENE_H_
21 #include "cgmath/cgmath.h"
53 struct material_attrib {
59 struct goat3d_material {
62 struct material_attrib *attrib; /* dynarr */
66 #define OBJECT_COMMON \
80 struct goat3d_material *mtl;
87 cgm_vec4 *skin_weights;
91 struct goat3d_node **bones;
100 cgm_vec3 dir; /* for LTYPE_DIR */
101 float inner_cone, outer_cone; /* for LTYPE_SPOT */
104 struct goat3d_camera {
108 float near_clip, far_clip;
114 enum goat3d_node_type type;
119 /* local transformation */
122 /* values from animation evaluation, take precedence over the above if
125 cgm_vec3 apos, ascale;
128 /* matrix computed from the above*/
132 struct goat3d_node *parent;
133 struct goat3d_node *child;
134 struct goat3d_node *next;
146 struct goat3d_material **materials;
147 struct goat3d_mesh **meshes;
148 struct goat3d_light **lights;
149 struct goat3d_camera **cameras;
150 struct goat3d_node **nodes;
151 struct goat3d_anim **anims;
157 unsigned int namecnt[7];
161 extern int goat3d_log_level;
163 /* defined in goat3d.c, declared here to keep them out of the public API */
164 int goat3d_init(struct goat3d *g);
165 void goat3d_destroy(struct goat3d *g);
167 void goat3d_clear(struct goat3d *g);
169 /* defined in g3dscn.c */
170 int g3dimpl_obj_init(struct object *o, int type);
171 void g3dimpl_obj_destroy(struct object *o);
173 void g3dimpl_mesh_bounds(struct aabox *bb, struct goat3d_mesh *m, float *xform);
175 int g3dimpl_mtl_init(struct goat3d_material *mtl);
176 void g3dimpl_mtl_destroy(struct goat3d_material *mtl);
177 struct material_attrib *g3dimpl_mtl_findattr(struct goat3d_material *mtl, const char *name);
178 struct material_attrib *g3dimpl_mtl_getattr(struct goat3d_material *mtl, const char *name);
180 void g3dimpl_node_bounds(struct aabox *bb, struct goat3d_node *n);
183 void io_fprintf(goat3d_io *io, const char *fmt, ...);
184 void io_vfprintf(goat3d_io *io, const char *fmt, va_list ap);
187 /* defined in read.c */
188 int g3dimpl_scnload(struct goat3d *g, struct goat3d_io *io);
189 int g3dimpl_anmload(struct goat3d *g, struct goat3d_io *io);
191 /* defined in write.c */
192 int g3dimpl_scnsave(const struct goat3d *g, struct goat3d_io *io);
193 int g3dimpl_anmsave(const struct goat3d *g, struct goat3d_io *io);
195 /* defined in extmesh.c */
196 int g3dimpl_loadmesh(struct goat3d_mesh *mesh, const char *fname);
198 /* defined in readgltf.c */
199 int g3dimpl_loadgltf(struct goat3d *g, struct goat3d_io *io);
201 #endif /* GOAT3D_SCENE_H_ */