Table of Contents

Interface ITesselatorAPI

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Interface that allows custom model model meshing for items, blocks and entities
Texturing crash course:

  1. Block, Item and Entity textures are loaded from json files in the form of a CompositeTexture instance
  2. After connecting to a game server, the client inserts all of these textures into their type-respective texture atlasses
  3. After insertion a "texture sub-id" is left behind in the CompositeTexture.Baked Property
  4. You can now find the position of the texture inside the atlas through the Block/Item/Entity-TextureAtlasPositions arrays (teturesubid is the array key)

    Shape Tesselation crash course:
  5. Block and Item shapes are loaded from json files in the form of a CompositeShape instance
  6. A CompositeShape instance hold some block/item specific information as well as an identifier to a Shape instance
  7. After connecting to a game server, the client loads all shapes from the shape folder then finds each blocks/items shape by its shape identifier
  8. Result is a MeshData instance that holds all vertices, UV coords, colors and etc. for each block
  9. That meshdata instance is
    a) Held as-is in memory for using during chunk tesselation (you can get a reference to it through getDefaultBlockMesh())
    b) "Compiled" to a Model for use during rendering in the gui.
    Model Compilation means all it's mesh data is uploaded onto the graphcis through a VAO and a ModelRef instance is left behind which
    can be used by the RenderAPI to render it.
public interface ITesselatorAPI
Extension Methods

Methods

GetTexSource(Block, int, bool)

[Obsolete("Use GetTextureSource instead")]
ITexPositionSource GetTexSource(Block block, int altTextureNumber = 0, bool returnNullWhenMissing = false)

Parameters

block Block
altTextureNumber int
returnNullWhenMissing bool

Returns

ITexPositionSource

GetTextureSource(Block, int, bool)

Returns the texture source from given block. This can be used to obtain the positions of the textures in the block texture atlas.

ITexPositionSource GetTextureSource(Block block, int altTextureNumber = 0, bool returnNullWhenMissing = false)

Parameters

block Block
altTextureNumber int
returnNullWhenMissing bool

Returns

ITexPositionSource

GetTextureSource(Entity, Dictionary<string, CompositeTexture>, int, bool)

Returns the texture source from given entity. This can be used to obtain the positions of the textures in the entity texture atlas.

ITexPositionSource GetTextureSource(Entity entity, Dictionary<string, CompositeTexture> extraTextures = null, int altTextureNumber = 0, bool returnNullWhenMissing = false)

Parameters

entity Entity
extraTextures Dictionary<string, CompositeTexture>
altTextureNumber int
returnNullWhenMissing bool

Returns

ITexPositionSource

GetTextureSource(Item, bool)

Returns the texture source from given item. This can be used to obtain the positions of the textures in the item texture atlas.

ITexPositionSource GetTextureSource(Item item, bool returnNullWhenMissing = false)

Parameters

item Item
returnNullWhenMissing bool

Returns

ITexPositionSource

TesselateBlock(Block, out MeshData)

Tesselates a block for you using given blocks shape and texture configuration

void TesselateBlock(Block block, out MeshData modeldata)

Parameters

block Block
modeldata MeshData

TesselateItem(Item, out MeshData)

Tesselates an item for you using given items shape and texture configuration

void TesselateItem(Item item, out MeshData modeldata)

Parameters

item Item
modeldata MeshData

TesselateItem(Item, out MeshData, ITexPositionSource)

Tesselates an item for you using the items shape and your own defined texture configuration. You need to implement the ITextureSource yourself.

void TesselateItem(Item item, out MeshData modeldata, ITexPositionSource texSource)

Parameters

item Item
modeldata MeshData
texSource ITexPositionSource

TesselateItem(Item, CompositeShape, out MeshData)

Tesselates an item for you using given items shape and texture configuration

void TesselateItem(Item item, CompositeShape forShape, out MeshData modeldata)

Parameters

item Item
forShape CompositeShape
modeldata MeshData

TesselateShape(string, AssetLocation, CompositeShape, out MeshData, ITexPositionSource, int, byte, byte, int?, string[])

Tesselate a shape based on its composite shape file

