summaryrefslogtreecommitdiff
path: root/obj.h
diff options
context:
space:
mode:
Diffstat (limited to 'obj.h')
-rw-r--r--obj.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/obj.h b/obj.h
new file mode 100644
index 0000000..19bfdcb
--- /dev/null
+++ b/obj.h
@@ -0,0 +1,92 @@
+/* vertex types */
+enum {
+ OBJVGeometric,
+ OBJVTexture,
+ OBJVNormal,
+ OBJVParametric,
+ OBJNVERT
+};
+/* element types */
+enum {
+ OBJEPoint,
+ OBJELine,
+ OBJEFace,
+ OBJECurve,
+ OBJECurve2,
+ OBJESurface
+};
+/* grouping types */
+enum {
+ OBJGGlobal,
+ OBJGSmoothing,
+ OBJGMerging
+};
+/* object hash table size */
+enum {
+ OBJHTSIZE = 17
+};
+
+typedef struct OBJVertex OBJVertex;
+typedef struct OBJVertexArray OBJVertexArray;
+typedef struct OBJElem OBJElem;
+//typedef struct OBJGroup OBJGroup;
+typedef struct OBJObject OBJObject;
+typedef struct OBJ OBJ;
+
+#pragma varargck type "O" OBJ*
+
+struct OBJVertex
+{
+ union {
+ struct { double x, y, z, w; }; /* geometric */
+ struct { double u, v, vv; }; /* texture and parametric */
+ struct { double i, j, k; }; /* normal */
+ };
+};
+
+struct OBJVertexArray
+{
+ OBJVertex *verts;
+ int nvert;
+};
+
+struct OBJElem
+{
+ int *indices;
+ int nindex;
+ int type;
+ OBJElem *next;
+};
+
+//struct OBJGroup
+//{
+// char *name;
+// int type;
+// OBJElem *elem0;
+// OBJGroup *next;
+//};
+//struct OBJObject
+//{
+// char *name;
+// OBJGroup *grptab[OBJHTSIZE];
+// OBJObject *next;
+//};
+
+struct OBJObject
+{
+ char *name;
+ OBJElem *child;
+ OBJObject *next;
+};
+
+struct OBJ
+{
+ OBJVertexArray vertdata[OBJNVERT];
+ OBJObject *objtab[OBJHTSIZE];
+};
+
+OBJ *objparse(char*);
+void objfree(OBJ*);
+
+int OBJfmt(Fmt*);
+void OBJfmtinstall(void);