SetObjDrawTransform

Category: Objects / Display
Since engine version: 4.9.5.0 CE

Description

Transforms the image of the specified object.

Syntax

bool SetObjDrawTransform (int iWidth, int iXSkew, int iXAdjust, int iYSkew, int iHeight, int iYAdjust, object pObj, int iOverlayID);

Parameters

iWidth:
Width of the image. Original width is 1000. A negative value means horizontal mirroring. The image is always centered.
iXSkew:
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.
iXAdjust:
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.
iYSkew:
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.
iHeight:
Height of the image. Original height is 1000. A negative value means vertical mirroring. The image is always centered.
iYAdjust:
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.
pObj:
Object for which you want to perform an image transformation. Can be 0 in local calls.
iOverlayID:
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
  SetObjDrawTransform (
    +fcos, +fsin, (1000-fcos)*xoff - fsin*yoff,
    -fsin, +fcos, (1000-fcos)*yoff + fsin*xoff,
    obj
  );
}
Rotates the image of the object without rotating the actual object (i.e. vertices and other interactive elements stay where they are).
SetObjDrawTransform(1000,0,0,0,-1000,0,GetHiRank(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, Mai 2008