# Roof orientation

3421
8
04-18-2013 02:03 AM
New Contributor
Hello,

i have a simple Question:

The roof orientation is perpendicular to the longest side of the basis polygons or rectangles. It is possible to rotate the orientation of a gable roof by 90°?

andi
Tags (3)
8 Replies
Frequent Contributor
Roofs are the only operations which �?? this was not yet fixed, but it�??s on the to do list �?? are oriented based on the vertex order of the geometry, and NOT based on the scope orientation, as other ops.

There�??s 2 ways to fix this for rectangular geometries, basically 2 hacks.

1]
physically rotate the geometry in that case ( e.g. rotating the scope by 90 degs and inserting a quad. [ or inserting a builtin:cube, then take the bottom face with reversed Normals ]

2]
make a case statement, where you call roof twice, for both ratios :
Once normal and once with :
roofGable(angle, overhangX, overhangY, even, index)
this does a hardcoded-rotation of the geometry.

Bad side of 2] is that not all roof ops have an �??index�?? param.

You'll need to play with this a bit, but I've not always been able to make this happen correctly.

Matt
New Contributor

have tried 2. hack:

[PHP]/**
* File:    roof.cga
* Created:
*/

version "2012.1"

Lot -->

extrude( 10)
comp(f) { top: Top | all: X. }
Top  --> roofGable(30, 3, 3, true, 1)

[/PHP]

result:

[ATTACH=CONFIG]23592[/ATTACH]

[PHP]Lot -->
reverseNormals
extrude( 10)
comp(f) { top: Top | all: X. }
Top  --> roofGable(30, 3, 3, true, 1)

[/PHP]

result without overhang :(:

[ATTACH=CONFIG]23593[/ATTACH]

The basis shape is an imported dxf geometry.
Frequent Contributor
Hi !

why did you reverse the normals ?

m.
New Contributor II
Hi Matt,

Sorry for dragging this post back up again...

i am having a similar problem whereby I want all roofs to be aligned. In my attached image you will notice that the highlighted row of buildings have roofs which don't line up. However the row of buildings on the left are aligned properly (the way i want them all to be!).

You suggest:

"make a case statement, where you call roof twice, for both ratios :
Once normal and once with :
roofGable(angle, overhangX, overhangY, even, index)"

However I am not sure what you mean by call the roof twice for both ratios?

Thanks,
Jay
Frequent Contributor
Hi,

Yep, that was not very clear.

The issue is that roofs - sadly - react to the actual geometry ( edge numbering ) rather than the scope orientation. So e.g. depending on if the first edge is on the short or long side of a rectangle, the default roof orientation may change. CityEngine does not have an awareness of how shapes and their topology 'align together in the world' and that the roofs should align in the same direction. So if the footprints were digitized differently, the roofs just will change.

not what we can do is change the roof orientation index based on the overall scope ratio.

something like this :
```@Hidden
attr roofOrientationIndex = 0

RoofBase --> # assuming scope is yUp
case scope.sx > scope.sz :
CreateGableRoof
else:
set (roofOrientationIndex, 1)

CreateGableRoof -->
roofGable(30, 1, 1, true, roofOrientationIndex)```

Does that approach make sense ?

Lemme know !

matt
New Contributor II
Hi Matt,

unfortunately this has aligned all the roofs the wrong way. however the rule must be working as it has changed all the previously correct orientation to the opposite way...

which part of the rule do I need to tweak in order to get all roofs to be aligned the other way??

Thanks!
New Contributor II
Hi Matt,

ignore that last post- i changed the rooforientationindex to 1 and that's sorted it!
Frequent Contributor
hi,

ok, glad it works now. the code above was just trying to get the idea over, not the actual proper code.

with some shapes that have colinear edges, try also cleanupGeometry(). possibly also alignScopeToGeometry(yUp, any, longest)

let us know a bit the progress of your CGA journey.. ok ?

matt