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
capiICoreClientAPI
Fields
OverlayMaxAlpha
protected const float OverlayMaxAlpha = 0.5
Field Value
activeAnimationsByAnimCode
protected Dictionary<string, AnimationMetaData> activeAnimationsByAnimCode
Field Value
animator
protected ClientAnimator animator
Field Value
atlasTextureId
protected int atlasTextureId
Field Value
meshRef
protected MultiTextureMeshRef meshRef
Field Value
modelMatrix
protected Matrixf modelMatrix
Field Value
pendingAnimations
protected Queue<AnimationMetaData> pendingAnimations
Field Value
pitch
protected float pitch
Field Value
prog
protected IShaderProgram prog
Field Value
shape
protected Shape shape
Field Value
shapeTextureSource
protected ShapeTextureSource shapeTextureSource
Field Value
shouldRender
protected bool shouldRender
Field Value
yaw
protected float yaw
Field Value
Properties
AtlasSize
This returns the size of the atlas this texture resides in.
public Size2i AtlasSize { get; }
Property Value
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
FlipY
protected virtual bool FlipY { get; }
Property Value
this[string]
public TextureAtlasPosition this[string textureCode] { get; }
Parameters
textureCodestring
Property Value
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
RenderRange
Within what range to the player OnRenderFrame() should be called (currently not used!)
public int RenderRange { get; }
Property Value
RendererName
protected abstract string RendererName { get; }
Property Value
ShapePath
protected abstract string ShapePath { get; }
Property Value
Methods
Dispose()
Disposes the Dialog.
public override void Dispose()
GetDynamicAtlasSize(string)
protected virtual Size2i GetDynamicAtlasSize(string textureCode)
Parameters
textureCodestring
Returns
GetDynamicTexturePosition(string)
protected virtual TextureAtlasPosition GetDynamicTexturePosition(string textureCode)
Parameters
textureCodestring
Returns
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
GetModelScreenPosition()
protected virtual (float x, float y) GetModelScreenPosition()
Returns
GetModelZOffset()
Z position for the model in orthographic space. Only affects depth clipping, not apparent size.
protected virtual float GetModelZOffset()
Returns
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
deltaTimefloatstageEnumRenderStage
OnPreRender3D(float)
protected virtual void OnPreRender3D(float deltaTime)
Parameters
deltaTimefloat
OnRenderFrame(float, EnumRenderStage)
Called every frame for rendering whatever you need to render
public void OnRenderFrame(float deltaTime, EnumRenderStage stage)
Parameters
deltaTimefloatstageEnumRenderStage
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
composerGuiComposerfboFrameBufferRefcolorTextureRawTexturedeltaTimefloat
RenderDimOverlay(float)
protected void RenderDimOverlay(float alpha)
Parameters
alphafloat
RenderMeshWithCurrentState(MultiTextureMeshRef, bool)
Renders any MultiTextureMeshRef using the current model transform, shader, and animation state.
protected void RenderMeshWithCurrentState(MultiTextureMeshRef mesh, bool applyAnimation = true)
Parameters
meshMultiTextureMeshRefapplyAnimationbool
ShouldRenderMesh()
protected virtual bool ShouldRenderMesh()
Returns
StartAnimation(string, float, bool, EnumAnimationBlendMode)
public bool StartAnimation(string code, float speed = 1, bool stopOthers = false, EnumAnimationBlendMode blendMode = EnumAnimationBlendMode.Average)
Parameters
codestringspeedfloatstopOthersboolblendModeEnumAnimationBlendMode
Returns
StopAnimation(string)
public void StopAnimation(string code)
Parameters
codestring
StopAnimationsWithPrefix(string)
Stops all animations whose code starts with the given prefix.
public void StopAnimationsWithPrefix(string prefix)
Parameters
prefixstring
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
selectiveElementsstring[]If set, only these element names are tessellated.
ignoreElementsstring[]If set, these element names are excluded.
Returns
- MultiTextureMeshRef
Uploaded mesh ref, or null on failure. Caller owns disposal.