Skip to main content
GameDev.net gamedev.net
🔒 Locked

Uniform grid subdivision

Started by raydog Jan 21, 2004 at 3:27 PM 1 replies 1k views
Original Post
raydog
raydog
I understand the basic idea, but I really don't know how to start if off or how to end it. What I have is a scene of triangles, and I want to spatially subdivide it into an uniform grid, let's say along the XZ plane (Y is up), in basic C code. Any helpers? Google is no help at all. [edited by - raydog on January 21, 2004 4:29:18 PM]
orbano
orbano
what do you want. to calculate the points of the grids, or to specify the location of an object in the grid.
the first one:
(x,y,z) is element of {gridpoints} if either x,y and z are the multiplies of s, which is the size of one grid in one dimension.
I think you want whole numbers for this, so you can say:
x,y,z = 0 mod (gridsize) (x % grdisize=0 in C)

To determine the location of a point:
gridpoint.x= ||point.x| div gridsize;
if(coordinatex<0)sectornumber*=-1;
so the sectors around the origin are: (1,1)(1,-1), etc
(i did not extend div to negative values, but i think they can be used so you dont need the if())




"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin
raydog
raydog
I want know how to do spatial subdivision using the grid method as opposed to using BSP trees, or octrees.

How does that help me? Where can I find a step-by-step procedure of it, and the criteria for each step to complete it?

Topic Locked

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

Sign in to reply to this topic.