/
StaticModelNode.h
99 lines (78 loc) · 2.74 KB
/
StaticModelNode.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
90
91
92
93
94
95
96
97
98
99
#pragma once
#include "Transformable.h"
#include "iselectiontest.h"
#include "irender.h"
#include "itraceable.h"
#include "modelskin.h"
#include "irenderable.h"
#include "pivot.h"
#include "render/VectorLightList.h"
#include "StaticModel.h"
#include "scene/Node.h"
namespace model {
/**
* \brief Scenegraph node representing a static model loaded from a file (e.g.
* LWO or ASE).
*
* This node does not represent a "func_static" (or similar object) directly,
* but is added as a child of the respective entity node (e.g.
* StaticGeometryNode). It is normally created by the ModelCache in response to
* a particular entity gaining a "model" spawnarg.
*/
class StaticModelNode :
public scene::Node,
public ModelNode,
public SelectionTestable,
public LitObject,
public SkinnedModel,
public ITraceable,
public Transformable
{
// The actual model
StaticModelPtr _model;
std::string _name;
// The name of this model's skin
std::string _skin;
public:
typedef std::shared_ptr<StaticModelNode> Ptr;
/** Construct a StaticModelNode with a reference to the loaded picoModel.
*/
StaticModelNode(const StaticModelPtr& picoModel);
virtual ~StaticModelNode();
virtual void onInsertIntoScene(scene::IMapRootNode& root) override;
virtual void onRemoveFromScene(scene::IMapRootNode& root) override;
// ModelNode implementation
const IModel& getIModel() const override;
IModel& getIModel() override;
bool hasModifiedScale() override;
Vector3 getModelScale() override;
// SkinnedModel implementation
// Skin changed notify
void skinChanged(const std::string& newSkinName) override;
// Returns the name of the currently active skin
std::string getSkin() const override;
// Bounded implementation
virtual const AABB& localAABB() const override;
// SelectionTestable implementation
void testSelect(Selector& selector, SelectionTest& test) override;
virtual std::string name() const override;
Type getNodeType() const override;
const StaticModelPtr& getModel() const;
void setModel(const StaticModelPtr& model);
// LitObject test function
bool intersectsLight(const RendererLight& light) const override;
// Renderable implementation
void renderSolid(RenderableCollector& collector, const VolumeTest& volume) const override;
void renderWireframe(RenderableCollector& collector, const VolumeTest& volume) const override;
void setRenderSystem(const RenderSystemPtr& renderSystem) override;
std::size_t getHighlightFlags() override
{
return Highlight::NoHighlight; // models are never highlighted themselves
}
// Traceable implementation
bool getIntersection(const Ray& ray, Vector3& intersection) override;
protected:
virtual void _onTransformationChanged() override;
virtual void _applyTransformation() override;
};
} // namespace model