Rotate transform about arbitrary point.

Before I get into what exactly I’m having trouble with I’ll give a little context to what kind of system I’m trying to create.
The basic idea is to create a system that can attach two objects to each other via predefined “points” on each object. This operation would be looped any number of times with the first object to be placed being the “parent” or “base” that will have a child/s attached to it, then the now attached child becomes the parent and the cycle continues…
NOTE, I am working with instanced static meshes so the “parent the mesh to a dummy component” solution won’t work. Everything will have to be done purely mathematically.

This is the basic idea of what I’m ultimately intending to do, obviously there is a ton of other logic to be built before anything useful can be constructed. (although I have a lot of that done already lol).

So far, I’ve been able to get the “child” object into the correct location where the chosen points on both the “child” and “parent” are in the same location, as you can see here:


I’ve also stored the transforms for the point on the parent, child, and the child object’s origin as I know I’ll need all three.

The part that I’m struggling with has to with the math portion. More specifically the rotation of a transform about an arbitrary point. (not sure if the term “transform” is correct here but hopefully you get what I mean)

Important thing to note is that the “points” I mentioned earlier are mesh sockets. I’m using sockets as they contain their own transform data not just location and this will be important as the object being attached to the proverbial “base” or “parent” will need to align itself something like this:


All sockets will always have their Z-axis pointing away from the surface of the object. This is intended to be used to align the “child” to the “parent”

Honestly, I’ve been at this for the better part of a month and the deeper I dove into it the more I ran into mathematical concepts that are frankly beyond me (matrix math, quaternions).
Any help at this point would be greatly appreciated.

Sounds interesting… I think I need some clarification… what is rotating around what exactly? I read your post a few times but I think I’m a little slow :slight_smile:

I think it’s just the normal of the socket on the parent, no?

norm

1 Like

@mmmmGoodDinner

I’ll try to be more specific.

What I’m trying to do is rotate a transform (the child objects origin/pivot) about an arbitrary point of my choosing, in this case it’s the location of the parent socket




Keep in mind that I’m dealing with instances, so the sockets themselves are only there to indicate where an object will connect to another (as well as provide a common axis to use in aligning the child to the parent). They cannot be used like sockets would on a static mesh or skeletal mesh


Hers another illustration:

Note: normally the “Child” socket and the “Parent” socket would be in the same location.

I only pulled them apart to hopefully help illustrate my point.


@ClockworkOcean

Yes, that was the idea I had when I initially set up the socket orientations in 3DS Max.

This way I would be able to rotate the child objects transform about the parent socket such that the Parent & Child sockets had their Z-axis (normals) pointing towards each other thus indicating the correct alignment.

Again though I have to stress that this is all being done without any actual geometry being in the world and I’m working solely by rotating & translating transforms until I reach the desired orientation, then I can add an instance given the correct transform.

I’ve managed to get this far on my own:


This logic manages to translate the object into the correct position, as seen here:

However rotating it so that it aligns correctly is the part where I am struggling.


If it would help I can try recording a narrated video instead, or jump into the Unreal Slackers Discord and stream my screen.

I get what you mean. If you were connecting the child pivot at the hit point, then you could get the correct orientation using ‘get rot from AB’, where A is either X or Z and B is one of the others.

I know that’s a bit vague :slight_smile: but I don’t have time to experiment right now.

Then you have the added complication of attaching at the socket instead of the pivot. I think you can probably do that with a transform. The transform you need to get from the pivot to the socket.

I will come back tomorrow…

To clarify, you want to orbit the child mesh? (for lack of a better word?)

It looks like you are building a space-station and want to be able to have child-modules in their own mini-orbit around the torus of the main-body?

hi,
you want something like this ?



this will orbit around a given point even when moving… works in all axis…
in your case you may want to add LookRotation to your child rotator

hope this helps you :slight_smile:

cheers :vulcan_salute:

@Frenetic
Close but not exactly.
Conceptually what I’m trying to do is join pieces onto one and other. You could look at it like “stacking” blocks one on top of the other.

Where it gets more complicated (for me at least) is the fact that I have multiple points (sockets) on each mesh (parent & child) where one point will be selected from each mesh respectively and that will act as the joint where both meshes are connected.

On top of what I just mentioned I also need both meshes to be aligned correctly as well. I intend to accomplish this by using the +Z-axis of the chosen sockets which has been oriented to be pointing away from the object acting as a “normal”

This image here (which I used in a previous reply) is intended to illustrate how the sockets are oriented as well as what a correct alignment would be.
HOWEVER the two objects are pulled apart ONLY for the sake of illustration when in reality they would be joined with both sockets at the same location.


@AustrianMunzter
Thanks for the reply.

While the “Rotate vector around axis” function along with the “Look At Function” would indeed align the child objects transform to the parent socket that would not yield the result I am ultimately after.
What I am looking to do is align the Child socket’s transform to the Parent sockets transform, and in the process of aligning the child socket the origin/pivot of the child object would be rotated & translated as well.

The end result would look something like this where both objects have their objects have their chosen sockets overlapping with their +Z-axis pointing towards each other.


You can see the child objects pivot in that image isn’t actually aligned in the same fashion as its current orientation is simply a result of the alignment of the Child & Parent sockets.



Hopefully this helps clear things up a little more.

I am also open to hoping on a Discord call and sharing my screen as I feel like my text and imagery explanations are not very good and I would hate to be wasting peoples time unnecessarily.

So I made a NUTS mesh

image

As you can see, the pivot is at a weird angle in the middle of the mesh, and the socket is pointing up the arrow from the bottom.

If I use ‘rotfromX’, I get

image

because it’s putting the pivot point in the correct orientation.

But then I can then use the relative transform between the pivot and the socket, to correct

And now

rel trans