Sign in to follow this  
judeclarke

Creating an endless grid

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
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
[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

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