core/encoding/hxa
encoding_hxa
Types
15File
File :: struct {
header: Header,
backing: []u8,
allocator: runtime.Allocator,
nodes: []Node,
}SourceHeader
Header :: struct #packed {
magic_number: u32le,
version: u32le,
internal_node_count: u32le,
}SourceImage_Type
Image_Type :: enum u8 {
Image_Cube = 0, // 6 sided qube, in the order of: +x, -x, +y, -y, +z, -z.
Image_1D = 1, // One dimensional pixel data.
Image_2D = 2, // Two dimensional pixel data.
Image_3D = 3, // Three dimensional pixel data.
}SourcePixel data is arranged in the following configurations
Layer
Layer :: struct {
name: string,
components: u8,
data: union {
[]u8,
[]i32le,
[]f32le,
[]f64le,
},
}SourceLayer_Data_Type
Layer_Data_Type :: enum u8 {
Uint8 = 0, // 8-bit unsigned integer,
Int32 = 1, // 32-bit little-endian signed integer
Float = 2, // 32-bit little-endian IEEE 754 floating point value
Double = 3, // 64-bit little-endian IEEE 754 floating point value
}SourceLayer_Stack
Layer_Stack :: []LayerSourceLayers stacks are arrays of layers where all the layers have the same number of entries (polygons, edges, vertices or pixels)
Meta
Meta :: struct {
name: string,
value: union {
[]i64le,
[]f64le,
[]Node_Index,
string,
[]u8,
[]Meta,
},
}SourceMeta_Value_Type
Meta_Value_Type :: enum u8 {
Int64 = 0,
Double = 1,
Node = 2,
Text = 3,
Binary = 4,
Meta = 5,
}SourceNode
Node :: struct {
meta_data: []Meta,
content: union {
Node_Geometry,
Node_Image,
},
}SourceA file consists of an array of nodes, All nodes have meta data. Geometry nodes have geometry, image nodes have pixels
Node_Geometry
Node_Geometry :: struct {
vertex_count: u32le,
vertex_stack: Layer_Stack,
edge_corner_count: u32le,
corner_stack: Layer_Stack,
edge_stack: Layer_Stack,
face_count: u32le,
face_stack: Layer_Stack,
}SourceNode_Image
Node_Image :: struct {
type: Image_Type,
resolution: [3]u32le,
image_stack: Layer_Stack,
}SourceNode_Index
Node_Index :: u32leSourceNode_Type
Node_Type :: enum u8 {
Meta_Only = 0, // node only containing meta data.
Geometry = 1, // node containing a geometry mesh, and meta data.
Image = 2, // node containing a 1D, 2D, 3D, or Cube image, and meta data.
}SourceRead_Error
Read_Error :: enum int {
None = 0,
Short_Read = 1,
Invalid_Data = 2,
Unable_To_Read_File = 3,
}SourceWrite_Error
Write_Error :: enum int {
None = 0,
Buffer_Too_Small = 1,
Failed_File_Write = 2,
}SourceConstants
32CONVENTION_HARD_BASE_CORNER_LAYER_COMPONENTS
CONVENTION_HARD_BASE_CORNER_LAYER_COMPONENTS :: 1SourceCONVENTION_HARD_BASE_CORNER_LAYER_ID
CONVENTION_HARD_BASE_CORNER_LAYER_ID :: 0SourceCONVENTION_HARD_BASE_CORNER_LAYER_NAME
CONVENTION_HARD_BASE_CORNER_LAYER_NAME :: "reference"SourceCONVENTION_HARD_BASE_CORNER_LAYER_TYPE
CONVENTION_HARD_BASE_CORNER_LAYER_TYPE :: Layer_Data_Type.Int32SourceCONVENTION_HARD_BASE_VERTEX_LAYER_COMPONENTS
CONVENTION_HARD_BASE_VERTEX_LAYER_COMPONENTS :: 3SourceCONVENTION_HARD_BASE_VERTEX_LAYER_ID
CONVENTION_HARD_BASE_VERTEX_LAYER_ID :: 0SourceCONVENTION_HARD_BASE_VERTEX_LAYER_NAME
CONVENTION_HARD_BASE_VERTEX_LAYER_NAME :: "vertex"SourceConventions ------------ Much of HxA's use is based on convention. HxA lets users store arbitrary data in its structure that can be parsed but whose semantic meaning does not need to be understood. A few conventions are hard, and some are soft. Hard convention that a user HAS to follow in order to produce a valid file. Hard conventions simplify parsing becaus the parser can make some assumptions. Soft convenbtions are basically recomendations of how to store common data. If you use HxA for something not covered by the conventions but need a convention for your use case. Please let us know so that we can add it! Hard conventions ----------------
CONVENTION_HARD_EDGE_NEIGHBOUR_LAYER_NAME
CONVENTION_HARD_EDGE_NEIGHBOUR_LAYER_NAME :: "neighbour"SourceCONVENTION_HARD_EDGE_NEIGHBOUR_LAYER_TYPE
CONVENTION_HARD_EDGE_NEIGHBOUR_LAYER_TYPE :: Layer_Data_Type.Int32SourceCONVENTION_SOFT_ALBEDO
CONVENTION_SOFT_ALBEDO :: "albedo"SourceImage layers
CONVENTION_SOFT_AMBIENT_OCCLUSION
CONVENTION_SOFT_AMBIENT_OCCLUSION :: "ambient_occlusion"SourceCONVENTION_SOFT_DISPLACEMENT
CONVENTION_SOFT_DISPLACEMENT :: "displacement"SourceCONVENTION_SOFT_DISTORTION
CONVENTION_SOFT_DISTORTION :: "distortion"SourceCONVENTION_SOFT_LAYER_ADD_BLENDSHAPE
CONVENTION_SOFT_LAYER_ADD_BLENDSHAPE :: "addblendshape"SourceCONVENTION_SOFT_LAYER_BINORMAL
CONVENTION_SOFT_LAYER_BINORMAL :: "binormal"SourceCONVENTION_SOFT_LAYER_BLENDSHAPE
CONVENTION_SOFT_LAYER_BLENDSHAPE :: "blendshape"SourceCONVENTION_SOFT_LAYER_COLOR
CONVENTION_SOFT_LAYER_COLOR :: "color"SourceCONVENTION_SOFT_LAYER_CREASES
CONVENTION_SOFT_LAYER_CREASES :: "creases"SourceCONVENTION_SOFT_LAYER_MATERIAL_ID
CONVENTION_SOFT_LAYER_MATERIAL_ID :: "material"SourceCONVENTION_SOFT_LAYER_NAME_UV0
CONVENTION_SOFT_LAYER_NAME_UV0 :: "uv"SourceCONVENTION_SOFT_LAYER_NORMALS
CONVENTION_SOFT_LAYER_NORMALS :: "normal"SourceCONVENTION_SOFT_LAYER_SELECTION
CONVENTION_SOFT_LAYER_SELECTION :: "select"SourceCONVENTION_SOFT_LAYER_SEQUENCE0
CONVENTION_SOFT_LAYER_SEQUENCE0 :: "sequence"SourceSoft Conventions ---------------- geometry layers
CONVENTION_SOFT_LAYER_SKIN_REFERENCE
CONVENTION_SOFT_LAYER_SKIN_REFERENCE :: "skining_reference"SourceCONVENTION_SOFT_LAYER_SKIN_WEIGHT
CONVENTION_SOFT_LAYER_SKIN_WEIGHT :: "skining_weight"SourceCONVENTION_SOFT_LAYER_TANGENT
CONVENTION_SOFT_LAYER_TANGENT :: "tangent"SourceCONVENTION_SOFT_LIGHT
CONVENTION_SOFT_LIGHT :: "light"SourceCONVENTION_SOFT_NAME
CONVENTION_SOFT_NAME :: "name"Sourcetags layers
CONVENTION_SOFT_TRANSFORM
CONVENTION_SOFT_TRANSFORM :: "transform"SourceLATEST_VERSION
LATEST_VERSION :: 3SourceMAGIC_NUMBER
MAGIC_NUMBER :: _ = 'H'<<0 | 'x'<<8 | 'A'<<16 | '\x00'<<24SourceVERSION_API
VERSION_API :: "0.3"SourceProcedures
8file_destroy
file_destroy :: proc(file: File, loc = #caller_location)Sourcemeta_destroy
meta_destroy :: proc(meta: Meta, allocator: mem.Allocator = context.allocator, loc = #caller_location)Sourcedestroy procedures
nodes_destroy
nodes_destroy :: proc(nodes: []Node, allocator: mem.Allocator = context.allocator, loc = #caller_location)Sourceread
read :: proc(data: []u8, filename: untyped string = "<input>", print_error: untyped boolean = false, allocator: mem.Allocator = context.allocator, loc = #caller_location) -> (file: File, err: Read_Error)Sourceread_from_file
read_from_file :: proc(filename: string, print_error: untyped boolean = false, allocator: mem.Allocator = context.allocator, loc = #caller_location) -> (file: File, err: Read_Error)Sourcerequired_write_size
required_write_size :: proc(file: File) -> (n: int)Sourcewrite
write :: proc(buf: []u8, file: File) -> (n: int, err: Write_Error)Sourcewrite_to_file
write_to_file :: proc(filepath: string, file: File) -> (err: Write_Error)Source