Today I Implemented a MeshBuilder class, which allows to create meshes from scratch. This was possible thanks to the changes I made yesterday to the loading system of the meshes.
The class allows to create new vertices, to modify their pos, uvs and normals, and it also provides two functions, add_triangle and add_quads to map indices on newly created vertices.
There are also two more important functions: generate_normals and generate_tangents.
The first one can be called if the normals are not manually specified, and it creates them automatically for each triangle. The second one should be always called, because tangents are not added manually, but built from uvs and normals.
That's about it, I started by creating a simple quad, and then I created a bumpy plane to replace the floor of the house i'm always using to test the engine. As you can see from the picture the lighting is correct, thanks to normals and tangent generation, as well as positions as uvs.
Shadows are also correctly casted (except for some moire pattern due to low precision), because the mesh, once created, acts as every other mesh.

Nessun commento:
Posta un commento