-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjNode.cpp
68 lines (61 loc) · 1.65 KB
/
ObjNode.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 "ObjNode.h"
#include <assert.h>
#include "os.h"
#include "ColorSpec.h"
#include "Config.h"
#include "PropSpec.h"
#include "objreader.h"
ObjNode::ObjNode(const string& id, const PropSpec& initSpec)
: PropNode(id, initSpec) {
objReader o;
double scaleHeight = 1.0;
double liftHeight = 0.0;
double scaleDimension = 1.0;
const ColorSpec* c;
if (initSpec.getType() == TORCH_PROP) {
o.loadObj(Config::TORCH_OBJ_FILE);
scaleHeight = 1.5;
liftHeight = 0.0;
c = Config::TORCH_COLOR;
}
else if (initSpec.getType() == THRONE_PROP) {
o.loadObj(Config::THRONE_OBJ_FILE);
scaleHeight = 1.5;
liftHeight = 0.5;
c = Config::THRONE_COLOR;
}
else if (initSpec.getType() == TROPHY_PROP) {
o.loadObj(Config::TROPHY_OBJ_FILE);
scaleHeight = 1.0;
liftHeight = 1;
// Minor hack
scaleDimension *= 2.8;
c = Config::TROPHY_COLOR;
}
else {
assert(false);
}
myList_ = glGenLists(1);
o.centerObject();
glNewList(myList_, GL_COMPILE);
glPushMatrix();
glPushAttrib(GL_LIGHTING_BIT);
c -> set();
glMaterialfv(GL_FRONT, GL_AMBIENT, Config::SHINY_MAT_AMB);
glMaterialfv(GL_FRONT, GL_DIFFUSE, Config::SHINY_MAT_DIF);
glMaterialfv(GL_FRONT, GL_SPECULAR, Config::SHINY_MAT_SPEC);
glMaterialf(GL_FRONT, GL_SHININESS, 50);
glTranslated(myProp_.getXPos(), liftHeight, myProp_.getYPos());
o.resizeObject();
glScaled(scaleDimension * myProp_.getXDim(), scaleHeight, scaleDimension * myProp_.getYDim());
o.displayObj();
glPopAttrib();
glPopMatrix();
glEndList();
}
ObjNode::~ObjNode() {
}
void ObjNode::render() {
glCallList(myList_);
SceneNode::render();
}