-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.cpp
85 lines (61 loc) · 1.92 KB
/
export.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "export.h"
ofstream dout ("c:/temp/max_export/runlog");
static int total_process = 0, cur_process = 0;
bool flag_export_selected = false;
bool flag_export_materials = true;
bool flag_export_nodes = true;
bool flag_export_lights = true;
bool flag_export_cameras = true;
bool flag_export_shapes = true;
bool flag_export_geometry = true;
bool flag_export_helpers = true;
Interval anim_range;
float anim_fps;
static DWORD WINAPI Progress (LPVOID arg);
void Export ()
{
anim_range = iface->GetAnimRange ();
anim_fps = GetFrameRate ();
ResetMaterials ();
Preprocess (iface->GetRootNode ());
iface->ProgressStart (_T("Export scene..."),TRUE,Progress,NULL);
dump<<"anim_range\t"<<anim_range.Start()/GetFrameRate()/GetTicksPerFrame()<<" "
<<anim_range.End()/GetFrameRate()/GetTicksPerFrame()<<" "
<<anim_range.Duration()/GetFrameRate()/GetTicksPerFrame()<<endl;
dump<<"fps\t"<<anim_fps<<endl;
dump<<"ambient_light\t"<<iface->GetAmbient (static_frame,FOREVER)<<endl;
ViewExp* vp = iface->GetActiveViewport ();
if (vp)
{
INode* cam = vp->GetViewCamera ();
if (cam)
dump<<"active_camera\t'"<<cam->GetName()<<"'"<<endl;
iface->ReleaseViewport (vp);
}
Export (root,NULL);
iface->ProgressEnd ();
}
void Preprocess (INode* node)
{
if (node)
{
total_process++;
if (node->GetMtl ())
Export (node->GetMtl (),NULL);
for (int i=0;i<node->NumberOfChildren ();i++)
if (!flag_export_selected || node->GetChildNode (i)->Selected ())
Preprocess (node->GetChildNode (i));
}
}
void logProgressNext ()
{
cur_process++;
iface->ProgressUpdate ((int)((float)cur_process/total_process*100.0f));
}
DWORD WINAPI Progress (LPVOID arg)
{
iface->ProgressUpdate ((int)((float)cur_process/total_process*100.0f));
if (cur_process >= total_process)
iface->ProgressEnd ();
return 0;
}