-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmktree.cpp
More file actions
100 lines (80 loc) · 3.28 KB
/
Copy pathmktree.cpp
File metadata and controls
100 lines (80 loc) · 3.28 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
@brief ツリープリムの生成のテスト
@author Fumi.Iseki
@date 2015 5/31
@version 1.0
*/
#include "oarconv.h"
using namespace jbxl;
int main(int argc, char** argv)
{
Buffer inpdir = init_Buffer();
Buffer outdir = init_Buffer();
Buffer adddir = make_Buffer_bystr("./");
Buffer texture = init_Buffer();
int format = JBXL_3D_FORMAT_DAE;
float xsize = 1.0;
float ysize = 1.0;
int pnum = 4;
DebugMode = ON;
if (argc>1) copy_s2Buffer(argv[1], &texture);
for (int i=1; i<argc; i++) {
if (!strcmp(argv[i], "-i")) { if (i!=argc-1) copy_s2Buffer(argv[i+1], &inpdir);}
else if (!strcmp(argv[i], "-o")) { if (i!=argc-1) copy_s2Buffer(argv[i+1], &outdir);}
else if (!strcmp(argv[i], "-a")) { if (i!=argc-1) copy_s2Buffer(argv[i+1], &adddir);}
else if (!strcmp(argv[i], "-x")) { if (i!=argc-1) xsize = (float)atof(argv[i+1]);}
else if (!strcmp(argv[i], "-y")) { if (i!=argc-1) ysize = (float)atof(argv[i+1]);}
else if (!strcmp(argv[i], "-n")) { if (i!=argc-1) pnum = (int)atoi(argv[i+1]);}
else if (!strcmp(argv[i], "-j")) { format = JBXL_3D_FORMAT_OBJ;} // OBJデータを出力
else if (!strcmp(argv[i], "-b")) { format = JBXL_3D_FORMAT_STL_B;} // STLデータを出力
}
if (texture.buf==NULL) {
print_message("Usage.... %s texture_uuid [オプション]\n", argv[0]);
print_message("ex.) %s 0452407d-dcc5-4377-9fba-49cfb33112df -i OAR\n", argv[0]);
exit(1);
}
//////////////////////////////////////////////////////////////////////////////////////////////
// main process
OARTool oar;
oar.SetEngine(JBXL_3D_ENGINE_UNITY);
oar.SetDataFormat(format);
//oar.SetNoOffset(noOffset);
oar.SetPathInfo((char*)inpdir.buf, (char*)outdir.buf, (char*)adddir.buf);
oar.GetDataInfo(); // OARファイルから情報を得る.
// oar.MakeOutputFolder(makedir);
// oar.SetShift(xshift, yshift, zshift);
TreeTool* tree = oar.GetTreeTool(); //
ColladaXML* dae = new ColladaXML();
PrimBaseShape shape;
shape.State = TREM_TREE_TEST;
shape.PCode = PRIM_PCODE_TREE;
tree->treeParam[shape.State].texture.setName((char*)texture.buf);
tree->treeParam[shape.State].size = Vector<float>(xsize, 0.0001, ysize);
MeshObjectData* data = tree->GenerateTree(shape, pnum);
MeshFacetNode* facet = data->facet;
char* image_type = oar.GetTextureExtension();
while (facet!=NULL) {
if (facet->material_param.enable) {
// convert texture
//oar.ConvertTexture(facet->material_param.getTextureName(), facet->material_param.getAdditionalName(), image_type);
oar.ConvertTexture(facet->material_param.getTextureName(), NULL, image_type);
facet->material_param.setFullName(image_type);
}
facet = facet->next;
}
dae->addShell(data, false, NULL);
dae->outputFile("test_tree.dae", oar.get_outpath());
/////////////////////////////////////////////////////////////
dae->free();
tree->free();
oar.free();
shape.free();
//
freeMeshObjectData(data);
freeColladaXML(dae);
free_Buffer(&inpdir);
free_Buffer(&outdir);
free_Buffer(&adddir);
free_Buffer(&texture);
return 0;
}