I'm trying to determine the pitch and roll of an object (tank) on a heightmap. There's a twist that the object is larger than the cells of the heightmap, so I am using 8 control points, 4 at the corners and the other 4 aligned with the center of mass on a side (for my objects, center of mass is 0,0,0). This diagram may help (numbers are the indices into the array of the control points):
| | |
| | |
Determining the height for a particular control point is easy and I've verified that part is working properly. But using those control points to determine the pitch and roll is where I'm stuck. I've computed angle of pitch between indices 6-0, 2-6, and 2-0 (same for 1, 7, and 3). For roll, it's 4-0, 1-4, and 1-0 (again, same for 3, 5, and 2). I've tried different ways of combining to get the final pitch and roll (max per side, then min; max per side then min/max magnitude; if statements creating special cases which work only in default orientation; etc). Then I scale back the computed pitch by multiplying it by |pitch| / (|pitch| + |roll|), and scale back roll by multiplying it by 1 - that value. How should the individual pitches and rolls be combined to get the final pitch and roll of the object? Or is there a better approach to this problem? I've thought about averaging the normals of the terrain the object is over, but going over a trench (or just starting over the ledge of one) should throw that off.
I've tried searching on google and this site, and can only find discussions of generating heightmaps, determining the height of a single point, or using a particular API's heightmap.
LyostMember Since 13 Aug 2003
Offline Last Active Apr 16 2013 06:35 PM
- Group GDNet+
- Active Posts 24
- Profile Views 1,385
- Submitted Links 0
- Member Title Member
- Age 31 years old
- Birthday July 19, 1982
Lyost hasn't added any contacts yet.