-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnvironmentNode.h
90 lines (74 loc) · 2.93 KB
/
EnvironmentNode.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef _ENVIRONMENTNODE_H
#define _ENVIRONMENTNODE_H
#include <string>
#include "math/common.h"
#include "IMeshContainer.h"
#include "IPhysicsObject.h"
#include "Node.h"
// EnvironmentNode is a Node-style class that can contain static meshes
class EnvironmentNode : public Node, public IMeshContainer, public IPhysicsObject
{
public:
EnvironmentNode(unsigned int flags = 0,
std::string model_file_ref = "",
unsigned int nlayer = NodeLayer::ENVIRONMENT)
{
m_sModelFile = model_file_ref;
addFlags(flags);
layer(nlayer);
}
virtual ~EnvironmentNode() {}
virtual void logicSelf(unsigned int advance){
IMeshContainer::logic(advance);
}
virtual void renderSelf(IPartitioner* partitioner, unsigned int flags = 0) const;
virtual bool hasAttribute(unsigned int attr) const {
if(attr == NodeAttributes::PHYSICS)
return true;
if(attr = NodeAttributes::MESH_CONTAINER)
return true;
if(attr == NodeAttributes::FILENAME)
return !m_sModelFile.empty();
if(attr == NodeAttributes::SIZE)
return true;
return const_cast<EnvironmentNode*>(this)->Node::hasAttribute(attr);
}
virtual void* getAttribute(unsigned int attr) {
if(attr == NodeAttributes::PHYSICS)
return (void*)this;
if(attr == NodeAttributes::MESH_CONTAINER)
return (void*)this;
if(attr == NodeAttributes::FILENAME && !m_sModelFile.empty())
return (void*)this;
if(attr == NodeAttributes::SIZE)
return (void*)this;
return Node::getAttribute(attr);
}
virtual void* getAttribute(unsigned int attr) const {
return const_cast<EnvironmentNode*>(this)->getAttribute(attr);
}
virtual IPhysicsObject::Type getPhysicsType() { return IPhysicsObject::STATIC; }
virtual std::string filename() const {
return m_sModelFile;
}
virtual void filename(std::string fn) {
m_sModelFile = fn;
}
virtual std::string nodeTypeString() const { return "environment"; }
virtual SCOPED_ENUM_TYPE(NodeType) nodeType() const { return NodeType::ENVIRONMENT; }
virtual const AABB* box() const { return &m_Box; }
virtual AABB* box() { return &m_Box; }
virtual void recalculate();
virtual const Node* superParent() const {
if(layer() == NodeLayer::SUB_ENVIRONMENT/* && getParent_c()*/)
{
ASSERT(getParent_c());
return getParent_c()->superParent();
}
return this;
}
private:
std::string m_sModelFile; // model file that this node was loaded from originally
AABB m_Box;
};
#endif