GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


OBJ Loading (JAVA) by beardo2
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
 
relevant indices saving code:

float[] indices = {}

byte[] newIndices = new byte[indices.length + 3];
System.arraycopy(indices, 0, newIndices, 0, indices.length);

//X, Y, Z are parsed out of the lines below starting with F and contain the numbers shown below 
//IE, line "f 13//13 15//15 14//14" causes x=13, y=15, z=14
newIndices[indices.length] = (byte)x;
newIndices[indices.length + 1] = (byte)y;
newIndices[indices.length + 2] = (byte)z;
indices = newIndices;
indicesCount++;



dodecahedron.obj
# Exported from Wings 3D 1.2
mtllib decohedron.mtl
o dodecahedron1
#20 vertices, 36 faces
v -0.50000000 0.0000000e+0 1.30901699
v 0.50000000 0.0000000e+0 1.30901699
v -0.80901699 -0.80901699 -0.80901699
v -0.80901699 -0.80901699 0.80901699
v -0.80901699 0.80901699 -0.80901699
v -0.80901699 0.80901699 0.80901699
v 0.80901699 -0.80901699 -0.80901699
v 0.80901699 -0.80901699 0.80901699
v 0.80901699 0.80901699 -0.80901699
v 0.80901699 0.80901699 0.80901699
v 1.30901699 0.50000000 0.0000000e+0
v 1.30901699 -0.50000000 0.0000000e+0
v -1.30901699 0.50000000 0.0000000e+0
v -1.30901699 -0.50000000 0.0000000e+0
v -0.50000000 0.0000000e+0 -1.30901699
v 0.50000000 0.0000000e+0 -1.30901699
v 0.0000000e+0 1.30901699 0.50000000
v 0.0000000e+0 1.30901699 -0.50000000
v 0.0000000e+0 -1.30901699 0.50000000
v 0.0000000e+0 -1.30901699 -0.50000000
vn -0.30404229 9.3954233e-2 0.94801418
vn 0.52267448 -0.10767687 0.84570508
vn -0.57735027 -0.57735027 -0.57735027
vn -0.68487271 -0.55407366 0.47323540
vn -0.57735027 0.57735027 -0.57735027
vn -0.57735027 0.57735027 0.57735027
vn 0.55407366 -0.47323540 -0.68487271
vn 0.57735027 -0.57735027 0.57735027
vn 0.57735027 0.57735027 -0.57735027
vn 0.47323540 0.68487271 0.55407366
vn 0.94801418 0.30404229 -9.3954233e-2
vn 0.84570508 -0.52267448 0.10767687
vn -0.91298249 0.39960705 8.2323580e-2
vn -0.89651002 -0.42327461 -0.13079905
vn -0.39960705 -8.2323580e-2 -0.91298249
vn 0.42327461 0.13079905 -0.89651002
vn -0.13079905 0.89651002 0.42327461
vn 8.2323580e-2 0.91298249 -0.39960705
vn 0.10767687 -0.84570508 0.52267448
vn -9.3954233e-2 -0.94801418 -0.30404229
g dodecahedron1_default
usemtl default
s 1
f 1//1 13//13 4//4
f 1//1 17//17 6//6
f 1//1 19//19 2//2
f 2//2 10//10 1//1
f 2//2 11//11 10//10
f 2//2 19//19 8//8
f 3//3 20//20 14//14
f 4//4 13//13 14//14
f 4//4 19//19 1//1
f 4//4 20//20 19//19
f 5//5 15//15 13//13
f 5//5 18//18 15//15
f 6//6 13//13 1//1
f 6//6 17//17 13//13
f 7//7 11//11 12//12
f 7//7 15//15 16//16
f 8//8 12//12 2//2
f 8//8 19//19 12//12
f 9//9 18//18 11//11
f 10//10 18//18 17//17
f 11//11 2//2 12//12
f 11//11 16//16 9//9
f 11//11 18//18 10//10
f 12//12 20//20 7//7
f 13//13 15//15 14//14
f 13//13 18//18 5//5
f 14//14 15//15 3//3
f 14//14 20//20 4//4
f 15//15 18//18 16//16
f 15//15 20//20 3//3
f 16//16 11//11 7//7
f 16//16 18//18 9//9
f 17//17 1//1 10//10
f 18//18 13//13 17//17
f 20//20 12//12 19//19
f 20//20 15//15 7//7