-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSceneObject.cpp
46 lines (38 loc) · 1.14 KB
/
SceneObject.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
37
38
39
40
41
42
43
44
45
46
/*----------------------------------------------------------
* COSC363 Ray Tracer
*
* The object class
* This is a generic type for storing objects in the scene
* Sphere, Plane etc. must be defined as subclasses of Object.
* Being an abstract class, this class cannot be instantiated.
-------------------------------------------------------------*/
#include "SceneObject.h"
glm::vec3 SceneObject::getColor()
{
return color;
}
void SceneObject::setColor(glm::vec3 col)
{
color = col;
}
glm::mat4 SceneObject::getTransform()
{
return transform;
}
void SceneObject::setTransform(glm::mat4 trans)
{
transformInv = glm::inverse(trans);
transformInvTrans = glm::transpose(glm::inverse(trans));
transform = trans;
}
glm::vec3 transformProj(glm::mat4 matx, glm::vec3 pos) {
glm::vec4 p4 = matx * glm::vec4(pos, 1.0);
return glm::vec3(p4.x / p4.w); // TODO
}
float SceneObject::intersect(glm::vec3 pos, glm::vec3 dir) {
//return intersect_internal(transformProj(transformInv, pos), dir);
return intersect_internal(pos, dir);
}
glm::vec3 SceneObject::normal(glm::vec3 pos) {
return normal_internal(pos);
}