开发者

Vector to closest isosurface point on metaballs

开发者 https://www.devze.com 2023-03-11 01:09 出处:网络
I\'m currently making a prototype game 开发者_开发百科where the player walks along the isosurface of a collection of moving metaballs. I\'ve already implemented walking along a sphere with a forward a

I'm currently making a prototype game 开发者_开发百科where the player walks along the isosurface of a collection of moving metaballs. I've already implemented walking along a sphere with a forward and up vector. To extend this to the metaballs I need to be able to query for an arbitrary point the direction to the closest surface and the distance to the closest surface to be able to snap the player back to the surface after I've moved him along the forward vector. I can calculate the direction by taking a weighted average of all vectors but how do I get the distance?

I'm using the 1 / (x*x + y*y + z*z) function with an isosurface of 1 for my metaballs but I would appreciate any generalization so that I can use the same approach for other shapes.


In general, you would just derive your function to get the normal on the surface. Blackpawn has a nice explanation how to do it with your specific case here.

Once you got the normal, move along its direction until you hit the isosurface (this is generic "root" finding).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号