-
Notifications
You must be signed in to change notification settings - Fork 0
/
projection.hh
74 lines (66 loc) · 1.96 KB
/
projection.hh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <vector>
#include "util.hh"
#include <string>
#include <mutex>
//be very careful editing any of these values
//I might wanna add some protections for those
#ifndef screenClass
#define screenClass
class screen {
private:
void zbuffclear();
float zbuffCheckV1(int, int, const object&,int);
void triangleSplit(const v2&, const v2&, const v2&, auto);
void flatBottomTriangle(v2,v2,v2, auto);
void flatTopTriangle(const v2&, const v2&, const v2&, auto);
void polygonRender(const object&, const v2*, int);
std::mutex* locks;
public:
screen(int w, int h) : width(w), height(h){
zbuff = new float[w*h];
locks = new std::mutex[w*h];
scrnLoc = v3(550,0,0);
pjtLoc = v3(0,0,0);
scrnSlope = v3(1,0,0);
xUnitOrth = v3(0,0,1);
yUnitOrth = v3(0,-1,0);
lightLoc = v3(0,0,0);
ambientStrength = 0.15;
spotStrength = 0.75;
currentLoc = v3(0,0,0);
}
~screen() {
delete [] zbuff;
delete [] locks;
}
//funcs to generate the stuff on screen
v3 insectLoc(const v3);
v2 locOnScreen(const v3);
v3 pixTov3(int,int);
void renderObj(object&);
void renderScene();
void initFrame();
void translate(v3);
void rotX(float);
void rotY(float);
void rotZ(float);
void rotArb(v3, float);
void scaleFocalLength(float);
std::string toString();
const int width, height;
float* zbuff;
std::vector<object*> inScene;
v3 lightLoc;
v3 currentLoc;
float spotStrength; //0-1
float ambientStrength; //should be 0-1
v3 pjtLoc; //x,y,z of projection point
//next two are screen plane
v3 scrnLoc; //x0,y0,z0 in below
v3 scrnSlope; //a,b,c in a(x-x0) + b(y-y0) + c(z-z0) = 0
v3 xUnitOrth;
v3 yUnitOrth;//these should be perp. to eachother and to the normal of the screen
//normal vector can be found with x cross y
//note that that will point toward the projection point, not outward
};
#endif