!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Sandbox / Plugins / LodGeneratorPlugin / panel / LodGeneratorOptionsPanel.cpp
blobeb97ed1788a5f6a6578726315eeb8605a3e2de7e
1 #include "StdAfx.h"
2 #include "LodGeneratorOptionsPanel.h"
3 #include "../UIs/ui_clodgeneratoroptionspanel.h"
4 #include "LODInterface.h"
5 #include "../Util/StringTool.h"
6 #include "Util/Variable.h"
8 using namespace LODGenerator;
10 CLodGeneratorOptionsPanel::CLodGeneratorOptionsPanel(QWidget *parent) :
11 CGeneratorOptionsPanel(parent),
12 ui(new Ui::CLodGeneratorOptionsPanel)
14 ui->setupUi(this);
16 Update();
19 CLodGeneratorOptionsPanel::~CLodGeneratorOptionsPanel()
21 delete ui;
24 void CLodGeneratorOptionsPanel::FillProperty(SLodParameterGroup& sLodParameterGroup,CVarBlock* pVarBlock)
26 int iVarSize = pVarBlock->GetNumVariables();
27 for (int i=0;i<iVarSize;i++)
29 IVariable* pCurVariable = pVarBlock->GetVariable(i);
30 SLodParameter sLodParameter;
31 sLodParameter.SetOptionsPanel(this);
33 sLodParameter.SetName(pCurVariable->GetName());
34 sLodParameter.SetLabel(pCurVariable->GetName());
35 //sLodParameter.SetLabel(pCurVariable->GetDescription());
37 ELodParamType eLodParamType = SLodParameter::GetLodParamType(pCurVariable);
38 sLodParameter.SetTODParamType(eLodParamType);
39 int type = pCurVariable->GetDataType();
40 switch (eLodParamType)
42 case ELodParamType::eFloatType:
44 float value;
45 pCurVariable->Get(value);
46 sLodParameter.SetParamFloat(value);
47 break;
49 case ELodParamType::eBoolType:
51 bool value;
52 pCurVariable->Get(value);
53 sLodParameter.SetParamBool(value);
54 break;
56 case ELodParamType::eColorType:
58 Vec4 value;
59 pCurVariable->Get(value);
60 sLodParameter.SetParamFloat3(Vec3(value.x,value.y,value.z));
61 break;
63 case ELodParamType::eStringType:
65 string value;
66 pCurVariable->Get(value);
67 sLodParameter.SetParamString(CStringTool::CStringToQString(value).toStdString().c_str());
68 break;
70 case ELodParamType::eIntType:
72 int value;
73 pCurVariable->Get(value);
74 sLodParameter.SetParamInt(value);
75 break;
77 default:
79 CryLog("Unknow Type");
80 break;
84 sLodParameterGroup.m_Params.push_back(sLodParameter);
88 void CLodGeneratorOptionsPanel::Update()
90 m_groups.m_propertyGroups.clear();
92 ui->m_propertyTree->detach();
94 SLodParameterGroup sLodParameterGroupG;
95 FillProperty(sLodParameterGroupG,CLodGeneratorInteractionManager::Instance()->GetGeometryVarBlock());
96 m_groups.m_propertyGroups["Geometry Option"] = sLodParameterGroupG;
97 SLodParameterGroup sLodParameterGroupM;
98 FillProperty(sLodParameterGroupM,CLodGeneratorInteractionManager::Instance()->GetMaterialVarBlock());
99 m_groups.m_propertyGroups["Material Option"] = sLodParameterGroupM;
101 ui->m_propertyTree->attach(Serialization::SStruct(m_groups));
102 ui->m_propertyTree->expandAll();
105 void CLodGeneratorOptionsPanel::ParameterChanged(SLodParameter* parameter)
107 ELodParamType eLodParamType = parameter->GetTODParamType();
108 switch (eLodParamType)
110 case eFloatType:
112 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter->GetName().c_str()),parameter->GetParamFloat());
113 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter->GetName().c_str()),parameter->GetParamFloat());
114 break;
116 case eIntType:
118 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter->GetName().c_str()),parameter->GetParamInt());
119 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter->GetName().c_str()),parameter->GetParamInt());
120 break;
122 case eColorType:
124 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter->GetName().c_str()),parameter->GetParamColor());
125 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter->GetName().c_str()),parameter->GetParamColor());
126 break;
128 case eStringType:
130 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter->GetName().c_str()),parameter->GetParamString());
131 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter->GetName().c_str()),parameter->GetParamString());
132 break;
134 case eBoolType:
136 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter->GetName().c_str()),parameter->GetParamBool());
137 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter->GetName().c_str()),parameter->GetParamBool());
138 break;
140 default:
141 break;
145 void CLodGeneratorOptionsPanel::Reset()