![]() |
TGX 1.0.3
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
|
3D model mesh class. More...
#include "Misc.h"
#include "Vec2.h"
#include "Vec3.h"
#include "Box3.h"
#include "Color.h"
#include "Image.h"
#include <stdint.h>
#include "Mesh3D.inl"
Go to the source code of this file.
Classes | |
struct | tgx::Mesh3D< color_t > |
3D mesh data stucture. More... | |
Functions | |
template<typename color_t > | |
const Mesh3D< color_t > * | tgx::cacheMesh (const Mesh3D< color_t > *mesh, void *ram1_buffer, size_t ram1_size, void *ram2_buffer, size_t ram2_size, const char *copy_order="VNTIF", size_t *ram1_used=nullptr, size_t *ram2_used=nullptr) |
Creates a "cache version" of a mesh by copying part of its data into fast memory buffers. More... | |
template<typename color_t > | |
Mesh3D< color_t > * | tgx::copyMeshEXTMEM (const Mesh3D< color_t > *mesh, bool copy_vertices=false, bool copy_normals=false, bool copy_texcoords=false, bool copy_textures=true, bool copy_faces=false) |
Create a copy of a mesh where specified arrays in PROGMEM are copied to EXTMEM. More... | |
template<typename color_t > | |
void | tgx::freeMeshEXTMEM (Mesh3D< color_t > *mesh) |
Delete a mesh allocated with copyMeshEXTMEM(). More... | |
3D model mesh class.
const Mesh3D< color_t > * tgx::cacheMesh | ( | const Mesh3D< color_t > * | mesh, |
void * | ram1_buffer, | ||
size_t | ram1_size, | ||
void * | ram2_buffer, | ||
size_t | ram2_size, | ||
const char * | copy_order = "VNTIF" , |
||
size_t * | ram1_used = nullptr , |
||
size_t * | ram2_used = nullptr |
||
) |
Creates a "cache version" of a mesh by copying part of its data into fast memory buffers.
A typical scenario for using this method is when when using a MCU (Teesny, ESP32..) with limited RAM and slow FLASH memory.
The method copy as much as it can into the given RAM1/RAM2 buffers but will leave the arrays that are to big in their current place. The method never 'fails' but it may return the original mesh if caching is not possible.
A C-string describes which arrays should be copied and in which order:
For example "VIT" means: "copy vertex arrays first, then image texture and finally texture coord (if there is still room)".
mesh | Pointer to the mesh to cache. |
ram1_buffer | pointer to the first memory buffer (should have the fastest access). |
ram1_size | size in bytes of the ram1 buffer. |
ram2_buffer | pointer to a second memory buffer, may be nullptr. |
ram2_size | size in bytes of the ram2 buffer or 0 if not supplied. |
copy_order | (Optional) c string that describe which array should be copied and in which order. |
ram1_used | If non-null, the number of bytes consumed in ram1_buffer is put here. |
ram2_used | If non-null, the number of bytes consumed in ram2_buffer is put here. |
Mesh3D< color_t > * tgx::copyMeshEXTMEM | ( | const Mesh3D< color_t > * | mesh, |
bool | copy_vertices = false , |
||
bool | copy_normals = false , |
||
bool | copy_texcoords = false , |
||
bool | copy_textures = true , |
||
bool | copy_faces = false |
||
) |
Create a copy of a mesh where specified arrays in PROGMEM are copied to EXTMEM.
void tgx::freeMeshEXTMEM | ( | Mesh3D< color_t > * | mesh | ) |
Delete a mesh allocated with copyMeshEXTMEM().
Deletes also the linked sub-meshes is any.