building a 3d grid function
Hey, I have been working on a 3d program for just over a month now, and I need help setting up a 3d grid function (just add width, height, and size of the box. It should run on the x and z axis I guess, y is vertical height). So the function should look like:
BuildGrid(float width, float height, float units).
But I am having trouble figuring out how to do the rest. I know I don't want to do it using textures for the units, so would glVertexs work best? What I need is a way to figure out how to draw the right amount of lines and where at. Any tips?
[Edited by - snowfell on July 18, 2008 3:00:25 PM]
Here you go, let me know if this accomplished what you were looking for:
void BuildGrid(float width, float height, float units){ for(float i = -(width / 2); i <= (width / 2); i += (width / units)) { glBegin(GL_LINES); //line along x axis glVertex3f(-(width / 2), height, i); glVertex3f((width / 2), height, i); //line along z axis glVertex3f(i, height, -(width / 2)); glVertex3f(i, height, (width / 2)); glEnd(); }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement