/
ModelPreview.h
106 lines (78 loc) · 2.4 KB
/
ModelPreview.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
#pragma once
#include "RenderPreview.h"
#include "imodel.h"
#include "imap.h"
#include <sigc++/signal.h>
#include <string>
#include <map>
namespace wxutil
{
/**
* \brief
* Preview widget for models and skins.
*
* Subclass of RenderPreview which holds a model and displays it optionally with
* a skin.
*/
class ModelPreview
: public RenderPreview
{
private:
// TRUE when the scene, model and skin have been set up
// is set back to FALSE if the model or skin config is changed
bool _sceneIsReady;
// The name of the model to render
std::string _model;
// The name of the skin to render
std::string _skin;
scene::IMapRootNodePtr _rootNode;
// The parent entity
scene::INodePtr _entity;
// Current model to display
scene::INodePtr _modelNode;
// The light
scene::INodePtr _light;
// Name of last model, to detect changes in model which require camera
// recalculation
std::string _lastModel;
float _defaultCamDistanceFactor;
sigc::signal<void, const model::ModelNodePtr&> _modelLoadedSignal;
private:
// Creates parent entity etc.
void setupSceneGraph() override;
AABB getSceneBounds() override;
bool onPreRender() override;
RenderStateFlags getRenderFlagsFill() override;
void prepareScene();
protected:
virtual void onModelRotationChanged() override;
public:
/// Construct a ModelPreview widget.
ModelPreview(wxWindow* parent);
// Returns the name of the current model
const std::string& getModel() const;
// Returns the name of the current skin
const std::string& getSkin() const;
/**
* Set the widget to display the given model. If the model name is the
* empty string, the widget will release the currently displayed model.
*
* @param
* String name of the model to display.
*/
void setModel(const std::string& model);
/// Set the skin to apply to the model for rendering
void setSkin(const std::string& skin);
// Multiply the model node's AABB radius by this factor to get the default camera distance
// defaults to 6.
void setDefaultCamDistanceFactor(float factor);
/// Return the current model node
scene::INodePtr getModelNode()
{
return _modelNode;
}
// Signal emitted when the preview is done loading a new model
sigc::signal<void, const model::ModelNodePtr&>& signal_ModelLoaded();
};
typedef std::shared_ptr<ModelPreview> ModelPreviewPtr;
} // namespace