I'm creating a grid-system for our world editor, and I am going to share it with the community because I think it could be useful for more people. And maybe some people have useful comments or ideas about it...
Only orthographic camera support for now, but that's the hardest case anyway.
Features (orthographic):
- Grid is automatically updated when necessary (and only when necessary)
- Grid lines are automatically inserted / removed when the pixel spacing between the lines reaches a certain treshold
- Major grid lines (full alpha) and minor grid lines (alpha-faded according to their pixel spacing)
- Options: grid color, division (in how many lines a grid is divided when zooming in), render layer (behind or in front of all objects)
Screenshots:
(white grid, behind objects)
(white grid, in front of objects)
(black grid)
You can find the current header and implementation files on my webspace. I'll wiki this if some people find it useful
TODO:
- Support other modes than top-view (some values are still hardcoded)
- Perspective view support: user can set the grid radius and color, and the grid is rendered on the Y=0 plane
- Optional mini-axes and scale rendered on an overlay
Edit: This is also on the wiki.
Greetz,
JeDi