diff --git a/README.md b/README.md index 92cf5a3b..3f6ce8d5 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,6 @@ [![glTF status](https://img.shields.io/badge/glTF-2%2E0-green.svg?style=flat)](https://github.com/KhronosGroup/glTF) [![Action status](https://github.com/fanvanzh/3dtiles/actions/workflows/rust.yml/badge.svg)](https://github.com/fanvanzh/3dtiles/actions/workflows/rust.yml) -[![Build status](https://ci.appveyor.com/api/projects/status/lyhf989tnt9jhi9y?svg=true)](https://ci.appveyor.com/project/fanvanzh/3dtiles) - - - Tools for 3D-Tiles convertion. This is a `RUST language` project with cpp lib to handle osgb data. @@ -131,13 +127,12 @@ To Translate. ``` json { "x": 120, - "y": 30, - "offset": 0 , // 模型最低面地面距离 - "max_lvl" : 20 // 处理切片模型到20级停止 + "y": 30, + "offset": 0 , // 模型最低面地面距离 + "max_lvl" : 20 // 处理切片模型到20级停止 } ``` - - `-f, --format ` 输入数据格式。 diff --git a/appveyor.yml b/appveyor.yml.old similarity index 100% rename from appveyor.yml rename to appveyor.yml.old diff --git a/build.rs b/build.rs index 1e71ef39..796625f0 100644 --- a/build.rs +++ b/build.rs @@ -22,6 +22,7 @@ fn build_win_msvc() { println!("cargo:rustc-link-search=native=./lib"); // ------------- println!("cargo:rustc-link-lib=gdal_i"); + println!("cargo:rustc-link-lib=OpenThreads"); println!("cargo:rustc-link-lib=osg"); println!("cargo:rustc-link-lib=osgDB"); println!("cargo:rustc-link-lib=osgUtil"); diff --git a/src/osgb.rs b/src/osgb.rs index d903612b..af2974a8 100644 --- a/src/osgb.rs +++ b/src/osgb.rs @@ -73,7 +73,7 @@ pub fn osgb_batch_convert( use std::sync::mpsc::channel; let path = dir.join("Data"); - // 指定 .\Data 目录 + // .\Data directory if !path.exists() || !path.is_dir() { return Err(From::from(format!("dir {} not exist", path.display()))); } diff --git a/src/osgb23dtile.cpp b/src/osgb23dtile.cpp index 44987151..bc8325a1 100644 --- a/src/osgb23dtile.cpp +++ b/src/osgb23dtile.cpp @@ -110,7 +110,6 @@ class InfoVisitor : public osg::NodeVisitor public: std::vector geometry_array; std::set texture_array; - // 记录 mesh 和 texture 的关系,暂时认为一个模型最多只有一个 texture std::map texture_map; std::vector sub_node_names; }; @@ -829,10 +828,8 @@ bool osgb2glb_buf(std::string path, std::string& glb_buff, MeshInfo& mesh_info) } // scene { - // 一个场景 tinygltf::Scene sence; sence.nodes.push_back(0); - // 所有场景 model.scenes = { sence }; model.defaultScene = 0; } @@ -851,7 +848,6 @@ bool osgb2glb_buf(std::string path, std::string& glb_buff, MeshInfo& mesh_info) for (int i = 0 ; i < infoVisitor.texture_array.size(); i++) { tinygltf::Material mat = make_color_material_osgb(1.0, 1.0, 1.0); - // 可能会出现多材质的情况 tinygltf::Parameter baseColorTexture; baseColorTexture.json_int_value = { std::pair("index",i) }; mat.values["baseColorTexture"] = baseColorTexture; @@ -969,17 +965,13 @@ std::vector convert_bbox(TileBox tile) { return v; } -// 生成 b3dm , 再统一外扩模型的 bbox void do_tile_job(osg_tree& tree, std::string out_path, int max_lvl) { - // 转瓦片、写json std::string json_str; if (tree.file_name.empty()) return; int lvl = get_lvl_num(tree.file_name); if (lvl > max_lvl) return; - // 转 tile std::string b3dm_buf; osgb2b3dm_buf(tree.file_name, b3dm_buf, tree.bbox); - // false 可能当前为空, 但存在子节点 std::string out_file = out_path; out_file += "/"; out_file += replace(get_file_name(tree.file_name),".osgb",".b3dm"); @@ -1131,11 +1123,7 @@ encode_tile_json(osg_tree& tree, double x, double y) return tile; } -/** -外部创建好目录 -外面分配好 box[6][double] -外面分配好 string [1024*1024] -*/ +/***/ extern "C" void* osgb23dtile_path(const char* in_path, const char* out_path, double *box, int* len, double x, double y, @@ -1150,7 +1138,6 @@ osgb23dtile_path(const char* in_path, const char* out_path, } b_pbr_texture = pbr_texture; do_tile_job(root, out_path, max_lvl); - // 返回 json 和 最大bbox extend_tile_box(root); if (root.bbox.max.empty() || root.bbox.min.empty()) { @@ -1170,7 +1157,6 @@ osgb23dtile_path(const char* in_path, const char* out_path, return str; } -// 所有接口都是 utf8 字符串 extern "C" bool osgb2glb(const char* in, const char* out) { diff --git a/src/shp23dtile.cpp b/src/shp23dtile.cpp index 18177bac..275d3da5 100644 --- a/src/shp23dtile.cpp +++ b/src/shp23dtile.cpp @@ -64,7 +64,7 @@ struct bbox class node { public: bbox _box; - // 1 公里 ~ 0.01 + // 1 km ~ 0.01 double metric = 0.01; node* subnode[4]; std::vector geo_items; @@ -178,7 +178,7 @@ class node { struct Polygon_Mesh { - std::string mesh_name; // 模型名称 + std::string mesh_name; Vextex vertex; Index index; Normal normal; @@ -195,7 +195,6 @@ osg::ref_ptr make_triangle_mesh_auto(Polygon_Mesh& mesh) { trig->setInputPointArray(va); osg::Vec3Array *norms = new osg::Vec3Array; trig->setOutputNormalArray(norms); - //三角化处理 trig->triangulate(); osg::ref_ptr geometry = new osg::Geometry; geometry->setVertexArray(va); @@ -250,12 +249,6 @@ void calc_normal(int baseCnt, int ptNum, Polygon_Mesh &mesh) } #ifdef _WIN32 -/** -@brief: convet polygon to mesh -@param: polygon , 多边形 -@param: center_x, 投影中心点 -@param: center_y, 投影中心点 -*/ Polygon_Mesh convert_polygon(OGRPolygon* polyon, double center_x, double center_y, double height) { @@ -364,7 +357,6 @@ convert_polygon(OGRPolygon* polyon, double center_x, double center_y, double hei } } std::vector indices = mapbox::earcut(polygon); - // 剖分三角形 for (int idx = 0; idx < indices.size(); idx += 3) { mesh.index.push_back({ pt_count + 2 * indices[idx], @@ -762,18 +754,15 @@ std::string make_polymesh(std::vector& meshes) { model.meshes.push_back(mesh); } - // 加载所有的模型 for (int i = 0; i < meshes.size(); i++) { tinygltf::Node node; node.mesh = i; model.nodes.push_back(node); } - // 一个场景 tinygltf::Scene sence; for (int i = 0; i < meshes.size(); i++) { sence.nodes.push_back(i); } - // 所有场景 model.scenes = { sence }; model.defaultScene = 0; /// -------------- diff --git a/src/tileset.cpp b/src/tileset.cpp index b342b15a..f8ca20cd 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -252,9 +252,7 @@ bool write_tileset_region( return ret; } -/** -根据经纬度,生成tileset -*/ +/***/ bool write_tileset( double radian_x, double radian_y, double tile_w, double tile_h,