Using Unity

Set Android SDK paths

Platform switch, set API level, package name, etc.

Since the Ramanujan release, all of the Unity examples are included as Scenes in a single Unity Project.


Adding offset to Tango AR Camera (Eisa)

Background

Tango AR Camera prefab by default locates itself based on the world coordinate system of a Unity scene, where (0, 0, 0) is set to the initial pose of an active ADF or "start of service" (see Frames of Reference.) To gain more flexibility of the camera's position, you may directly edit TangoARPoseController.cs:

(TangoPrefabs/Scripts/TangoARPoseController.cs)
         ...
236    private void _UpdateTransformation(double timestamp) {
             ...   
280        // Apply final position and rotation.
281        transform.position = m_tangoPosition;
282        transform.rotation = m_tangoRotation;
283    }

where lines 281 to 282 define the position and rotation of the camera in a Unity scene, according to pose data provided by Tango service whenever a new pose is available.

Example: Using Offsets

This example modifies the camera's position and rotation with an offset that you may define. You can update the offset anytime so that the camera's coordinate system will move and rotate to your desired position and angles.

(TangoPrefabs/Scripts/TangoARPoseController.cs)
    ...
    public Vector3 positionOffset;
    public Quaternion rotationOffset;    
    ...
    private void _UpdateTransformation(double timestamp) {
        ...
        transform.position = positionOffset + m_tangoPosition;
        transform.rotation = rotationOffset * m_tangoRotation;
    }
Example: Using Transform

This example makes the camera's coordinate system follow a specified object in a Unity scene. You can move and rotate the specified object to adjust the camera's coordinate system.

(TangoPrefabs/Scripts/TangoARPoseController.cs)
    ...
    public Transform offset;
    ...
    private void _UpdateTransformation(double timestamp) {
        ...
        transform.position = offset.position + m_tangoPosition;
        transform.rotation = offset.rotation * m_tangoRotation;
    }
Example: Using Local Coordinate System

This example makes the camera's coordinate system follow its parent object in the Transform hierarchy in a Unity scene. You can move and rotate the parent object to adjust the camera's coordinate system.

(TangoPrefabs/Scripts/TangoARPoseController.cs)
    ...
    private void _UpdateTransformation(double timestamp) {
        ...
        transform.localPosition = m_tangoPosition;
        transform.localRotation = m_tangoRotation;
    }

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License