-
Notifications
You must be signed in to change notification settings - Fork 0
/
headers.h
98 lines (89 loc) · 2.28 KB
/
headers.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
// Created by prasanga on 3/2/19.
//
#ifndef GRAPHICSPROJECT_HEADERS_H
#define GRAPHICSPROJECT_HEADERS_H
#include<GL/glut.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <cmath>
#include <map>
#include <utility>
#include <cstring>
using namespace std;
#define rep(i,a,b) for(int i=a; i<b; i++)
typedef std::vector<std::vector<float> > matrix;
typedef std::vector<std::vector<int> > matrixint;
matrix originalVertices(4);
matrix result(4);
matrixint face(3);
matrix normals(3);
matrix colors(3);
matrix newcolors(3);
matrixint facenormals(3);
matrix Ka(3);
matrix Kd(3);
matrix Ks(3);
//matrix projectionMatrix = {};
char filename[] = "object.txt";
float anglz, anglx, angly, transx, transy, scal,lightangle;
int screenwidth = 1200;
int screenheight = 600;
int startx = 90;
int starty = 90;
int lightmode = 0;
float Ia = 0.35, Id = 1.0;
float isoangle = M_PI / 5.25;
float lightinitx, lightinity, lightinitz;
void globalVariablesInitializer() {
if(strcmp(filename, "object.txt")==0) {
anglz = -0.85f;
anglx = -0.3;
angly = 0.35;
transx = 0;
transy = 0;
scal = 7;
lightangle = 2;
lightinitx = 120;
lightinity = 0;
lightinitz = 20;
}
else if(strcmp(filename, "try.txt")==0){
anglz = 0.9f;
anglx = 0;
angly = 0;
transx = 0;
transy = 0;
scal = 40;
lightangle = 2;
lightangle = 2;
lightinitx = -15;
lightinity = -42;
lightinitz = 18.5;
}
}
void logstates(){
cout<<"Anglz: "<<anglz<<" "<<"Angley: "<<angly<<" "<<"Anglex: "<<anglx<<endl;
cout<<"Scal: "<<scal<<endl;
cout<<"LightSource: "<<originalVertices[0][0]<<" "<<originalVertices[1][0]<<" "<<originalVertices[2][0]<<endl;
cout<<"Lightangle: "<<lightangle<<endl;
cout<<"Light Intensities: "<<Ia<<" "<<Id<<endl;
}
map<pair<int, int>, float> depthbuf;
matrix matmultiply(const matrix & a, const matrix & b){
std::vector<std::vector<float> > c(a.size());
float sum;
rep(i,0,a.size()){
rep(j,0,b[0].size()){
sum=0;
rep(k,0,b.size()){
sum+= a[i][k]*b[k][j];
}
c[i].push_back(sum);
}
}
return c;
}
#endif //GRAPHICSPROJECT_HEADERS_H