-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA4.hpp
56 lines (48 loc) · 1.68 KB
/
A4.hpp
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
#pragma once
#include <glm/glm.hpp>
#include "SceneNode.hpp"
#include "GeometryNode.hpp"
#include "PhongMaterial.hpp"
#include "Mesh.hpp"
#include "Light.hpp"
#include "Image.hpp"
#include "polyroots.hpp"
#include <vector>
void A4_Render(
// What to render
SceneNode * root,
// Image to write to, set to a given width and height
Image & image,
// Viewing parameters
const glm::vec3 & eye,
const glm::vec3 & view,
const glm::vec3 & up,
double fovy,
// Lighting parameters
const glm::vec3 & ambient,
const std::list<Light *> & lights
);
//trarvese the tree, check the collision
void checkCollision(SceneNode * node,const glm::vec3 &eye,const glm::vec3 &ray
,glm::vec3 &kd,glm::vec3 &ks,glm::vec3 &ke,bool &hit,double &point,glm::vec3 &normal);
void flatenTree(SceneNode * node);
bool collision(const glm::vec3 &eye,const glm::vec3 &ray,
glm::vec3 &kd,glm::vec3 &ks,
double &shiny,double &point,glm::vec3 &norm);
bool recurseCollision(SceneNode* node,const glm::vec3 &eye,const glm::vec3 &ray,
glm::vec3 &kd,glm::vec3 &ks,
double &shiny,double &point,glm::vec3 &norm);
glm::vec3 rayColour(int depth,
const glm::vec3 &eye,
glm::vec3 &ray,
const std::list<Light *> & lights,
const glm::vec3 &ambient);
glm::vec3 directLight(const Light * light,
const glm::vec3 &hit_p ,
const glm::vec3 &norm);
glm::vec3 ggReflect(const Light * light,
const glm::vec3 &hit_p ,
const glm::vec3 &norm);
//make ray
glm::vec3 makeRay(uint x, uint y,double h, double w,double fovy,
const glm::vec3 &eye, const glm::vec3 &view, const glm::vec3 &up);