-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvec3.cpp
More file actions
85 lines (73 loc) · 1.24 KB
/
vec3.cpp
File metadata and controls
85 lines (73 loc) · 1.24 KB
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
/*
Author: Lucas Parzych
Personal vec3 struct
Main use is for the dump_into function, which is made use of in the noise_terrain class
*/
using namespace std;
struct vec3
{
GLfloat x,y,z;
vec3()
{
x=0;
y=0;
z=0;
}
vec3(GLfloat a, GLfloat b, GLfloat c)
{
x=a;
y=b;
z=c;
}
void dump_into(GLfloat data[])
{
//considers anything less than -9999 as empty
//use with caution, dummy function might walk off the edge of the cliff.
int pos=0;
while(true)
{
if(data[pos] >= -9999)
{
pos++;
}
else break;
}
data[pos]=x;
data[pos+1]=y;
data[pos+2]=z;
}
float red()
{
return x;
}
float green()
{
return y;
}
float blue()
{
return z;
}
void red(float val)
{
x=val;
}
void green(float val)
{
y=val;
}
void blue(float val)
{
z=val;
}
void print(void)
{
cout<<"\nX:\t";
cout<<x;
cout<<"\nY:\t";
cout<<y;
cout<<"\nZ:\t";
cout<<z;
cout<<"\n";
}
};