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
)
19 CLodGeneratorOptionsPanel::~CLodGeneratorOptionsPanel()
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
:
45 pCurVariable
->Get(value
);
46 sLodParameter
.SetParamFloat(value
);
49 case ELodParamType::eBoolType
:
52 pCurVariable
->Get(value
);
53 sLodParameter
.SetParamBool(value
);
56 case ELodParamType::eColorType
:
59 pCurVariable
->Get(value
);
60 sLodParameter
.SetParamFloat3(Vec3(value
.x
,value
.y
,value
.z
));
63 case ELodParamType::eStringType
:
66 pCurVariable
->Get(value
);
67 sLodParameter
.SetParamString(CStringTool::CStringToQString(value
).toStdString().c_str());
70 case ELodParamType::eIntType
:
73 pCurVariable
->Get(value
);
74 sLodParameter
.SetParamInt(value
);
79 CryLog("Unknow Type");
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
)
112 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter
->GetName().c_str()),parameter
->GetParamFloat());
113 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter
->GetName().c_str()),parameter
->GetParamFloat());
118 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter
->GetName().c_str()),parameter
->GetParamInt());
119 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter
->GetName().c_str()),parameter
->GetParamInt());
124 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter
->GetName().c_str()),parameter
->GetParamColor());
125 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter
->GetName().c_str()),parameter
->GetParamColor());
130 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter
->GetName().c_str()),parameter
->GetParamString());
131 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter
->GetName().c_str()),parameter
->GetParamString());
136 CLodGeneratorInteractionManager::Instance()->SetGeometryOption(string(parameter
->GetName().c_str()),parameter
->GetParamBool());
137 CLodGeneratorInteractionManager::Instance()->SetMaterialOption(string(parameter
->GetName().c_str()),parameter
->GetParamBool());
145 void CLodGeneratorOptionsPanel::Reset()