2010-07-12 98 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