| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <sigc++/connection.h> |
| 4 |
#include "ishaders.h" |
| 5 |
#include "modelskin.h" |
| 6 |
#include "scene/BasicRootNode.h" |
| 7 |
#include "TestModelSkin.h" |
| 8 |
#include "wxutil/preview/RenderPreview.h" |
| 9 |
|
| 10 |
namespace ui |
| 11 |
{ |
| 12 |
|
| 13 |
/** |
| 14 |
* A render preview to display materials on a rotating object |
| 15 |
* placed in a room with customisable material and lighting. |
| 16 |
*/ |
| 17 |
class MaterialPreview : |
| 18 |
public wxutil::RenderPreview |
| 19 |
{ |
| 20 |
private: |
| 21 |
bool _sceneIsReady; |
| 22 |
|
| 23 |
MaterialPtr _material; |
| 24 |
sigc::connection _materialChanged; |
| 25 |
|
| 26 |
scene::IMapRootNodePtr _rootNode; |
| 27 |
|
| 28 |
scene::INodePtr _entity; // The func_static entity |
| 29 |
scene::INodePtr _model; // The textured model |
| 30 |
scene::INodePtr _room; // The textured room |
| 31 |
scene::INodePtr _light; // The light |
| 32 |
|
| 33 |
std::shared_ptr<TestModelSkin> _testModelSkin; |
| 34 |
std::shared_ptr<TestModelSkin> _testRoomSkin; |
| 35 |
|
| 36 |
std::string _roomMaterial; |
| 37 |
std::string _lightClassname; |
| 38 |
bool _swapBackgroundMaterial; |
| 39 |
|
| 40 |
float _defaultCamDistanceFactor; |
| 41 |
|
| 42 |
wxToolBarToolBase* _testModelCubeButton; |
| 43 |
wxToolBarToolBase* _testModelSphereButton; |
| 44 |
wxToolBarToolBase* _testModelTilesButton; |
| 45 |
wxToolBarToolBase* _swapBackgroundMaterialButton; |
| 46 |
|
| 47 |
sigc::signal<void> _sigSceneChanged; |
| 48 |
|
| 49 |
public: |
| 50 |
enum class TestModel |
| 51 |
{ |
| 52 |
Cube, |
| 53 |
Sphere, |
| 54 |
Tiles, |
| 55 |
}; |
| 56 |
|
| 57 |
MaterialPreview(wxWindow* parent); |
| 58 |
|
| 59 |
virtual ~MaterialPreview(); |
| 60 |
|
| 61 |
const MaterialPtr& getMaterial(); |
| 62 |
void setMaterial(const MaterialPtr& material); |
| 63 |
|
| 64 |
void enableFrobHighlight(bool enable); |
| 65 |
|
| 66 |
// Light management |
| 67 |
std::string getLightClassname(); |
| 68 |
void setLightClassname(const std::string& className); |
| 69 |
Vector3 getLightColour(); |
| 70 |
void setLightColour(const Vector3& colour); |
| 71 |
void resetLightColour(); |
| 72 |
|
| 73 |
const std::string& getRoomMaterial(); |
| 74 |
void setRoomMaterial(const std::string& material); |
| 75 |
|
| 76 |
TestModel getTestModelType(); |
| 77 |
void setTestModelType(TestModel type); |
| 78 |
|
| 79 |
static std::string GetTestModelTypeName(TestModel type); |
| 80 |
static TestModel GetTestModelType(const std::string& typeName); |
| 81 |
|
| 82 |
sigc::signal<void>& signal_SceneChanged(); |
| 83 |
|
| 84 |
protected: |
| 85 |
bool canDrawGrid() override; |
| 86 |
void setupSceneGraph() override; |
| 87 |
RenderStateFlags getRenderFlagsFill() override; |
| 88 |
|
| 89 |
private: |
| 90 |
void onMaterialChanged(); |
| 91 |
bool onPreRender() override; |
| 92 |
void prepareScene(); |
| 93 |
void setupToolbar(); |
| 94 |
void setupTestModel(); |
| 95 |
void setupRoom(); |
| 96 |
void updateModelSkin(const std::string& material); |
| 97 |
void updateRoomSkin(const std::string& material); |
| 98 |
void updateSceneMaterials(); |
| 99 |
std::string getDefaultLightDef(); |
| 100 |
void onTestModelSelectionChanged(wxCommandEvent& ev); |
| 101 |
void onSwapBackgroundMaterialChanged(wxCommandEvent& ev); |
| 102 |
}; |
| 103 |
|
| 104 |
} |