Creating an endless grid
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?
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:
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)
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 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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement