Table of Contents

Class ModelHitboxTransform

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Handles transformation matrix building and ray transformations for 3D model raycasting. Encapsulates the logic for converting between screen space and model local space. Open in GitHub

public class ModelHitboxTransform
Inheritance
ModelHitboxTransform
Inherited Members
Extension Methods

Constructors

ModelHitboxTransform(ICoreClientAPI, Func<float>, Func<float>, Func<float>, Func<(float, float)>, bool)

public ModelHitboxTransform(ICoreClientAPI capi, Func<float> getYaw, Func<float> getPitch, Func<float> getScale, Func<(float, float)> getScreenPosition = null, bool flipY = false)

Parameters

capi ICoreClientAPI
getYaw Func<float>
getPitch Func<float>
getScale Func<float>
getScreenPosition Func<(float x, float y)>
flipY bool

Properties

GetAnimatorMatrices

Optional accessor for the animator's joint matrices. When set, BuildTransformMatrix will apply joint animation transforms so raycasting matches animated positions.

public Func<float[]> GetAnimatorMatrices { get; set; }

Property Value

Func<float[]>

ModelOriginOffset

Optional offset applied in model space after scale (e.g. -0.5, 0, -0.5 to center VS block models).

public (float x, float y, float z) ModelOriginOffset { get; set; }

Property Value

(float x, float y, float z)

Methods

BuildFullTransformMatrix(ElementHitbox)

Builds the full transformation matrix for rendering (including hitbox position and size). Used for wireframe rendering.

public Matrixf BuildFullTransformMatrix(ElementHitbox hitbox)

Parameters

hitbox ElementHitbox

Returns

Matrixf

BuildTransformMatrix(ElementHitbox)

Builds a transformation matrix for rendering a hitbox. Matches the rendering transformation order.

public Matrixf BuildTransformMatrix(ElementHitbox hitbox)

Parameters

hitbox ElementHitbox

Returns

Matrixf

GetScreenCenter(out float, out float)

Gets the screen center coordinates.

public void GetScreenCenter(out float centerX, out float centerY)

Parameters

centerX float
centerY float

TransformHitToScreen(Vec3d, ElementHitbox)

Transforms a local space hit position back to screen space.

public Vec3d TransformHitToScreen(Vec3d localHitPos, ElementHitbox hitbox)

Parameters

localHitPos Vec3d
hitbox ElementHitbox

Returns

Vec3d

TransformRayToLocal(Vec3d, Vec3d, ElementHitbox, out Vec3d, out Vec3d)

Transforms a ray from screen space to local hitbox space using matrix inversion.

public void TransformRayToLocal(Vec3d rayOrigin, Vec3d rayDir, ElementHitbox hitbox, out Vec3d localOrigin, out Vec3d localDir)

Parameters

rayOrigin Vec3d
rayDir Vec3d
hitbox ElementHitbox
localOrigin Vec3d
localDir Vec3d