-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node.cpp
68 lines (56 loc) · 1.85 KB
/
Node.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
58
59
60
61
62
63
64
65
66
67
68
#include <vector>
#include <tuple>
#include <iostream>
#include <GL/glut.h>
#include "gl.hpp"
#include "Node.hpp"
Node::Node(std::string name, Triple pos):
Ent(name, pos)
{}
void Node::add_adj(Node *node) {
adj.push_back(node);
}
bool Node::is_adj(Node *node) {
for (auto it = adj.begin(); it != adj.end(); ++it) {
if ((*it) == node) return true;
}
return false;
}
void Node::print_node() {
std::cout << "Node " << static_cast<void *>(this) << ": name == " << this->name << "; pos == (" << this->pos.x << ", " << this->pos.y << ", " << this->pos.z << ")" << std::endl;
}
void Node::print_adj() {
this->print_node();
std::cout << "\tAdjacency nodes:" << std::endl;
Node *node;
for (auto it = adj.begin(); it != adj.end(); ++it) {
node = (*it);
std::cout << "\tNode " << static_cast<void *>(node) << ": name == " << node->name << "; pos == (" << node->pos.x << ", " << node->pos.y << ", " << node->pos.z << ")" << std::endl;
}
}
void Node::add_mod(Ent *e, double c) {
std::tuple<Ent *, double> mod;
std::get<0>(mod) = e;
std::get<1>(mod) = c;
mods.push_back(mod);
}
void Node::draw() const {
glPushMatrix();
glColor4ub(255, 255, 0, 255);
// TODO: no usar glutSolidSphere!!!
glScalef(1, 1, 0.2);
glutSolidSphere(0.5, 4, 4);
#if 0
glCallList(cubo);
glBegin(GL_LINES);
glVertex3f(0, 0, 0);
glVertex3f(2, 0, 0);
glEnd();
#endif
glPopMatrix();
}
void Node::steer(unsigned int ticks, unsigned int delta_ticks) {}
void Node::update() {}
std::tuple<Triple, Triple> points(Node *n1, Node *n2) {
return std::make_tuple(n1->pos, n2->pos);
}