CesiumGS / cesium-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

load and updateView, there are only tilesvisited but no render data

arvrschool opened this issue · comments

I have one 3dtiles file, when I use cesium-native to load and updateView, there are only tilesvisited but no render data. I think this is because of the issue with ViewState. I get the transform from root tileset.json as follows.

dmat4x4((-0.890310, -0.455354, 0.000000, 0.000000), (0.188912, -0.369362, 0.909881, 0.000000), (-0.413837, 0.809136, 0.417180, 0.000000), (-2641045.873043, 5163786.710629, 2644556.901013, 1.000000))

And I get the mock camera position in ecef like this:

glm::dvec3 originEcef{-2641045.873043, 5163786.710629, 2644556.901013 };
  // // glm::dvec3 originEcef{-2646780.52544459, 5164537.68626643, 0};
  const LocalHorizontalCoordinateSystem* pCoordinateSystem = new LocalHorizontalCoordinateSystem(originEcef);
  glm::dvec3 originLocal = pCoordinateSystem->ecefPositionToLocal(originEcef);
  std::cout << "originLocal = " << originLocal.x << ":" << originLocal.y << ":" << originLocal.z << std::endl;
  glm::dvec3 cameraLocal = originLocal + glm::dvec3{0, 0, 3000 - 100 * i};
  std::cout << "cameraLocal = " << cameraLocal.x << ":" << cameraLocal.y << ":" << cameraLocal.z << std::endl;
  // glm::dvec3 cameraEcef{-2641045.873043, 5163786.710629, 2644556.901013+3000 };
  glm::dvec3 cameraEcef = pCoordinateSystem->localPositionToEcef(cameraLocal);
  std::cout << std::cout.setf(ios::fixed) << "cameraEcef = " << cameraEcef.x << ":" << cameraEcef.y << ":" << cameraEcef.z << std::endl;
  glm::dvec3 viewUp{0.0, 0.0, 1.0};
  double verticalFOV = Math::degreesToRadians(60);
  const glm::dvec2 viewPortSize{1080.0, 1080.0};
  double aspect = viewPortSize.x / viewPortSize.y;
  double horizontalFOV =
      2 * glm::atan(aspect * glm::tan(verticalFOV * 0.5));
  std::vector<ViewState> result;
  glm::dvec3 direction = glm::normalize(originEcef - cameraEcef);
  result.push_back(ViewState::create(
      cameraEcef,
      direction,
      glm::normalize(viewUp),
      viewPortSize,
      horizontalFOV,
      verticalFOV));

But the result looks strange, the printed log is as follows, please give me some guidance, thanks very much~

