10 |
|
#ifndef _OBJUTIL_H_ |
11 |
|
#define _OBJUTIL_H_ |
12 |
|
|
13 |
+ |
#ifdef __cplusplus |
14 |
+ |
extern "C" { |
15 |
+ |
#endif |
16 |
+ |
|
17 |
|
#ifndef DUP_CHECK_REVERSE |
18 |
|
#define DUP_CHECK_REVERSE 1 /* eliminate flipped duplicates */ |
19 |
|
#endif |
21 |
|
#define POPEN_SUPPORT 1 /* support "!command" i/o */ |
22 |
|
#endif |
23 |
|
/* face flags */ |
24 |
< |
#define FACE_SELECTED 01 |
25 |
< |
#define FACE_DEGENERATE 02 |
26 |
< |
#define FACE_DUPLICATE 04 |
24 |
> |
#define FACE_DEGENERATE 01 |
25 |
> |
#define FACE_DUPLICATE 02 |
26 |
> |
#define FACE_SELECTED 04 |
27 |
> |
#define FACE_CUSTOM(n) (FACE_SELECTED<<(n)) |
28 |
> |
#define FACE_RESERVED (1<<15) |
29 |
|
|
30 |
|
struct Face; /* forward declaration */ |
31 |
|
|
84 |
|
int nfaces; /* count of faces */ |
85 |
|
} Scene; |
86 |
|
|
81 |
– |
#ifdef __cplusplus |
82 |
– |
extern "C" { |
83 |
– |
#endif |
84 |
– |
|
87 |
|
/* Allocate a new scene holder */ |
88 |
|
Scene * newScene(void); |
89 |
|
|
90 |
|
/* Add a .OBJ file to a scene */ |
91 |
|
Scene * loadOBJ(Scene *sc, const char *fspec); |
92 |
|
|
93 |
< |
/* Duplicate a scene */ |
94 |
< |
Scene * dupScene(const Scene *sc); |
93 |
> |
/* Duplicate a scene, optionally selecting faces */ |
94 |
> |
Scene * dupScene(const Scene *sc, int flreq, int flexc); |
95 |
|
|
96 |
+ |
/* Add one scene to another, not checking for redundancies */ |
97 |
+ |
int addScene(Scene *scdst, const Scene *scsrc); |
98 |
+ |
|
99 |
|
/* Transform entire scene */ |
100 |
|
int xfScene(Scene *sc, int xac, char *xav[]); |
101 |
|
int xfmScene(Scene *sc, const char *xfm); |
103 |
|
/* Add a descriptive comment */ |
104 |
|
void addComment(Scene *sc, const char *comment); |
105 |
|
|
106 |
+ |
/* Find index for comment containing the given string (starting from n) */ |
107 |
+ |
int findComment(Scene *sc, const char *match, int n); |
108 |
+ |
|
109 |
|
/* Clear comments */ |
110 |
|
void clearComments(Scene *sc); |
111 |
|
|
181 |
|
/* Add a new face to our scene, using current group and material */ |
182 |
|
Face * addFace(Scene *sc, VNDX vid[], int nv); |
183 |
|
|
184 |
+ |
/* Convert all faces with > 3 vertices to triangles */ |
185 |
+ |
int triangulateScene(Scene *sc); |
186 |
+ |
|
187 |
+ |
/* Delete unreferenced vertices, normals, texture coords */ |
188 |
+ |
void deleteUnreferenced(Scene *sc); |
189 |
+ |
|
190 |
|
/* Free a scene */ |
191 |
|
void freeScene(Scene *sc); |
192 |
|
|
199 |
|
extern char *emalloc(unsigned int n); |
200 |
|
extern char *ecalloc(unsigned int ne, unsigned int n); |
201 |
|
extern char *erealloc(char *cp, unsigned int n); |
202 |
< |
extern void efree(char *cp); |
202 |
> |
extern void efree(char *cp); |
203 |
> |
|
204 |
> |
#define getGroupID(sc,nm) findName(nm, (const char **)(sc)->grpname, (sc)->ngrps) |
205 |
> |
#define getMaterialID(sc,nm) findName(nm, (const char **)(sc)->matname, (sc)->nmats) |
206 |
|
|
207 |
|
#define CHUNKSIZ 128 /* object allocation chunk size */ |
208 |
|
|