SetObjDrawTransform

Category: Objects / Display
Since engine version: 1.0 OC

Description

Transforms the image of the object.

Syntax

bool SetObjDrawTransform(int width, int xskew, int xadjust, int yskew, int height, int yadjust, int overlay_id);

Parameters

width:
Width of the image. Original width is 1000. A negative value means horizontal mirroring. The image is always centered.
xskew:
Horizontal skew of the image: 0 means no skewing. 1000 yields a 45° offset of the horizontal edges (top edge to the left, bottom edge to the right). Negative values yield an offset into the opposite direction.
xadjust:
Horizontal image offset. Value 1000 moves the image one pixel to the right. Negative values move the image to the left. This means you can also move the image by fractions of a pixel.
yskew:
Vertical skew of the image: 0 means no skewing. 1000 yields a 45° offset of the vertical edges (left edge up, right edge down). Negative values yield an offset into the opposite direction.
height:
Height of the image. Original height is 1000. A negative value means vertical mirroring. The image is always centered.
yadjust:
Vertical image offset. Value 1000 moves the image one pixel down. Negative values move the image up. This means you can also move the image by fractions of a pixel.
overlay_id:
ID of the overlay the transform of which you want to adjust. Value 0 (default) indicates the main image (not an overlay).

Remark

As there are no floating-point values in Clonk, all values are per thousand (1000 = 1 = 100%). This allows specifiying fractions of one.

Examples

SetObjDrawTransform(1000,0,0,0,1000,0);
Resets all transformation.
global func SetDTRotation (int r, int xoff, int yoff, object obj) {
  var fsin=Sin(r, 1000), fcos=Cos(r, 1000);
  // set matrix values
  obj->SetObjDrawTransform (
    +fcos, +fsin, (1000-fcos)*xoff - fsin*yoff,
    -fsin, +fcos, (1000-fcos)*yoff + fsin*xoff,
  );
}
Rotates the image of the object without rotating the actual object (i.e. vertices and other interactive elements stay where they are).
GetHiRank(0)->SetObjDrawTransform(1000,0,0,0,-1000,0);
Turns the image of the player's highest ranking clonk upside down.
SetObjDrawTransform(500,0,0,0,500,GetDefHeight(GetID())*1000/4);
Reduces the image of the object by 50% and moves the bottom edge of the reduced image to the bottom edge of the object: if you use this to reduce the image of a tree, the reduced tree will not float in mid-air but will properly rest with its roots on the ground).
Clonkonaut, 2008-05