Archived

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

drawing a sphere in a terrain created by Draw Elements

This topic is 5043 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, I''m reading the book "opengl for game programming" and in chapter 15 there is a Cacti terrain created using DrawElements. In addition there are cacti using bitmaps on the terrain. Now, the problem is I thought I understood it all but realise I don''t !! So I have two questions: 1. On drawing the cacti the author doesn''t use Translate to get to the relevant positions on the map - he just creates a random vector and uses Vertexfv to do it (without loading identity matrix or pushing matrices). How does this work - I mean all examples I''ve seen we need to get the position in terms of the position from the model view matrix ? 2. I then tried to draw a very large sphere on this terrain - using the quadric functions (and then the glut function). I tried positioning it using a translation from the model view and then by loading the identity and translating from this. In fact I tried verything and couldn''t get it to work at all. I can''t even see it although I''ve tried every color (black/white/red etc) and made it very large and dead in the centre of what shouldbe the centre of the terrain - I can''t even see it. I can easily draw spheres in every other example in the book !! What am I doing wrong ??!! example code snip here: Draw Cacti() { .... ... for (int n = 0; n < NUM_CACTI; n++) { ... ... // pick a random position on the map vector3_t pos .... glBegin(GL_QUADS); ... ... glEnd(); } ... ... //now my bit glPushAttrib(GL_CURRENT_BIT); //save the current matrix glPushMatrix(); glLoadIdentity(); glColor3f(0.0, 0.0, 0.0); //bright black !! glTranslatef(0.0, 0.0, 70.0); gluSphere(g_Sun, 55.0, 10, 10); glPopMatrix(); glPopAttrib(); ... ... }

Share this post


Link to post
Share on other sites
the random vector is maybe clamped / modulated to fit into the terrain, and then adjusted to be on the surface of it?





[edited by - 666_1337 on February 20, 2004 11:51:41 AM]

Share this post


Link to post
Share on other sites