How to display a point on the earth map? #1131
Replies: 1 comment
-
The VSG uses a vsg::EllipsoidModel class for converting data between lat/long/altitude to Earth Centred Earth Fixed (ECEF) coordinate systems. The defaults settings of vsg::EllipsoidModel are based on WGS84. The tile database functionality you have been experimenting with uses vsg::EllipsoidModel to compute where to put the tiles, and each tile has it's own local origin and a vsg::MatrixTransform that decorates the geometry subgraph. The combination of geometry with a local origin and transform (which is uses double matrix) that places it in world coodinates (ECEF), along with the vsg::Camera being set up with doubles with the main record traversal accumulating the camera and scene graph transform in doubles before passing to the GPU as a float modelview matrix is the VSG's way of ensuring that precision is kept where it's required but drops down to floats for efficient GPU operation. This scheme avoids precision issues that plague applications which attempt to handle whole earth databases but lack such builtin functionality. When placing your own geometries into an ECEF model it's important to follow the same sceheme and create your geometries with a local origin and then place it in ECEF using a MatrixTransform. You can use the EllipsoidModel::computeLocalToWorldTransform(..) to set the MatrixTransform.matrix value: /// latitude and longitude in degrees, altitude in metres
dmat4 computeLocalToWorldTransform(const dvec3& lla) const; The computed transform has Z up, Y to the north and X to the east. The tile,cpp that does the tile database scene graph loading/creation utilize this approach so have a look at it's tile::createECEFTile() method imple,mentation. To create a point I'd suggest creating a sphere geometry using vsg::Builder, the vsgbuilder example shows how. The subgraph you create using vsg::Builder you'll add to the transform node you created and set up as per above. To add a 3D model like a building your just use the same approach, create a transform to place the model and add the loaded subgraph to it. To load the model just use auto model = vsg::read_castvsg::Node("my_model.gltf", options) as illustrated in most examples. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I built the vsgExample and run the vsgpagedlod example. It shows the earth without problem. I want to show a point in a WSG84 position and I have some questions:
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions