Hi, Could you please point me to an article on a Line of Sight RENDERING algorithm? I'm looking for something similar to the one used in the Commandos series of games (by Pyro Studios). The Line of Sight cone/triangle must be rendered (in a top down view) with appropriate shadows caused by obstructions. Thanks
+1
A:
In pseudo-code:
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
egarcia
2010-07-13 08:01:01
Thanks for your answer, but I was mainly looking for an algorithm for rendering the LOS region.
Evans
2010-08-23 15:46:02