diff --git a/src/hexgame.cpp b/src/hexgame.cpp index 205086e..345df2a 100644 --- a/src/hexgame.cpp +++ b/src/hexgame.cpp @@ -540,7 +540,7 @@ int main(int argc, char* argv[]) e->num_vertices = getVertexCount(); e->num_indices = getIndexCount(); e->vertices = (glm::vec3 *) std::calloc(e->num_vertices, sizeof(glm::vec3)); - e->indices = (uint *) std::calloc (e->num_indices, sizeof(uint)); + e->indices = (uint *) std::calloc(e->num_indices, sizeof(uint)); convertMesh(e); g_render_state->entities = e; g_render_state->entity_count++; diff --git a/src/mesh.cpp b/src/mesh.cpp index 4824df9..847ab74 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -1,5 +1,9 @@ #include +#include +#include +#include + #include // vec3 #include "aixlog.hpp" @@ -7,11 +11,24 @@ #include "mesh.h" +//typedef struct meMatInfo meMatInfo; +struct meMatInfo +{ + aiString name; + aiColor3D diffuse_color; +}; + +struct meMeshInfo +{ + aiString name; + meMatInfo* mat; +}; + /* the global Assimp scene object */ const aiScene* g_scene = NULL; bool -initAssimp() +meInitAssimp() { /* get a handle to the predefined STDOUT log stream and attach * it to the logging system. It remains active for all further @@ -21,6 +38,16 @@ initAssimp() g_scene = aiImportFile("../data/animated.block.dae", aiProcessPreset_TargetRealtime_MaxQuality); + // testing + + aiMaterial* mat = g_scene->mMaterials[0]; + aiColor3D color(0.f, 0.f, 0.f); + if (AI_SUCCESS != mat->Get(AI_MATKEY_COLOR_DIFFUSE, color)) { + LOG(ERROR) << "Some Assimp-type-error\n"; + } + + ////////// + if (g_scene->mNumMeshes != 1) { LOG(ERROR) << "We Can only handle 1 mesh per entity atm\n"; return false; @@ -29,15 +56,21 @@ initAssimp() return true; } +bool +meLoadFromFile(const char* filename, meMeshInfo* mesh) +{ + return true; +} + uint -getVertexCount() +meGetVertexCount(meMeshInfo* mesh) { assert(g_scene); return g_scene->mMeshes[0]->mNumVertices; } uint -getIndexCount() +meGetIndexCount(meMeshInfo* mesh) { assert(g_scene); return g_scene->mMeshes[0]->mNumFaces * 3; // NOTE: assume 3 vertices per face @@ -49,12 +82,12 @@ getIndexCount() // copy data from assimp for use in our renderer Entity* -convertMesh(Entity* e) +meConvertMesh(Entity* e, meMeshInfo* mesh) { assert(g_scene); - uint numVertices = getVertexCount(); + uint numVertices = meGetVertexCount(mesh); assert(e && e->num_vertices == numVertices); - aiMesh* mesh = g_scene->mMeshes[0]; + //aiMesh* mesh = g_scene->mMeshes[0]; // copy vertices for (uint i = 0; i < numVertices; i++) { @@ -77,7 +110,7 @@ convertMesh(Entity* e) } void -shutdownAssimp() +meShutdownAssimp() { /* cleanup - calling 'aiReleaseImport' is important, as the library diff --git a/src/mesh.h b/src/mesh.h index e5595de..ecaf1cb 100644 --- a/src/mesh.h +++ b/src/mesh.h @@ -5,21 +5,21 @@ #pragma once -#include -#include -#include - #include "hexgame.h" -bool initAssimp(); +typedef struct meMeshInfo meMeshInfo; + +bool meInitAssimp(); + +bool meLoadFromFile(const char* filename, meMeshInfo* mesh); -uint getVertexCount(); +uint meGetVertexCount(meMeshInfo* mesh); -uint getIndexCount(); +uint meGetIndexCount(meMeshInfo* mesh); // copy data from assimp for use in our renderer -Entity* convertMesh(Entity* e); +Entity* meConvertMesh(Entity* e); -void shutdownAssimp(); +void meShutdownAssimp(); diff --git a/src/render_group.cpp b/src/render_group.cpp index 8c91856..da87170 100644 --- a/src/render_group.cpp +++ b/src/render_group.cpp @@ -134,7 +134,7 @@ rgInitEntity(gl_render_group* rg, Entity* e) uint vertex_index = 0; uint vertex_prop_index = 0; GLfloat entity_test_color[3]; - convertColor(entity_test_color, 0xF46000FF); + convertColor(entity_test_color, 0xCCCCCCFF /*0xF46000FF*/); for (uint j = 0; j < entity_buf_len; j++) { const glm::vec3& vertex = e->vertices[vertex_index]; diff --git a/src/render_group.h b/src/render_group.h index fd72162..b15363f 100644 --- a/src/render_group.h +++ b/src/render_group.h @@ -4,6 +4,7 @@ #include "hexgame.h" +// TODO: can these structs be used as opaque pointers? struct gl_buffer { GLuint buffer_id = 0;