algorithm - 突击队风格的视线算法

标签 algorithm

你能给我指点一篇关于视线渲染算法的文章吗?我正在寻找类似于 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/

相关文章:

java - 查找列表中的频率差异元素

algorithm - 从给定集合中找到所有对给定数字(允许重复)求和的方法

algorithm - 找到 bin 和 objects 的所有可能性

algorithm - 计算 3D 高度图的轮廓?

java - 使用 DFS 生成迷宫失败,我不知道为什么

java - 分析单词文本的算法

javascript - 按另一个数组中指定的索引对数组进行排序,最佳算法

algorithm - 高效计算 n 组的交集

algorithm - Eratosthenes 概率筛法

java - 创建一个单词中一组字母的每个可能频率的列表?