I'm working on a floor design app that allows the user to pick preset floor images and view them within a preset room image.
My problem is I'm struggling to get the perspective of the floor image to match the room image properly. I have played around with setting the height of the viewpoint and the tilt but is there a way to calculate what these should be by using the real world measurements of the floor and room image? My knowledge in perspective drawing is very limited so I apologise if I'm using the wrong terminology.
Any help or advice would be appreciated.
Thanks
You should try to find the vanishing point of the structural lines of the room. There are many line-finding algorithms for this.
Once you have this, you can build a regular tiling starting from these two points:![Not so regular tiling](https://i.stack.imgur.com/dAABI.jpg)
To map a texture on the floor, you just have to find the bounding rectangle following the tiling:![enter image description here](https://i.stack.imgur.com/OTlhv.jpg)
to stretch your texture inside it:![enter image description here](https://i.stack.imgur.com/tDDd1.jpg)
and to remove extra parts and apply shadows:![enter image description here](https://i.stack.imgur.com/uMOFs.jpg)