List
MAXST & Billboard scripts
Posted Date: 2020-02-07 9:06     Edited Date: 2020-02-11 2:08     Writer: martin.haintz

Hey,

We are using MAXST ImageTracker feature in our team now for almost a year in our Android and iOS application and are very happy with it. However, we experienced a strange behavior in connection with Billboard scripts.
I have read a lot of forum articles and also had a look into how quaternions are working in the last week, but wasn't able to find the cause for these problems and neither find a way to fix it.

These are the things i have problems with.

1) Result in editor and on device is different(90° rotation on devices)
2) Lock axis(preferable Z axis but also X or Y axis, or a combination of all axis)
3) Consider the parents and the initial rotation of the gameobject.

We are using:
Unity 2018.4.6f1
MAXST 4.1.4

#Prerequisite
Make a new Unity Project and download the MAXST 4.1.4 framework. Register and get a free serialnumber for image tracking with a maxst watermark.
Import the unitypackage, set the package name to the name you chose on the maxst website.
Open the ImageTracker scene from the examples, select the ar camera gameobject, go to config in the inspector and insert your serial number.
Exchange the child object of the first ImageTrackable with the Billboard prefab and the second ImageTrackable with the BillboardRotated prefab. You can find both unity packages for the prefabs here: https://forum.unity.com/threads/maxst-billboard-scripts.823215/
In these prefab, i have a collection of different billboard scripts i found on the web. 3 of them are from the Unity Wiki and one is from the Microsoft MixedRealityToolkit and one mixed from an forum post.

1) If we have a look at the Billboard Prefab in play mode in the editor everything looks like this. UnityEditor.png
This is what we expected to see. The object is following the orientation of the camera and you can read the text from every angle.
Lets deploy it on an android device and see whats happening.

Screenshot_20200205-184157_MaxstTest[1].jpg

Not what we expect. Everything is rotated by 90° at the Z axis. Although we have portrait mode in the editor and in the app.
The thing what i came up with was, checking if the app is running in the editor or not and if not, adding an offset of 90 degree's on the Z axis, with this code at the and of every billboard script.

transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x,

        transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z + 90);



I don't think this is the right way to solve this behavior. I would prefer to find the cause, because i think this is also the reason for the other problems.

How can i achieve to react it the same in editor and on the device?

2) As you found out, the billboards are following the camera movement and this also means, if i am rotating the phone on the Z axis, the billboards follow. In my case the billboards should only rotate on the X and Y axis and shouldn't rotate on their Z axis.
If we have a look at the MixedRealityToolkit Billboard script(Billboard.cs), we see the option to select "Pivot Axis" if we choose "XY", so the Z axis should be locked.
If we set it that way nothing happens. It rotates on every axis as before where it was on "free", although it should only rotate on the X and Y axis...

What am i doing wrong? Why isn't it working? Or should i extend one of the other billboard scripts with a couple of extra lines of code?


3) Lets change to the other prefab "BillboardRotated"...
Assume, that i have a big 3D model right under the "ImageTrackable" gameobject with a big hierarchy and a lot of rotated objects in it. Somewhere in the 5th or more level from the top hierarchy, where al parents have some sort of rotation in any axis, i have an element where i want to use the billboard script. Also i have an initial rotation on the element for some reason. Here i want to use the option to lock the Z axis and X axis, so it only rotates on the Y axis, without overwriting the initial rotation.

Sorry for the long post, i hope everything is clear.

Would be great if you could help me.

Thanks in advance, Martin.

 

1. SDK Version: 4.1.4
2. Development Environment: Unity-Android
3. Tracker/Scanner: ImageTracker
4. License Type: Pro-One Time Fee
5. Target Device(Optional): Samsung Galaxy S8 (Android 9 / latest Android)

Posted Date: 2020-02-11 2:08     Edited Date: 2020-02-11 2:08     Writer: inactive

You should know this first. When you import this project with a billboard prefab obtained from the web, you try to find a problem in our SDK with the belief that the billboard prefab will always work correctly. But the opposite is true. Billboards should always look towards the camera, depending on the angle the camera is looking at. This means that billboards are camera dependent. To understand why the billboard prefab does not normally look at the camera, we need to analyze the billboard prefab and the script so that it works with our camera.
Also, this is not a problem created by our SDK, and it would be correct to get advice on billboards from the Unity community.
I can't analyze the code with the prefab you uploaded. Because it is not code included in our SDK. However, I would like to read your situation and briefly advise you.

1) Rotate 90 Degrees See how your billboard script works. Check out our Unity coordinate system and how the AR Camera looks, then analyze the billboard script to see why it rotates 90 degrees. It is not our role to analyze the billboard scripts you import.

2) Item 2 also has confidence in the billboard script that the target you want does not follow the camera. Again, the camera is the main character and the billboard script needs to move with the camera. Doubt the billboard why the billboard does not follow the camera. And one piece of advice, typically, is to move the object up and down on the xy plane to the z-axis. However, our camera is set up as if the camera is looking down at the object from the top down so that the object is down on the xz plane and then the y-axis is moved up and down.

I was thinking about it while I was writing, and I used to implement a billboard. At that time, the script was very simple.

public Transform target;
void Update () {
    // Rotate the camera every frame so it keeps looking at the target
    transform.LookAt (target);
}

Just use this function to set the object you want to view as a camera, and the billboard will be very simple. Please apply once.

Thank you.

 

Leo

Maxst Support Team