Jump to content

  • Log In with Google      Sign In   
  • Create Account

KamRandle

Member Since 14 Aug 2012
Offline Last Active May 25 2015 01:05 PM

Posts I've Made

In Topic: Rotating to Match The Rotation Of Something Else

21 May 2015 - 06:36 PM

*bump* :-D


In Topic: Rotating to Match The Rotation Of Something Else

18 May 2015 - 10:22 PM

 

It is hard to tell from your screenshots. Check the attachment points and your order of matrix concatination. Your code reads like this to me:

Tm1 = inv(Ta1_Translation) * Ta1_Rotation * Ta2 * Tm2 

So, what happens if you reverse the order in your code ?

FTransform NewTransform = OtherModule->GetTransform();
NewTransform *= OtherAttachmentPoint->GetRelativeTransform(); 
NewTransform *= ThisAttachmentPoint->GetRelativeTransform().GetRotation();
NewTransform *= FTransform(ThisAttachmentPoint->GetRelativeTransform().GetTranslation()).Inverse(); 
SetActorTransform(NewTransform); 


 

I just tried that and the module no longer matches up correctly.  They still only rotate correctly when the attachment point rotations are different and not exactly the opposite.  When they are exactly opposite, the module just rotates around and faces the direction the other attachment point is facing (the attachment point on the module that the new module is trying to connect to).


In Topic: Rotating to Match The Rotation Of Something Else

16 May 2015 - 08:55 AM

*bump* smile.png


In Topic: Rotating to Match The Rotation Of Something Else

12 May 2015 - 10:42 PM

 

I don't know UE4, so you need to map the transformation description to UE4 compatible code.

You must read this

Tm1  = Tm2 * Ta2 * Ta1_Rotation * inv(Ta1_Translation)

as
first invert the TA1 translation, then apply the TA1 rotation, afterwards the Ta2 transformation and eventually the TM2 transformation (in this order). Ensure that GetComponentLocation() delivers the (local) transformation relative to the module and not the location in worldspace. So your code looks correct at first glance.

 

When your objects (module/attachment) are in relation, then check if you can access the local/relative transformation. If you only have the worldspace transformation, then you can get the local transformation by doing this

Tm_world * Ta_local = Ta_world
<=>
Ta_local = inv(Tm_world) * Ta_world

 

Ashaman, you are absolutely awesome.  I almost have it working perfectly.  

FTransform NewTransform = FTransform(ThisAttachmentPoint->GetRelativeTransform().GetTranslation()).Inverse(); 
NewTransform *= ThisAttachmentPoint->GetRelativeTransform().GetRotation();
NewTransform *= OtherAttachmentPoint->GetRelativeTransform(); 
NewTransform *= OtherModule->GetTransform();
SetActorTransform(NewTransform); 

I am having one problem though.  When trying to connect two modules whose rotations are the exact opposite of each other, 'Tm1' ends up equaling 'Tm2'.  This is very odd.  It only does this on modules with exactly opposite rotations.  For example:

 

Correct:

Attaching Module 2 Attachment Point 2 (Yaw = -90) to Module 1 Attachment Point 1 (Yaw = 0) does this:

Untitled.png?dl=1

Incorrect:

Attaching Module 2 Attachment Point 3 (Yaw = -180) to Module 1 Attachment Point 1 (Yaw = 0) does this:

Untitled2.png?dl=1

Screenshot%202015-05-13%2000.27.38.png?d

 

What Attaching Module 2 Attachment Point 3 (Yaw = -180) to Module 1 Attachment Point 1 (Yaw = 0) should result in:

Screenshot%202015-05-13%2000.30.09.png?d

 

Any idea? Thanks! :-)


In Topic: Rotating to Match The Rotation Of Something Else

07 May 2015 - 02:27 PM

Hello Ashaman!  Thanks for the response.  Please forgive me but I thought I wrote the new code correctly but I am a little confused as to how this would translate into C++.  My transformation code now looks like this:

 

FTransform NewTransform = OtherModule->GetTransform() * OtherAttachmentPoint->GetComponentTransform() * FTransform(ThisAttachmentPoint->GetComponentRotation()) * FTransform(ThisAttachmentPoint->GetComponentLocation()).Inverse();

SetActorTransform(NewTransform);

 

 

Does this look correct?  I tried it out and it doesn't seem to be working.  Thanks man, I really appreciate it. :-)


PARTNERS