Final project

Carlos Eduardo González Alvarez
cegonzalez13
Published in
5 min readMay 30, 2018
Car moving in its environment

The following project is the final assignment from the Interactive Visual Computing class at Universidad de Los Andes. Here are the links for the code and the repo.

Project Description

The project is centered around having a way of visualizing a car moving around a field with the possibility of customizing the car. The objectives for this project were separated by multiple sprints:

Sprint 1

In the first sprint, delivered at May 3, we established the theme of the project by starting to implement both of the ideas I had in mind: a song visualization or a UI to setup a car in 3D. I started by adding the primitives that we were going to use on each project. That’s where I realized that primitives for a car were going to be a lot easier than primitives for a song visualization, which is more abstract.

Each of the primitives can be called from outside their respective files. We just need to import the script before declaring the main script. Here is the structure of the primitives files:

Here you can see the most basic structure we have, the cube:

After doing this, I established that the project I was going to implement was the one with the car setup. The most important thing here is to define all the primitives properly to let me focus on the other aspects that we have to do.

Sprint 2

In this sprint, done on May 25, I added some textures to the primitives. I added some code in the Fragmet and Vertex shaders for it to work properly, considering the current color of the object we have right now. I made sure that i was able to add the primitives to the objects as simple as possible, just adding the url of the image. I do this because I need to add the textures depending on what the user selects at the moment. I also added some ilumination to the shaders as general as I could:

Sprint 3: Final Sprint

In this sprint, that was developed from May 26 to May 29, I focused on 3 main things: Integrating the UI to the colors of the car, and getting the camera to follow the car correctly, with a 3rd person perspective. This was one of the hardest things to acomplish in all of the project. This is because we had to move the camera, not the car, and get the car to follow the movement of the camera as if it was his succesor. We also needed to detect the turns and breaks in the car and do the camera work accordingly. This process led up to about 3 days of work and it was the main issue that didn’t let me finish the specified objectives in time.

Here you can see the piece of code where I struggled the most. It looks really simple, but the handling of the variables was the most troublesome part. Having the car to move its tires and its entire body according to the angle of view of the camera was really challenging.

The inputs were given by an event listener that listened on the keys WASD. Depending on each of the inputs the camera would move a certain way. Thats the px, py, pz and ang variables we see in the code. Here we can see how the variables change over time:

The last thing I did was letting the primitives change their uniforms accordingly to what the user puts in the UI. This wasn’t done with too much time so for now I am only able to change the colors of the different parts of the car and the environment. Now, in order to update each of the uniforms accordingly, I made a for loop which keeps up rendering each of the objects in the render method:

And the updating off the uniform is simply made with this function:

Time Log

The times of each of the sprints were roughly calculated by hours depending on the amount of time I spent sitting doing code, not investigating outside things.

So, for the first sprint I spent just about 8 hours, because I already had some primitives defined and i just needed them to work as quickly as possible without having to add any more code when I add a new object.

The second sprint took me about 7 hours. That’s because additionaly to adding the textures, I had to be sure that changing the textures wouldn’t be such a problem as it was.

The third sprint was the longest of all. It took about 12 hours. This is because I had a lot of trouble with the camera handling, and in fact I spent nearly 4 hours just trying to add another program which showed a nice looking skybox. This was impossible to do without messing up the camera so I left it with a cube and some texture as the background. Additionaly there was some time spent with the calculation of the speed of the car and trying to show the car as it was moving, even though the thing that is moving is the camera at all times.

In overall, I spent aroung 30 hours in this project. My estimated time for the project was about 40 hours, having 5 hours for the first sprint and roughly 15 and 20 hours for the second and third one, respectively. The subjects seen in class helped me do a lot of more stuff that we had done in the weekly examples. I profundized my knowledge in things like the camera movement, the player construction and the 3rd person perspective. Additionaly I learned how simple it can be to add textures and colors to a scene if we have the correct shaders and uniforms defined.

--

--