Saturday, August 8, 2015

A Lovelier Farmhouse and the Key to the Fog Problem: Terrain

Back to fixing up the btBvhTriangleMeshShape! Luckily enough, it was a strange but quick fix: ensure that the btTriangleMesh was a pointer to an object instead of an actual object initialized. Now that the mesh farmhouse worked, the ball could run and correctly collide into a mesh surface. The next issue was how the farmhouse looked; the texture coordinates looked as if they were all over the place instead of following the texture map. Solution? It turns out the Assimp code I was using to load models was flipping the UVs for OpenGL use; DirectX does not require UV flipping, so I disabled that when the importer was calling importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs); by removing the flag. And thus, the farmhouse looked quite beautiful.



As a short fix, the balls also lacked a bouncyness to them, so I quickly added restitution to the world to generate a proper bouncing reaction between the player/enemy and the farmhouse and general world.

Next up was to figure out the ground; I could not work with terrain that did not obey the laws of fog factors, so I had to generate my own. Luckily there was a set of tutorials here that I could utilize to load a heightmap based on a bitmap file created in a 2D art program such as Gimp. The only setback was properly setting the vertices and indices of the model to render properly and separately from the rest of the models. Currently the terrain has no collision body, so I made the world transparent to show the terrain properly adjusting to the fog below:


Was there still a problem? Yes, unfortunately; the terrain looked as if it was a long rectangle instead of being the square generation I was looking for. Later on after I load the collision, I will see what is wrong with loading the heightmap.

No comments:

Post a Comment