Move selected Bodies to cursor position.

Let us know if you have a nice R.U.B.E script to share!
Post Reply
dAlex65
Posts: 16
Joined: Tue Feb 19, 2013 8:55 am

Move selected Bodies to cursor position.

Post by dAlex65 » Tue Mar 05, 2013 1:42 pm

See the title ;)
Attachments
postoCursor.zip
(644 Bytes) Downloaded 929 times

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: Move selected Bodies to cursor position.

Post by iforce2d » Tue Mar 05, 2013 2:45 pm

aha... there is something in Blender a bit like this, I think it's called 'Selection to cursor', so it's the reverse of the 'Cursor to selection'.

I was thinking of adding it someday, but in Blender it moves the selection as a whole to the cursor. In RUBE the selection is the white cross shown when more than one item is selected. So 'Selection to cursor' would move all the bodies so that the white cross moves to the cursor, which I think is a bit more useful than clumping all selected bodies at the same place. The white cross is simply the average of the currently selected body positions. I will add this eventually, but if you feel like doing it don't let me stop you :D

dAlex65
Posts: 16
Joined: Tue Feb 19, 2013 8:55 am

Re: Move selected Bodies to cursor position.

Post by dAlex65 » Thu Apr 11, 2013 2:53 pm

Align one axis. Use cursor position too, but adjust Y or X, and move selected bodies to horizontal or vertical line.

Code: Select all

vec2 pb = getCursor();
body[] sb = getSelectedBodies();

int n = sb.length;
for (int i = 0; i < n; i++) {
  sb[i].setPos(pb.x, sb[i].pos.y);
}

Code: Select all

vec2 pb = getCursor();
body[] sb = getSelectedBodies();

int n = sb.length;
for (int i = 0; i < n; i++) {
  sb[i].setPos(sb[i].pos.x, pb.y);
}

Post Reply