initial commit
[liquidmodel] / src / metaobj.h
1 /* Molten Metal - Tech demo for the COM32 DOS protected mode system
2  * Copyright (C) 2023  John Tsiombikas <nuclear@mutantstargoat.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (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, see <https://www.gnu.org/licenses/>.
16  */
17 #ifndef METAOBJ_H_
18 #define METAOBJ_H_
19
20 enum {
21         MOBJ_IDLE,
22         MOBJ_GRABING,
23         MOBJ_HELD,
24         MOBJ_DROPPING
25 };
26
27 struct mball {
28         float energy;
29         cgm_vec3 pos;
30 };
31
32 struct mcapsule {
33         float energy;
34         cgm_vec3 end[2];
35         float len;
36 };
37
38 struct mobject {
39         cgm_vec3 pos, mouse;
40         int state;
41         struct mball *balls;
42         struct mcapsule *caps;
43         int num_balls, num_caps;
44         cgm_vec3 *idlepos;
45         cgm_vec4 *mot;
46         float tstart;
47         float xform[16];
48
49         void (*swstate)(struct mobject *mobj, int newst);
50         void (*update)(struct mobject *mobj, float tsec);
51         void (*upd_ball)(struct mobject *mobj, struct mball *ball, float tsec, float t);
52         void (*upd_caps)(struct mobject *mobj, struct mcapsule *caps, float tsec, float t);
53         float (*eval)(struct mobject *mobj, cgm_vec3 *pos);
54 };
55
56 struct mobject *metaobj_sflake(void);
57 struct mobject *metaobj_sgi(void);
58
59 #endif  /* METAOBJ_H_ */