Mapping Floor Plan Coordinates to Render/3DView Coordiantes

by shmuelzon » Sun Dec 24, 2023 6:26 am

Hello,

I'm trying to develop a plugin and, as a part of it, I want to get the pixel location of a piece of furniture in the rendered image.
I have the X, Y and elevation of the furniture and I managed to create a rendered 3D image, but I want to find the correlation between the two.

I found the `getVirtualWorldPointAt()` of `HomeComponent3D` which I thought would do just that but it crashes when I try to call it:

Code: Select all

HomeLight light = ...;
HomeComponent3D home3d = new HomeComponent3D(getHome());
float[] pos = home3d.getVirtualWorldPointAt((int)light.getX(), (int)light.getY(), light.getElevation());

Code: Select all

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException
        at com.eteks.sweethome3d.swing.HomeComponent3D.getCanvas3D(Unknown Source)
        at com.eteks.sweethome3d.swing.HomeComponent3D.convertPixelLocationToVirtualWorldPoint(Unknown Source)
        at com.eteks.sweethome3d.swing.HomeComponent3D.getVirtualWorldPointAt(Unknown Source)

I'm new to Sweet Home 3D and it's been decades since I wrote any Java so please excuse anything stupid I've done.

Thanks in advance!