Am 16.04.2008 um 17:41 schrieb Kai Sterker:

Lets start simple, with what we need for rendering an object visible in a map view:

* Its "base point", i.e. the location at which it needs to be drawn.
* Its position and size, so that we know when it intersects with the map view.
* Its z position, for the order in which to draw overlapping objects.

All that information is available when placing objects on the map, we only need to get it into a structure that is efficient for rendering.

Which we kind of have right now, except for the problem with the objects at height != zero. Here's a little sketch to demonstrate what is going on there:

First, a view of our map, as seen in the game:

<<inline: top-view.png>>


The dark brown rectangles represent the ground covered by objects placed on the map, with a distance -z and +z below/above ground. The lighter rectangles show where they end up when rendered in the map view. Now lets look sideways at the same scene (thanks for the inspiring scary eye, James!), so that we can see actual heights:

<<inline: side-view.png>>



Imagine our map view just contains cell no. 2 and 3. There are no objects located directly on that cell (they are at 0, 1 and 4), but we could for example precompute a min_z and max_z value for each cell that would tell us how far away to look for objects that might have to be rendered on that square.

Even better though might be to enhance the square class (that represents a single cell in the map grid) to store two distinct types of information. The actual position of objects (for collision detection) and the position where objects would be rendered (for the map view). This seems to be a much simpler solution than what I was thinking about before, and it could be put to a test fairly fast with the current code. It will also show whether the rendering will still work as expected (I actually expect it to improve).

Yay ... back to coding!

Kai
_______________________________________________
Adonthell-devel mailing list
Adonthell-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/adonthell-devel

Reply via email to