Graphics:Models

From Adonthell
Jump to navigation Jump to search

By augmenting a sprite with additional information, we can create an object that is ready for placement on the map: a model.

Purpose of Models

A model combines the graphical representation of an object with a physical shape. As explained in the chapter about in-game graphics, sprites are drawn to give a 3-dimensional appearance to the game world. Internally, the engine uses indeed a (simple) 3-dimensional representation for the purpose of collision detection and rendering. The shape of each model is used to build this internal 3D representation and the sprite is used to visualize it on screen.

As such, it is important to understand how sprite and shape fit together, as only precisely built models will ensure a game world where characters won't get stuck or fall through the ground and where objects are rendered without glitches.

Construction of Models

Example Models

Since the 3D representation will not be visible directly, it does not have to be very detailed. Therefore, the basic shape is a simple cube. It can be deformed to match the actual sprite and, where necessary, multiple cubes can be used to represent more complex sprites.

For non-rectangular sprites, individual corners of the cube can be moved freely in space and even onto each other to make diagonal or triangular shapes. Note however that it is not allowed to make completely flat (i.e. two-dimensional) shapes, as collision detection will not function properly around those. So even floor tiles will have to have a certain height.

To align a sprite with the shapes, an additional offset can be specified. This offset is only 2-dimensional, since from the renderers perspective, depth and height (y and z axis) are the same.

To aid with the construction of models, the modeller tool has been created. There is a tutorial providing step-by-step instructions to its basic functionality and a more detailed reference explaining all of its features.

Restrictions


Wall and ceiling don't overlap

Wall and ceiling intersect

While one can create models in any possible shape and size, the way a scene is rendered imposes some restrictions on that freedom. The most important restriction is to avoid overlap or intersections of two models when placed next to each other. Consider the example of a wall corner and a ceiling tile on the right (presented in a more 3D-ish view to better illustrate the situation):

In the first picture, a ceiling tile aligned to grid will intersect with the inner part of the wall. During rendering, this may cause parts of the wall to appear on top of the ceiling.

The solution to this problem can be seen in the second picture, where the wall has been split into an outer and inner part, that allows the ceiling tile to rest on top of the inner wall.

Conventions

All models created for Adonthell should adhere to the standards described below, as it will ensure that everything will line up correctly.

Floor

Floor tiles should have a length of 48px and a width of 36px or multiples thereof. 48px by 72px and 96px by 72px would be common sizes. The height of floor tiles is 8px. (Zero height floors are not supported by the engine).

Walls

Wall tiles come in two variations. Inside walls have a height of 88px, outside walls have a height of 96px. The remaining dimensions can be had from the templates available for inside and outside walls.

Wall tiles follow a specific naming scheme that can be gleaned from the picture below. Filenames for inside walls (shown in turquoise) begin with "ins-", while filenames for outside walls (shown in purple) begin with "out-". This is then followed by 3 characters: The first denotes if it is a straight (S), inside corner (I) or outside corner (O). The 2nd denotes front (F) or back (B) or is (x) if it is neither/irrelevant. The 3rd then if left (L), right (R) or neither (x).

Parts and naming of wall tiles

The parts of a particular kind of wall (stone, wood, etc.) are grouped in a folder. Adding that to the individual filenames is therefore redundant. Finally, if there are variations of certain parts, then "_variation-name" can be appended. E.g.:

 ...
  |
  +- wall
        +- stone
               +- out-SBx.png
               +- out-SBx_cracked.png
               +- out-SBx_double_with_window.png

Doorways

Doorways are handled mostly like walls, except they are prefixed with _doorway. They have the size of horizontal or vertical walls, with an opening of 48px for horizontal and 36px for vertical doors. In both cases, the height of the opening should be at least 64px. For vertical doorways, some indication is needed to help locate the actual opening, as it will not be directly visible with the top-down view that Adonthell uses.