ModelSceneSymbol in lat lon space

800
2
07-10-2019 11:28 AM
PaulGrenning
New Contributor II

I am using the ModelSceneSymbol to load collada files.

The collada are already projected to a specific lat lon. When I set the spatial reference and load the collada files, they are visualized at an offset. The offset appears to be the center of the models bounding box. This is not helpful since my model was already spatially correct.

The next step I do is calculate that offset manually to attempt to put the model at its original position instead of the bounding box center position. Now the models are close to where they should be but are still off. This is what I cannot figure out.

When I use the same spatial reference in ArcGIS pro and load the same collada file, everything aligns perfectly. How can I achieve this in the java sdk?

Can anyone suggest a better way to load collada files in the java api or explain what the offset actually is?

I will attach some images for a description. The true origin of the collada files is near the southern edge of the roads, this is why the offset moves them so far north.

Here is my code that loads a collada file:

private Point LoadModel(String filePath, SpatialReference spatialReference, GraphicsOverlay graphicsOverlay)
    {
        Parser parser = new Parser();
        ColladaData data = null;
        try {
            data = parser.parseToColladaData(new FileInputStream(new File(filePath)));
        } catch (IOException e) {
            e.printStackTrace();
        }
        MeshData mesh = (MeshData) data.getGeomertires().get(0);
         // calculate the model center
        float[] center = mesh.getCenter();

         // project the model center using the spatial reference
        Point roadProjectedPosition = new Point(center[0], center[1], center[2], spatialReference);

        ModelSceneSymbol modelSymbol = new ModelSceneSymbol(filePath, 1);
        modelSymbol.setAnchorPosition(AnchorPosition.ORIGIN);
        modelSymbol.loadAsync();
        modelSymbol.addDoneLoadingListener(() -> {
            if (modelSymbol.getLoadStatus() == LoadStatus.LOADED) {

               // use the projected point instead of 0,0,0 for the model position
                Graphic graphic=new Graphic(roadProjectedPosition, modelSymbol);

                graphicsOverlay.getGraphics().add(graphic);
            }
        });

        return roadProjectedPosition;
    }
0 Kudos
2 Replies
PaulGrenning
New Contributor II

I figured out the issue to my own problem.

The ModelSceneSymbol uses the centroid of the model, not the center of the models bounding box.

This would be a good thing to add to the documentation. I kept assuming I had the spatial reference wrong, or my initial data was wrong, or my code was incorrect for calculating the offset.

0 Kudos
GuntherHeppner
Esri Contributor

Hi Paul,

Thanks for your feedback. We will extent our doc to make it clearer as to how a ModelSceneSymbol is placed in the scene.

Gunther