Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Drawing a Wavefront OBJ cube

  1. #11
    Junior Member Newbie
    Join Date
    May 2012
    Posts
    8
    Quote Originally Posted by BionicBytes View Post
    Code :
    glDrawArrays(GL_TRIANGLES, 0, indicesize);
    Are you sure you have the right value for indicesize as this needs to represent all faces (where each face = 3 triangles, and each triangle=3 verticies).
    So you could be a factor of 9 out.
    I have made some slight changes in my code and cut back to creating one array in the form of:
    posX,posY,posZ,normX,normY,normZ

    If we take an example i have 7055 faces (indices).
    Each created in this form: f 716/4636/4636 717/4637/4637 710/4638/4638

    Since i only need the position and norm i create an array of the size faces*6.

    So if i were in the former case of using texturecoords i would be a factor 9 from the real size.

    But so far i have following rendering, which is still "broken".
    Click image for larger version. 

Name:	Skærmbillede 2012-05-25 kl. 14.18.07.jpg 
Views:	100 
Size:	10.7 KB 
ID:	741

  2. #12
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,169
    Quote Originally Posted by Graphicz View Post
    If we take an example i have 7055 faces (indices).
    Each created in this form: f 716/4636/4636 717/4637/4637 710/4638/4638
    7055 faces does not equal 7055 indices.

    1 face = 3 verticies (to create a triangle) = 3 indicies.
    f 716/4636/4636
    This arrangement of "f x/y/z" implies that for each face your OBJ file contains vertex/normal/texturecoord.
    Therefore your array sizes (assuming an interleaved array) would be #faces * (3 vertex + 3 Normal + 2 Texcoord) [glfloat]
    and the number of indicies required would be #faces * 3

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •