/
PicoModelNode.h
112 lines (88 loc) · 2.96 KB
/
PicoModelNode.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
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
#include "iselectiontest.h"
#include "irender.h"
#include "itraceable.h"
#include "modelskin.h"
#include "irenderable.h"
#include "render/VectorLightList.h"
#include "RenderablePicoModel.h"
#include "scene/Node.h"
#include "Transformable.h"
namespace model {
class PicoModelNode :
public scene::Node,
public ModelNode,
public SelectionTestable,
public LitObject,
public SkinnedModel,
public ITraceable,
public Transformable
{
private:
// The actual model
RenderablePicoModelPtr _picoModel;
std::string _name;
// Vector of RendererLight references which illuminate this instance, set
// with addLight() and clearLights()
render::lib::VectorLightList _lights;
// The light list from the shader cache when we attach
LightList& _lightList;
// The name of this model's skin
std::string _skin;
public:
/** Construct a PicoModelNode with a reference to the loaded picoModel.
*/
PicoModelNode(const RenderablePicoModelPtr& picoModel);
virtual ~PicoModelNode();
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;
// SkinnedModel implementation
// Skin changed notify
void skinChanged(const std::string& newSkinName);
// Returns the name of the currently active skin
std::string getSkin() const;
// Bounded implementation
virtual const AABB& localAABB() const;
// Lights changed function
void lightsChanged()
{
_lightList.setDirty();
}
// SelectionTestable implementation
void testSelect(Selector& selector, SelectionTest& test);
virtual std::string name() const;
Type getNodeType() const;
const RenderablePicoModelPtr& getModel() const;
void setModel(const RenderablePicoModelPtr& model);
// LitObject test function
bool intersectsLight(const RendererLight& light) const;
// Add a light to this model instance
void insertLight(const RendererLight& light);
// Clear all lights from this model instance
void clearLights();
// 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);
protected:
virtual void _onTransformationChanged() override;
virtual void _applyTransformation() override;
private:
// Instance render function
void submitRenderables(RenderableCollector& collector,
const VolumeTest& volume,
const Matrix4& localToWorld,
const IRenderEntity& entity) const;
};
typedef std::shared_ptr<PicoModelNode> PicoModelNodePtr;
} // namespace model