Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ruudje

Need help rendering

This topic is 5388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I just wrote a class with structures to load in a 3ds file. But now im faced with a new problem. The file is read in and all of its vertices are stored For example, a simple cube results in this: Vertices: x: 1 y: 1 z: -1 x: 1 y: -1 z: -1 x: -1 y: -1 z: -1 x: -1 y: -1 z: -1 x: -1 y: -1 z: -1 x: -1 y: -1 z: 1 x: -1 y: -1 z: 1 x: -1 y: -1 z: 1 x: 1 y: -1 z: 1 x: -1 y: 1 z: -1 x: -1 y: 1 z: -1 x: 1 y: 1 z: 1 x: -1 y: 1 z: 1 x: -1 y: 1 z: 1 (appoligies for the long text ) My problem: How do I render this in opengl?? Up until now I experimented with glBegin(glQuads) but that obviously doesnt work with this. I thought NeHe had a tutor about Vertex-Lists, or whatever its called, but I cant find it (anymore?) Please tell me how to render this data to the screen. I tried something like this: glBegin(GL_TRIANGLE_STRIP); for(int i = 0; i < test->object->vertices_count; i++) { glTexCoord2f(test->object->mapcoord.u, test->object->mapcoord[i].v); glVertex3f(test->object->vertex[i].x, test->object->vertex[i].y,test->object->vertex[i].z); } where test is a class pointer, and object holds the real data in structures. This code results in 3 triangles being drawn, but all wrong, and the other 9 are missing/invisible... [edited by - Ruudje on September 22, 2003 5:41:03 AM]

Share this post


Link to post
Share on other sites
Advertisement
Format you described, most likely stores only 8 needed vertices of a cube. You need to have indices to these vertices. 1 triangle has at least 3 values, index number of all 3 vertices.

...and a cube has 12 triangle face.

[edited by - User137 on September 22, 2003 7:55:16 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!