01-09-2023, 05:26 PM
(01-09-2023, 12:12 PM)OldMoses Wrote: A couple of thoughts:
If there's a simple solution, I don't know it.
I think it would probably involve some sort of parametric algorithm after determining which triangle grid element was being approached. I've not done anything like that myself, having mostly worked with line/sphere intersections. Most line/plane intersection stuff I've looked at presumes an infinite plane, so you would need to narrow your inputs to the correct grid element with some Pythagorean checking.
https://courseware.cemc.uwaterloo.ca/web...APlane.pdf
There's lots of other stuff on parametric equations available.
The other possibility, is that you can take the plane 'normal' {i.e. perpendicular} of a target terrain grid element, and dot it with the position vector relative to that normal, updating it as you go along the path (easier to do than to describe). When the sign of the dot product result changes, you've intersected the plane, and likely gone through it. If the dot product result went to zero and stayed there, you would be moving along the plane. It would be a 3D version of what we were discussing at https://staging.qb64phoenix.com/showthread.php?tid=972 Generally, the same concepts apply for 3D as for 2D
The former would have the advantage of being able to calculate exact points of intersection, the later would be computationally simpler for a crash scenario.
Thanks for the PDF...that should help make sense of this. Some interesting math there too...quadradic equations? Been a long time since I've done that.
Using vector math would really open up some possibilities. Definitely over my head but this seems like the way to go for a good 3d physics engine.