Orienting the camera with respect to added layers #2832
-
|
I'm loading 3D tile datasets using osgEarth::Map::addLayer and my meshes have different elevations than the base globe. Since the elevations are so different, I've noticed that the camera does not orient based on my 3D tiles surface. The orientation seems to orient based on the base globe only. Looking at the EarthManipulator source, I see that the intersect method queries the Terrain Engine from the map node and uses that for intersection calls, so my assumption is the layers I've added via addLayer aren't associated with the Terrain Engine and then aren't considered for the intersection tests. Is my assumption correct here? Is there a way to add some information to my map layer, or tie it somehow to the Terrain Engine, so that I can orient based on these separate meshes? Or do I need to write my own camera manipulator to do this? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
You are correct, the EarthManipulator only intersects against the terrain engine. Try changing the EarthManipulator::intersect and EarthManipulator::intersectLookVector to use the mapNode for doing intersection instead of mapNode->getTerrainEngine() and see if it works better for you. If it does then perhaps we can make that change to EarthManipulator. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, thank you, this seems to work for my use case. I can see it orienting properly when my terrain is higher than the base globe, and then when I pan off my terrain it orients correctly based on base globe. I am now curious when there are multiple layers in the same spot, I may need a way to toggle certain layers to not be considered during this check. Could I accomplish this by applying a mask on the layer node, or something else already built in? Thanks again. |
Beta Was this translation helpful? Give feedback.
-
|
Correct, you'd have to set a node mask on the layer you were interested in and then modify the code in EarthManipulator to only intersect against those layers that pass the mask. This isn't something that is supported out of the box in osgEarth so feel free to do some experiments and see if you come up with something good and maybe submit a PR! |
Beta Was this translation helpful? Give feedback.
You are correct, the EarthManipulator only intersects against the terrain engine. Try changing the EarthManipulator::intersect and EarthManipulator::intersectLookVector to use the mapNode for doing intersection instead of mapNode->getTerrainEngine() and see if it works better for you. If it does then perhaps we can make that change to EarthManipulator.