void TesselateShape(string type, AssetLocation name, CompositeShape compositeShape, out MeshData modeldata, ITexPositionSource texSource, int generalGlowLevel = 0, byte climateColorMapIndex = 0, byte seasonColorMapIndex = 0, int? quantityElements = null, string[] selectiveElements = null)

Parameters

type string
name AssetLocation
compositeShape CompositeShape
modeldata MeshData
texSource ITexPositionSource
generalGlowLevel int
climateColorMapIndex byte
seasonColorMapIndex byte
quantityElements int?
selectiveElements string[]

TesselateShape(string, Shape, out MeshData, ITexPositionSource, Vec3f, int, byte, byte, int?, string[])

Turns a shape into a mesh data object that you can feed into the chunk tesselator or upload to the graphics card for rendering. Can be used to supply a custom texture source.

void TesselateShape(string typeForLogging, Shape shapeBase, out MeshData modeldata, ITexPositionSource texSource, Vec3f meshRotationDeg = null, int generalGlowLevel = 0, byte climateColorMapId = 0, byte seasonColorMapId = 0, int? quantityElements = null, string[] selectiveElements = null)

Parameters

typeForLogging string
shapeBase Shape
modeldata MeshData
texSource ITexPositionSource
meshRotationDeg Vec3f
generalGlowLevel int
climateColorMapId byte
seasonColorMapId byte
quantityElements int?
selectiveElements string[]

TesselateShape(TesselationMetaData, Shape, out MeshData)

Turns a shape into a mesh data object that you can feed into the chunk tesselator or upload to the graphics card for rendering. Can be used to supply a custom texture source. Will add a customints array to the meshdata that holds each elements JointId for all its vertices (you will have to manually set the jointid for each element though)

void TesselateShape(TesselationMetaData meta, Shape shapeBase, out MeshData modeldata)

Parameters

meta TesselationMetaData
shapeBase Shape
modeldata MeshData

TesselateShape(CollectibleObject, Shape, out MeshData, Vec3f, int?, string[])

Turns a shape into a mesh data object that you can feed into the chunk tesselator or upload to the graphics card for rendering. Uses the given collectible texture configuration as texture source.

void TesselateShape(CollectibleObject textureSourceCollectible, Shape shape, out MeshData modeldata, Vec3f meshRotationDeg = null, int? quantityElements = null, string[] selectiveElements = null)

Parameters

textureSourceCollectible CollectibleObject
shape Shape
modeldata MeshData
meshRotationDeg Vec3f
quantityElements int?
selectiveElements string[]

TesselateShapeWithJointIds(string, Shape, out MeshData, ITexPositionSource, Vec3f, int?, string[])

Turns a shape into a mesh data object that you can feed into the chunk tesselator or upload to the graphics card for rendering. Can be used to supply a custom texture source. Will add a customints array to the meshdata that holds each elements JointId for all its vertices (you will have to manually set the jointid for each element though)

void TesselateShapeWithJointIds(string typeForLogging, Shape shapeBase, out MeshData modeldata, ITexPositionSource texSource, Vec3f rotation, int? quantityElements = null, string[] selectiveElements = null)

Parameters

typeForLogging string
shapeBase Shape
modeldata MeshData
texSource ITexPositionSource
rotation Vec3f
quantityElements int?
selectiveElements string[]

VoxelizeTexture(int[], int, int, Size2i, TextureAtlasPosition)

A helper method that turns a flat texture into its 1-voxel thick voxelized form

MeshData VoxelizeTexture(int[] texturePixels, int width, int height, Size2i atlasSize, TextureAtlasPosition pos)

Parameters

texturePixels int[]
width int
height int
atlasSize Size2i
pos TextureAtlasPosition

Returns

MeshData

VoxelizeTexture(CompositeTexture, Size2i, TextureAtlasPosition)

A helper method that turns a flat texture into its 1-voxel thick voxelized form

MeshData VoxelizeTexture(CompositeTexture texture, Size2i atlasSize, TextureAtlasPosition atlasPos)

Parameters

texture CompositeTexture
atlasSize Size2i
atlasPos TextureAtlasPosition

Returns

MeshData