1 /*************************************************************************
3 Copyright (C), Crytek Studios, 2013.
4 *************************************************************************/
9 class CCMeshBakerPopupPreview
;
12 #include "Util/LODGeneratorLib.h"
14 namespace LODGenerator
16 class CLodGeneratorInteractionManager
21 eTextureType_Diffuse
= 0,
22 eTextureType_Normal
= 1,
23 eTextureType_Spec
= 2,
28 CLodGeneratorInteractionManager();
29 virtual ~CLodGeneratorInteractionManager();
31 static CLodGeneratorInteractionManager
* m_pInstance
;
34 static CLodGeneratorInteractionManager
* Instance();
35 static void DestroyInstance();
37 const string
GetSelectedBrushFilepath();
38 const string
GetSelectedBrushMaterial();
39 const string
GetDefaultBrushMaterial(const string
& filepath
);
41 const string
GetParameterFilePath() { return m_parameterFilePath
; };
42 void SetParameterFilePath(const string
& filePath
) { m_parameterFilePath
= filePath
; };
44 void OpenMaterialEditor();
46 bool LoadStatObj(const string
& filepath
);
47 bool LoadMaterial(string strMaterial
);
48 CMaterial
* LoadSpecificMaterial(string strMaterial
);
50 IStatObj
* GetLoadedModel(int nLod
= 0);
51 CMaterial
* GetLoadedMaterial();
52 CMaterial
* GetLODMaterial();
53 void SetLODMaterial(CMaterial
*pMat
);
54 const string
GetLoadedFilename();
55 const string
GetLoadedMaterialFilename();
57 void ReloadMaterial();
59 const IStatObj::SStatistics
GetLoadedStatistics();
60 float GetRadius(const int nSourceLod
);
62 int GetSubMatId(const int nLodId
);
63 int GetSubMatCount(const int nLodId
);
66 float GetLodsPercentage(const int nLodIdx
);
68 float GetErrorAtMove(const int nIndex
);
70 bool LodGenGenerate();
71 bool LodGenGenerateTick(float* fProgress
);
74 IStatObj
* TryLoadCageObject(const int nLodId
);
75 bool UsingLodCage(const int nLodId
);
76 IStatObj
* CreateLODStatObj(const int nLodId
,const float fPercentage
);
78 bool GenerateTemporaryLod(const float fPercentage
, CCMeshBakerPopupPreview
* ctrl
, CCRampControl
* ramp
);
79 void GenerateLod(const int nLodId
, const float fPercentage
);
80 void ClearUnusedLods(const int nNewLods
);
81 bool GenerateLodFromCageMesh(IStatObj
**pLodStatObj
);
83 bool RunProcess(const int nLod
, int nWidth
, const int nHeight
);
84 void SaveTextures(const int nLod
);
85 string
GetPreset(const int texturetype
);
86 const SMeshBakingOutput
* GetResults(const int nLod
);
91 XmlNodeRef
GetSettings(const string
& settings
);
95 T
GetGeometryOption(string paramName
)
98 if (IVariable
* pVar
= m_pGeometryVarBlock
->FindVariable(paramName
))
104 void SetGeometryOption(string paramName
, T paramValue
)
106 if (IVariable
* pVar
= m_pGeometryVarBlock
->FindVariable(paramName
))
107 pVar
->Set(paramValue
);
111 T
GetMaterialOption(string paramName
)
114 if (IVariable
* pVar
= m_pMaterialVarBlock
->FindVariable(paramName
))
120 void SetMaterialOption(string paramName
, T paramValue
)
122 if (IVariable
* pVar
= m_pMaterialVarBlock
->FindVariable(paramName
))
123 pVar
->Set(paramValue
);
127 void OpenExportPath();
128 void ShowLodInExplorer(const int nLodId
);
129 void UpdateFilename(string filename
);
131 bool CreateChangelist();
132 bool CheckoutInSourceControl(const string
& filename
);
133 bool CheckoutOrExtract(const char * filename
);
135 CVarBlock
* GetGeometryVarBlock() { return m_pGeometryVarBlock
; }
136 CVarBlock
* GetMaterialVarBlock() { return m_pMaterialVarBlock
; }
140 bool PrepareMaterial(const string
& materialName
, bool bAddToMultiMaterial
);
141 int FindExistingLODMaterial(const string
& matName
);
142 CMaterial
* CreateMaterialFromTemplate(const string
& matName
);
143 int CreateLODMaterial(const string
& submatName
);
144 void SetLODMaterialId(IStatObj
* pStatObj
, const int matId
);
146 string
GetDefaultTextureName(const int i
, const int nLod
, const bool bAlpha
, const string
& exportPath
, const string
& fileNameTemplate
);
147 bool SaveTexture(ITexture
* pTex
, const bool bAlpha
, const string
& fileName
, const string
& texturePreset
);
148 void AssignToMaterial(const int nLod
, const bool bAlpha
, const bool bSaveSpec
, const string
& exportPath
, const string
& fileNameTemplate
);
149 bool VerifyNoOverlap(const int nSubMatIdx
);
150 bool RasteriseTriangle(Vec2
*tri
, byte
*buffer
, const int width
, const int height
);
152 void CreateSettings();
156 _smart_ptr
<IStatObj
> m_pLoadedStatObj
;
157 _smart_ptr
<CMaterial
> m_pLoadedMaterial
;
158 _smart_ptr
<CMaterial
> m_pLODMaterial
;
160 std::map
<int,SMeshBakingOutput
> m_resultsMap
;
161 CLODGeneratorLib::SLODSequenceGenerationOutput m_results
;
162 string m_parameterFilePath
;
163 bool m_bAwaitingResults
;
165 XmlNodeRef m_xmlSettings
;
167 _smart_ptr
<CVarBlock
> m_pGeometryVarBlock
;
168 CSmartVariable
<int> m_nSourceLod
;
169 CSmartVariable
<bool> m_bObjectHasBase
;
170 CSmartVariable
<int> m_nViewsAround
;
171 CSmartVariable
<int> m_nViewElevations
;
172 CSmartVariable
<float> m_fSilhouetteWeight
;
173 CSmartVariable
<float> m_fViewResolution
;
174 CSmartVariable
<float> m_fVertexWelding
;
175 CSmartVariable
<bool> m_bCheckTopology
;
176 CSmartVariable
<bool> m_bWireframe
;
177 CSmartVariable
<bool> m_bExportObj
;
178 CSmartVariable
<bool> m_bAddToParentMaterial
;
179 CSmartVariable
<bool> m_bUseCageMesh
;
180 CSmartVariable
<bool> m_bPreviewSourceLod
;
182 _smart_ptr
<CVarBlock
> m_pMaterialVarBlock
;
183 CSmartVariable
<float> m_fRayLength
;
184 CSmartVariable
<float> m_fRayStartDist
;
185 CSmartVariable
<bool> m_bBakeAlpha
;
186 CSmartVariable
<bool> m_bBakeSpec
;
187 CSmartVariable
<bool> m_bSmoothCage
;
188 CSmartVariable
<bool> m_bDilationPass
;
189 CSmartVariable
<Vec3
> m_cBackgroundColour
;
190 CSmartVariable
<string
> m_strExportPath
;
191 CSmartVariable
<string
> m_strFilename
;
192 CSmartVariable
<string
> m_strPresetDiffuse
;
193 CSmartVariable
<string
> m_strPresetNormal
;
194 CSmartVariable
<string
> m_strPresetSpecular
;
195 CSmartVariable
<bool> m_useAutoTextureSize
;
196 CSmartVariable
<float> m_autoTextureRadius1
;
197 CSmartVariable
<int> m_autoTextureSize1
;
198 CSmartVariable
<float> m_autoTextureRadius2
;
199 CSmartVariable
<int> m_autoTextureSize2
;
200 CSmartVariable
<float> m_autoTextureRadius3
;
201 CSmartVariable
<int> m_autoTextureSize3
;