-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vert.cpp
57 lines (46 loc) · 1003 Bytes
/
Vert.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
47
48
49
50
51
52
53
54
55
56
57
#include "Vert.h"
#include "common.h"
Vert::Vert()
{
x = 0.f;
y = 0.f;
z = 0.f;
radius = 0;
}
void Vert::setX(float newX)
{
x = newX;
}
void Vert::setY(float newY)
{
y = newY;
}
void Vert::setZ(float newZ)
{
z = newZ;
}
void Vert::setRadius(int newRadius)
{
radius = newRadius;
}
int Vert::getRadius(){
return radius;
}
float Vert::getX(){
return x;
}
float Vert::getY(){
return y;
}
float Vert::getZ(){
return z;
}
void Vert::adjust(Vert adjustor)
{
float difference, distance;
//calculates distance of the vertex to the hill or ridge being tested, as well as the difference in height between the two
distance = sqrt(pow( (float)(x - adjustor.getX()), 2.f) + pow( (float)(z - adjustor.getZ()), 2.f));
difference = adjustor.getY() - y;
//moves the vertex up or down by a factor directly related to the hill's radius of influence and inversely related to the vertex' distance to the hill squared
y += difference / (1 + (1.f / adjustor.getRadius()) * distance * distance);
}