Skip to content

Commit

Permalink
remove chinese comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fanvanzh authored and nicos-fan committed Jul 29, 2021
1 parent 2278b78 commit d540b5d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 40 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 <FORMAT>` 输入数据格式。

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/osgb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
}
Expand Down
16 changes: 1 addition & 15 deletions src/osgb23dtile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class InfoVisitor : public osg::NodeVisitor
public:
std::vector<osg::Geometry*> geometry_array;
std::set<osg::Texture*> texture_array;
// 记录 mesh 和 texture 的关系,暂时认为一个模型最多只有一个 texture
std::map<osg::Geometry*, osg::Texture*> texture_map;
std::vector<std::string> sub_node_names;
};
Expand Down Expand Up @@ -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;
}
Expand All @@ -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<string,int>("index",i) };
mat.values["baseColorTexture"] = baseColorTexture;
Expand Down Expand Up @@ -969,17 +965,13 @@ std::vector<double> 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");
Expand Down Expand Up @@ -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,
Expand All @@ -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())
{
Expand All @@ -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)
{
Expand Down
15 changes: 2 additions & 13 deletions src/shp23dtile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> geo_items;
Expand Down Expand Up @@ -178,7 +178,7 @@ class node {

struct Polygon_Mesh
{
std::string mesh_name; // 模型名称
std::string mesh_name;
Vextex vertex;
Index index;
Normal normal;
Expand All @@ -195,7 +195,6 @@ osg::ref_ptr<osg::Geometry> make_triangle_mesh_auto(Polygon_Mesh& mesh) {
trig->setInputPointArray(va);
osg::Vec3Array *norms = new osg::Vec3Array;
trig->setOutputNormalArray(norms);
//三角化处理
trig->triangulate();
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
geometry->setVertexArray(va);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -364,7 +357,6 @@ convert_polygon(OGRPolygon* polyon, double center_x, double center_y, double hei
}
}
std::vector<int> indices = mapbox::earcut<int>(polygon);
// 剖分三角形
for (int idx = 0; idx < indices.size(); idx += 3) {
mesh.index.push_back({
pt_count + 2 * indices[idx],
Expand Down Expand Up @@ -762,18 +754,15 @@ std::string make_polymesh(std::vector<Polygon_Mesh>& 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;
/// --------------
Expand Down
4 changes: 1 addition & 3 deletions src/tileset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d540b5d

Please sign in to comment.