Object Model¶
What a world object looks like once the game has built it: how tall it stands and the colours its faces are drawn in.
The models are put together the way the client does it for the shape the object is placed with, recoloured, retextured, resized and moved as the definition asks, and lit from the same fixed light and with the same ambient and contrast the client lights objects with. The colours are the lit ones, so they cover the range of shades the object is actually drawn in rather than only the flat colour it was modelled with.
Example:
model := TObjectModel.Create(objectDef, 10);
WriteLn(model.Height, ' ', model.Colors);
TObjectModel¶
Heightis how far the object rises above the ground, in the game’s units: a tile is128.Colorsare the colours its visible faces are drawn in, asTColors, most common first.Countsis how many face corners were drawn in each ofColors.ValidisFalsewhen the object has no model for the shape it was asked for.
ObjectModel.ModelType¶
function TObjectModel.ModelType(locType: Integer): Integer; static;
The shape whose models the client draws an object placed as locType with. Wall decorations of
every kind share the models of the straight one, 4, and a diagonal object (11) is an ordinary
one (10) turned by 45 degrees.
ObjectModel.ModelIDs¶
function TObjectModel.ModelIDs(constref def: TObjectDefinition; locType: Integer): TIntegerArray; static;
The ids of the models the client builds def from when it is placed as locType.
A definition that lists no shapes only has models for an ordinary object and every model it lists is drawn together. One that does list shapes has a single model per shape.
ObjectModel.Build¶
function TObjectModel.Build(ids, recolorFind, recolorReplace, retextureFind, retextureReplace: TIntegerArray; scaleX, scaleHeight, scaleY, ambient, contrast: Integer): TObjectModel; static;
Builds the models ids and measures them. Each one is recoloured, retextured and resized as
asked and lit with ambient and contrast, which are the values TLitModel.Light takes, the
client’s base already added.
It is always built facing north: turning it would only move which of its faces the light falls on, not the range of shades they are drawn in.
Faces that are hidden or see-through are left out of the colours, since what shows through them is whatever is behind the model. Textured faces count as their texture’s TTextureLoader.AverageColor, darkened by their light the way the rasterizer darkens each texel.
This is what TObjectModel.Create and TNPCModel.Create build their models with.
ObjectModel.Create¶
function TObjectModel.Create(constref def: TObjectDefinition; locType: Integer): TObjectModel; static;
Builds def as it is drawn when placed as locType and measures it with
TObjectModel.Build, lit the way the client lights world objects.