|
Sweet Home 3D Forum » List all forums » » Forum: Developers » » » Thread: Mapping Floor Plan Coordinates to Render/3DView Coordiantes » » » » Post: Re: Mapping Floor Plan Coordinates to Render/3DView Coordiantes |
Print at Dec 15, 2025, 11:28:16 PM |
| Posted by shmuelzon at Jan 13, 2024, 12:41:43 PM |
|
Re: Mapping Floor Plan Coordinates to Render/3DView Coordiantes Hey, Unfortunately, I'm still stuck... I was able to integrate the relevant parts of the Pan3dView plugin and can, accurately, get the pixel locations from the 3D view of the application but, since the rendered image might have a different aspect ratio, it doesn't help directly. I even tried to create my own Canvas3D object so I could defer those calculations to it but I wasn't able to get that to work either. In any case, I have figured out that the SH3D's Y and Z axes are reversed, compared to the standard right-handed coordinates, so I switch between those values. I also think that the SH3D's pitch goes in the other direction (clockwise instead of counter-clockwise) so that needs to be negated before performing the calculations. I believe I do have the correct calculation for moving the object's location to be relative to the camera while taking the camera's position, pitch and yaw into account. For reference, this is what I have (playing around with Python, will convert to Java when it's working): object_location = np.array([749.2, 95, -2611.5])The final part, performing the actual perspective projection, is what I'm failing at. I found online a few different variants but none have worked well for me. One of them is: image_width = 1024The other is: image_width = 1024For the above example, I've rendered the image and the object in question appears at pixel (426, 303). The first calculation results with (463, 278) while the second comes very close with (425, 297). I then proceeded with testing a different scenario with: object_location = np.array([1009.1, 0, -1071.6])Here I expect the pixel to be located at (375, 334) but the first method returns (417, 261) and the second (344, 314). Can anyone suggest a projection matrix / calculation that's similar to the SH3D's renderers? Thanks again! |
|
|
Current timezone is GMT Dec 15, 2025, 11:28:16 PM |