|
Gama C Library
Gama C API Documentation
|
Defines structures for 3D materials and material libraries, and functions for loading MTL files. More...
#include "../color.h"#include "../image.h"#include "../str.h"#include "../utils.h"#include <ctype.h>#include <stdio.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Data Structures | |
| struct | gm3Material |
| Represents a single 3D material with various rendering properties. More... | |
| struct | gm3Texture |
| Represents a 3D texture, including its raw image data and file path. More... | |
| struct | gm3MtlLib |
| Represents a material library, typically loaded from an .mtl file. More... | |
Functions | |
| long | gm3_mtl_add_texture (gm3MtlLib *mtllib, const char *path) |
| Adds a texture to the material library, loading it if not already present. | |
| int | gm3_mtl_load (gm3MtlLib *mtl_lib, const char *path, const char *dir) |
| Loads materials and textures from an OBJ-style .mtl file. | |
| gm3Material * | gm3_mtl_find_mat (gm3MtlLib *file, const char *name, int *index) |
| Finds a material by name within a loaded MTL file. | |
| void | gm3_mtl_free (gm3MtlLib *file) |
Defines structures for 3D materials and material libraries, and functions for loading MTL files.
This file handles parsing and representing material data typically found in .mtl files accompanying .obj models. It includes material properties like colors, shininess, alpha, and references to texture maps.
| long gm3_mtl_add_texture | ( | gm3MtlLib * | mtllib, |
| const char * | path ) |
Adds a texture to the material library, loading it if not already present.
This function checks if a texture with the given path already exists in the mtllib. If so, it returns its index. Otherwise, it loads the image data, adds it to the mtllib's texture array, and returns the new index.
| mtllib | A pointer to the gm3MtlLib to add the texture to. |
| path | The file path of the texture to add. |
| gm3Material * gm3_mtl_find_mat | ( | gm3MtlLib * | file, |
| const char * | name, | ||
| int * | index ) |
Finds a material by name within a loaded MTL file.
| void gm3_mtl_free | ( | gm3MtlLib * | file | ) |
| int gm3_mtl_load | ( | gm3MtlLib * | mtl_lib, |
| const char * | path, | ||
| const char * | dir ) |
Loads materials and textures from an OBJ-style .mtl file.
This function parses the specified .mtl file, extracting material properties and loading any referenced textures.
| mtl_lib | A pointer to the gm3MtlLib struct to populate with loaded data. |
| path | The file path to the .mtl file. |
| dir | The base directory for resolving relative texture paths. |