Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
PolygonCruncherInterface.h
Go to the documentation of this file.
1//! @file PolygonCruncherInterface.h
2//! @brief Defines some class for batch optimization and scene conversion for CSceneOptimizer
3#ifndef POLYGONCRUNCHER_INTERFACE_H
4#define POLYGONCRUNCHER_INTERFACE_H
5
6#include "common_cpp_type.h"
7#include "3DType.h"
10#include "3DScene.h"
11#include "BatchTools.h"
12
13#if defined(MOOTOOLS_PRODUCT_BUILD)
14#include "PolygonCruncherPrivate.h"
15#ifdef MOOTOOLS_MFC_PRODUCT_BUILD
16#include "DeiCommand.h"
17#include "CruncherCommands.h"
18
19class COptimizerWnd;
20class CCruncherSheet;
21#endif
22#endif
23
24BEGIN_MOOTOOLS_NAMESPACE
25
26class C3DScene;
27class C3DFaceList;
28class C3DPointList;
29class C3DObject;
30class C3DPatch;
31class C3DSceneNode;
32class CSceneOptimizer;
34class C3DExtObject;
36
37//! @class CruncherProgressInfo
38//! @brief This class provides information about computation progress to the different progress callback.
39//! @details It is called during the different optimization steps giving a chance to provide some feedback to the user or to cancel the operation.
40class DLLFUNCTION CruncherProgressInfo
41{
42 friend CSceneOptimizer;
43
44protected:
45 void Init();
46
47public:
48 //! @enum ProgressState
49 //! CruncherProgressInfo::GetState returns optimization operation currently in progress;\n
50 //! This gives information about what the optimizer is doing.\n
51 //! You can set userCancel to true to stop the operation.
52 typedef enum ProgressState
53 {
54 STATE_UNDEFINED = 0,
55 INIT_OPTIMIZATION = 1,
56 OPTIMIZE_NODE,
57 INIT_MULTIRES_NODE,
58 MATERIAL_CHANGES,
59 CREATEMR,
60 MAGICCRUNCHER,
61 BATCH_INFO,
62 BATCH_INFO_LOG_FAILS,
63 } ProgressState;
64
65 typedef enum LogLevel
66 {
67 MACRO_RESULT_UNDEFINED = 0,
68 MACRO_RESULT_OK = 1,
69 MACRO_RESULT_WARNING = 2,
70 MACRO_RESULT_ERROR = 3,
71 } LogLevel;
72
74 CruncherProgressInfo(const CXString& txt, LogLevel logLevel, bool replaceLine, ProgressState state = BATCH_INFO);
75
76 int GetPos() const { return pos; }
77 int GetMin() const { return min; }
78 int GetMax() const { return max; }
79 const CXString& GetText() const { return txt; }
80 ProgressState GetState() const { return progressState; }
81 LogLevel GetLogLevel() const { return logLevel; }
82 bool ReplaceLastLogLine() const { return replaceLastLogLine; }
83 bool GetCancelState() const { return userCancel; }
84 xThreadID GetMainOptimizerThreadID() const { return mainThreadID; }
85
86public:
87 mutable bool userCancel;
88 bool doubleBarMode;
89 xThreadID mainThreadID;
90 CXString txt;
91 int curmesh, meshnbr;
92 int min, max;
93 int pos;
94 ProgressState progressState;
95 LogLevel logLevel;
96
97 // Log info (when CruncherProgress = CRUNCHER_PROGRESS_BATCH_INFO)
98 bool replaceLastLogLine;
99};
100
101//! @enum PolygonCruncherObjectCreatorFlags
102//! Defines the conversion mode to prepare the scene for the CSceneOptimizer. The mode depends on the usage of the optimizer:
103//! * DEFAULT_OPTIMIZATION means that an object is created and optimize once for all with given optimization flags.\n
104//! This flag matches for static and dynamic optimization. cf. #OPTIMIZATION and #OPTIMIZATION_DYNAMIC
105//! * INTERACTIVE_OPTIMIZATION means that the object might be optimized several time with several optimization flags
106//! This flag matches for interactive optimization. cf. #OPTIMIZATION_INTERACTIVE
107//! * MULTIRESOLUTION_DATA means that we create a CMultiresolutionObject from a saved multiresolution data (C3DExtObject::SetMultiresolutionData)
109{
110 DEFAULT_OPTIMIZATION_OBJECT = 1,
111 INTERACTIVE_OPTIMIZATION_OBJECT,
112 MULTIRESOLUTION_DATA_OBJECT,
114
115// DLL delay loading required constructor and destructor to be defined.
116// Otherwise it can't link for a unexplained reason.
117
118//! @class C3DPolygonCruncherObjectCreator
119//! @brief This class converts an usual C3DScene to a C3DScene containing object that can be used by CSceneOptimizer.
120//! @details The class is provided to C3DScene::Copy.
121//! Use the PolygonCruncherObjectCreatorFlags accordingly to the type of optimization you want to perform.
123{
124public:
127
128 C3DObject* GetNewPolygonalObject(); //!< Creates a C3DObject with the appropriate required face list and point list classes.
129
130protected:
132
133 C3DBaseObject* ConvertToType(const C3DSceneNode* refnode, const C3DBaseObject* refobject);
134 C3DBaseObject* GetNewObjectFrom(const C3DBaseObject* object, bool& emptyCopy);
135
136 C3DFaceList* GetNewFaceList();
137 C3DPointList* GetNewPointList();
138 C3DPatch* GetNewPatchObject();
139};
140
141class CStdioFileEx;
142class CBatchOptimizer;
143
144//! @class BatchCruncherOptions
145//! @brief This class allows to perform batch optimization, which means process a set of files.
146//! @details BatchCruncherOptions is construct using a CCustomData filled with the BatchCruncherOptions::Parameters properly initialized.
147//! Some methods allows to define the batch folder or the file to be process during optimization.\n
148//!
149//! The options are then provided to CBatchOptimizer object and a call to CBatchOptimizer::Batch starts the batch.
150class DLLFUNCTION BatchCruncherOptions
151{
152 friend CBatchOptimizer;
153public:
154 //! @enum Parameters
155 //! The following information fill a CCustomData in order to call the batch module remotely.
156 //! The CCustomData is provided through BatchCruncherOptions::data and provided through DoBatchOptimization
157 typedef enum Parameters
158 {
159 CRUNCHER_SRCMODE_PARAM = MAKE_CUSTOM_ID('S', 'R', 'M', 'D'), //!< UInt, 0: a set of files, 1: the current directory, 2: a selected dir, default: 1. Cf. BatchSrcMode
160 CRUNCHER_SRCFILES_PARAM = MAKE_CUSTOM_ID('S', 'R', 'F', 'I'), //!< String Array, define the set of file to optimize
161 CRUNCHER_SRCDIR_PARAM = MAKE_CUSTOM_ID('S', 'R', 'D', 'I'), //!< String, a full path to the current directory (CRUNCHER_SRCMODE_PARAM=1)
162 CRUNCHER_SRCSUBDIR_PARAM = MAKE_CUSTOM_ID('S', 'R', 'S', 'D'), //!< Bool, used if CRUNCHER_SRCMODE_PARAM != 0, false: the files contained in CRUNCHER_SRCDIR_PARAM are optimized, true: the files contained in CRUNCHER_SRCDIR_PARAM and subfolders are optimized, default: true
163 CRUNCHER_SRCKINDOF_PARAM = MAKE_CUSTOM_ID('K', 'I', 'N', 'D'), //!< UInt, 0: All 3d files are optimized, 1: only provided extensions are optimized, 2: only not provided extensions are optimized, default: 0
164 CRUNCHER_SRCEXT_PARAM = MAKE_CUSTOM_ID('E', 'X', 'T', 'E'), //!< String, only if CRUNCHER_SRCKINDOF_PARAM != 0, a set of extension separated by ; (ie: .3ds; .dxf)
165 CRUNCHER_OPTIMIZE_PREDEFINED_LEVEL_NBR = 5, //!< The number of predefined level
166 CRUNCHER_OPTIMIZE_LEVEL1 = MAKE_CUSTOM_ID('L', 'E', 'V', '1'), //!< UInt, only if CRUNCHER_OPTIMIZE_LEVEL_MODE=0, value from 0 to 100, default: 25 (remove 25% of the vertices)
167 CRUNCHER_OPTIMIZE_LEVEL2 = MAKE_CUSTOM_ID('L', 'E', 'V', '2'), //!< UInt, only if CRUNCHER_OPTIMIZE_LEVEL_MODE=0, value from 0 to 100, default: 50
168 CRUNCHER_OPTIMIZE_LEVEL3 = MAKE_CUSTOM_ID('L', 'E', 'V', '3'), //!< UInt, only if CRUNCHER_OPTIMIZE_LEVEL_MODE=0, value from 0 to 100, default: 65
169 CRUNCHER_OPTIMIZE_LEVEL4 = MAKE_CUSTOM_ID('L', 'E', 'V', '4'), //!< UInt, only if CRUNCHER_OPTIMIZE_LEVEL_MODE=0, value from 0 to 100, default: 75
170 CRUNCHER_OPTIMIZE_LEVEL5 = MAKE_CUSTOM_ID('L', 'E', 'V', '5'), //!< UInt, only if CRUNCHER_OPTIMIZE_LEVEL_MODE=0, value from 0 to 100, default: 90
171 CRUNCHER_OPTIMIZE_LEVEL_NBR = MAKE_CUSTOM_ID('L', 'E', 'V', 'N'), //!< UInt, only if CRUNCHER_OPTIMIZE_LEVEL_MODE=1, the number of LOD to generate
172 CRUNCHER_OPTIMIZE_START_LEVEL = MAKE_CUSTOM_ID('L', 'E', 'V', 'S'), //!< UInt, only if CRUNCHER_OPTIMIZE_LEVEL_MODE=1, the ratio of the first LOD to generate, default: 50
173 CRUNCHER_OPTIMIZE_LEVEL_MODE = MAKE_CUSTOM_ID('L', 'E', 'V', 'M'), //!< UInt, 0: predefined ratio (CRUNCHER_OPTIMIZE_LEVEL1 to CRUNCHER_OPTIMIZE_LEVEL5) 1: Automatic % (starting at CRUNCHER_OPTIMIZE_START_LEVEL) 2:MagicCruncher (combined with CRUNCHER_OPTIMIZE_MAGICCRUNCHER_SIMILARITY and CRUNCHER_OPTIMIZE_MAGICCRUNCHER_FAST), default: 1
174 CRUNCHER_OPTIMIZE_MAGICCRUNCHER_SIMILARITY = MAKE_CUSTOM_ID('M', 'C', 'S', 'M'), //!< UInt: value from 0 to 2, 0: roughly similar, 1: similar, 2: very similar
175 CRUNCHER_OPTIMIZE_MAGICCRUNCHER_FAST = MAKE_CUSTOM_ID('M', 'C', 'F', 'S'), //!< UInt, 0: faster magicCruncher, 1: normal (default) process, 1 : accurate process that try to reach the number of points closer to the similarity threshold condition
176 CRUNCHER_OPTIMIZE_MODE = MAKE_CUSTOM_ID('M', 'O', 'D', 'E'), //!< UInt, 0: Crunch borders, 1: Protect borders, 2: Exclude Borders, Default: 1
177 CRUNCHER_OPTIMIZE_PROGRESSIVE_RATIO = MAKE_CUSTOM_ID('P', 'G', 'R', 'T'), //!< Bool, use progressive ratio when the scene has several objects, default: true
178 CRUNCHER_OPTIMIZE_CORNER_MODE = MAKE_CUSTOM_ID('C', 'R', 'M', 'D'), //!< UInt, 0: Don't care corners, 1: preserve corners, 2: protect corners, 3: exclude corners, default: 0
179 CRUNCHER_OPTIMIZE_HIDDEN_NODE = MAKE_CUSTOM_ID('H', 'D', 'N', 'D'), //!< Bool, import and optimize hidden node, default: true
180 CRUNCHER_OPTIMIZE_MERGE_POINTS = MAKE_CUSTOM_ID('M', 'R', 'G', 'P'), //!< Bool, enable merge of confused points, default: false
181 CRUNCHER_OPTIMIZE_MERGE_POINTS_THRESHOLD = MAKE_CUSTOM_ID('M', 'R', 'P', 'T'), //!< Float, confused points distance threshold, default: 0.0f
182 CRUNCHER_OPTIMIZE_MERGE_FACES = MAKE_CUSTOM_ID('M', 'R', 'G', 'F'), //!< Bool, merge coplanar faces, default: false
183 CRUNCHER_OPTIMIZE_MERGE_FACES_THRESHOLD = MAKE_CUSTOM_ID('M', 'R', 'F', 'T'), //!< Float, coplanar faces threshold angle, default: 0.0f
184 CRUNCHER_OPTIMIZE_MATERIAL_FRONTIER = MAKE_CUSTOM_ID('K', 'P', 'M', 'A'), //!< Bool, protect material boundaries if any, default: true
185 CRUNCHER_OPTIMIZE_MATERIAL_FRONTIER_MODE = MAKE_CUSTOM_ID('M', 'A', 'M', 'D'), //!< UInt, only if CRUNCHER_OPTIMIZE_MATERIAL_FRONTIER=true, otherwise 0: preserve frontier boundaries, 1: protect frontier boundaries, 2: exclude frontier boundaries
186 CRUNCHER_OPTIMIZE_FAVORITE_COMPACITY = MAKE_CUSTOM_ID('C', 'O', 'M', 'P'), //!< Bool, preserve face compacity, default: true
187 CRUNCHER_OPTIMIZE_LIMIT_RATIO = MAKE_CUSTOM_ID('L', 'M', 'R', 'T'), //!< Bool, limit ratio and avoid to generate an invalid mesh, default: true
188 CRUNCHER_OPTIMIZE_LOCK_POINT = MAKE_CUSTOM_ID('L', 'K', 'P', 'T'), //!< Bool, lock point position, default: false
189 CRUNCHER_OPTIMIZE_PREVENT_FLIP = MAKE_CUSTOM_ID('F', 'L', 'I', 'P'), //!< Bool, prevent face flipping, default: true
190 CRUNCHER_OPTIMIZE_KEEP_VC = MAKE_CUSTOM_ID('K', 'P', 'V', 'C'), //!< Bool, keep vertex colors if any, default: false
191 CRUNCHER_OPTIMIZE_VC_MODE = MAKE_CUSTOM_ID('V', 'C', 'M', 'D'), //!< UInt, only if CRUNCHER_OPTIMIZE_KEEP_VC=true, otherwise 0: preserve VC boundaries, 1: protect VC boundaries, 2: exclude VC boundaries
192 CRUNCHER_OPTIMIZE_TOLERANCE_VC = MAKE_CUSTOM_ID('T', 'L', 'V', 'C'), //!< UInt, a threshold value from 0 to 255 corresponding to the difference allowed for RGB values on an edge, default: 128
193 CRUNCHER_OPTIMIZE_KEEP_UV = MAKE_CUSTOM_ID('K', 'P', 'U', 'V'), //!< Bool, keep UVs if any, default: true
194 CRUNCHER_OPTIMIZE_UV_MODE = MAKE_CUSTOM_ID('U', 'V', 'M', 'D'), //!< UInt, only if CRUNCHER_OPTIMIZE_KEEP_UV=true, otherwise 0: preserve UV boundaries, 1: protect UV boundaries, 2: exclude UV boundaries
195 CRUNCHER_OPTIMIZE_TOLERANCE_UV = MAKE_CUSTOM_ID('T', 'L', 'U', 'V'), //!< Float, a threshold value from 0 to 1.0 corresponding to the difference allowed for UVs values on an edge, default: 128
196 CRUNCHER_OPTIMIZE_KEEP_NORMALS = MAKE_CUSTOM_ID('K', 'P', 'N', 'R'), //!< Bool, keep normals if any, default: false
197 CRUNCHER_OPTIMIZE_NORMAL_MODE = MAKE_CUSTOM_ID('N', 'R', 'M', 'D'), //!< UInt, only if CRUNCHER_OPTIMIZE_NORMAL_MODE=true, otherwise 0: preserve normal breaks, 1: protect normal breaks, 2: exclude normal breaks
198 CRUNCHER_OPTIMIZE_NORMAL_THRESHOLD = MAKE_CUSTOM_ID('N', 'R', 'T', 'H'), //!< Float, a threshold value from 0 to 90.0 corresponding to the normal angle in degree for normals values between faces under which no break is detected, default: 10.0f
199 CRUNCHER_OPTIMIZE_SYMETRY_MODE = MAKE_CUSTOM_ID('S', 'Y', 'M', 'E'), //!< UInt, 0: no symmetry taken into account, 1: XY symmetry mode, 2: YZ symmetry mode, 3: XZ symmetry mode
200 CRUNCHER_OPTIMIZE_SYMETRY_TOLERANCE = MAKE_CUSTOM_ID('S', 'Y', 'T', 'L'), //!< UInt, a tolerance value from 0 to 100 related to point position for considering that two points are symmetric
201 CRUNCHER_OPTIMIZE_CONVERT_ONLY = MAKE_CUSTOM_ID('C', 'V', 'O', 'L'), //!< Bool, if true no optimization if performed. The file is read and simply converted without any processing. default: false
202 CRUNCHER_DSTNAME_MODE = MAKE_CUSTOM_ID('N', 'A', 'M', 'E'), //!< UInt, 0: ouput files are numbered from 1, 1: output files are numbered using the % ratio value, default: 0
203 CRUNCHER_DSTPREFIX_PARAM = MAKE_CUSTOM_ID('D', 'S', 'P', 'X'), //!< String: a prefix to add to the source filename (ie.: optimized_)
204 CRUNCHER_DSTSUFFIX_PARAM = MAKE_CUSTOM_ID('D', 'S', 'S', 'X'), //!< String: a suffix to add to the source filename (ie.: _optimized)
205 CRUNCHER_DSTMODE_PARAM = MAKE_CUSTOM_ID('D', 'S', 'M', 'D'), //!< UInt: 0: output file are created in the same folder than the source, 1: output files are created in a sub folder of the source file folder, 2: output files are created in a selected directory. Cf. BatchDstMode
206 CRUNCHER_DSTSUBDIR_PARAM = MAKE_CUSTOM_ID('D', 'S', 'S', 'D'), //!< String, used internally when CRUNCHER_DSTMODE_PARAM = 1, contains a subdir folder name in a relative form (ie: .\result)
207 CRUNCHER_DSTNEWDIR_PARAM = MAKE_CUSTOM_ID('D', 'S', 'N', 'D'), //!< String, contains the sub folder name when CRUNCHER_DSTMODE_PARAM = 1 in a relative form, or contains the destination folder name when CRUNCHER_DSTMODE_PARAM = 2 in a relative form (relative to source folder) or in an absolute form
208 CRUNCHER_DSTRECREATEDIR_PARAM = MAKE_CUSTOM_ID('D', 'S', 'R', 'D'), //!< Bool, used when CRUNCHER_DSTMODE_PARAM = 2 and if CRUNCHER_SRCSUBDIR_PARAM=true, recreates the source folders tree in the destination folder
209 CRUNCHER_DSTRENAME_PARAM = MAKE_CUSTOM_ID('D', 'S', 'R', 'E'), //!< Bool, rename the destination file in order to newer overwrite a file, default = true
210 CRUNCHER_DSTUPDATE_MODE = MAKE_CUSTOM_ID('U', 'P', 'D', 'M'), //!< Bool, the output file use update mode, which try to kept a maximum information, default = false
211 CRUNCHER_DSTLOG_NAME = MAKE_CUSTOM_ID('D', 'S', 'L', 'G'), //!< String, log file name path in a relative form (dependent of the destination folder), or in an absolute short, default: empty, meaning no log file is generated
212 CRUNCHER_DSTLOG_AUTORENAME = MAKE_CUSTOM_ID('L', 'G', 'R', 'N'), //!< Bool, auto rename the log file name, default: false
213 // CRUNCHER_NOUI = MAKE_CUSTOM_ID('N', 'O', 'U', 'I'), //!< Bool, if set to true it prevents to display any kind of dialog and it guaranties that no user interaction is required during the process
214 // CRUNCHER_AUTOCLOSE = MAKE_CUSTOM_ID('A', 'T', 'C', 'L'), //!< Bool, if set the optimization process automatically close at exit
215
216 //
217 // The output format is defined by additional parameters which are described in FormatSelectionParameters (DlgFormatSelection.h)
218 // If nothing specified, the optimized file is output using the input format or wavefront format if input format cannot be generated
219 //
220 // These one are privates tag, use for specific purposes
221 CRUNCHER_ALBUMFILES_PARAM = MAKE_CUSTOM_ID('A', 'L', 'F', 'I'), //!< String Array, private, define a second set of files used when album mode is defined.
222 CRUNCHER_SELDIR_PARAM = MAKE_CUSTOM_ID('S', 'E', 'D', 'I'), //!< String, a full path to a selected directory (CRUNCHER_SRCMODE_PARAM=2), mainly use in an interactive context to store two different paths (one dependent of the application path, the other dependent of a user defined path)
223
224#ifdef PLY_ALPHA_FEATURE
225 CRUNCHER_OPTIMIZE_STRENGTH = MAKE_CUSTOM_ID('M', 'O', 'S', 'G'),
226 CRUNCHER_CORNER_STRENGTH = MAKE_CUSTOM_ID('C', 'R', 'S', 'G'),
227 CRUNCHER_OPTIMIZE_MATERIAL_FRONTIER_STRENGTH = MAKE_CUSTOM_ID('M', 'A', 'S', 'G'),
228 CRUNCHER_OPTIMIZE_SMALL_FACE_FIRST = MAKE_CUSTOM_ID('S', 'L', 'F', 'T'),
229 CRUNCHER_OPTIMIZE_WEIGHT_MAP = MAKE_CUSTOM_ID('W', 'G', 'M', 'P'),
230#endif
231 } Parameters;
232
233
234 //! @enum DefaultValues
235 //! A set of default values for some parameters of the optimization
236 typedef enum DefaultValues
237 {
238 DEFAULT_NORMAL_ANGLE = 10, //!< 10 degree
239 DEFAULT_VC_TOLERANCE = 128, //!< 128 (intermediate between 0..255)
240 DEFAULT_UV_TOLERANCE = 0, //!< no tolerance
241 DEFAULT_SYMETRY_TOLERANCE = 1, //!< nearly exact symetry
242 DEFAULT_MERGEPOINTS_TOLERANCE = 0, //!< Points should be confused
243 DEFAULT_MERGEFACES_TOLERANCE = 0, //!< faces must be coplanar
244 } DefaultValues;
245
246 //! @enum BatchCruncherOptionsFlags
247 //! Specific options for the batch optimization
249 {
250 BATCH_CRUNCHER_DEFAULT = 0x00,
251
252 //! @name These options give control on the way the batch module is used
253 //! @{
254 BATCH_HANDLE_SCENE_DELETION = 0x01, //!< The batch handles the scene deletion internally
255 BATCH_NO_SPLASH = 0x02, //!< No splash screen is displayed when opening the batch module
256 BATCH_NO_LOGWINDOW = 0x04, //!< No log window
257 BATCH_NO_DIALOG = 0x08, //!< No dialog, predefined settings must be provided in data field
258 BATCH_LOG_AUTOCLOSE = 0x10, //!< The log window closes itself at the end of the process...
259 BATCH_NO_CANCEL_BY_ESCAPTE = 0x100, //!< By default the base class cancel the batch by pressing escape
260
261 //! @}
262
263 //! @name These options give control on the Polygon Cruncher batch dialog
264 //! @{
265 BATCH_NO_MODE_CHOICE = 0x100, //!< Don't show any mode choice
266 BATCH_NO_CURRENT_DIRECTORY_CHOICE = 0x200, //!< Don't show current directory mode
267 BATCH_ENABLE_FILE_SELECTION = 0x400, //!< Allow to select files
268 BATCH_ALBUM_MODE = 0x800, //!< Replace current directory by current album
269
270 //! @}
271 } BatchCruncherOptionsFlags;
272
273 typedef enum
274 {
275 CRUNCHER_BATCH_PREFS1 = MAKE_CUSTOM_ID('C', 'R', 'N', 'C'),
276 CRUNCHER_BATCH_PREFS2 = MAKE_CUSTOM_ID('B', 'A', 'T', 'C'),
277 } BatchEnum;
278
279 BatchCruncherOptions(CCustomData& batchSettingsData, unsigned int flags = BATCH_CRUNCHER_DEFAULT);
280
281#ifdef __WINDOWS__
282 bool InitFromCommandLine(int argc, wchar_t* argv[]);
283#else
284 bool InitFromCommandLine(int argc, char* argv[]);
285#endif
286
287 // Can be used to define the initial folder, file or files to optimize
288 void SetCurrentFolder(const CXString& folder);
289 CXString GetCurrentFolder() const;
290 void SetFileToOptimize(const CXString& file);
291 void SetFilesToOptimize(const CXStringArray& files, bool albumSet = false);
292
293 // Load and save previous preferences
294 void SetPreferencesFilePath(const CXString& preffile);
295 CXString GetPreferencesFilePath() const;
296 void PrefsLoadBatchOptions();
297 void PrefsSaveBatchOptions() const;
298
299 const CCustomData& GetSettingsData() const { return *(cmddata); }
300 unsigned int GetFlags() { return flags; }
301
302protected:
303 unsigned int flags; // Options flags (BatchCruncherOptionsFlags)
304 CXString preferencePath;
305 CCustomData* cmddata; // Data provided to call the batch module remotely
306};
307
308typedef C3DScene* (*LoadCruncherBatchCallback)(const CXString& filename, CSceneImportOptions& options, CXString& resultTxt, void* data); //!< A callback for loading a 3D file specified by its filename and giving some options. It returns the loaded scene. resultTxt can returns some textual information about the load operation.
309typedef bool (*SaveCruncherBatchCallback)(bool freeSceneOnly, const CFileNameSpec& filename, CSceneExportOptions& options, C3DScene* optimizedResult, CXString& resultTxt, void* data); //!< A callback for saving a to file using some options and the provided scene. If freeSceneOnly, then the scene must be released using C3DScene::Delete(). resultTxt can returns some textual information about the load operation.
310typedef bool (*CruncherProgressCallback)(unsigned int cruncherProgressFlags, const CruncherProgressInfo& info, void* data); //!< Progress callback. cruncherProgressFlags is a combination of CruncherProgress flags which inform about the useful data to retrieve in CruncherProgressInfo.
311
312//! @class CBatchOptimizer
313//! @brief CBatchOptimizer allows to perform batch optimization providing BatchCruncherOptions settings and calling CBatchOptimizer::Batch.
314//! @details It is possible to provide different kind of callback for handling an user progress bar or provide a customized load / save 3d file mechanism.
315class DLLFUNCTION CBatchOptimizer
316{
317public:
318 //! @enum BatchState
319 //! The batch running state which is provided to CBatchOptimizer::OnBatchStateChanged
320 typedef enum BatchState XEnumType(unsigned int)
321 {
322 BATCH_INACTIVE = 0,
323 BATCH_INIT_BEFORE_BATCH, //!< A place to set a first initialization. info is a bool set to true by default. If set to false GetBatchInfoHelper is not initialized with the providing settings (useful for specific purpose if overidding settings by dialog user choices for example)
324 BATCH_BEFORE_OPEN_LOG_FILE, //!< info is a const pointer to the log filename
325 BATCH_AFTER_OPEN_LOG_FILE,
326 BATCH_START_BATCH, //!< The batch will start to load file and process them. The following event sequence will occurs each time a file is processed.
327 BATCH_PRELOAD_FILE,
328 BATCH_POSTLOAD_FILE, //!< info is a bool that allow to know if load succeed or fails
329 BATCH_PREPROCESS,
330 BATCH_POSTPROCESS,
331 BATCH_PREOPTIMIZE,
332 BATCH_POSTOPTIMIZE,
333 BATCH_PREMAGICCRUNCHER,
334 BATCH_POSTMAGICCRUNCHER,
335 BATCH_PRESAVE_SCENE,
336 BATCH_POSTSAVE_SCENE, // info is a bool that allow to know if save succeed or fails
337 BATCH_FREE_SCENE,
338 BATCH_END_BATCH, //!< The batch is over, all file have been processed
339 } BatchState;
340
341private:
342 const BatchCruncherOptions* settings;
343 BatchState state;
344
345 // Callback for loading and saving file if needed
346 SaveCruncherBatchCallback saveCallback; // Callback for saving scene
347 LoadCruncherBatchCallback loadCallback; // Callback for loading scene
348 CruncherProgressCallback progressCallback;
349 void* callbackData;
350
351 //CXStringArray selfiles;
352 //CXStringArray albumfiles;
353 CXString optimizedFilePath;
354
355 CXString prevLogLine;
356 void* logCallbackData;
357 CStdioFileEx* logFile;
358
359 // These variable are valid during the batch
360 BatchInfo batchInfoHelper; // This is a helper used during the batch process and initialized before the batch process using the provided settings, or dialog user settings
361 unsigned int outputFormatMode, outputFormat, inputFormat;
362 CHashTable<CXString> hashExt;
363 CHashTable<CXString> fileWritten;
364
365 xWndHandle pParentWindow; // A possible parent window
366
367public:
368 CBatchOptimizer(const BatchCruncherOptions& settings, xWndHandle parentWindow = NULL); //!< Initialize an optimization batch providing specific settings through BatchCruncherOptions
369 virtual ~CBatchOptimizer() {};
370
371 const CCustomData& GetSettingsData() const { return *(settings->cmddata); }
372 void SetSettingsData(const CCustomData& settingsData);
373 unsigned int GetFlags() const { return settings->flags; } //!< Return BatchCruncherOptionsFlags flags
374 xWndHandle GetParentWindow() const { return pParentWindow; } //!< optional parent window for overidden classes
375 CStdioFileEx* GetLogFile() const { return logFile; } //!< return the log file
376
377 BatchInfo& GetBatchInfoHelper(bool initFromSettings = false); //!< Can be used by dialog to get folder from settings. If initFromSettings set, the batchinfo is initialized from BatchCruncherOptions
378
379 //!< @name Batch callbacks
380 void SetCallbackData(void* data); //!< Sets an opaque pointer which is provided in the different callbacks
381 void SetProgressCallback(CruncherProgressCallback callback); //!< Provides a progress callback to provide feedback to user
382 void SetLoadCallback(LoadCruncherBatchCallback callback); //!< Provides a callback for loading files which can be used instead of the default callback.
383 void SetSaveCallback(SaveCruncherBatchCallback callback); //!< Provides a callback for saving files which can be used instead of the default callback. The callback is repeatedly called for the same loaded scene, depending on the requested optimization ratio for the batch operation.
384
385 CXString GetCurrentOptimizedFilePath() const { return optimizedFilePath; } //!< Returns the currently processed file
386 BatchState GetBatchState() const { return state; } //!< Returns the current batch state
387
388 virtual bool CheckCancel(); //!< Override to handle cancel on the process. Returning true will cancel the operation cancel
389 virtual void OnBatchStateChanged(BatchState state, void* info) {}; //!< Override this method to catch some different step in the batch
390
391 virtual void Log(const CXString& loginfo, bool replacePrevLine = false); //!< Override this method to catch different log information
392 virtual bool Batch(); //!< Start the batch using the provided BatchCruncherOptions settings.
393
394protected:
395 virtual bool DoBatch(); // Begin the batch itself
396
397 void SetBatchState(BatchState state, void* info = NULL);
398
399 void InitBeforeBatch(); // Send BATCH_INIT_BEFORE_BATCH
400 void InitOutputFormatParams(const CFileNameSpec& filename);
401 bool FileMatch(const CXString& name);
402
403 bool LoadFiles(const CXString& dir);
404 bool LoadFileToCallback(const CXStringArray& files);
405 bool SaveScene(bool freeScene, const CXString& name, C3DScene* scene, int iscene = 0, double ratio = 0, int scenenbr = 0);
406
407 static C3DScene* DefaultLoadSceneCallback(const CXString& filename, CSceneImportOptions& options, CXString& resultTxt, void* data);
408 static bool DefaultSaveSceneCallback(bool freeSceneOnly, const CFileNameSpec& filename, CSceneExportOptions& options, C3DScene* sceneResult, CXString& resultTxt, void* data);
409 static bool DefaultProgressCallback(unsigned int progresstype, const CruncherProgressInfo& progressInfo, void* data);
410};
411
412#define CRUNCHER_CRASH_FILE_KEY _T("CurrentOptimizedFile")
413
414#ifdef MOOTOOLS_AUTODESK
415// No specifics
417#endif
418
419#if defined(MOOTOOLS_PRODUCT_BUILD)
420#if defined(MOOTOOLS_MFC_PRODUCT_BUILD)
421typedef struct _CruncherInfo
422{
423 COptimizerWnd* pWindow;
426 unsigned int flags;
427
429 {
430 pWindow = NULL;
432 pSheet = NULL;
433 flags = 0;
434 };
436
438DLLFUNCTION CruncherInfo* InitOptimizer(C3DScene*, CFileNameSpec& fileSpec, CWnd* pDisableWindow, unsigned int flags);
439DLLFUNCTION void StartOptimizer(CruncherInfo*, float);
441DLLFUNCTION void StopOptimizer(CruncherInfo*, CWnd* pEnableWindow);
442DLLFUNCTION bool DoBatchOptimization(CBatchOptimizer& options);
443#endif // MOOTOOLS_MFC_PRODUCT_BUILD
444#endif
445
446// Debug
447#ifndef MOOTOOLS_NO_DEBUG_HANDLER
448void SetCurrentOptimizedFile(const CXString& file = CXString());
449DLLFUNCTION void SetupCruncherCrashHandler(bool install);
450#else
451#define SetCurrentOptimizedFile(...) __noop
452#endif
453
454END_MOOTOOLS_NAMESPACE
455
456#endif // POLYGONCRUNCHER_INTERFACE_H
C3DScene class definition.
The file contains enum and type declarations used by the SDK.
bool(* SaveCruncherBatchCallback)(bool freeSceneOnly, const CFileNameSpec &filename, CSceneExportOptions &options, C3DScene *optimizedResult, CXString &resultTxt, void *data)
A callback for saving a to file using some options and the provided scene. If freeSceneOnly,...
Definition PolygonCruncherInterface.h:309
PolygonCruncherObjectCreatorFlags
Definition PolygonCruncherInterface.h:109
C3DScene *(* LoadCruncherBatchCallback)(const CXString &filename, CSceneImportOptions &options, CXString &resultTxt, void *data)
A callback for loading a 3D file specified by its filename and giving some options....
Definition PolygonCruncherInterface.h:308
bool(* CruncherProgressCallback)(unsigned int cruncherProgressFlags, const CruncherProgressInfo &info, void *data)
Progress callback. cruncherProgressFlags is a combination of CruncherProgress flags which inform abou...
Definition PolygonCruncherInterface.h:310
CXTString< TCHAR > CXString
CXString depend on the target OS. Could be CXStringW (Windows) or CXStringA (Linux / Macos)
Definition XString.h:118
This class allows to perform batch optimization, which means process a set of files.
Definition PolygonCruncherInterface.h:151
BatchCruncherOptionsFlags
Definition PolygonCruncherInterface.h:249
Parameters
Definition PolygonCruncherInterface.h:158
DefaultValues
Definition PolygonCruncherInterface.h:237
This is the base class for any kind of object.
Definition 3DBaseObject.h:106
This class handles static optimization of an object.
Definition 3DExtObject.h:66
C3DFaceList class which implement a list of C3DFace. Each face contains indexes to 3D points stored i...
Definition 3DFaceList.h:249
This class can be provided in C3DScene::Copy operations and allows to modify the created kind of clas...
Definition 3DScene.h:47
C3DObject handles polygonal mesh.
Definition 3DObject.h:24
C3DPatch handles handles patch object smoothed using a subdivision algorithm.
Definition 3DPatch.h:34
Definition 3DPointList.h:267
This class converts an usual C3DScene to a C3DScene containing object that can be used by CSceneOptim...
Definition PolygonCruncherInterface.h:123
C3DObject * GetNewPolygonalObject()
Creates a C3DObject with the appropriate required face list and point list classes.
The class allows to get access to the scene graph, node hierarchy, material.
Definition 3DScene.h:306
A node matches one element that is part of the C3DScene graph. It references a C3DBaseObject and has ...
Definition 3DSceneNode.h:64
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CBatchOptimizer allows to perform batch optimization providing BatchCruncherOptions settings and call...
Definition PolygonCruncherInterface.h:316
BatchState
Definition PolygonCruncherInterface.h:321
@ BATCH_INIT_BEFORE_BATCH
A place to set a first initialization. info is a bool set to true by default. If set to false GetBatc...
Definition PolygonCruncherInterface.h:323
@ BATCH_END_BATCH
The batch is over, all file have been processed.
Definition PolygonCruncherInterface.h:338
@ BATCH_START_BATCH
The batch will start to load file and process them. The following event sequence will occurs each tim...
Definition PolygonCruncherInterface.h:326
@ BATCH_POSTLOAD_FILE
info is a bool that allow to know if load succeed or fails
Definition PolygonCruncherInterface.h:328
@ BATCH_BEFORE_OPEN_LOG_FILE
info is a const pointer to the log filename
Definition PolygonCruncherInterface.h:324
xWndHandle GetParentWindow() const
optional parent window for overidden classes
Definition PolygonCruncherInterface.h:374
CStdioFileEx * GetLogFile() const
return the log file
Definition PolygonCruncherInterface.h:375
virtual bool CheckCancel()
Override to handle cancel on the process. Returning true will cancel the operation cancel.
virtual bool Batch()
Start the batch using the provided BatchCruncherOptions settings.
CBatchOptimizer(const BatchCruncherOptions &settings, xWndHandle parentWindow=NULL)
Initialize an optimization batch providing specific settings through BatchCruncherOptions.
unsigned int GetFlags() const
Return BatchCruncherOptionsFlags flags.
Definition PolygonCruncherInterface.h:373
BatchState GetBatchState() const
Returns the current batch state.
Definition PolygonCruncherInterface.h:386
virtual void Log(const CXString &loginfo, bool replacePrevLine=false)
Override this method to catch some different step in the batch.
void SetProgressCallback(CruncherProgressCallback callback)
Provides a progress callback to provide feedback to user.
void SetLoadCallback(LoadCruncherBatchCallback callback)
Provides a callback for loading files which can be used instead of the default callback.
void SetCallbackData(void *data)
Sets an opaque pointer which is provided in the different callbacks.
void SetSaveCallback(SaveCruncherBatchCallback callback)
Provides a callback for saving files which can be used instead of the default callback....
CXString GetCurrentOptimizedFilePath() const
Returns the currently processed file.
Definition PolygonCruncherInterface.h:385
CCustomData is a handly class for storing any kind of data.
Definition CustomData.h:106
A given extension may match several formats. In case of conflict CFileNameSpec is a way to indicate t...
Definition FileInfo.h:156
CMultiresolutionObject is the base class for multiresolution object. There is two kind of multiresolu...
Definition MultiresolutionObject.h:33
This class is used to provide some specific options when exporting a 3D scene.
Definition Io3dmgr.h:157
This class is used to provide some specific options when loading scene file.
Definition Io3dmgr.h:133
CSceneOptimizer is the main entry to optimize a scene. There are various optimization modes and which...
Definition SceneOptimizer.h:147
CStdioFileEx reads or write unicode or ansi / utf8 string and convert them to CXString using string c...
Definition StdioFileEx.h:41
CXStringArray implement an array of CXString.
Definition XStringArray.h:25
This class provides information about computation progress to the different progress callback.
Definition PolygonCruncherInterface.h:41
ProgressState
Definition PolygonCruncherInterface.h:53