コード例 #1
0
    //To activate,

    void Awake()
    {
        //trackedObj = GetComponent<SteamVR_TrackedObject>();
        mBrainWaves        = new float[NumberOfWaves];
        mBrainWaveBaseline = new float[NumberOfWaves];
        for (int index = 0; index < NumberOfWaves; ++index)
        {
            mBrainWaves[index]        = 0.0f;
            mBrainWaveBaseline[index] = 0.0f;
        }
        mCurrentTarget    = null;
        mCurrentAttention = 0.0f;
    }
コード例 #2
0
    /****UTILITY METHODS****/

    //If the headset is currently pointing at an object that has a brain-affected script, return it.
    private BrainAffected CheckGrabObject()
    {
        //Then figure out what object is at the other end of that raytrace.
        RaycastHit aRaycastReturn;
        bool       hitAThing = Physics.Raycast(mCameraFacing.transform.position, mCameraFacing.transform.forward, out aRaycastReturn, mLaserVisibleDistance, brainAffectedLayer.value);

        if (!hitAThing)
        {
            return(null);
        }
        Debug.Log("Raycast hit!");
        //If the brain (or controller for now) is engaged, start affecting/moving the targeted object.
        if (aRaycastReturn.transform.gameObject != null)
        {
            Debug.Log("Raycast hit " + aRaycastReturn.transform.gameObject.name);
            Debug.DrawLine(mCameraFacing.transform.position, aRaycastReturn.point, Color.green);
        }
        BrainAffected theBrainPart = aRaycastReturn.transform.GetComponent <BrainAffected>();

        return(theBrainPart);
    }
コード例 #3
0
    private void NotInteractingState()
    {
        //Draw a line down the facing line so folks can see it.
        DrawheadLine();
        //Read the current frame of brain data
        ReadBrainlevel();
        //Try to get an object.
        BrainAffected thisFrameLookTarget = CheckGrabObject();

        //If this frame's look target is the same as the saved one, accumulate attention!
        if (thisFrameLookTarget == mCurrentTarget)
        {
            AccumulateActivation(1.0f, 0.1f, true);
            if (mCurrentAttention > mActivationBucketSize)
            {
                EnterState(BrainGrabberStates.Brain_Interacting);
            }
        }
        //If this frame's look target is different, reduce attention on the current, and switch if the threshold is low enough.
        else
        {
            mCurrentAttention = Mathf.Clamp(mCurrentAttention - (Time.deltaTime * mActivationLossOnOtherObjectPerSecond),
                                            0.0f, Mathf.Infinity);
            if (mCurrentAttention <= 0.0f)
            {
                mCurrentTarget = thisFrameLookTarget;
                //if ( mCurrentTarget != null )
                //    SetColorOfObject(mCurrentTarget.gameObject);
            }
        }
        //If we have a valid target, pass the current activation levels along to it. Rescale to 0-1
        if (mCurrentTarget != null)
        {
            mCurrentTarget.ActivationLevel = Mathf.Clamp01(mCurrentAttention / mActivationBucketSize);
        }
    }
コード例 #4
0
 private void Start()
 {
     brainFuse = GetComponent <BrainAffected>();
 }