[2024-01-13 23:00:36.688] [info] [test_read_3dtiles2.cpp:651] Creating Cesium3DTilesSelection::Tileset DONE
update view state = 0
originLocal = 0:0:0
cameraLocal = 0:0:3000
4098cameraEcef = -2643716.804489:5162420.648693:2644556.901013
viewPosition = -2642551.000000:5165899.000000:2646305.000000
viewStates size = 1
[2024-01-13 23:00:36.689] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 413
tilesCulled : 0
maxDepthVisited : 2
render
update view state = 1
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2900.000000
4102cameraEcef = -2643627.773440:5162466.184091:2644556.901013
viewPosition = -2642509.612611:5165818.092169:2646263.274625
viewStates size = 1
[2024-01-13 23:00:38.690] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 413
tilesCulled : 0
maxDepthVisited : 2
render
update view state = 2
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2800.000000
4102cameraEcef = -2643538.742392:5162511.719489:2644556.901013
viewPosition = -2642468.225223:5165737.184338:2646221.549250
viewStates size = 1
[2024-01-13 23:00:40.693] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 453
tilesCulled : 0
maxDepthVisited : 4
render
update view state = 3
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2700.000000
4102cameraEcef = -2643449.711344:5162557.254887:2644556.901013
viewPosition = -2642426.837834:5165656.276507:2646179.823875
viewStates size = 1
[2024-01-13 23:00:42.695] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 453
tilesCulled : 0
maxDepthVisited : 4
render
update view state = 4
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2600.000000
4102cameraEcef = -2643360.680296:5162602.790284:2644556.901013
viewPosition = -2642385.450445:5165575.368676:2646138.098500
viewStates size = 1
[2024-01-13 23:00:44.698] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 494
tilesCulled : 0
maxDepthVisited : 5
render
update view state = 5
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2500.000000
4102cameraEcef = -2643271.649248:5162648.325682:2644556.901013
viewPosition = -2642344.063056:5165494.460845:2646096.373125
viewStates size = 1
[2024-01-13 23:00:46.700] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 494
tilesCulled : 0
maxDepthVisited : 5
render
update view state = 6
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2400.000000
4102cameraEcef = -2643182.618199:5162693.861080:2644556.901013
viewPosition = -2642302.675668:5165413.553014:2646054.647749
viewStates size = 1
[2024-01-13 23:00:48.703] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 534
tilesCulled : 0
maxDepthVisited : 5
render
update view state = 7
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2300.000000
4102cameraEcef = -2643093.587151:5162739.396478:2644556.901013
viewPosition = -2642261.288279:5165332.645182:2646012.922374
viewStates size = 1
[2024-01-13 23:00:50.706] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 533
tilesCulled : 1
maxDepthVisited : 5
render
update view state = 8
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2200.000000
4102cameraEcef = -2643004.556103:5162784.931876:2644556.901013
viewPosition = -2642219.900890:5165251.737351:2645971.196999
viewStates size = 1
[2024-01-13 23:00:52.709] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 567
tilesCulled : 7
maxDepthVisited : 5
render
update view state = 9
originLocal = 0.000000:0.000000:0.000000
cameraLocal = 0.000000:0.000000:2100.000000
4102cameraEcef = -2642915.525055:5162830.467274:2644556.901013
viewPosition = -2642178.513502:5165170.829520:2645929.471624
viewStates size = 1
[2024-01-13 23:00:54.711] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 554
tilesCulled : 22
maxDepthVisited : 5
render

Can you break it down for me? You've shared a lot of code and a lot of output, but I can't tell what the actual problem is. We have high confidence in updateView for general use-cases because it's used in all our game engine integrations. Perhaps it's useful to take a look at one of those (cesium-unreal or cesium-unity perhaps?) to see how it is meant to be used.

Can you break it down for me? You've shared a lot of code and a lot of output, but I can't tell what the actual problem is. We have high confidence in updateView for general use-cases because it's used in all our game engine integrations. Perhaps it's useful to take a look at one of those (cesium-unreal or cesium-unity perhaps?) to see how it is meant to be used.

OK,thanks for your reply. I hava tested my 3dtiles in unity3d, and it works well. I know the cesium-native lib is fine, my core problem is that there are only tilesvisited but no render data when I load and updateview data in cesium-native, the compact log message is :

[2024-01-13 23:00:50.706] [info] [test_read_3dtiles2.cpp:207] ViewUpdateResult:
tilesToRenderThisFrame : 1
ID error 2000 height 2
tilesVisited : 533
tilesCulled : 1
maxDepthVisited : 5

I suspect it's a problem with my viewstate construction, but I don't have a clear answer, so I hope you give me some guidance.

I can't debug your application for you, but as I guess: the camera parameters are probably incorrect, so the camera isn't "looking" where you think it is. Set up a similar configuration in one of the game engines, take a look at the camera parameters it passes into updateView, and compare to yours.

I can't debug your application for you, but as I guess: the camera parameters are probably incorrect, so the camera isn't "looking" where you think it is. Set up a similar configuration in one of the game engines, take a look at the camera parameters it passes into updateView, and compare to yours.

Okay, I'll try. Thanks~