你能给我指点一篇关于视线渲染算法的文章吗?我正在寻找类似于 Commandos 系列游戏(由 Pyro Studios 开发)中使用的东西。视线锥体/三角形必须渲染(在自上而下的 View 中)由障碍物引起的适当阴影。 谢谢
最佳答案
在伪代码中:
function get_visible_objects(observer)
/* get the list of objects inside the cone of vision */
in_cone = get_the_objects_inside(observer.cone)
/* sort the objects by proximity to the observer */
sorted = in_cone.sort_by_distance_to(observer)
/* visible is the result. start with all the objects in the cone */
visible = sorted.copy
/* parse the objects in the cone, from nearest to the observer to farthest away,
and remove any objects occluded */
for each object in sorted do
/* remove any other object that is occluded by object */
to_remove = []
for each other in visible do
if object.occludes(other) then
to_remove.add(other)
end
end
visible = visible - to_remove
end
return visible
end
关于algorithm - 突击队风格的视线算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3227523/