Skip to content

Commit

Permalink
[Add]增加对yUpAxis支持
Browse files Browse the repository at this point in the history
  • Loading branch information
scially committed Mar 23, 2022
1 parent 40c73ea commit bbf55ab
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Converter.exe --format <FORMAT> --input <INPUT> --output <OUTPUT> [OPTIONS]

```sh
# from osgb dataset
Converter.exe --format osgb -input E:\osgb_path -o E:\out_path --yUpAxis true
Converter.exe --format osgb -input E:\osgb_path --output E:\out_path --yUpAxis true

# from single shp file
Converter.exe --format gdal --input <Shapefile Path> --output <DIR> --field height --layer <Shapefile Name>
Expand All @@ -60,7 +60,7 @@ Converter.exe --format gdal --input <GDB Path> --output <DIR> --field height --
- `--thread` 处理线程数量(仅对OSGB生效)
- `--yUpAxis` 是否将gltf模型转为y轴朝上

`yUpAxis` 可选: true, false
`yUpAxis` 可选: true, false
如果是用`Cesium for Unreal`加载数据,需要启用yUpAxis

# 数据要求及说明
Expand Down
4 changes: 3 additions & 1 deletion include/OSGBConvertJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ namespace scially {
}

}
void setYUpAxis(bool y) {osgbLevel.setYUpAxis(y);}
void setYUpAxis(bool y) {
osgbLevel.setYUpAxis(y);
}

OSGBLevel osgbLevel;
bool isSucceed;
Expand Down
6 changes: 5 additions & 1 deletion src/OSGBConvertJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ namespace scially {
// 合并子节点
BaseTile baseTile;
baseTile.geometricError = 2000;
baseTile.asset.assets["gltfUpAxis"] = "Y";
if(yUpAxis)
baseTile.asset.assets["gltfUpAxis"] = "Y";
else
baseTile.asset.assets["gltfUpAxis"] = "Z";

baseTile.asset.assets["version"] = "1.0";
baseTile.root.transform = TileMatrix::fromXYZ(lon, lat, height);
baseTile.root.geometricError = 1000;
Expand Down
6 changes: 5 additions & 1 deletion src/OSGBLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ namespace scially {

for (int i = 0; i < lodVisitor.subNodeNames.size(); i++) {
OSGBLevel subLevel(lodVisitor.subNodeNames[i]);
subLevel.setYUpAxis(yUpAxis);
if (subLevel.getAllOSGBLevels(maxLevel)) {
subNodes.append(subLevel);
}
Expand Down Expand Up @@ -89,7 +90,10 @@ namespace scially {

// update root tile
tile.geometricError = 2000;
tile.asset.assets["gltfUpAxis"] = "Y";
if(yUpAxis)
tile.asset.assets["gltfUpAxis"] = "Y";
else
tile.asset.assets["gltfUpAxis"] = "Z";
tile.asset.assets["version"] = "1.0";

tile.root.children.append(childTile);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main(int argc, char** argv){

}
else{
qCritical() << "Only support osgb and shape format";
qCritical() << "Only support OSGB and GDAL format";
return 1;
}
qInfo() << "Finish convert in " << beginTime.secsTo( QTime::currentTime()) << "s";
Expand Down

0 comments on commit bbf55ab

Please sign in to comment.