Table of Contents

Class Hud3DElement

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Abstract base class for HUD elements rendered as 3D models in orthographic projection. Open in GitHub

public abstract class Hud3DElement : HudElement, IRenderer, IDisposable, ITexPositionSource
Inheritance
Hud3DElement
Implements
Derived
Inherited Members
Extension Methods

Constructors

Hud3DElement(ICoreClientAPI)

public Hud3DElement(ICoreClientAPI capi)

Parameters

capi ICoreClientAPI

Fields

OverlayMaxAlpha

protected const float OverlayMaxAlpha = 0.5

Field Value

float

activeAnimationsByAnimCode

protected Dictionary<string, AnimationMetaData> activeAnimationsByAnimCode

Field Value

Dictionary<string, AnimationMetaData>

animator

protected ClientAnimator animator

Field Value

ClientAnimator

atlasTextureId

protected int atlasTextureId

Field Value

int

meshRef

protected MultiTextureMeshRef meshRef

Field Value

MultiTextureMeshRef

modelMatrix

protected Matrixf modelMatrix

Field Value

Matrixf

pendingAnimations

protected Queue<AnimationMetaData> pendingAnimations

Field Value

Queue<AnimationMetaData>

pitch

protected float pitch

Field Value

float

prog

protected IShaderProgram prog

Field Value

IShaderProgram

shape

protected Shape shape

Field Value

Shape

shapeTextureSource

protected ShapeTextureSource shapeTextureSource

Field Value

ShapeTextureSource

shouldRender

protected bool shouldRender

Field Value

bool

yaw

protected float yaw

Field Value

float

Properties

AtlasSize

This returns the size of the atlas this texture resides in.

public Size2i AtlasSize { get; }

Property Value

Size2i

CenterModelOrigin

If true, offsets the model by -0.5, 0, -0.5 (in model space) to center it. VS block/shape models have their origin at (8,0,8) in pixel coords = (0.5, 0, 0.5) in units.

protected virtual bool CenterModelOrigin { get; }

Property Value

bool

FlipY

protected virtual bool FlipY { get; }

Property Value

bool

this[string]

public TextureAtlasPosition this[string textureCode] { get; }

Parameters

textureCode string

Property Value

TextureAtlasPosition

RenderOrder

0 = drawn first, 1 = drawn last
Default render orders by render stage:
Before:
0 = Ambient Manager
0 = Camera

Opaque:
0.1 = Blue sky (Icosahedron)
0.2 = Night skybox
0.3 = Sun and moon
0.37 = Terrain opaque
0.4 = Enitities
0.5 = Decals
0.5 = Debug wireframe
0.6 = particles
0.7 = Cinematic camera line preview
0.8 = fp held item
0.9 = held item opaque custom renderer

OIT:
0.2 = Frame buffer debug screen
0.35 = Clouds
0.37 = Terrain oit
0.4 = Enitities
0.6 = particles
0.9 = held item oit custom renderer

Shadow far:
0 = shadow map init
0.37 = Terrain shadow far
0.4 = Enitities

Shadow far done:
1 = shadow map finish

Shadow near:
0 = shadow map init
0.37 = Terrain shadow near
0.4 = Enitities

Shadow near done:
1 = shadow map finish
Ortho:
0.2 = Frame buffer debug screen
0.4 = Enitities
0.9 = held item ortho custom renderer
0.95 = sleeping overlay
0.98 = bow/spear aiming reticle
1 = Gui manager
1.02 = crosshair and mouse cursor

AfterFinalComposition:
2 = screenshot

Done:
0.1 = gui manager
2 = screenshot

0.98 = Cinematic camera camera advancing and frame capture when recording
0.99 = Chunk Tesselator Manager (uploads new/modified chunk meshes)
0.999 = Compress chunks scan
1 = video recorder

public double RenderOrder { get; }

Property Value

double

RenderRange

Within what range to the player OnRenderFrame() should be called (currently not used!)

public int RenderRange { get; }

Property Value

int

RendererName

