1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/**************************************************************
*
* ======== kalmia ========
*
* a COLLADA importer library
* copyright (c) 2022 kate swanson (sanine)
*
* This is anti-capitalist software, released for free use by individuals and
* organizations that do not operate by capitalist principles.
*
* Permission is hereby granted, free of charge, to any person or
* organization (the "User") obtaining a copy of this software and associated
* documentation files (the "Software"), to use, copy, modify, merge,
* distribute, and/or sell copies of the Software, subject to the following
* conditions:
*
* 1. The above copyright notice and this permission notice shall be included
* in all copies or modified versions of the Software.
*
* 2. The User is one of the following:
* a. An individual person, laboring for themselves
* b. A non-profit organization
* c. An educational institution
* d. An organization that seeks shared profit for all of its members, and
* allows non-members to set the cost of their labor
*
* 3. If the User is an organization with owners, then all owners are workers
* and all workers are owners with equal equity and/or equal vote.
*
* 4. If the User is an organization, then the User is not law enforcement or
* military, or working for or under either.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF
* ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://anticapitalist.software/
* https://sanine.net
*
****************************************************************/
#ifndef KALMIA_H
#define KALMIA_H
#include <stdbool.h>
#include <stdlib.h>
/* kalmia uses semantic versioning (semver.org) */
#define KALMIA_VERSION_MAJOR 0
#define KALMIA_VERSION_MINOR 0
#define KALMIA_VERSION_PATCH 0
/* determine precision */
#ifdef KALMIA_USE_DOUBLE
typedef double ka_real_t;
#define KA_STR_TO_REAL(nptr, end) strtod(nptr, end)
#else
typedef float ka_real_t;
#define KA_STR_TO_REAL(nptr, end) strtof(nptr, end)
#endif
/**************** geometry types ****************/
struct ka_float_array_t {
unsigned int count; /* required */
char *id;
unsigned int digits; /* default 6 */
int magnitude; /* default 38 */
ka_real_t *buf;
};
struct ka_param_t {
char *name;
char *sid;
char *type; /* required */
char *semantic;
};
struct ka_accessor_t {
unsigned int count; /* required */
unsigned int offset; /* default 0 */
char *source; /* required */
unsigned int stride; /* default 1 */
unsigned int param_count;
struct ka_param_t *param;
};
struct ka_source_t {
char *id; /* required */
char *name;
struct ka_float_array_t float_array;
struct ka_accessor_t accessor;
};
struct ka_input_t {
bool shared;
unsigned int offset; /* required if shared */
char *semantic; /* required */
char *source; /* required */
bool use_set;
unsigned int set;
};
struct ka_vertices_t {
char *id; /* required */
char *name;
unsigned int input_count;
struct ka_input_t *input;
};
struct ka_triangles_t {
char *name;
unsigned int count; /* required */
char *material;
unsigned int input_count;
struct ka_input_t *input;
unsigned int p_count;
unsigned int *p;
};
struct ka_mesh_t {
unsigned int source_count;
struct ka_source_t *source;
struct ka_vertices_t vertices;
unsigned int triangles_count;
struct ka_triangles_t *triangles;
};
struct ka_geometry_t {
char *id;
char *name;
struct ka_mesh_t mesh;
};
struct ka_library_geometries_t {
char *id;
char *name;
unsigned int geometry_count;
struct ka_geometry_t *geometry;
};
/******** kalmia_t ********/
struct kalmia_t {
struct ka_library_geometries_t *library_geometries;
};
struct kalmia_t * kalmia_parse_file(const char *filename);
void kalmia_destroy(struct kalmia_t *k);
#endif
|