Interface ITesselatorAPI
- Namespace
- Vintagestory.API.Client
- Assembly
- VintagestoryAPI.dll
Interface that allows custom model model meshing for items, blocks and entities
Texturing crash course:
- Block, Item and Entity textures are loaded from json files in the form of a CompositeTexture instance
- After connecting to a game server, the client inserts all of these textures into their type-respective texture atlasses
- After insertion a "texture sub-id" is left behind in the CompositeTexture.Baked Property
- 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: - Block and Item shapes are loaded from json files in the form of a CompositeShape instance
- A CompositeShape instance hold some block/item specific information as well as an identifier to a Shape instance
- 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
- Result is a MeshData instance that holds all vertices, UV coords, colors and etc. for each block
- 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
Returns
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
Returns
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
EntityextraTextures
Dictionary<string, CompositeTexture>altTextureNumber
intreturnNullWhenMissing
bool
Returns
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
Returns
TesselateBlock(Block, out MeshData)
Tesselates a block for you using given blocks shape and texture configuration
void TesselateBlock(Block block, out MeshData modeldata)
Parameters
TesselateItem(Item, out MeshData)
Tesselates an item for you using given items shape and texture configuration
void TesselateItem(Item item, out MeshData modeldata)
Parameters
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
Itemmodeldata
MeshDatatexSource
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
ItemforShape
CompositeShapemodeldata
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
stringname
AssetLocationcompositeShape
CompositeShapemodeldata
MeshDatatexSource
ITexPositionSourcegeneralGlowLevel
intclimateColorMapIndex
byteseasonColorMapIndex
bytequantityElements
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
stringshapeBase
Shapemodeldata
MeshDatatexSource
ITexPositionSourcemeshRotationDeg
Vec3fgeneralGlowLevel
intclimateColorMapId
byteseasonColorMapId
bytequantityElements
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
TesselationMetaDatashapeBase
Shapemodeldata
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
CollectibleObjectshape
Shapemodeldata
MeshDatameshRotationDeg
Vec3fquantityElements
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
stringshapeBase
Shapemodeldata
MeshDatatexSource
ITexPositionSourcerotation
Vec3fquantityElements
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
intheight
intatlasSize
Size2ipos
TextureAtlasPosition
Returns
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
CompositeTextureatlasSize
Size2iatlasPos
TextureAtlasPosition