与 Triton 的交集测试
Triton允许你在任何给定的位置查询海洋的高度和表面法线;这允许你在你的应用程序中模拟浮动物体与Triton的波浪一致。
为了使用相交测试,你必须在创建海洋对象时将Triton::Ocean::Create()的enableHeightTests参数设置为true。默认情况下,相交测试是禁用的,这使得Triton可以避免在某些系统上从GPU读回数据而带来的性能冲击。
有了正确构建的Triton::Ocean,只需在运行时调用Triton::Ocean::GetHeight()方法,就可以查询给定射线与海洋表面相交处的海洋表面的高度和法线。比如说:
Triton::Vector3 testPos(0.0, 100.0, 0.0);
Triton::Vector3 down(0.0, -1.0, 0.0);
Triton::Vector3 normal;
float height = 0;
if (ocean && ocean->GetHeight(testPos, down, height, normal, true)) {
// do something with the height at this point...
}
返回的高度将精确到海洋网格的一个网格顶点之内。
对于使用倾斜于海洋表面的射线进行相交测试的特殊情况,你可能想看看Triton::Ocean::GetWavesIntersection(),以获得更大的精度,但要以性能为代价。
渝公网安备50010702505508