aboutsummaryrefslogtreecommitdiff
path: root/obj.2.man
blob: 9196385dcbd438582bc3d6328cb4905c80771596 (plain)
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
.TH OBJ 2
.SH NAME
objparse,
objfree,
OBJfmt,
OBJfmtinstall
\- OBJ parser
.SH SYNOPSIS
.ta 0.7i +0.7i +0.7i +0.7i +0.7i +0.7i +0.7i
.EX
#include <u.h>
#include <libc.h>
#include <obj.h>

enum {
	OBJVGeometric,
	OBJVTexture,
	OBJVNormal,
	OBJVParametric,
	OBJNVERT
};

enum {
	OBJEPoint,
	OBJELine,
	OBJEFace,
	OBJECurve,
	OBJECurve2,
	OBJESurface
};

enum {
	OBJHTSIZE = 17
};

typedef struct
{
	union {
		struct { double x, y, z, w; };	/* geometric */
		struct { double u, v, vv; };	/* texture and parametric */
		struct { double i, j, k; };	/* normal */
	};
} OBJVertex;

typedef struct
{
	OBJVertex	*verts;
	int		nvert;
} OBJVertexArray;

typedef struct
{
	int	*indices;
	int	nindex;
	int	type;
	OBJElem	*next;
} OBJElem;

typedef struct
{
	char		*name;
	OBJElem		*child;
	OBJObject	*next;
} OBJObject;

typedef struct
{
	OBJVertexArray	vertdata[OBJNVERT];
	OBJObject	*objtab[OBJHTSIZE];
} OBJ;

OBJ	*objparse(char *file);
void	objfree(OBJ *obj);
int	OBJfmt(Fmt*);
void	OBJfmtinstall(void);
.EE
.SH DESCRIPTION
An OBJ structure contains geometry and material information about a set of 3D objects
.SH SOURCE
.B /sys/src/libobj
.SH SEE ALSO
.IR geometry (2)
.br
http://paulbourke.net/dataformats/obj
.br
https://people.sc.fsu.edu/~jburkardt/data/obj/obj.html
.SH DIAGNOSTICS
.SH BUGS