12 changed files with 115 additions and 92 deletions
@ -1,3 +1,6 @@
|
||||
[submodule "ext/stb_libs"] |
||||
path = ext/stb_libs |
||||
url = https://github.com/nothings/stb.git |
||||
[submodule "ext/tinygltf"] |
||||
path = ext/tinygltf |
||||
url = https://github.com/syoyo/tinygltf |
||||
|
||||
@ -0,0 +1,41 @@
|
||||
|
||||
#pragma once |
||||
|
||||
#include <glm/glm.hpp> |
||||
|
||||
#include "animation.h" |
||||
#include "util.h" |
||||
#include "util_image.h" |
||||
|
||||
|
||||
struct mesh_asset |
||||
{ |
||||
uint asset_size; |
||||
uint num_vertices; |
||||
uint num_indices; |
||||
mesh_asset* next; |
||||
glm::mat4 model_transform; |
||||
glm::vec3* vertices; |
||||
uint* indices; |
||||
glm::vec3* texture_coords; |
||||
}; |
||||
|
||||
#define MAX_PATH_SIZE 256 |
||||
struct render_asset |
||||
{ |
||||
uint total_size; |
||||
uint num_meshes; |
||||
uint name_len; |
||||
render_asset* next; |
||||
char* filepath; |
||||
mesh_asset* 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;
|
||||
}; |
||||
|
||||
render_asset* |
||||
assetLoadFromFile(const char* filename); |
||||
|
||||
@ -0,0 +1,28 @@
|
||||
|
||||
#include <iostream> |
||||
|
||||
#define TINYGLTF_IMPLEMENTATION |
||||
//#define STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION |
||||
#include "tiny_gltf.h" |
||||
|
||||
#include "asset.h" |
||||
|
||||
|
||||
render_asset* |
||||
assetLoadFromFile(const char* filename) |
||||
{ |
||||
tinygltf::Model model; |
||||
// TODO: see if there's any impact in creating a new context for each file
|
||||
tinygltf::TinyGLTF gltf_ctx; |
||||
std::string err; |
||||
std::string warn; |
||||
bool ret = false; |
||||
|
||||
ret = gltf_ctx.LoadASCIIFromFile(&model, &err, &warn, filename); |
||||
|
||||
|
||||
|
||||
|
||||
return nullptr; |
||||
} |
||||
Loading…
Reference in new issue