Jamie Slowgrove - OOT Assignment 1 - A Mission in Afghanistan
 All Classes Namespaces Files Functions Variables Macros
GamePhysics.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "stdafx.h"
4 #include <iostream>
5 #include <memory>
6 #include "MyUtils.h"
7 
9 #define GRAVITY 98.1f
10 
16 {
17 private:
18 protected:
24  {
26  Ogre::Vector3 displacement;
28  Ogre::Vector3 initalVelocity;
30  Ogre::Vector3 velocity;
32  Ogre::Real acceleration;
34  Ogre::Real time;
35 
40  ProjectileObject(Ogre::Vector3 initalVelocity)
41  {
42  /*initialise the variables*/
43  this->initalVelocity = velocity = initalVelocity;
44  acceleration = -GRAVITY;
45  time = 0.0f;
46  displacement = 0.0f;
47  }
48 
55  ProjectileObject(Ogre::Real initalXVelocity, Ogre::Real initalYVelocity, Ogre::Real initalZVelocity)
56  {
57  /*initialise the variables*/
58  this->initalVelocity = velocity = Ogre::Vector3(initalXVelocity, initalYVelocity, initalZVelocity);
59  acceleration = -GRAVITY;
60  time = 0.0f;
61  displacement = 0.0f;
62  }
63  };
64 
66  std::shared_ptr<ProjectileObject> projectile;
67 
68 public:
72  GamePhysics();
73 
77  ~GamePhysics();
78 
83  void updateProjectile(float dt);
84 
89  Ogre::Vector3 getProjectileDisplacement();
90 
99  Ogre::Real getVfromUAT(Ogre::Real u, Ogre::Real a, Ogre::Real t);
100 
109  Ogre::Real getSfromUAT(Ogre::Real u, Ogre::Real a, Ogre::Real t);
110 
119  Ogre::Real getSfromUVT(Ogre::Real u, Ogre::Real v, Ogre::Real t);
120 
129  Ogre::Real getVSquaredfromUAS(Ogre::Real u, Ogre::Real a, Ogre::Real s);
130 
139  Ogre::Real getSfromVAT(Ogre::Real v, Ogre::Real a, Ogre::Real t);
140 
146  bool collisionTest(Ogre::Vector3 position, Ogre::Vector3 testPosition);
147 };
Ogre::Vector3 velocity
Definition: GamePhysics.h:30
Ogre::Real time
Definition: GamePhysics.h:34
Ogre::Vector3 initalVelocity
Definition: GamePhysics.h:28
ProjectileObject(Ogre::Vector3 initalVelocity)
Definition: GamePhysics.h:40
A class for the GamePhysics.
Definition: GamePhysics.h:15
~GamePhysics()
Definition: GamePhysics.cpp:14
#define GRAVITY
Definition: GamePhysics.h:9
Ogre::Real getSfromVAT(Ogre::Real v, Ogre::Real a, Ogre::Real t)
Definition: GamePhysics.cpp:102
Ogre::Vector3 displacement
Definition: GamePhysics.h:26
Ogre::Real acceleration
Definition: GamePhysics.h:32
ProjectileObject(Ogre::Real initalXVelocity, Ogre::Real initalYVelocity, Ogre::Real initalZVelocity)
Definition: GamePhysics.h:55
std::shared_ptr< ProjectileObject > projectile
Definition: GamePhysics.h:66
Ogre::Vector3 getProjectileDisplacement()
Definition: GamePhysics.cpp:45
Ogre::Real getVfromUAT(Ogre::Real u, Ogre::Real a, Ogre::Real t)
Definition: GamePhysics.cpp:54
GamePhysics()
Definition: GamePhysics.cpp:7
Definition: GamePhysics.h:23
Ogre::Real getSfromUVT(Ogre::Real u, Ogre::Real v, Ogre::Real t)
Definition: GamePhysics.cpp:78
void updateProjectile(float dt)
Definition: GamePhysics.cpp:21
bool collisionTest(Ogre::Vector3 position, Ogre::Vector3 testPosition)
Definition: GamePhysics.cpp:115
Ogre::Real getVSquaredfromUAS(Ogre::Real u, Ogre::Real a, Ogre::Real s)
Definition: GamePhysics.cpp:90
Ogre::Real getSfromUAT(Ogre::Real u, Ogre::Real a, Ogre::Real t)
Definition: GamePhysics.cpp:66