reading wavefront-file in array
hi, i like to read an wavefront model in one big array to use it with
glDrawElements...
i like to render them with:
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?
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/1i 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?
Comes up all the time. Here's a link in: http://www.idevgames.com/forum/archive/i...13440.html
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???
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???
that's why you eliminate the duplicates.
It's not very difficult, just a bit annoying.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Vertex Array & Interleaved Array troubles | TomorrowPlusX | 5 | 4,920 |
Nov 17, 2007 09:59 AM Last Post: TomorrowPlusX |
|
| wavefront obj format | Duane | 6 | 3,744 |
Aug 9, 2007 09:59 PM Last Post: wyrmmage |
|
| Reading a PNG file via QuickTIme | WhatMeWorry | 1 | 2,386 |
Jun 23, 2005 06:12 PM Last Post: OneSadCookie |
|

