X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=libs%2Fgoat3d%2Fsrc%2Fg3danm.c;fp=libs%2Fgoat3d%2Fsrc%2Fg3danm.c;h=8fdc41acf97e3650e7ef2fd3830474e6d4002816;hb=d5f45e3128c537f272615cf76242e1dfebccdee7;hp=0000000000000000000000000000000000000000;hpb=dd7ce87b0ad2b8a1b4758bcc9354e993b71c8599;p=raydungeon diff --git a/libs/goat3d/src/g3danm.c b/libs/goat3d/src/g3danm.c new file mode 100644 index 0000000..8fdc41a --- /dev/null +++ b/libs/goat3d/src/g3danm.c @@ -0,0 +1,68 @@ +/* +goat3d - 3D scene, and animation file format library. +Copyright (C) 2013-2023 John Tsiombikas + +This program 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. + +This program 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 Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include +#include "g3danm.h" +#include "dynarr.h" +#include "log.h" + +int g3dimpl_anim_init(struct goat3d_anim *anim) +{ + anim->name = 0; + if(!(anim->tracks = dynarr_alloc(0, sizeof *anim->tracks))) { + goat3d_logmsg(LOG_ERROR, "g3dimpl_anim_init: failed to allocate tracks array\n"); + return -1; + } + return 0; +} + +void g3dimpl_anim_destroy(struct goat3d_anim *anim) +{ + int i, num; + + if(!anim) return; + + free(anim->name); + num = dynarr_size(anim->tracks); + for(i=0; itracks[i]); + } + dynarr_free(anim->tracks); +} + + +const char *g3dimpl_trktypestr(enum goat3d_track_type type) +{ + switch(type) { + case GOAT3D_TRACK_VAL: + return "val"; + case GOAT3D_TRACK_VEC3: + return "vec3"; + case GOAT3D_TRACK_VEC4: + return "vec4"; + case GOAT3D_TRACK_QUAT: + return "quat"; + case GOAT3D_TRACK_POS: + return "pos"; + case GOAT3D_TRACK_ROT: + return "rot"; + case GOAT3D_TRACK_SCALE: + return "scale"; + } + return 0; +} +