libsf3
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
sf3_model.h File Reference
#include "sf3_core.h"
Include dependency graph for sf3_model.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sf3_faces
 An array of faces. More...
 
struct  sf3_vertices
 An array of vertex data. More...
 
struct  sf3_model
 

Macros

#define SF3_FORMAT_ID_MODEL   0x05
 The format_id for a model file.
 

Enumerations

enum  sf3_material_type {
  SF3_MATERIAL_ALBEDO = 0x01 , SF3_MATERIAL_NORMAL = 0x02 , SF3_MATERIAL_METALLIC = 0x04 , SF3_MATERIAL_METALNESS = 0x08 ,
  SF3_MATERIAL_ROUGHNESS = 0x10 , SF3_MATERIAL_OCCLUSION = 0x20 , SF3_MATERIAL_SPECULAR = 0x40 , SF3_MATERIAL_EMISSION = 0x80
}
 The material types that can be stored, as bit-field flags. More...
 
enum  sf3_vertex_format {
  SF3_VERTEX_POSITION = 0x01 , SF3_VERTEX_UV = 0x02 , SF3_VERTEX_COLOR = 0x04 , SF3_VERTEX_NORMAL = 0x08 ,
  SF3_VERTEX_TANGENT = 0x10
}
 The vertex attributes that can be stored, as bit-field flags. More...
 

Functions

SF3_INLINE const sf3_str16sf3_model_next_texture (const struct sf3_str16 *texture)
 
SF3_INLINE const struct sf3_facessf3_model_faces (const struct sf3_model *model)
 Returns the faces array of the model.
 
SF3_INLINE const struct sf3_verticessf3_model_vertices (const struct sf3_model *model)
 Returns the vertices array of the model.
 
SF3_INLINE uint8_t sf3_model_texture_count (const struct sf3_model *model)
 Returns the number of textures stored in the model.
 
SF3_INLINE uint8_t sf3_model_vertex_stride (const struct sf3_model *model)
 Returns the number of floats per vertex.
 
SF3_INLINE uint8_t sf3_model_vertex_attribute_count (enum sf3_vertex_format format)
 
SF3_INLINE uint32_t sf3_model_vertex_count (const struct sf3_model *model)
 Returns the number of vertices stored in the model.
 
SF3_EXPORT enum sf3_material_type sf3_model_texture_material (const struct sf3_model *model, uint8_t index)
 Returns the material usage type for the given texture index in the model.
 
SF3_EXPORT const char * sf3_model_material_type (enum sf3_material_type type)
 
SF3_EXPORT size_t sf3_model_size (const struct sf3_model *model)
 Computes the size of the model file in bytes.
 

Macro Definition Documentation

◆ SF3_FORMAT_ID_MODEL

#define SF3_FORMAT_ID_MODEL   0x05

The format_id for a model file.

Definition at line 6 of file sf3_model.h.

Enumeration Type Documentation

◆ sf3_material_type

The material types that can be stored, as bit-field flags.

Enumerator
SF3_MATERIAL_ALBEDO 

The texture stores the albedo colour.

SF3_MATERIAL_NORMAL 

The texture stores the normal vectors.

SF3_MATERIAL_METALLIC 

The texture stores the metalness, roughness, and occlusion values in its R, G, and B channels respectively.

SF3_MATERIAL_METALNESS 

The texture stores the metalness value.

SF3_MATERIAL_ROUGHNESS 

The texture stores the roughness value.

SF3_MATERIAL_OCCLUSION 

The texture stores the occlusion value.

SF3_MATERIAL_SPECULAR 

The texture stores the specular reflectivity value.

SF3_MATERIAL_EMISSION 

The texture stores the emission colour.

Definition at line 9 of file sf3_model.h.

◆ sf3_vertex_format

The vertex attributes that can be stored, as bit-field flags.

Enumerator
SF3_VERTEX_POSITION 

The vertex position vector as an X, Y, Z triplet.

SF3_VERTEX_UV 

The texture coordinates as a U, V duplet.

SF3_VERTEX_COLOR 

The vertex colour as an R, G, B triplet.

SF3_VERTEX_NORMAL 

The vertex normal vector as an X, Y, Z triplet.

SF3_VERTEX_TANGENT 

The vertex tangent vector as an X, Y, Z triplet.

Definition at line 30 of file sf3_model.h.

Function Documentation

◆ sf3_model_faces()

SF3_INLINE const struct sf3_faces * sf3_model_faces ( const struct sf3_model model)

Returns the faces array of the model.

Definition at line 82 of file sf3_model.h.

◆ sf3_model_material_type()

SF3_EXPORT const char * sf3_model_material_type ( enum sf3_material_type  type)

Returns a human-readable string describing the material type. Note that you cannot call this with a combination of material types flags, only with a singular type as outlined in the sf3_material_type enumeration.

Definition at line 155 of file sf3_model.h.

◆ sf3_model_next_texture()

SF3_INLINE const sf3_str16 * sf3_model_next_texture ( const struct sf3_str16 texture)

Returns the next texture after this one. Note that this function does not perform any bounds checking whatsoever. It is up to you to ensure you do not call this with the last texture.

Definition at line 77 of file sf3_model.h.

◆ sf3_model_size()

SF3_EXPORT size_t sf3_model_size ( const struct sf3_model model)

Computes the size of the model file in bytes.

Definition at line 170 of file sf3_model.h.

◆ sf3_model_texture_count()

SF3_INLINE uint8_t sf3_model_texture_count ( const struct sf3_model model)

Returns the number of textures stored in the model.

Definition at line 93 of file sf3_model.h.

◆ sf3_model_texture_material()

SF3_EXPORT enum sf3_material_type sf3_model_texture_material ( const struct sf3_model model,
uint8_t  index 
)

Returns the material usage type for the given texture index in the model.

Definition at line 138 of file sf3_model.h.

◆ sf3_model_vertex_attribute_count()

SF3_INLINE uint8_t sf3_model_vertex_attribute_count ( enum sf3_vertex_format  format)

Returns the number of floats per the specified attribute. Note that you cannot call this with a combination of vertex format type flags, only with a singular format type as outlined in the sf3_vertex_format enumeration. If the attribute is unknown, 0 is returned.

Definition at line 121 of file sf3_model.h.

◆ sf3_model_vertex_count()

SF3_INLINE uint32_t sf3_model_vertex_count ( const struct sf3_model model)

Returns the number of vertices stored in the model.

Definition at line 133 of file sf3_model.h.

◆ sf3_model_vertex_stride()

SF3_INLINE uint8_t sf3_model_vertex_stride ( const struct sf3_model model)

Returns the number of floats per vertex.

Definition at line 106 of file sf3_model.h.

◆ sf3_model_vertices()

SF3_INLINE const struct sf3_vertices * sf3_model_vertices ( const struct sf3_model model)

Returns the vertices array of the model.

Definition at line 87 of file sf3_model.h.