# 3D Grid

## Recommended Posts

I need to draw a Grid in Directx 9 much like the one in 3D Studio Max. How can I draw such a grid without using images to represent cells of the grid? Also how could I cntrol how big the cells are in the grid? Bellow is a example of a grid I would like to draw.

##### Share on other sites
Cowboy Coder    365
Use 3d line primitives, and just space them out as you need them.

##### Share on other sites
Rand    193
You need to use the line primitive instead of triangles. Untextured aswell. To render it have 2 for loops, not nested but 1 after the other. The for loop goes for the number of lines in 1 axis (say 10). Have floats for the minX and maxX. Then the x coord is n*(maxX-minX)+minX, with the Y coords for all these lines from minY to maxY.

Heres psuedo code for one axis.
for(n=0; n<maxLines; n++){ x=n*(maxX-minX)+minX; drawline(x,minY,x,maxY,r,g,b);}

You need to put an if in there though to change the colour for the middle line.