Sign in to follow this  

Creating an endless grid

This topic is 2391 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
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:
[code]
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)[/code]

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.
[/quote]

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='judeclarke' timestamp='1306718509' post='4817316']
[quote name='VildNinja' timestamp='1306703285' post='4817239']
If the user zooms out, you should just create a new grid.
[/quote]

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

This topic is 2391 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this