Page 1 of 1

How to get the Center of an image? [possible BUG?] [Images]

Posted: Fri Mar 31, 2017 11:27 am
by JesusR
I am having issues with placing images attached to a body and I suspect this can be a bug of the editor:

Lets say I have this body which represents a car:

Image

The position of the body is: 0.662346, 1.01895

If I set the cursor there --> setCursor(0.662346, 1.01895);

The cursor is placed properly:

Image

Now have an image attached to that body. See it here:

Image


I want to know where is the center of that image relative to the origin of coordinates!

Obviously, it is not the property center whose value is: 0.664493, -0.819155

If I place the cursor in that point:
setCursor(0.664493, -0.819155);

Image

It is not the center of the image, obviously. I can see that maybe, the center of the image is RELATIVE to the position of the body the image is attached to. Let's try, I place the cursor in the body position + the center of the image:
setCursor(0.662346+0.664493, 1.01895-0.819155);

Image

IT IS NOT THE CENTER OF THE IMAGE NEITHER!

This smells like a bug to me... I am using R.U.B.E for osx version 1.7.4 (paid version ofc).

Re: How to get the Center of an image? [possible BUG?] [Imag

Posted: Fri Mar 31, 2017 4:24 pm
by JesusR
Ok, I have realized that the center of the image is relative to the body position and ROTATION.

The trick is to rotate the center of the image(point) as much as the body is rotated having as pivot the body position of the car.

Fuck, it wasn't that obvious :ugeek:

Re: How to get the Center of an image? [possible BUG?] [Imag

Posted: Sat Apr 01, 2017 12:31 pm
by iforce2d
Yes, images attached to a body need to be rotated and moved when the body moves. If you want to make manual changes like setting position coordinates directly, it will really help to set the angle of the body to zero first :)

By the way, you can set the position of the cursor to the current selection with the keyboard shortcut C, S (cursor to selection).
You can also open a dialog to manually set the position with the keyboard shortcut C, C. Keep the context help panel open to see all the keyboard options you have available at any given time.

Re: How to get the Center of an image? [possible BUG?] [Imag

Posted: Sat Apr 01, 2017 10:42 pm
by JesusR
Thanks for the tips! I didn't know about the shortcuts, they are really handy.

Is there a full documentation I can read with all those tips?

Re: How to get the Center of an image? [possible BUG?] [Imag

Posted: Mon Apr 03, 2017 11:01 pm
by iforce2d
Well, the built-in help (open with F1 key) is the full documentation.
For example about the cursor, see the topic "Editing items" -> "The cursor".
You can also search for topics under the Search tab.