# Calculating roof tile angles for a curved roof?

## Recommended Posts

Hey all

I'm currently working on a project where I want to create a scale like effect with boxes overlapping.
Currently I'm able to calculate the required angle for each box so the end of one box rest on the start of the next when there all in a straight line.
But when placing the boxes on a curve they start to intersectin with each other.

The goal is to get them nicely laying on top of each other as in this image but i don't know how.

So i was hoping someone could help me, I'm guessing in need to calculate the angle but I tried several different methods with no success.

The expression I'm using now to get the angle needed for the boxes to overlap is.

```atan(ch("../box/thicknes") / ch("../box/overlapPoint"))
```

The placing of boxes is done using a curve and a copy node, each box is rotated using a stamp value.

##### Share on other sites

hi maurits, interesting!

here is my approach. the tiles either touch at the corner or somewhere along the edge. i solved the first case. for the latter you probably need another pointvop, which is calculating based on the results of the first one (or you have to bloat the first one).

please keep us posted, even if you dont have any questions!

roof.hiplc

Edited by konstantin magnus
##### Share on other sites

here is a further developped version from last night. this time also featuring overlappings. i did not finish it yet, so it contains bugs.

roof_b.hiplc

##### Share on other sites

Thank for the help so far konstantin magnus. Using your examples i'm also trying to get it working, but the progress is slow going.

So all help remains more then welcome.

##### Share on other sites

here is another quick attempt.

hth.

petz

roof.hiplc

##### Share on other sites

That seems to do the job perfectly Petz thank you and konstantin magnus for your help.
Gone spends some time to disect and understand both methods used.

##### Share on other sites

• 2 weeks later...

@Petz that setup is really nice. This may be a dumb question, but my VEXfu isn't terribly strong...in your wrangle, sometimes you're using @OpInput1 and sometimes geoself(). Since it's only operating on a single input anyway, just curious if there's a reason for choosing one sometimes over the other.

##### Share on other sites

I't might be preference.
if you use the @OpInput1 version you don't have to rewrite allot to change to the second input or think about it.

While using the geoself() you have to rewrite more or think a bit more about it when you wan't to execs another input.

##### Share on other sites

or you can just put "0" or "1" as integers

##### Share on other sites

@Petz that setup is really nice. This may be a dumb question, but my VEXfu isn't terribly strong...in your wrangle, sometimes you're using @OpInput1 and sometimes geoself(). Since it's only operating on a single input anyway, just curious if there's a reason for choosing one sometimes over the other.

geoself() is a handle to the current geometry of the node while OpInput is the incomming geometry from the node wired into the first, second or nth input.

in the example above i had to use geoself() because the wrangle is set to run over primitives but is updating point attributes as well. therefore it uses setpointattrib() and that´s a function working on the current geometry.

since the example uses attributes just from the first input (OpInput1) you could use geoself() for everything. not doing this, as well as using OpInput instead of the integer number as suggested by acey195 ist just a personal preference...

hth.

petz

Edited by petz
##### Share on other sites

Well while we're on the subject of roofing tiles...how would you guys go about laying out a perfectly spaced set of curves onto a piece of roof geometry to then use as the basis for tiles to get placed?

I guess really the question is more what the easiest way is to turn a polygon roof face into a NURBS or a mesh or something so that you can start to Creep lines across either the s or t parameter.

##### Share on other sites

I use 2 different methods while working on this project
The basis for the first one comes down to the following.
The first methods removes all except for the bottom points of a polygon after adding the normal, tangent and bi tangent values to the polygon.
Then refine the edge depending on the width of your tiles.
Next you create a line with points equally spaced out depending on the tile height and copy these onto the bottom line. As this line maintained the normal data the lines should be placed in the same angle as the original polygon.
This results in a series of lines with points correctly spaced for roof tiles.

The basis for the second one is rotating a polygons so all polygons always align along the same axis.
Then you can use a division node to create the vertical lines using the tile width, afterwards the lines are refined vertically depending on the tile height.

Finally rotate the object back and copy your tiles.

But depending on your roof shape this might or might not work, a mayor difficulty is when the roof is bend, while vertically bend roof like chinese buildings are still relative easy it's when they are horizontally bend like a tower when it gets difficult especial if you want to keep streight vertical lines, if you want tiles to overlap horizontally it becomes less difficult.

But i think there might be beter way's out these.

##### Share on other sites

Yeah something like that would be pretty quick to do, but I'd be hoping to set up something much more automated and procedural.

##### Share on other sites

If you know the steps you can automate them.
So converting these examples methods to be procedural is not that hard.

##### Share on other sites

If you know the steps you can automate them.

So converting these examples methods to be procedural is not that hard.

For sure, but in that workflow there would be some manual work of determining which edges become the boundary that you use as the basis for your grid. There's probably some easy way I'm not thinking of right now, but I can't really come up with a good automated approach to getting perfect roof tile layouts on roofs with arbitrary geometry.

Here's some roof geo if anyone feels like playing with it. It's locked into the .hip file containing my somewhat feeble attempt at this.

roofing_v001.hip

##### Share on other sites

I know the feeling, been trying to create a roofing tool on and off again for a while facing the same problems.

Don'y think you can use a single methods that works with every roof shape. Instead it might be better to let the user choose the methods depending on the roof shape or find a way to do this automatically.
When i have time i'm gone have a look at your approach to see how you did it.

##### Share on other sites

Can you not use Convert-SOP to change geometry to NURBS or mesh and get curves with Carve-SOP?

Edited by renderfan
##### Share on other sites

Can you not use Convert-SOP to change geometry to NURBS or mesh and get curves with Carve-SOP?

Yeah that could work, but I'll admit here I really don't know enough about converting polygons to meshes to come up with a really good solution. I'm doing pretty badly at coming up with a pts/prim sort operation to get a single clean mesh out of it.

There's some good roof examples in that .hip file I'd linked further up if anyone wants to give it a whirl and convert them to mesh objects.

##### Share on other sites

I was to quick. Sorry! I did try with your file but it is not work because u and v direction do not match when I convert to Mesh. Perhaps there is better way but I do not know.

##### Share on other sites

depending on the type of tiling there are several things you could try. take a look at the attached example. it´s not a production ready solution but might give you some ideas ...

hth,

petz

roof.hipnc

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×