2010-07-12 148 views
2

的突击队式线能否请你点我的视线渲染算法的线的文章?我正在寻找类似于Commandos系列游戏中使用的类似游戏(由Pyro Studios制作)。视线圆锥/三角形必须呈现(在自上而下的视图中)并带有由障碍物引起的适当阴影。 感谢视觉算法

+4

你能描述的功能,还是应该购买游戏的答案吗? – 2010-07-12 11:26:09

+0

你有没有发现一种方法来做到这一点?我正在考虑制作一款Commandos风格的游戏,并且需要包含此功能。 – rfcoder89 2017-08-12 10:13:08

回答

1

在伪代码:

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 
+0

感谢您的回答,但我主要是在寻找渲染LOS区域的算法。 – BlueSilver 2010-08-23 15:46:02