Today we sat down for the first time to start the project. To get started we all sat down and started to implement a scene together with a plane and a sphere. This process went better than we had predicted and by the end of our four hour session we had also started to work on camera movement, a moving light source, and investigate wave functionality on a plane.
One of the aims of the project, besides creating a smooth, good-looking, 3D scene, is to examine how a user perceives a 3D rendered water surface. Today, we discovered, that a surface made up of only 4x4 segments, looked almost as good as one made up of 512x512, when a simple wave function was applied to the plane. We did not have time to discuss this phenomena thoroughly, but will explore this further on in the project.
Camera movement and rotation
The movement and rotation of the camera object was handled as follows:
In the panCamera function we take 2 parameters, a direction and an amount. Depending on the direction we then change that attribute of the cameras position with the corresponding amount. This function is called on WASD with the keyDown event.
RotateCamera is called on the mousedrag event and then we change the rotation matrix of the camera object with a sinus function.
The zoomCamera function is triggered on a scroll event, and depending on what direction (wheelDeltaY) a user scrolls, we can translate the z-position in the correct direction.
Wave functionality
A problem we faced when implementing an animation of the vertices that the plane consists of was that we mixed up local and global coordinates. As you can see in the code to the left the height of the vertices is depending on the vertices z-coordinate. This is due to the fact that when the plane is created, its y-axis is pointing up and therefore the plane is drawn vertically to the user. We then rotated it 90° which implies that the planes y-axis is pointing inwards, in the same direction as the global z-axis. Therefore, the height of each vertex on the plane is changed by its z-value. The height is also depending on a variable step which is incremented when a frame is rendered.
How to proceed
We need to start look at refraction on the surface of the plane. We need to create an environment (possible walls, a seabed, sun lighting etc.) that enhances the user experience and start to think about the physics of water and waves. If we want to create objects that can interact with our water surface we need to create colliders and implement physics of how the water should behave when a user, for example, drops a sphere into it,
Summary
- Implemented a plane
- Implemented a sphere
- Implemented light source that moves
- Implemented user controls - WASD and mouse with scroll zoom.
- First attempts at creating waves
- Started to look at refraction
// Emil
Inga kommentarer:
Skicka en kommentar