PDA

View Full Version : Imported data from .obj file wont render



HaplessHalfwit
04-03-2017, 03:56 PM
Hey guys,

I'm stuck and I was wondering if anyone could help me.
Bellow it the output of my "Hello Cube" where the vertices have been defined by some boilerplate code.

https://lh3.googleusercontent.com/KiuzYifRuNy4zj2l_F_D49f-XxgB5I4ExS8_X0EKFNJNYgWIn9I3EJo1wtxCsMu1ac3mHNTxDA D9EYmQakmUr9ZC3ckSZ0lhYI98e-kqzg11Mpx8skN7PLnRIskOfksglIXNK3PQwwsaOHssZ68HgLrM K00T32JY90-QZpjBmgTW4GiXfXhdZSaQ9nglZJ0wg0aLwaasELIve6hp2w1Ah zIOgVdm7jaj3TCpRQ1PdPl8yGwLLy_nVfPzMlV6TJnxZkyn9Y3 RSjK1CQG39ZaG3riAmw53KV0kGXrdjyHdJhdfTba2ZzeHVQ_ua qLK5Plc1mzpnAvGi6H2eMneaBQ_myexZIIRAKY10aoDlQg9v07 isPpOWakTcTtrH0i7arFsLOu-HViyA0kxlgkcQwUgdz2nJGpISScwvEkZvnUu8Bb5BxPNBpMyxV ku4gk41hhTnH0AY5NxG_9IoF3JEDym4w6cfX1yqwfWJJMsS3Gj lFiRDKhJ7SkNd1H7qyZBmYed65gG6m4A8GAz2d5j9AM6zH58Br 7q6N2Ltec8sufH8juAlILR98ZCZXE5IhXyqUa3jiVCr_K97G-AEDrejoz1WhuiAqaqpo-mYOR9U-T41vg1MhN7nIlVCG7YTAXzIGrFH-kh0qwBj-hneal6yZW1tiNuuaA7VmLKmWCKrPJ-pA=w802-h602-no

The mesh data for the cube above is comprised of 24 vertices, 36 indices.

However, imported data from an .obj file does not appear to render. It has 8 vertices and 36 indices.

This question simply boils down to "Why does one set of shape data render, and not the other?".
My guess is that the ordering of vertices / indices is wrong to some degree, but in my ignorance I can't see it.
I would appreciate any help on offer.


Below is the data.
I removed normals/uv coords/colours as they're not currently used by the shader; though each vertex holds that information.

Cube 1 (Renders)

Vertex t1Verts[] = {
//Top
Vector3(-1.0f, +1.0f, +1.0f), // 0
Vector3(+1.0f, +1.0f, +1.0f), // 1
Vector3(+1.0f, +1.0f, -1.0f), // 2
Vector3(-1.0f, +1.0f, -1.0f), // 3
Vector3(-1.0f, +1.0f, -1.0f), // 4
Vector3(+1.0f, +1.0f, -1.0f), // 5
Vector3(+1.0f, -1.0f, -1.0f), // 6
Vector3(-1.0f, -1.0f, -1.0f), // 7
Vector3(+1.0f, +1.0f, -1.0f), // 8
Vector3(+1.0f, +1.0f, +1.0f), // 9
Vector3(+1.0f, -1.0f, +1.0f), // 10
Vector3(+1.0f, -1.0f, -1.0f), // 11
Vector3(-1.0f, +1.0f, +1.0f), // 12
Vector3(-1.0f, +1.0f, -1.0f), // 13
Vector3(-1.0f, -1.0f, -1.0f), // 14
Vector3(-1.0f, -1.0f, 1.0f), // 15
Vector3(+1.0f, +1.0f, +1.0f), // 16
Vector3(-1.0f, +1.0f, +1.0f), // 17
Vector3(-1.0f, -1.0f, +1.0f), // 18
Vector3(+1.0f, -1.0f, +1.0f), // 19
Vector3(+1.0f, -1.0f, -1.0f), // 20
Vector3(-1.0f, -1.0f, -1.0f), // 21
Vector3(-1.0f, -1.0f, +1.0f), // 22
Vector3(+1.0f, -1.0f, +1.0f), // 23
};

GLushort iArr[] = {
0,1,2,
0,2,3, // Top
4,5,6,
4,6,7, // Front
8,9,10,
8,10,11, // Right
12,13,14,
12,14,15, // Left
16,17,18,
16,18,19, // Back
20,22,21,
20,23,22 // Bottom
};



Cube 1 (Imported from .obj - Doesn't render)

Vertex tVerts[]{
Vector3(1.0f, -1.0f, -1.0f), // 0
Vector3(1.0f, -1.0f, 1.0f), // 1
Vector3(-1.0f, -1.0f, 1.0f), // 2
Vector3(-1.0f, -1.0f, -1.0f), // 3
Vector3(1.0f, 1.0f, -1.0f), // 4
Vector3(1.0f, 1.0f, 1.0f), // 5
Vector3(-1.0f, 1.0f, 1.0f), // 6
Vector3(-1.0f, 1.0f, -1.0f), // 7
};

GLushort iArr[] = {
1,3,0,
7,5,4,
4,1,0,
5,2,1,
2,7,3,
0,7,4,
1,2,3,
7,6,5,
4,5,1,
5,6,2,
2,6,7,
0,3,7
};


Thanks,