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
capiICoreClientAPIgetYawFunc<float>getPitchFunc<float>getScaleFunc<float>getScreenPositionFunc<(float x, float y)>flipYbool
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
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
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
hitboxElementHitbox
Returns
BuildTransformMatrix(ElementHitbox)
Builds a transformation matrix for rendering a hitbox. Matches the rendering transformation order.
public Matrixf BuildTransformMatrix(ElementHitbox hitbox)
Parameters
hitboxElementHitbox
Returns
GetScreenCenter(out float, out float)
Gets the screen center coordinates.
public void GetScreenCenter(out float centerX, out float centerY)
Parameters
TransformHitToScreen(Vec3d, ElementHitbox)
Transforms a local space hit position back to screen space.
public Vec3d TransformHitToScreen(Vec3d localHitPos, ElementHitbox hitbox)
Parameters
localHitPosVec3dhitboxElementHitbox
Returns
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
rayOriginVec3drayDirVec3dhitboxElementHitboxlocalOriginVec3dlocalDirVec3d