Exercise 4 of Introduction to Computer graphics course.
C C++ Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


<!DOCTYPE html>
    <title>Exercise 4 - Introduction to computer graphics</title>
        body {
            background-color: #101010;
            color: #F0F0F0;
            font-family: Helvetica;
            max-width: 800px;
            margin-left: auto;
            margin-right: auto;
            padding: 10px;

        h1 {
            background-color: #F0F0F0;
            color: #101010;
            padding: 10px;
            text-align: center;

        h2 {
            margin-top: 1.5em;

        .center {
            text-align: center;

        img {
            box-shadow: 0px 0px 15px white;
            -webkit-border-radius: 10px;
            -moz-border-radius: 10px;
            border-radius: 10px;

<h1>Introduction to computer graphics</h1>
by Javier Martín de Valmaseda and Amos Wenger 
<h2>4.1 Introduction</h2>

<p>We found it odd that we had to add all these models as command-line arguments. Couldn't the program just load them if we gave it the models folder?</p>

<p>We used both XCode and Visual C++ to develop the code, so we made sure it works in both.</p>

<h2>4.2 Scale and Translations (2 points)</h2>

<p>We used scaleObject and translateWorld to set up the solar system in a plausible manner, according to the values given to us.</p>

<h2>4.3 Rotations (8 points)</h2>

<p>Rotations were a bit tricky - we used constants for readability of the code. The sun is easy because it only rotates about itself, the sun rotates about itself and the sun, and as for the moon, it's applied the same rotation than the earth around the sun, plus its own rotation about itself.</p>

<p>At first we didn't apply the rotation of the earth around the sun to the moon, and that's why it looked wrong (the moon was penetrating the earth)</p>

<h2>4.4 Lighting and Textures (10 points)</h2>

<p>With a simple translation we have moved the light to center of the sun and with matrix multiplication we have calculated the light position in camera coordinates.</p>

<p>After that we have setup the indirect light. The slides have been very practical. </p>

<p>We get the angle between the vectors (moonEarth and moonSun) and then with the half of the sin(angle) multiplied by m_recSunlightInt we have the moonLightIntensity. It's the same for the earth but with their respective vectors.</p>

<p>We have used the sinus for this calculation because of, as the slides say, when the angle is 90º or 270º the intensity should be 50/100 and when is 0º or 180º the intensity should be 0/100.</p>

<p>In order to finish we need to make the light and indirectlight calculations in the shader. We have used the slides formula (I = Ip * kd * (N· L)) and the available variables to make it work.</p>

<h2>4.5 Geocentric model (5 points)</h2>

<p>That one was easy, we just had to translate the camera using sunToEarthVector at the beginning of draw_scene, and translate it of -sunToEarthVector at the end. We tried set_scene_pos in the beginning, which kinda worked but didn't allow rotation and zooming of the camera using the mouse.</p>

<h2>4.6 Other planets (5 points)</h2>

<p>It's the same calculations like the earth or the moon but with the planets and their parameters</p>