#pragma once #include #include #include "animation.h" #include "util.h" #include "util_image.h" // NOTE: wrapper for tinygltf https://github.com/syoyo/tinygltf // https://github.com/KhronosGroup/glTF struct mesh { GLenum draw_mode; // NOTE: GL_LINES, GL_TRIANGLES GLenum usage; // NOTE: GL_STATIC_DRAW, GL_DYNAMIC_DRAW uint num_vertices; uint num_indices; glm::vec3* vertices; glm::vec3* normals; glm::vec2* texture_coords; uint* indices; glm::mat4* xform; }; // TODO: will eventually need a tree structure with child nodes and transforms // at each branch. Can then combine each transform down from the root node to // the mesh, and send the final combination down to the shader #define MAX_PATH_SIZE 256 struct model { uint num_meshes; char* filepath; uint64_t filepath_hash; mesh* meshes; // NOTE: fixed sized array // NOTE: pointer to a texture in render_state->textures util_image* diffuse_texture; // FIXME: node_animation has a pointer to a render_object. need to decouple // that somehow //node_animation* node_anim; }; struct model_assets { model* models; uint count; uint max; }; struct texture_assets { util_image* images; uint count; uint max; }; // TODO: would be nice to make these init functions generic model_assets* assetInitModelBlock(memory_arena* arena, uint asset_count); texture_assets* assetInitTextureBlock(memory_arena* arena, uint asset_count); model* assetLoadFromFile(model_assets* assets, texture_assets* textures, memory_arena* arena, const char* filename); model* assetGetCached(model_assets* assets, uint64_t path_hash);