Skip to main content
gamedev.net
🔒 Locked

3D Grid

Started by hungryhippo5000 Mar 18, 2007 at 2:07 PM 1 replies 4.9k views
Original Post
hungryhippo5000
hungryhippo5000
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. Grid
Cowboy Coder
Cowboy Coder
Use 3d line primitives, and just space them out as you need them.
Rand
Rand
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.