reading wavefront-file in array

Apprentice
Posts: 9
Joined: 2010.02
Post: #1
hi, i like to read an wavefront model in one big array to use it with
glDrawElements...

Code:
v  0.50000000 -0.50000000 -0.50000000
v  0.50000000 -0.50000000  0.50000000
v  0.50000000  0.50000000 -0.50000000
v  0.50000000  0.50000000  0.50000000

vt  0.50000000  0.66666698
vt  0.75000000  0.66666698
vt  0.50000000  0.66666698
vt  0.75000000  0.33333299
vt  0.50000000  0.66666698
vt  0.50000000  0.66666698
vt  0.50000000  0.33333299
vt  0.75000000  0.33333299
vt  0.50000000  0.66666698

vn  1.00000000  0.00000000  0.00000000
vn  1.00000000  0.00000000  0.00000000
vn  1.00000000  0.00000000  0.00000000
vn  1.00000000  0.00000000  0.00000000

g Default
f 3/2/3 4/3/4 1/4/1
f 4/6/4 2/7/2 1/8/1

i like to render them with:
Code:
glEnableClientState( GL_VERTEX_ARRAY );
    glEnableClientState( GL_TEXTURE_COORD_ARRAY );
    glEnableClientState(GL_NORMAL_ARRAY);
    
    glVertexPointer(   3, GL_FLOAT, 8*sizeof(GLfloat), aVertex );
    glTexCoordPointer( 2, GL_FLOAT, 8*sizeof(GLfloat), &aVertex[3] );
    glNormalPointer(      GL_FLOAT, 8*sizeof(GLfloat), &aVertex[5] );

    glDrawElements( GL_TRIANGLES, numIndexes*3, GL_UNSIGNED_INT, vertexIndicies );
    
    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState( GL_TEXTURE_COORD_ARRAY );

the problem is, i have more texturecoordinates then vertices.
the indicies for the normals and texturecoordinates are not the same as for the vertices.
how i can read the file to put it in one array???
any suggestions?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Comes up all the time. Here's a link in: http://www.idevgames.com/forum/archive/i...13440.html
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #3
thanks,
a solution can be, to create 6 new v/t/n objects for each f-object

f 3/2/3 4/3/4 1/4/1
f 4/6/4 2/7/2 1/8/1

and use a new index like 0,1,2,3,4,5.
But i get duplicates. right???
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
that's why you eliminate the duplicates.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #5
ok, but i think searching this, and reordering the indicies are tricky
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
It's not very difficult, just a bit annoying.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #7
thanks for help
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Vertex Array & Interleaved Array troubles TomorrowPlusX 5 5,555 Nov 17, 2007 09:59 AM
Last Post: TomorrowPlusX
  wavefront obj format Duane 6 4,339 Aug 9, 2007 09:59 PM
Last Post: wyrmmage
  Reading a PNG file via QuickTIme WhatMeWorry 1 2,597 Jun 23, 2005 06:12 PM
Last Post: OneSadCookie