I have this obj file from blender.It is the default cube:
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib untitled.mtl
o Cube_Cube.002
v -1.000000 -1.000000 1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -1.000000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.875000 0.500000
vt 0.625000 1.000000
vt 0.875000 0.750000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 2/1/1 3/2/1 1/3/1
f 4/4/2 7/5/2 3/2/2
f 8/6/3 5/7/3 7/5/3
f 6/8/4 1/9/4 5/7/4
f 7/5/5 1/10/5 3/11/5
f 4/12/6 6/8/6 8/6/6
f 2/1/1 4/4/1 3/2/1
f 4/4/2 8/6/2 7/5/2
f 8/6/3 6/8/3 5/7/3
f 6/8/4 2/13/4 1/9/4
f 7/5/5 5/7/5 1/10/5
f 4/12/6 2/14/6 6/8/6
I set them in c# like this and it's working I have a cube.
Vector3[] verts =
{
new Vector3(-1f, -1f, 1f),
new Vector3(-1f, 1f, 1f),
new Vector3(-1f, -1f, -1f),
new Vector3(-1f, 1f, -1f),
new Vector3(1f, -1f, 1f),
new Vector3(1f, 1f, 1f),
new Vector3(1f, -1f, -1f),
new Vector3(1f, 1f, -1f),
};
int[] tris =
{
1,2,0,
3,6,2,
7,4,6,
5,0,4,
6,0,2,
3,5,7,
1,3,2,
3,7,6,
7,5,4,
5,1,0,
6,4,0,
3,1,5,
};
I don't unerstand the uv part.
1) As far as I understand
f 3/2/1 means:
use the 3rd element from position array as this vertex position
use the 2nd element from uv array as this vertex texture coordinate
use the 1st element from the normal array as this vertex normal
Then why there are more Vector2s in uvs array than Vector3s in positions array since a vertex has 1 position, 1 uv and 1 normal?
And if I use this method to index uvs can I send the uv indexes in the shader with the indexed positions?