Пример #1
0
    // Update is called once per frame
    void Update()
    {
        mean_position = mean_position + new Vector3(0.01f, 0, 0);
        mean_euler    = mean_euler + new Vector3(0.05f, 0, 0);

        float random_magnitude = Random.value * seed_magnitude;

        float   noise_euler  = 2 * random_magnitude;
        Vector3 noised_euler = mean_euler + new Vector3(Random.value * noise_euler, Random.value * noise_euler, Random.value * noise_euler);

        float   noise_position  = 0.1f * random_magnitude;
        Vector3 noised_position = mean_position + new Vector3(Random.value * noise_position, Random.value * noise_position, Random.value * noise_position);


        Quaternion rotation = Quaternion.Euler(noised_euler);
        Vector3    position = noised_position;

        if (bUseSmoother)
        {
            tPoseSmoother.UpdatePose(ref rotation, ref position, random_magnitude);
        }

        this.transform.localRotation = rotation;
        this.transform.localPosition = position;
    }
Пример #2
0
    void MessageCallback(string message)
    {
        float[] matrix = new float[16];
        matrix = GetFloatArrayFromJson(message);

        count = count + 1;

        if (!initCameraPose.ReceivePoseFromServer(matrix))
        {
            txt.text   = count + "[LOST]";
            is_waiting = false;
            return;
        }

        Quaternion rotation = initCameraPose.convertMatrixRelative.GetQuaternion();
        Vector3    position = initCameraPose.convertMatrixRelative.GetPosition();

        tPoseSmoother.UpdatePose(ref rotation, ref position, 1.0f);

        cameraParent.transform.localRotation = rotation;
        cameraParent.transform.localPosition = position;

        txt.text       = count + " [SUCCESS]";
        is_waiting     = false;
        bHaveLocalized = true;
    }