Okay here's my early draft for the view design doc.

Background info

===============

Prerequisites: background info on elevation, layer, camera

Handedness

The handedness of a coordinate system determines how the axes grow from the origin. There are only 2 of them: left or right. Those who have taken higher chemistry classes might find this familiar with the term 'chiralty'. [1]

our engine

=======================

#1 - Relationship between elevation, layer(cellgrid) and screen coordinate system.Each exists in their own coordinate space. Since each layer is contained within an elevation, layer->elevation coordinate mapping can be done. This is also what happens when an instance is drawn. A layer->elevation->screen coordinate mapping is used to find the screen coordinate of an instance and draw it.

Layer coordinate transformation sequence is rotate->scale->translate for easy visibility on changes during mapping. Keep this in mind when you are adjusting cellgrids for a map. Transformation on the layer coordinate is visually independent of the elevation coordinate space.

Elevation coordinate transformation is translate->scale->rotate->tilt. Transformation on elevation coordinate will have a visual effect on layer/cellgrid coordinate space.

Lastly ,we have the screen coordinate, which is basically the coordinate space on which everything is drawn. take note that although it says 'screen', it's not a 2d space. It's in fact, 3D. the elevation->screencoord transformation maps the model coordinate onto actual pixels for rendering. Thus, the z-coord of a screencoordinate is in pixels unit.

#2 - Coordinate system and transformationAll coordinate spaces are left-handed. The most important feature is that the y-axis increases downward instead of upward (in keeping with SDL coordinate ). Another point is that z-axis increases as it goes out of the screen into the observer's face.

Our transformation matrix reflects the left-handed transformation. for example, our rotation matrix looks something similar to this(left side):

* from

http://www.cprogramming.com/tutorial/3d/rotation.htmlRotations at positive angle around a left-handed axes is shown here,

#3 - Camera positioning & movement The camera, at 0 angle and constant reference scale, is located at a constant z-coord. The reference scale specifies that at certain zoom value, how much of an area is viewed through the viewport. Changing the camera's location will only change it's (x,y) value. The camera is also capable of infinite(almost

) zoom/scale factor. Tilting the camera keeps it's pointing vector at the same magnitude. However, the camera itself moves around the elevation x-axis (range:[0,-90] for now, with the vector changing direction to keep pointing at it's x,y location.

When a camera rotates, the camera pointing vector also changes while the magnitude is preserved. The camera position range & movement can be described in a circular track around it's location[2]. However, the track of which the camera follows will depend on the tilt value. At tilt value of 90, the track's z-coord is 0.

My comments

=====================

[1] Transformation matrix between a left-hand & right hand coordinates system will differ, and thus we need to choose one that we are comfortable with and stick with that. From the original codebase, I found that a left-handed transformation matrix was used in LoadRotate. So, we will use left-handed coordinate axes for the rest of the time.

[2]Remember, a camera's location is the layer coordinate of which is viewed at the center of the camera's viewport.