-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.cpp
29 lines (28 loc) · 890 Bytes
/
main2.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
#include "camera.h"
#include "render.h"
#include "shape.h"
#include <vector>
// Example with rotating camera and a sphere moving towards the camera and a cube
int main(){
Rectangle* testShape = new Rectangle{std::vector<double>{10,5,0}, 5, 5, 5};
Sphere* testSphere = new Sphere{std::vector<double>{10, 2, 0}, 2};
Camera testCamera{std::vector<double>{0,0,0}};
testCamera.world.push_back(testShape);
testCamera.world.push_back(testSphere);
double speedLeft = 0.05;
int i = 0;
double angleLeft = 0;
while(true){
angleLeft += 3;
testCamera.lookAt(angleLeft, 90);
testSphere->center[0] -= 0.05;
i++;
testSphere->center[2] += speedLeft * 2;
testSphere->center[1] += speedLeft * 0.5;
if(i==100){
i=0;
speedLeft *= -1;
}
renderFrame(testCamera.getRender());
}
}