protected abstract string RendererName { get; }

Property Value

string

ShapePath

protected abstract string ShapePath { get; }

Property Value

string

Methods

Dispose()

Disposes the Dialog.

public override void Dispose()

GetDynamicAtlasSize(string)

protected virtual Size2i GetDynamicAtlasSize(string textureCode)

Parameters

textureCode string

Returns

Size2i

GetDynamicTexturePosition(string)

protected virtual TextureAtlasPosition GetDynamicTexturePosition(string textureCode)

Parameters

textureCode string

Returns

TextureAtlasPosition

GetModelScale()

We should aim for 100 scale as it fits best on the UI but other scales are supported for special elements or elements that require manual rescaling.

protected virtual float GetModelScale()

Returns

float

GetModelScreenPosition()

protected virtual (float x, float y) GetModelScreenPosition()

Returns

(float yOffsetDeg, float zOffsetDeg)

GetModelZOffset()

Z position for the model in orthographic space. Only affects depth clipping, not apparent size.

protected virtual float GetModelZOffset()

Returns

float

LoadAndTessellateShape()

Loads shape, inserts textures into atlas, tessellates, uploads mesh, creates animator.

protected void LoadAndTessellateShape()

OnBeforeRenderMesh()

protected virtual void OnBeforeRenderMesh()

OnPostRender3D(float, EnumRenderStage)

protected virtual void OnPostRender3D(float deltaTime, EnumRenderStage stage)

Parameters

deltaTime float
stage EnumRenderStage

OnPreRender3D(float)

protected virtual void OnPreRender3D(float deltaTime)

Parameters

deltaTime float

OnRenderFrame(float, EnumRenderStage)

Called every frame for rendering whatever you need to render

public void OnRenderFrame(float deltaTime, EnumRenderStage stage)

Parameters

deltaTime float
stage EnumRenderStage

OnShapeTessellated()

protected virtual void OnShapeTessellated()

RenderComposerToFbo(GuiComposer, FrameBufferRef, RawTexture, float)

Renders a GuiComposer into a framebuffer, saving and restoring GL state.

protected void RenderComposerToFbo(GuiComposer composer, FrameBufferRef fbo, RawTexture colorTexture, float deltaTime)

Parameters

composer GuiComposer
fbo FrameBufferRef
colorTexture RawTexture
deltaTime float

RenderDimOverlay(float)

protected void RenderDimOverlay(float alpha)

Parameters

alpha float

RenderMeshWithCurrentState(MultiTextureMeshRef, bool)

Renders any MultiTextureMeshRef using the current model transform, shader, and animation state.

protected void RenderMeshWithCurrentState(MultiTextureMeshRef mesh, bool applyAnimation = true)

Parameters

mesh MultiTextureMeshRef
applyAnimation bool

ShouldRenderMesh()

protected virtual bool ShouldRenderMesh()

Returns

bool

StartAnimation(string, float, bool, EnumAnimationBlendMode)

public bool StartAnimation(string code, float speed = 1, bool stopOthers = false, EnumAnimationBlendMode blendMode = EnumAnimationBlendMode.Average)

Parameters

code string
speed float
stopOthers bool
blendMode EnumAnimationBlendMode

Returns

bool

StopAnimation(string)

public void StopAnimation(string code)

Parameters

code string

StopAnimationsWithPrefix(string)

Stops all animations whose code starts with the given prefix.

public void StopAnimationsWithPrefix(string prefix)

Parameters

prefix string

TessellateFiltered(string[], string[])

Tessellates the current shape with element name filters. Uses the already-resolved shape (joints, textures, etc.) from LoadAndTessellateShape.

protected MultiTextureMeshRef TessellateFiltered(string[] selectiveElements = null, string[] ignoreElements = null)

Parameters

selectiveElements string[]

If set, only these element names are tessellated.

ignoreElements string[]

If set, these element names are excluded.

Returns

MultiTextureMeshRef

Uploaded mesh ref, or null on failure. Caller owns disposal.