-
Notifications
You must be signed in to change notification settings - Fork 0
/
bodymanager.cpp
36 lines (30 loc) · 911 Bytes
/
bodymanager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "bodymanager.hpp"
#include <iostream>
#include "main.hpp"
#include "geometry.hpp"
BodyManager::BodyManager()
{
bodyList = new std::vector<Body>();
}
void BodyManager::addBody(Body newBody){
bodyList->push_back(newBody);
}
void BodyManager::addRandomBody(bool isStar){
vector3 rPos(randf()*10.0f, randf()*10.0f, randf()*10.0f);
vector3 rVel(randf(), randf(), randf());
float rMass = randf()*0.5f;
float rRad = randf()*0.5f+0.1f;
float rColor[4] = {randf(), randf(), randf(), randf()};
bodyList->push_back(Body(rPos,rVel,rMass,rRad, get_geometry(get_num_geometries()*randf(), true), rColor, isStar));
}
std::vector<Body>* BodyManager::getBodyList(){
return bodyList;
}
void BodyManager::drawBodys(){
for(std::vector<Body>::iterator i=bodyList->begin(); i!=bodyList->end(); i++){
i->draw();
}
}
BodyManager::~BodyManager(){
delete bodyList;
}