View Full Version : Determing Cell I'm in
I have written a small program in which I can walk through a landscape made up of triangles. What I would like to know is how to determine what triangle I am standing in. Your help is much appreciated, thank you very much.
06-19-2001, 05:12 PM
Are the triangle vertices in a regular grid as viewed from above? Or are the vertices irregularly placed?
They are in a grid as viewed from above
06-21-2001, 02:29 AM
Think of the data as a 2d array where each cell contains a pair of triangles. To understand what pair of triangles you're on, determine what row of triangles you're in, what column of triangles you're in and, voila you'll know what pair of triangles you're standing on. Say that origo is at the bottom left of the terrain for example, then the column you're in is :
and the row is:
Now you know which pair of triangles you're on, so just test against collisions with those.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.