Skip to content
Permalink
Browse files
Update README.md
  • Loading branch information
ab8809 committed Sep 9, 2019
1 parent 5159ba9 commit 3c59b4ba4c0ce769193e191a17f52725a630cacc
Showing 1 changed file with 8 additions and 4 deletions.
@@ -269,6 +269,7 @@ We have one cube in the scene. Let's add more! We can do this by creating more i
> Create 2 new instances of cubes and call the _Draw_ function for each of them. I will call mine cube2 and cube3 (so that I have 3 instances of the Cube class in my scene). Check the example below when you have done this.
<br/>
<details>
<summary> Example Code </summary>
@@ -287,7 +288,7 @@ void drawScene()
```
</details>
<br/>
Running the project shows us the same scene... But we have 3 cubes now and should see 3 cubes. Why is this the case?
@@ -299,6 +300,7 @@ To fix this, the Cube class will have to hold a position value so each instance
We have already included the right library code (_#include <glm/glm.hpp>_) so we can go straight to adding a variable to the Cube class. Do this now and give it a sensible name. (Check my example below when you are happy.)
<br/>
<details>
<summary> Example Code </summary>
@@ -317,7 +319,7 @@ public:
};
```
</details>
<br/>
We need a way to give _position_ a value because at the moment it will be a default (0, 0, 0) value and is also not used anywhere.
@@ -327,6 +329,7 @@ We can create a new constructor that, given a _vec3_ value, gives that instance
> Create a new constructor that takes in a _vec3_ value and then assigns that value to the _position_ variable. When you are happy, make sure your code does the same as the example below.
<br/>
<details>
<summary> Example Code </summary>
@@ -347,12 +350,13 @@ Cube::Cube(glm::vec3 pos)
```
</details>
<br/>
The final code change to the Cube class we will do is in the _Draw_ function. (If you ran the project now, there would still be no change). We will change the _glTranslatef_ line so it uses the value of the _position_ variable instead of the current "hard coded" value of _0, 0, 0_.
> Change the _glTranslatef_ line so it uses the position variable. Check this against the example below.
<br/>
<details>
<summary> Example Code </summary>
@@ -368,7 +372,7 @@ void Cube::Draw()
```
</details>
<br/>
Now we just need to use the new constructor for the instances we create in the _main/Source.cpp_.

0 comments on commit 3c59b4b

Please sign in to comment.