Jump to content
  • Advertisement
Sign in to follow this  
judeclarke

Creating an endless grid

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

For the background of my level editor I would like to create a grid, much like how UDK or Maya has. I know how to create a grid dynamically using line lists, so that is not the problem. The problem is developing a smart system that uses the grid. My concern is, do I create a very large grid at the start and hope the user never zooms out enough to notice the edges of the grid? Or do I create a small grid and tile it? Does anyone have any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
Create the grid so it's one tile bigger than the screen, when ever the user pans on the x-axis, you can just move the grid to -(xOffset % tileWidth). Then it will just look like an endless grid for the user.
If the user zooms out, you should just create a new grid.

Alternatively you could just create the grid dynamically every frame, with two for loops.
some thing like:

for (x = tileWidth - (xOffset % tileWidth); x < screenWidth; x += tileWidth)
drawLine(x, 0, x, screenHeight);


for (y = tileHeight - (yOffset % tileHeight ); y < screenHeight; y += tileHeight )
drawLine(0, y, screenWidth, y)

Share this post


Link to post
Share on other sites
i'm using a transparent texture with one grid cell and tile it all over a really huge quad

Share this post


Link to post
Share on other sites

If the user zooms out, you should just create a new grid.


How do you know how often to create the grid? Or how big to make the grid?

Share this post


Link to post
Share on other sites

[quote name='VildNinja' timestamp='1306703285' post='4817239']
If the user zooms out, you should just create a new grid.


How do you know how often to create the grid? Or how big to make the grid?
[/quote]

Calculate them: you know the limits of the view. I can't be specific because the actual calculations depend on many things. Anyway, it shouldn't be hard to figure it out with a little basic math and just draw it with lines.

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!