-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGroup.h
57 lines (42 loc) · 1005 Bytes
/
Group.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef GROUP_H
#define GROUP_H
#include "Object3D.h"
#include "Ray.h"
#include "Hit.h"
#include <iostream>
using namespace std;
///TODO:
///Implement Group
///Add data structure to store a list of Object*
class Group : public Object3D
{
public:
Object3D** objects;
int numObjects = 0;
Group(){
}
Group( int num_objects ){
numObjects = num_objects;
objects = new Object3D*[num_objects];
}
~Group(){
delete [] objects;
}
virtual bool intersect( const Ray& r, Hit& h, float tmin ) {
bool didInsersect = false;
for (int i = 0; i < numObjects; i++) {
if (objects[i]->intersect(r, h, tmin)) {
didInsersect = true;
}
}
return didInsersect;
}
void addObject( int index, Object3D* obj ){
objects[index] = obj;
}
int getGroupSize(){
return numObjects;
}
private:
};
#endif