-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDotNode.cpp
More file actions
49 lines (39 loc) · 1.11 KB
/
DotNode.cpp
File metadata and controls
49 lines (39 loc) · 1.11 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
#include "DotNode.h"
#include "os.h"
#include "ColorSpec.h"
#include "Config.h"
#include "PropSpec.h"
DotNode::DotNode(const string& id, const PropSpec& initSpec)
: PropNode(id, initSpec) {
delta_h_ = 0;
delta_hv_ = Config::DOT_DIM/10;
myDList_ = glGenLists(1);
glNewList(myDList_, GL_COMPILE);
glPushMatrix();
glPushAttrib(GL_LIGHTING_BIT);
glMaterialfv(GL_FRONT, GL_AMBIENT, Config::SHINY_MAT_AMB);
glMaterialfv(GL_FRONT, GL_DIFFUSE, Config::SHINY_MAT_AMB);
glMaterialfv(GL_FRONT, GL_SPECULAR, Config::SHINY_MAT_SPEC);
glMaterialf(GL_FRONT, GL_SHININESS, 50);
Config::DOT_COLOR->set();
glutSolidSphere(Config::DOT_DIM, 20, 20);
glPopAttrib();
glPopMatrix();
glEndList();
}
DotNode::~DotNode() {
}
void DotNode::render() {
if (myProp_.isActive()) {
// compute delta_h_
if (delta_h_ > 0)
delta_hv_ -= Config::DOT_DIM/60;
else
delta_hv_ += Config::DOT_DIM/60;
delta_h_ += delta_hv_;
glPushMatrix();
glTranslated(myProp_.getXPos(), Config::DOT_CENTER_HEIGHT + delta_h_, myProp_.getYPos());
glCallList(myDList_);
glPopMatrix();
}
}