Terrain mesh construction
Progress is starting to be made!
First of all, here is the link to the KTH Github page where the source code and other project files are available: https://gits-15.sys.kth.se/astee/metawater.
Second of all, the first thing that was implemented in the project was a movable camera that rotates using mouse movements and translates using keyboard input. It felt necessary to get the camera completed early for debugging purposes.
Third of all, a true milestone has already been reached. The milestone is to be able to use a heightmap represented as an image file, such as the one in the picture below, to generate a terrain mesh inside Unity.
The image is imported into Unity as a texture and set to be readable and writable, then loaded into a script called TerrainConstructor.cs as a Texture2D. The script extracts the color data from the texture and creates a vertex for each pixel in the heightmap corresponding to the pixel coordinates and the intensity of the pixel color. The vertices are then used to construct a uniform grid of triangles according to the informal schema shown below.
After the grid is constructed, the vertices and triangles are assigned to a mesh object native to Unity, after which the mesh is rendered in Unity when running the script. The result of the heightmap above in Unity using the script is shown below.
The script works with arbitrary heightmaps, too, not just the specific example shown here. As previously stated, this is a major step towards reaching the minimum goal of the project. That is all for now!
Github commit for this progress: 6241a990c1766c35d4c7473c2e1ede9fae928558
First of all, here is the link to the KTH Github page where the source code and other project files are available: https://gits-15.sys.kth.se/astee/metawater.
Second of all, the first thing that was implemented in the project was a movable camera that rotates using mouse movements and translates using keyboard input. It felt necessary to get the camera completed early for debugging purposes.
Third of all, a true milestone has already been reached. The milestone is to be able to use a heightmap represented as an image file, such as the one in the picture below, to generate a terrain mesh inside Unity.
The image is imported into Unity as a texture and set to be readable and writable, then loaded into a script called TerrainConstructor.cs as a Texture2D. The script extracts the color data from the texture and creates a vertex for each pixel in the heightmap corresponding to the pixel coordinates and the intensity of the pixel color. The vertices are then used to construct a uniform grid of triangles according to the informal schema shown below.
After the grid is constructed, the vertices and triangles are assigned to a mesh object native to Unity, after which the mesh is rendered in Unity when running the script. The result of the heightmap above in Unity using the script is shown below.
The script works with arbitrary heightmaps, too, not just the specific example shown here. As previously stated, this is a major step towards reaching the minimum goal of the project. That is all for now!
Github commit for this progress: 6241a990c1766c35d4c7473c2e1ede9fae928558



Kommentarer
Skicka en kommentar