Jump to content
  • Advertisement
Sign in to follow this  
snowfell

building a 3d grid function

This topic is 3686 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

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]

Share this post


Link to post
Share on other sites
Advertisement
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();
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!