-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdrawer.h
More file actions
executable file
·48 lines (36 loc) · 980 Bytes
/
drawer.h
File metadata and controls
executable file
·48 lines (36 loc) · 980 Bytes
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
#ifndef DRAWER_H
#define DRAWER_H
#include <vector>
#include "uniforms.h"
#include "scenegraph.h"
#include "asstcommon.h"
class Drawer : public SgNodeVisitor {
protected:
std::vector<RigTForm> rbtStack_;
Uniforms& uniforms_;
public:
Drawer(const RigTForm& initialRbt, Uniforms& uniforms)
: rbtStack_(1, initialRbt)
, uniforms_(uniforms) {}
virtual bool visit(SgTransformNode& node) {
rbtStack_.push_back(rbtStack_.back() * node.getRbt());
return true;
}
virtual bool postVisit(SgTransformNode& node) {
rbtStack_.pop_back();
return true;
}
virtual bool visit(SgShapeNode& shapeNode) {
const Matrix4 MVM = rigTFormToMatrix(rbtStack_.back()) * shapeNode.getAffineMatrix();
sendModelViewNormalMatrix(uniforms_, MVM, normalMatrix(MVM));
shapeNode.draw(uniforms_);
return true;
}
virtual bool postVisit(SgShapeNode& shapeNode) {
return true;
}
Uniforms& getUniforms() {
return uniforms_;
}
};
#endif