"looking At" node with a camera!

hello,

I found the “looking At” node and I use it with a camera!

But, I have to apply the trait on an empty as parent of cam. And fix the camera rotation with (90,0,-90).

It’s very wierd we can’t use “looking At” directly with a camera!?
Why do you use it?

You can apply it to the camera, but the problem is that the LookAt node works strange by itself.
LookAt.blend (107.4 KB)

TL;DR: The “strangeness” comes from the conversion between euler angles and quaternions. In the node you see (x,y,z) to represent the rotation but internally is using (a,b,c,d) to perform the calculations because is more convenient and is not affected by issues like gimbal lock. But this has a problem, the conversion back from (a,b,c,d) to (x,y,z) has multiple results (or representations), and is complicated to guess what was the result the user expected.


When you want to rotate something there is a conversion from the input of the user (x,y,z)(Euler angles) to (a,b,c,d)(Quaternion). After converting to (a,b,c,d) the calculations are done to perform the rotation and then the result is converted back to (x,y,z) for the user to see.

The problem comes when converting back from (a,b,c,d) to (x,y,z): There are multiple representation for (a,b,c,d) in (x,y,z), that is the result you expected and the result you got.

You can obtain both internally but the problem is guessing what was the result the user expected.

Some stuff can be done to aid this issue but they are not perfect and still break, you can test this yourself in more mature engines that rotation using (x,y,z) in multiple angles can break too!

So it’s a presentation vs usability problem. The rotation nodes and the Transform could be modified to instead of using (x,y,z) uses (a,b,c,d) directly and the problem would be gone, but you will loose the “convenience” of (x,y,z).
Some engines prefer simply to encourage using quaternion instead of (x,y,z) to solve the issue.

A solution would be, modifying the lookAt node to return a value of (a,b,c,d), skipping the conversion, and then the Transform node could be changed to receive (a,b,c,d) instead of (x,y,z) and that would solve the issue I think. The problem is if the user has no issue not seeing (x,y,z) anywhere.

I will try later to post here some modified version of the nodes to test it.

Hello,
I am no programer but I’ve been working on my own “Track to” Node for a while ( which is kinda similar ).

This forum helped me to figure how to proceed but the problem I found is that the " fromEuler " function converts Quaternion from YZX Euler ( which Gimbal Lock on the Y axis) , instead of XYZ Euler ( which Gimbal Lock on the Z axis).

As a test I wanted to create my own node with the XYZ Euler to Quaternion conversion.
I based my node on the “Track to” Actuator from BGE which I’m use to.
TracktoNodeExample
Edit:
I upload the Node to whoever want to try it.

The Node definition ( it’s a python file, just remove the “.hx” extention to make it work ):
track_to_test.py.hx (1.4 KB)

The Node Itself:
TrackToTestNode.hx (6.6 KB)

There, I hope it could help somebody.
Again I’m no programmer so the code might be messy.

2 Likes

Thank you for this! Just the thing I was looking for.
One question… noob here… what process do I do to get it into Armory3D?
So sorry for the dumb question.
M

I was following this, but am having trouble getting it to work.


Is there a different process?

Hi

Wiki:

Example:

Developed custom nodes (can be seen as an example):
http://www.dzynek.pl/for-developers/armory3d
(Openurl - logic node (browser only)
Update Tween Nodes for Armory3D - Move, Scale, Rotate Euler and Quat, Float)

Hi Morbott,
I made this node some time ago and I think it doesnt work anymore
Here’s the last update of the node:

The Node Definition: ( it’s a python file, just remove the “.hx” extention to make it work ):
track_to.py.hx (1.4 KB)
Put it in the following folder : ArmorySDK/armory/blender/arm/logicnode/

The Node Itself:
TrackToNode.hx (8.6 KB)
Put it in the following folder : ArmorySDK/armory/Sources/armory/logicnode/

You can place those files in the folders I indicated you with the rest of armory official nodes ( This is the method I use ).
Or you can follow the armory example above to add this node as a custom node.
Both method should work.

I hope you’ll have fun with it.

Hi Hikibob,
Thanks for the update. I think I’m still having issues.
When I put track_to.py into Libraries/trackto/
and
TrackToNode.hx into Libraries\trackto\Sources\armory\logicnode
It doesn’t show up under Action, in the node list.
From what I understood from this page:


… the .py file should be named blender.py
When I change track_to.py to blender.py… no nodes show in Blender…none.
I’m sorry, I wish this process was a little cleaner to do. Do you know what I might be doing wrong?
I tried this in v2.83 and v2.9
Thanks
M

I think I fixed it!!!
The .py file should be named blender.py, and this is how it should look on the inside:

I changed the first 3 lines.
Then changed line 6 so it matches the convention of TrackToNode with no spaces. Not sure if this helped.
lastly I changed the ending, lines 47 48 and 49.

P.S. Just tested it out in an actual file. IT WORKS!!!
Thank you Hikibob for this.
:slight_smile:

Hi Morbott,
I’m glad you managed to make it work.

I’m sorry, as I made this node mainly for myself, I didn’t check if it was working as “custom node”. I just put it in the armory official nodes folder with all the other nodes, bad habit…

Thanks for the fix :slight_smile:

You can do that? How? Where?
It would be great if there was a way to make it a global custom node, separate from all the ones Armory provides. Therefore, less chance of muddying the waters, I guess.
M