-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSceneObjectCylinder.c
43 lines (28 loc) · 1.31 KB
/
SceneObjectCylinder.c
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
#include "SceneObjectCylinder.h"
#include "pi.h"
#include "randf.h"
#include <math.h>
const SceneObjectVTable sceneObjectCylinderVTable = (SceneObjectVTable) {
&sceneObjectCylinderIntersectRay,
&sceneObjectCylinderEmitPhotons,
&sceneObjectCylinderRadiantFlux
};
SceneObjectCylinder makeSceneObjectCylinder (const Vector endA, const Vector endB, const float radius, const Material *material) {
return (SceneObjectCylinder) {makeSceneObject(&sceneObjectCylinderVTable), makeCylinder(endA, endB, radius), material};
}
defineAllocator(SceneObjectCylinder)
Intersection sceneObjectCylinderIntersectRay(const SceneObject *superobject, const Ray ray) {
const SceneObjectCylinder *object = (SceneObjectCylinder *) superobject;
Intersection intersection = cIntersect(object->cylinder, ray);
intersection.material = object->material;
return intersection;
}
bool sceneObjectCylinderEmitPhotons(const SceneObject *superobject, const int numPhotons, PhotonContainer *photons) {
// TODO: Implement this. Use code from SceneObjectSphere.
return false;
}
Color sceneObjectCylinderRadiantFlux(const SceneObject *superobject) {
const SceneObjectCylinder *object = (SceneObjectCylinder *) superobject;
Color averageIrradiance = materialIrradience(object->material);
return csMul(averageIrradiance, cSurfaceArea(object->cylinder));
}