This questions is not necessarily SketchUp related, but I’ve been trying to figure out texture mapping for several days and am not making any progress.
So in SketchUp textures can be assigned to any face an the texture points ‘up’ and is automatically sized and positioned correctly no mater what the plane is.
Consider the following picture where my texture lines run vertically.
When the top is flat the texture runs along the green axis.
However when I give some slope to the roof faces the texture (correctly) follows the vector that points from low to high point.
Two things I’m trying to figure out.
- How do I calculate the ‘slope direction’ vector given three points?
- How do I calculate the 2D texture coordinates using this vector (or in some other way)?
Also note how the texture on the roof aligns with the texture of the walls?
I’m suspicious the answer involves some trigonometry, which I’m willing to learn if I can figure out how.
I posted a question on stack overflow several days ago, but haven’t gotten an explanation there. I’m hoping some 3D math wiz here can shed some light to my foggy brain.