Itoo Software Forum

Author Topic: scatter objects and align rotation by color map  (Read 416 times)

in3des

  • Full Member
  • ***
  • Posts: 100
scatter objects and align rotation by color map
« on: October 06, 2020, 06:36:10 PM »
Hi,
I'm trying to scatter roof stuff on top of the buildings using forest.
created rotation color map, it works somehow - but still objects not following desired direction.
screen_496 - UVs for roof
screen_500 - how I want all objects to be directed

Could you please help with the correct color map for this case?

Thanks!

Rokas

  • iToo Software
  • Hero Member
  • *****
  • Posts: 3134
    • iToo
Re: scatter objects and align rotation by color map
« Reply #1 on: October 07, 2020, 08:42:59 AM »
Hi. Thanks for the question.

You can use this Slope Angle Face Towards effect:
Code: [Select]
vector v = fpItem.surfnormal;
real angle = atan2(v.y,v.x)-degtoRad(Angle1);
fpItem.rotation.z = angle+fpItem.rotation.z;
fpItem.surfDirection = 100;

Full scene attached for Your reference. I have used reference mode and placed items on their pivots. Effect aligned them to face away from roof.


Hope this helps.
Rokas
iToo Software

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #2 on: October 07, 2020, 09:38:03 AM »
Hi, Rokas!
Thanks for reply.
The thing is - I have all roof absolutely flat (forgot to attach perspective view).
Is there any solution in this case?

PS. cannot open your example because my max version is 2018.

Thx!

Rokas

  • iToo Software
  • Hero Member
  • *****
  • Posts: 3134
    • iToo
Re: scatter objects and align rotation by color map
« Reply #3 on: October 07, 2020, 01:02:14 PM »
In that case use Surface- UV mode and Align feature:
Rokas
iToo Software

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #4 on: October 07, 2020, 02:23:26 PM »
Cool! Thanks a lot, Rokas!
That works for me  :)
One more thing - is there any way to combine my custom distribution map + default scattered?  So boxes populated not on every roof but with some randomness?
Thx

P.S. and I forgot how to avoid objects being scattered too close to the surface edge. Thx

Rokas

  • iToo Software
  • Hero Member
  • *****
  • Posts: 3134
    • iToo
Re: scatter objects and align rotation by color map
« Reply #5 on: October 07, 2020, 02:38:43 PM »
That is now controlled by Your UVs. Move UV ilands to (re-)move items.
Rokas
iToo Software

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #6 on: October 07, 2020, 02:44:36 PM »
Ok, I see...
Any way to select random objects in 'Custom Edit' mode? So I could delete those manually.

Rokas

  • iToo Software
  • Hero Member
  • *****
  • Posts: 3134
    • iToo
Re: scatter objects and align rotation by color map
« Reply #7 on: October 07, 2020, 02:59:26 PM »
Not really built in,  You can use this scripts Limit to feature.
Rokas
iToo Software

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #8 on: October 07, 2020, 03:15:33 PM »
Thanks!
Will give it a try

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #9 on: October 08, 2020, 07:12:27 PM »
Hi,
Limit works fine!
Got another issue - if I want to scatter 2 types of objects then it scatters only object #2 in UV align mode... object #1 is missing
Any walkaround for this?
Thx

Rokas

  • iToo Software
  • Hero Member
  • *****
  • Posts: 3134
    • iToo
Re: scatter objects and align rotation by color map
« Reply #10 on: October 09, 2020, 08:17:37 AM »
That is UV mode in effect. They are in the same UV position, so they get the same element scattered.

You can run this command while FP is in custom edit mode to randomly assign geometry items:

Code: [Select]
(for i = 0 to ($.trees.count()-1) do $.trees.setGeomID i (random 1 $.cobjlist.count) ; $.trees.update())

Rokas
iToo Software

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #11 on: October 09, 2020, 09:05:57 AM »
Thank you, Rokas!!!  :)

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #12 on: October 09, 2020, 01:21:55 PM »
In that case use Surface- UV mode and Align feature:


Hi, Rokas.
Another one tiny thing...
can we combine UV align + stepped rotation?
looks like it doesn't work in UV mode (actually it works, but breaks UV alignment)

Rokas

  • iToo Software
  • Hero Member
  • *****
  • Posts: 3134
    • iToo
Re: scatter objects and align rotation by color map
« Reply #13 on: October 09, 2020, 03:17:18 PM »
once again UV mode controls distribution and rotation as well.

You can once again override it in custom edit mode:
Code: [Select]
(step= 90 ; for i=0 to ($.trees.count()-1) do $.trees.setRotation i [0,0,(($.trees.getRotation i)[3]+ pi/180*step*(random 0 360/step))] ;$.trees.update())
Rokas
iToo Software

in3des

  • Full Member
  • ***
  • Posts: 100
Re: scatter objects and align rotation by color map
« Reply #14 on: October 09, 2020, 03:49:39 PM »
Thank you!
Works like a charm! ))