Exemplo n.º 1
0
    /// <summary>
    /// draw a specific person
    /// </summary>
    /// <param name="personIndex">the person to draw</param>
    /// <param name="state">the person state</param>
    void DrawPerson(uint personIndex, PlayerSelection.PersonIDState state)
    {
        OmekFramework.Common.BasicTypes.SpaceTypes.Vector3 personPositionFrmk;
        BeckonData.Persons[personIndex].CenterOfMass3D.Get(out personPositionFrmk);
        Vector3 personPosition     = UnityConverter.ToUnity(personPositionFrmk);
        Vector2 screenPosition     = WorldToScreenProjection(personPosition);
        int     playerRectHalfSize = m_personRectSize / 2;

        if (UnityPlayerColorThemes.Instance != null)
        {
            GUI.color = UnityPlayerColorThemes.Instance.GetPlayerColorTheme((int)personIndex).m_radar;
        }
        else
        {
            GUI.color = BeckonManager.BeckonInstance.PersonProperties.GetPropertyOfPerson <Color32>(personIndex, m_radarColors, UnityPlayerManagement.IndexingScheme);
        }
        Rect playerRect = new Rect(screenPosition.x - playerRectHalfSize, screenPosition.y - playerRectHalfSize, m_personRectSize, m_personRectSize);

        if (m_personTexture != null)
        {
            GUI.DrawTexture(playerRect, m_personTexture, ScaleMode.ScaleToFit, true);
        }
        else
        {
            GUI.Label(playerRect, "", m_playerRectStyle);
        }
    }
Exemplo n.º 2
0
    private Vector3 ConstrainPosition(OmekFramework.Common.BasicTypes.SpaceTypes.Vector3 pointerPosition)
    {
        Vector2 unityCurPosition    = UnityConverter.ToUnity(pointerPosition);
        Vector2 constrainedPosition = new Vector2(m_relativeActiveScreenArea.x + Mathf.Clamp01(unityCurPosition.x) * m_relativeActiveScreenArea.width,
                                                  m_relativeActiveScreenArea.y + Mathf.Clamp01(unityCurPosition.y) * m_relativeActiveScreenArea.height);

        return(constrainedPosition);
    }
Exemplo n.º 3
0
    public void OnDrawGizmosSelected()
    {
        if (!enabled || !Application.isPlaying)
        {
            return;
        }

        // find who has most pointers
        int maxPointerHolder = GetMaxPointerHolder();

        if (maxPointerHolder == -1)
        {
            return;
        }

        Gizmos.color = Color.blue;
        foreach (Omek.JointID joint in
                 System.Enum.GetValues(typeof(Omek.JointID)))
        {
            if (joint == Omek.JointID.unknown)
            {
                continue;
            }
            Omek.JointID commonJoint = (Omek.JointID)joint;

            OmekFramework.Common.BasicTypes.SpaceTypes.Vector3 frameworkPos;
            OmekFramework.Common.BasicTypes.ReturnCode         rc = BeckonData.Persons[(uint)maxPointerHolder].Skeleton[commonJoint].Position.World.Get(out frameworkPos);
            if (!rc.IsError())
            {
                frameworkPos.x = -frameworkPos.x;
                //Debug.Log(joint + " pos = " + jointPos);
                Gizmos.DrawSphere(transform.position + UnityConverter.ToUnitySpace(frameworkPos) * 0.01f, 0.05f);
            }
        }

        foreach (PointerData pd in m_currentPointers)
        {
            if (pd.m_personID != maxPointerHolder || pd.m_pointer == null)
            {
                continue;
            }

            Vector3 boxCenter = UnityConverter.ToUnitySpace(pd.m_pointer.ActualMovementBox.CenterOffset) * 0.01f;
            boxCenter.x  = -boxCenter.x;
            boxCenter   += transform.position;
            Gizmos.color = Color.red;
            Gizmos.DrawWireCube(boxCenter, UnityConverter.ToUnity(pd.m_pointer.ActualMovementBox.Dimensions) * 0.01f);

            Gizmos.color = Color.green;
            Vector3 jointPosition = UnityConverter.ToUnitySpace(pd.m_pointer.NoiseReduceJointPosition) * 0.01f;
            jointPosition.x = -jointPosition.x;
            Gizmos.DrawSphere(transform.position + jointPosition, 0.05f);
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// Center the world box so the CurrentValue will be at targetPosition
    /// </summary>
    /// <param name="targetPosition">the wanted position for CurrentValue, must be inside TargetBox</param>
    /// <param name="smoothChange">should the change in position be smoothed or should it happen abruptly</param>
    /// <returns>Return code that represent the status of the run</returns>
    public bool RecenterOnTargetPosition(UnityEngine.Vector3 targetPosition, bool smoothChange = true)
    {
        ReturnCode rc = m_transformer.RecenterOnTargetPosition(UnityConverter.ToFramework(targetPosition), smoothChange);

        if (!rc.IsError())
        {
            WorldBox.CenterOffset  = UnityConverter.ToUnity(m_transformer.WorldBox.CenterOffset);
            WorldBox.Dimensions    = UnityConverter.ToUnity(m_transformer.WorldBox.Dimensions);
            TargetBox.CenterOffset = UnityConverter.ToUnity(m_transformer.TargetBox.CenterOffset);
            TargetBox.Dimensions   = UnityConverter.ToUnity(m_transformer.TargetBox.Dimensions);
            return(true);
        }
        else
        {
            Debug.LogError(rc);
            return(false);
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Center the world box so the current position will be the center of the new box
    /// </summary>
    /// <param name="updateTargetBox">should the TargetBox be updated accordingly so the CurrentValue will stay in place</param>
    /// <param name="smoothChange">should the change in position be smoothed or should it happen abruptly</param>
    /// <returns>Return code that represent the status of the run</returns>
    public bool RecenterOnWorldPosition(bool updateTargetBox, bool smoothChange)
    {
        ReturnCode rc = m_transformer.RecenterOnWorldPosition(updateTargetBox, smoothChange);

        if (!rc.IsError())
        {
            WorldBox.CenterOffset  = UnityConverter.ToUnity(m_transformer.WorldBox.CenterOffset);
            WorldBox.Dimensions    = UnityConverter.ToUnity(m_transformer.WorldBox.Dimensions);
            TargetBox.CenterOffset = UnityConverter.ToUnity(m_transformer.TargetBox.CenterOffset);
            TargetBox.Dimensions   = UnityConverter.ToUnity(m_transformer.TargetBox.Dimensions);
            return(true);
        }
        else
        {
            Debug.LogError(rc);
            return(false);
        }
    }
Exemplo n.º 6
0
 /// <summary>
 /// Constructor from a framework movement box
 /// </summary>
 /// <param name="movementBox">Framework movement box</param>
 public MovementBox(OmekFramework.Common.BasicTypes.MovementBox movementBox)
 {
     CenterOffset = UnityConverter.ToUnity(movementBox.CenterOffset);
     Dimensions   = UnityConverter.ToUnity(movementBox.Dimensions);
 }