Orientation

By
Dave
2011
May
17
20:48
Posted in

Since I wanted to support running the application on a Microsoft Surface device, it was important to cater for multi-directional interaction. User interface (UI) components can eiher be directional or not. For example, the camera view is non-directional in the sense that it is valid for all users regardless of direction (it is perfectly acceptable to be "upside down" when rolling through 180° in a 3D environment). Text labels, on the other hand, are directional and most beneficial when directly facing a user.

The following screenshots illustrate how the user interface supports multiple directions and multiple users.

Orientation

Figure 1. User interface shown orientated for single user.

Orientation

Figure 2. User interface components are shown with varying orientation to support multiple users.

Figure 2 shows a menu and reticle for each of two users on opposite sides. While there can be many instances of menus and reticles at any one time, a given instance is typically used by one user at a time. It is therefore possible to orient them to the relevant user, either by using the orientation of a Surface tag, or by using the orienation reported by the API for a touch event.

For items such as background labels which are shared between multiple users, it is necessary to pick a consistent orientation for all instances. This "system orientation" can either be determined in code (e.g. by examining the orientation of other directional UI components) or by a user via a menu setting. In Figure 2 the orienation has been chosen to face one of the two users.

While the system orientation is an analogue value (i.e. the background labels, for example, can face any consistent direction), it makes sense to axis-align the orientation of items such as the clock to a side of the screen.

Orbital Motion

By
Dave
2011
May
15
00:09
Posted in

Rather than simply using a fixed set of positions for planatary bodies, I wanted to calculate their positions. My initial apprach would only calculate approximate positions, however it was important to consider the following, regardless of the position algorithm used:

  • Calculating positions efficiently.
  • Displaying the system time.
  • Controlling the system time.
  • Camera behaviour when the point of interest changes position.
  • Camera behaviour when a new point of interest is chosen.

Position calculation

My first approach to optimising calculating positions is to only process items which may be visible in the current view. For items in an elliptical orbit, the item may be visible if the orbit is greater than a certain size in the current field of view. The semi-major axis is used to estimate orbital size.

An additional problem which arises is the requirement to correctly draw orbits, which are pre-calculated using a specified number of points. As a body moves around the orbit, drawing the orbit so a vertex exactly coincides with the selected object requires dynamically calculating vertices, at least near to the selected object in each frame.

Time display and control

Date and time is shown using a digital clock. The orientation of the time display is dertermined from the system orientation, rounded to the nearest 90° (i.e. aligned with an edge of the screen).

A dial menu is used to specify a positive or negative factor for adjusting time. A button on the menu can also be used to reset the time display to real-time (i.e. the current time and a factor of +1).

Time control and display

Figure 1. Time control and display.

Camera behaviour

The first consideration was how to adjust the absolute position of each camera type with respect to a moving body. For orbital cameras, the same relative position between the camera and the selected body is maintained. This also has the effect of keeping the background stars fixed. A free camera can operate with or without tracking the current point of interest (if any). When tracking is enabled, the camera maitains its position in space, but adjusts its orientation to keep the point of interest fixed.

Another implication for camera behaviour concerns how a camera transitions from one object to another. Previously the objects were fixed and a linear interpolation between initial and target positions could be used. When the target is moving a velocity-based approach can be used, which accelerates the camera towards the target while tracking its current position, until the camera has reached a given distance from the target and has synchronised velocity. Another option is a distance-based linear interpolation, which reduces the distance to the target over a specified time. While less physically realistic, it is easy to implement and has the benefit of a fixed time to move between objects. I am initially using the latter approach, combined with a simple SLERP of orientation.

Digital Clock

By
Dave
2011
May
07
17:03
Posted in

I was thinking about approaches for displaying the date and time in XNA applications. The easiest approach is simply to use the SpriteBatch class and render a string, however I wanted to be able to support a display of arbitrary sizes, which can be problemmatic with rasterized fonts.

I could use a set of vector fonts, however I would then have to calculate the vertices dynamically when the date or time changed.

An interesting alternative is to pre-generate the vertices for a digital clock. In this way, I have all the vertices I need in a VertexBuffer and can decide the colors for each segment on the GPU after passing the date and time as an effect parameter. An initial screenshot is shown in Figure 1.

Digital Clock

Figure 1. Digital Clock.

The "on" and "off" colors are set with effect parameters, and in Figure 1 I have used an "off" color to simulate light-bleed in a physical display.

The geometry is configurable with parameters for segment thickness, size of gap between segments, character spacing, seperator width and slant.