4 #include <dragonstd/array.h>
5 #include <dragonstd/list.h>
8 #include <linmath.h/linmath.h>
11 #include "client/mesh.h"
12 #include "client/texture.h"
27 typedef struct ModelNode {
29 v3f32 pos, rot, scale;
32 struct ModelNode *parent;
34 unsigned int visible: 1;
35 unsigned int clockwise: 1;
50 typedef struct Model {
55 struct Model *replace;
57 void (*step)(struct Model *model, f64 dtime);
58 void (*before_render)(struct Model *model);
59 void (*after_render)(struct Model *model);
60 void (*delete)(struct Model *model);
63 unsigned int delete: 1;
64 unsigned int frustum_culling: 1;
65 unsigned int transparent: 1;
75 Model *model_create();
76 // load model from file
77 Model *model_load(const char *path, const char *textures_path, Mesh *cube, ModelShader *shader);
78 // clone existing model
79 Model *model_clone(Model *model);
81 void model_delete(Model *model);
82 // use this as delete callback to free all meshes associated with the model on delete
83 void model_free_meshes(Model *model);
85 void model_get_bones(Model *model, ModelBoneMapping *mappings, size_t num_mappings);
88 ModelNode *model_node_create(ModelNode *parent);
89 // recalculate transform matrices
90 void model_node_transform(ModelNode *node);
91 // add a mesh to model node (will be copied)
92 void model_node_add_mesh(ModelNode *node, const ModelMesh *mesh);
93 // add and delete batch (may add multiple meshes depending on available texture units)
94 void model_node_add_batch(ModelNode *node, ModelBatch *batch);
97 ModelBatch *model_batch_create(ModelShader *shader, VertexLayout *layout, size_t off_tex_idx);
99 void model_batch_free(ModelBatch *batch);
100 // add a vertex to batch
101 void model_batch_add_vertex(ModelBatch *batch, GLuint texture, const void *vertex);
103 // add model to scene
104 void model_scene_add(Model *model);
106 void model_scene_render(f64 dtime);