5 #include "TileAssembler.h"
7 //=======================================================
8 // remove last return or LF and tailing SPACE
9 // remove all char after a #
11 void chompAndTrim(std::string
& str
)
13 for(unsigned int i
=0;i
<str
.length(); ++i
) {
16 str
= str
.substr(0,i
);
21 while(str
.length() >0) {
22 char lc
= str
[str
.length()-1];
23 if(lc
== '\r' || lc
== '\n' || lc
== ' ') {
24 str
= str
.substr(0,str
.length()-1);
31 //=======================================================
33 This callback method is called for each model found in the dir file.
34 return true if it should be included in the vmap
36 bool modelNameFilter(char *pName
)
40 result
= !Wildcard::wildcardfit("*bush[0-9]*", pName
);
41 if(result
) result
= !Wildcard::wildcardfit("*shrub[0-9]*", pName
);
42 if(result
) result
= !Wildcard::wildcardfit("*_Bushes_*", pName
);
43 if(result
) result
= !Wildcard::wildcardfit("*_Bush_*", pName
);
51 //=======================================================
53 File contains map names that should be split into tiles
54 A '#' at the beginning of a line defines a comment
57 bool readConfigFile(char *pConffile
, VMAP::TileAssembler
* pTa
)
61 FILE *cf
= fopen(pConffile
, "rb");
63 while(fgets(buffer
, 500, cf
)) {
64 std::string name
= std::string(buffer
);
65 size_t pos
= name
.find_first_not_of(' ');
66 name
= name
.substr(pos
);
67 chompAndTrim(name
); // just to be sure
68 if(name
[0] != '#' && name
.size() >0) { // comment?
69 unsigned int mapId
= atoi(name
.c_str());
70 pTa
->addWorldAreaMapId(mapId
);
78 //=======================================================
79 int main(int argc
, char* argv
[])
81 if(argc
!= 3 && argc
!= 4)
83 printf("\nusage: %s <raw data dir> <vmap dest dir> [config file name]\n", argv
[0]);
89 char *conffile
= NULL
;
93 VMAP::TileAssembler
* ta
= new VMAP::TileAssembler(std::string(src
), std::string(dest
));
94 ta
->setModelNameFilterMethod(modelNameFilter
);
97 All the names in the list are considered to be world maps or huge instances.
98 These maps will be spilt into tiles in the vmap assemble process
102 if(!readConfigFile(conffile
, ta
))
104 printf("Can not open file config file: %s\n", conffile
);
110 if(!ta
->convertWorld())
112 printf("exit with errors\n");
118 printf("Ok, all done\n");