示例#1
0
    /// <summary>
    /// Update the DataHandler data for the continuous CoP and CoM tracking
    /// </summary>
    /// <param name="posn"></param>
    private void UpdateContinuousData(Vector2 posn)
    {
        // The current color of the target
        Target.posnIndicator curColor = targets[targetIndex].indication;
        float delta = Time.deltaTime;

        // Add the time that the user spent in the current target color
        if (curColor == Target.posnIndicator.GREEN)
        {
            curGreenTime = curGreenTime + delta;
        }
        else if (curColor == Target.posnIndicator.YELLOW)
        {
            curYellowTime = curYellowTime + delta;
        }
        else
        {
            curRedTime = curRedTime + delta;
        }

        // Divide by 100 to convert from cm/s to m/s
        CoPVelocity = new Vector2((posn.x - previousCoP.x) / delta, (posn.y - previousCoP.y) / delta) / 100f;

        previousCoP = posn;

        // Record the continuous data like CoP and CoM
        if (OnRecordContinuousData != null)
        {
            // note: convert target index to a one-indexed value for data recording
            OnRecordContinuousData(participantId, time, posn,
                                   curColor, pelvisTracker.transform.position, targetIndex + 1, curTrial, CoPVelocity);
        }
    }
        public readonly Vector2 CoPVelocity;           // current Velocity of the CoP

        public ContinuousData(string participantId, float time, Vector2 CoPposition, Target.posnIndicator curColor,
                              Vector3 CoMposition, int targetNum, int trialNum, Vector2 CoPVelocity)
        {
            this.participantId = participantId;
            this.time          = time;
            this.CoPposition   = CoPposition;
            this.curColor      = curColor;
            this.CoMposition   = CoMposition;
            this.targetNum     = targetNum;
            this.trialNum      = trialNum;
            this.CoPVelocity   = CoPVelocity;
        }
示例#3
0
    /// <summary>
    /// Sets the appropriate target's indication to the given color, and assigns the appropriate
    /// material to the target GameObject.
    /// </summary>
    /// <param name="indication">The color that the target should be.</param>
    private void setColor(Target.posnIndicator indication)
    {
        targets[targetIndex].indication = indication;

        switch (indication)
        {
        case Target.posnIndicator.GREEN:
            rend.material = greenMat;
            break;

        case Target.posnIndicator.YELLOW:
            rend.material = yellowMat;
            break;

        default:
            rend.material = redMat;
            break;
        }
    }
 // Records the continuous data like CoP and CoM to the list of data
 private void recordContinuousTrial(string participantId, float time, Vector2 CoPposition, Target.posnIndicator curColor,
                                    Vector3 CoMposition, int targetNum, int trialNum, Vector2 CoPVelocity)
 {
     continuousData.Add(new ContinuousData(participantId, time, CoPposition, curColor, CoMposition, targetNum, trialNum, CoPVelocity));
 }