Extrude primitives then flatten the top

   1674   6   0
User Avatar
Member
14 posts
Joined: 12月 2018
Offline
Hi to all,

I'm struggling with a first Houdini project. I have an irregular ground and need to extrude some faces to produce blocks of specific heights (attribute). But I need to flatten the faces that I extruded. I hope this screencopies will help you understand my meaning.

The terrain :


What I want to do with all the primitives :


So far, I end up with this to flatten the top :
vector P = point(0, "P", 0);
float PY = P.y;
@P.y = PY;

But then I don't really know how to bring back the face to the right Y position.

I'm sure there are better ways to do it. Any idea ?

Thanks !
Nikos Priniotakis
Heritage, visualisation and 3D modeling
Cergy Paris University
User Avatar
Member
555 posts
Joined: 2月 2017
Offline
not sure if you want to flatten them INDIVIDUALLY or as a whole group.

for as a whole group, in Point SOP, I did the ‘Flatten Bottom’ preset. Just adapt to flatten top instead…(apply this preset to a torus so you get to see the effect first)

something like this:

set(self.x, min(self.y, ch('level') + getbbox_max(0).y), self.z)
User Avatar
Member
14 posts
Joined: 12月 2018
Offline
Thanks a lot, Vusta ! Neat expression !
In order to do it individually, is the for-each primitive the solution ?
Nikos Priniotakis
Heritage, visualisation and 3D modeling
Cergy Paris University
User Avatar
Member
555 posts
Joined: 2月 2017
Offline
here you are…magic…

Attachments:
FlattenPrims.gif (990.6 KB)
vu_FlattenPrims.hiplc (125.9 KB)

User Avatar
Member
14 posts
Joined: 12月 2018
Offline
You're genius !! Thank you so much !! Problem solved
Nikos Priniotakis
Heritage, visualisation and 3D modeling
Cergy Paris University
User Avatar
Member
2 posts
Joined: 6月 2020
Offline
This worked great for me flattening the tops of OSM buildings, i projected the data onto my heightfield and needed to straighten the roofs, @Vusta's example worked fantastic, thanks for sharing your knowledge!
User Avatar
Member
11 posts
Joined: 9月 2017
Offline
This was suuuuper helpful, thanks. I am not a programmer though and was wondering how I would do the same operation for the other axis' like for each side of a box? The code in the file provided works only for top and bottom. Thanks in advance!


Specifically, its this:

set(self.x,lerp(self,@opinput1_P,ch('amount')).y,self.z)

Im not sure how to make this work for other axis. I was hoping it was as easy as swapping the xyz location but its not, lol


edited: nvm I figured it out it was as easy as swapping

set(lerp(self,@opinput1_P,ch('amount')).x,self.y,self.z)

set(self.x,lerp(self,@opinput1_P,ch('amount')).y,self.z)

and

set(self.x,lerp(self,@opinput1_P,ch('amount')).y,self.z)
Edited by Thunderflex - 2023年5月3日 21:46:06
  • Quick Links