Example #1
0
    public BodyLandmarks GetBody(ActivityAvatar av)
    {
        BodyLandmarks body = null;

        switch (av)
        {
        case ActivityAvatar.Guide:
            body = this.AvatarGuide;
            break;

        case ActivityAvatar.Info:
            body = this.AvatarInfo;
            break;

        case ActivityAvatar.User:
            body = this.AvatarUser;
            break;

        default:
            throw new System.ArgumentException("Unknown avatar: " + av);
        }
        if (body == null)
        {
            throw new System.ArgumentException("Shared avatar not set: " + av);
        }
        return(body);
    }
Example #2
0
 public virtual ExcersizeActivityInst FindInstanceForBody(BodyLandmarks body)
 {
     foreach (var i in this.Instances)
     {
         if (i.Body == body)
         {
             return(i);
         }
     }
     return(null);
 }
Example #3
0
    public void EnsureSetup()
    {
        if (isSetup)
        {
            return;
        }
        isSetup = true;

        FieldOverallAlpha = 1.0f;
        ParticleFlowRate  = 1.0f;
        if (!this.Body)
        {
            this.Body = this.gameObject.GetComponentInParent <BodyLandmarks> ();
        }
        if (!this.Body)
        {
            if (!this.Hand)
            {
                this.Hand = this.gameObject.GetComponentInParent <MainEnergyApp> ();
            }
            this.ChiBall = this.gameObject.GetComponentInParent <ChiHandEnergyBall> ();
        }
        Debug.Assert((this.Body) || (this.Hand) || (this.ChiBall));
        if (!this.ExcersizeSystem)
        {
            this.ExcersizeSystem = GameObject.FindObjectOfType <ExcersizeSharedScheduler> ();
        }
        bool isMobile = (Application.platform == UnityEngine.RuntimePlatform.IPhonePlayer);
        int  sideRes  = (isMobile ? this.VoxelSideResMobile : this.VoxelSideRes);      // 8;

        if (this.Body)
        {
            this.Body.EnsureSetup();
            int chakraToShow = CurrentFocusChakra;             //3;
            this.FieldsCells = new VolumeBuffer <DynFieldCell> (Cubic <int> .CreateSame(sideRes));
            var scl  = OneOver(this.FieldsCells.Header.Size.AsVector3());
            var l2w  = this.transform.localToWorldMatrix;
            var cntr = Body.Chakras.AllChakras [chakraToShow].transform.position;            //  l2w.MultiplyPoint (Vector3.zero);
            foreach (var nd in this.FieldsCells.AllIndices3())
            {
                var cell = this.FieldsCells.Read(nd.AsCubic());
                cell.Pos = this.transform.localToWorldMatrix.MultiplyPoint(FieldsCells.Header.CubicToDecimalUnit(nd) - (Vector3.one * 0.5f));
                if (!(SkipRandomPlacement))
                {
                    cell.Pos += Scale(Random.insideUnitSphere, scl);                      // add random offset
                }
                cell.Direction   = cntr - cell.Pos;
                cell.LatestColor = Color.white;
                cell.Twist       = 0.0f;
                cell.VoxelIndex  = nd;
                this.FieldsCells.Write(nd.AsCubic(), cell);
            }
        }
        else if (this.Hand)
        {
            var arrows = this.Hand.FindAllFlowNodes();
            var n      = arrows.Count;
            this.IsStaticLayout = true;
            this.FieldsCells    = new VolumeBuffer <DynFieldCell> (Cubic <int> .Create(n, 1, 1));
            for (int i = 0; i < n; i++)
            {
                var cell  = this.FieldsCells.Array [i];
                var arrow = arrows [i];
                cell.Pos                   = arrow.transform.position;
                cell.Direction             = arrow.transform.up * 50.0f;
                cell.LatestColor           = Color.green;
                cell.Twist                 = 0.0f;
                cell.VoxelIndex            = new Int3(i, 0, 0);
                this.FieldsCells.Array [i] = cell;
            }
        }
        else if (this.ChiBall)
        {
            this.FieldsCells = new VolumeBuffer <DynFieldCell> (Cubic <int> .CreateSame(sideRes));
            var scl  = OneOver(this.FieldsCells.Header.Size.AsVector3());
            var cntr = this.ChiBall.transform.position;
            var l2w  = this.transform.localToWorldMatrix;
            foreach (var nd in this.FieldsCells.AllIndices3())
            {
                var cell = this.FieldsCells.Read(nd.AsCubic());
                cell.Pos = this.transform.localToWorldMatrix.MultiplyPoint(FieldsCells.Header.CubicToDecimalUnit(nd) - (Vector3.one * 0.5f));
                if (!(SkipRandomPlacement))
                {
                    cell.Pos += Scale(Random.insideUnitSphere, scl);                      // add random offset
                }
                cell.Direction   = cntr - cell.Pos;
                cell.LatestColor = Color.white;
                cell.Twist       = 0.0f;
                cell.VoxelIndex  = nd;
                this.FieldsCells.Write(nd.AsCubic(), cell);
            }
        }

        this.UpdateCellFieldDir(snapToCurrent: true);
    }