question

Jason Botha avatar image
0 Likes"
Jason Botha asked Jason Botha commented

Why does my object move when i set the size

moving-ore-face.fsmHi there,

I ran into something interesting and i cant figure out why it is happening.

I have a queue on a plane and i want to be able to increase the size of the plane to move the queue further away as the model runs so the operators will need to walk further.

However when i use the setSize ( current.up.as(Object).setSize(current.up.as(Object).size.x +2,6,1); ) method the object shifts its location, but only if the object in at an angle > 0.

Does anyone know why this is happening and more importantly how to stop it?

I have attached a small model (i set the size in the red process flow block)

size and shape factors
moving-ore-face.fsm (29.8 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ralf Gruber avatar image Ralf Gruber ♦ commented ·

Jason,

I do not exactly know, why the plane shifts in x-direction, but it remains at the same y-coordinate. However, this is caused by the centroid node within the spatial node set to 1. This sets the plane's coordinate system's origin to its center. If you set the centroid node to 0, you will see the origin move to the upper left corner of the plan...and the shifting stops.

@phil.bobo: Can you please look at this?

Good luck

Ralf

0 Likes 0 ·
Jason Botha avatar image Jason Botha Ralf Gruber ♦ commented ·

Thanks Ralf.

0 Likes 0 ·

1 Answer

Phil BoBo avatar image
3 Likes"
Phil BoBo answered Jason Botha commented

The object's location is not shifting. The object's direct spatial location is {-1.0, -1.45, 0.0}. After resizing, that is still the object's direction spatial location.

The confusion comes as to what the object's "direct spatial location" means. That is the location of the upper left corner of the object before any rotations have been applied.

When you rotation an object, that position is still its direct spatial location, which you can see by selecting "Direct Spatials" as the reference point for the object's location.

As Ralf explained, this object rotates around its center position rather than its upper left corner location position. This makes it so that when you change the size, you change the center of rotation, which makes it so that actual direct spatial location of the object doesn't align with the upper left corner of the object.

In order to keep the object's upper left corner stable as you resize it, you also need to set its location relative to the corner you want to keep stable. You can do this by getting its location relative to the upper left corner, setting the size, and then setting its location back to its original position, relative to the upper left corner:

Object obj = current.up;
Vec3 referencePosition = Vec3(0, 0, 0);
Vec3 prevLoc = obj.getLocation(referencePosition);
obj.setSize(obj.size.x + 2, 6, 1);
obj.setLocation(prevLoc, referencePosition);

Another option could be to change the object so that its rotation is relative to its upper-left corner instead of its center by changing its centroid attribute to 0:


1.png (16.5 KiB)
2.png (32.0 KiB)
4.gif (842.7 KiB)
3.png (61.0 KiB)
5.gif (832.5 KiB)
6.png (14.1 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Botha avatar image Jason Botha commented ·

Thanks Phil,

That works perfectly.

0 Likes 0 ·