Skip to content
Permalink
53bf0bd95c
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
54 lines (34 sloc) 981 Bytes
#include "Particle.h"
void Particle::Draw()
{
glPushMatrix();
glColor3f(0.F, 1.F, 0.F);
glTranslatef(position.x, position.y, position.z);
glutSolidSphere(1.f, 10, 10);
glPopMatrix();
}
Particle::Particle(float m, CR217::CRVec3 position) : GameObject (position.x, position.y, position.z)
{
mass = m;
velocity = CR217::CRVec3(0, 0, 0);
acceleration = CR217::CRVec3(0, 0, 0);
totalForce = CR217::CRVec3(0, 0, 0);
}
void Particle::calculateForces()
{
totalForce = CR217::CRVec3(0, 0, 0);
totalForce += CR217::CRVec3(0, -9.8f, 0) * mass;
}
void Particle::Update(float deltaTime)
{
acceleration += totalForce / mass;
futureVelocity = CR217::CRVec3(0, 0, 0);
futureVelocity += acceleration + (velocity * deltaTime);
futurePosition = CR217::CRVec3(0, 0, 0);
futurePosition += position + (velocity * deltaTime);
position = futurePosition;
velocity = futureVelocity;
}
Particle::~Particle()
{
}