diff --git a/PlanetMiner b/PlanetMiner index 22ad1a1..19c6d57 100755 Binary files a/PlanetMiner and b/PlanetMiner differ diff --git a/bin/main.o b/bin/main.o index 75c8d16..286cefb 100644 Binary files a/bin/main.o and b/bin/main.o differ diff --git a/bin/worldgen.o b/bin/worldgen.o index 3f8f7f3..182e0c3 100644 Binary files a/bin/worldgen.o and b/bin/worldgen.o differ diff --git a/src/main.c b/src/main.c index e7e2298..be94008 100644 --- a/src/main.c +++ b/src/main.c @@ -79,7 +79,7 @@ int main() vec3s planetPos = {0.0f, 0.0f, 0.0f}; worldMesh* mesh = generateWorld(planetPos); - setVertexBufferData(mesh.vertices, mesh.triangles, mesh.triangleArrayCount); + setVertexBufferData(mesh->vertices, mesh->triangles, mesh->triangleArrayCount); GLuint vertexbuffer; glGenBuffers(1, &vertexbuffer); @@ -90,42 +90,10 @@ int main() printf("Entering main loop\n"); - float theta = 0.0f; - float radius = 5.0f; - do { glClear( GL_COLOR_BUFFER_BIT ); - if( glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS ) - { - radius -= 0.05f; - } - if( glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS ) - { - radius += 0.05f; - } - if( glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS ) - { - theta += 0.05f; - } - if( glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS ) - { - theta -= 0.05f; - } - if( glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS ) - { - // eye.y += 0.05f; - } - if( glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS ) - { - // eye.y -= 0.05f; - } - - // center = glms_vec3_add(eye, direction); - eye.x = radius * sinf(theta); - eye.z = radius * cosf(theta); - mat4s view = glms_lookat(eye, center, up); mat4s model = glms_mat4_identity(); mat4s mvp = glms_mat4_mul(glms_mat4_mul(projection, view), model); @@ -230,8 +198,10 @@ GLuint loadShaders(const char* vertexShaderPath, const char* fragmentShaderPath) void setVertexBufferData(GLfloat* vertices, unsigned int* triangles, unsigned int triangleCount) { - printf("Loading %d triangles into buffer\n", triangleCount); for( int i = 0; i < triangleCount; ++i ) { + vertexBufferData[i*3] = vertices[triangles[i]*3]; + vertexBufferData[i*3 + 1] = vertices[triangles[i]*3 + 1]; + vertexBufferData[i*3 + 2] = vertices[triangles[i]*3 + 2]; } } diff --git a/src/worldgen.c b/src/worldgen.c index 9c7a7e4..9e44cf8 100644 --- a/src/worldgen.c +++ b/src/worldgen.c @@ -13,7 +13,7 @@ worldMesh* generateWorld(vec3s position) { // placeholder struct for world mesh worldMesh* mesh = (worldMesh*) malloc(sizeof(worldMesh)); - + populateIcosphere(mesh, ORDER, 1.0f); return mesh; } @@ -57,9 +57,8 @@ void normalizeVertices(GLfloat* vertices, unsigned int vertexArrayCount, GLfloat vertex.x = vertices[i]; vertex.y = vertices[i + 1]; vertex.z = vertices[i + 2]; - - glms_vec3_normalize(vertex); - glms_vec3_scale(vertex, radius); + + vertex = glms_vec3_scale_as(vertex, radius); vertices[i] = vertex.x; vertices[i + 1] = vertex.y; diff --git a/src/worldgen.h b/src/worldgen.h index 273da62..183a720 100644 --- a/src/worldgen.h +++ b/src/worldgen.h @@ -17,5 +17,5 @@ typedef struct worldMesh * @return the world mesh as a heap-allocated list of vertices. */ worldMesh* generateWorld(vec3s pos); -void populateIcosphere(worldMesh* mesh, unsigned char order, GLfoat radius); +void populateIcosphere(worldMesh* mesh, unsigned char order, GLfloat radius); void normalizeVertices(GLfloat* vertices, unsigned int vertexArrayCount, GLfloat radius); diff --git a/todo.md b/todo.md index 5a96f7d..d910963 100644 --- a/todo.md +++ b/todo.md @@ -5,6 +5,7 @@ - [x] Render a cube - [x] Render icosahedron - [ ] Vertices to triangle mesh + - [ ] Diffuse shader - [ ] Subdivide icosahedron 2. Procedural worlds - [ ] Morph vertices of the subdivided icosphere @@ -41,8 +42,16 @@ - Game starts on an Earth-like planet - Make basic tool with sticks rope and stone fragments - Stone fragments from smashing stones on rock + - Crash Landed ship, rebuild it as part of the tutorial + - Build warp drive to unlock multiplayer + - Warp to beacon or something + - Invite only/whitelist beacons? + - Public beacons + 4. Documentation - Error Codes! - In-Game Wiki-System + - Build wiki with some kind of knowledge tree +