Skip to content
Permalink
Browse files
Update README.md
  • Loading branch information
ab8809 committed Sep 9, 2019
1 parent 094e06f commit dabdc93da1ef369670f8fd4e663851b2f4d6cd71
Showing 1 changed file with 10 additions and 0 deletions.
@@ -48,6 +48,7 @@ Once we have the variables, we will need to consider what type each variable wil

> Look at the hidden variable list above if you have not already. For each variable, write down the type it should be. Try it yourself before looking at the list below.
<br/>
<details>
<summary> Variable types </summary>

@@ -60,11 +61,13 @@ Once we have the variables, we will need to consider what type each variable wil
| position | vec3 |

</details>
<br/>

Now we know the variables and the types we can start to code this, with the GameObject as a base class.

> Create a new class called Particle which inherits from GameObject. Add the variables and needed functions. No need to worry about the integrator yet - Just get the class structure in place. Once you are done, check your class against the one below.
<br/>
<details>
<summary> The Particle class </summary>

@@ -103,6 +106,7 @@ void Particle::Update(float deltaTime)
```
</details>
<br/>

Once the overall class structure is in place, we can add the constructor for a Particle in, allowing us to create instances of a Particle in our scene.

@@ -178,6 +182,7 @@ Per frame, we need to:

> Add a _CalculateForces_ function to the Particle class. This does not return anything or take any arguments. This should reset the "forces acting on the particle" variable to zero. Look at the example after you have tried this yourself.
<br/>
<details>
<summary> CalculateForces function </summary>

@@ -198,11 +203,13 @@ void Particle::CalculateForces()
}
```
</details>
<br/>

Once this is done, we can add forces to the "forces acting on the particle" variable in this function.

> Add a gravity force in this function. Think about the value needed for Earth-like gravity. As always, give it a go yourself before you look at the example below.
<br/>
<details>
<summary> Gravity added </summary>

@@ -214,6 +221,7 @@ void Particle::CalculateForces()
}
```
</details>
<br/>

Now a force is being applied, we need to run the integrator to work out the acceleration, velocity and position for the particle. This will make the particle move!

@@ -225,6 +233,7 @@ With a force applied, we need to use a numerical method to calculate an approxim

> Looking at the above formulae, turn this into code and add it to the _Update_ function of the Particle class. **I would suggest that you really do try it yourself as turning formulae (or even word problems) into code is a programming interview standard and the more practice the better!**
<br/>
<details>
<summary> Explicit Euler code </summary>

@@ -243,6 +252,7 @@ void Particle::Update()
}
```
</details>
<br/>

> Run your project. Does the particle move? It shouldn't at the moment! This is because we have not called _CalculateForces_ anywhere.

0 comments on commit dabdc93

Please sign in to comment.