Exemple #1
0
    private int personalDummyIndex;              // The index that represents the respective dummy in DMS for this particular ghost

    /* Coroutine that takes in a ghost sample index and begins moving to the next sample index by lerping over t. Will increment the ghost sample index and call itself
    * once t is greater than 1. If the ghost sample index becomes greater than the end slider sample index, will start the ghost from the start slider sample index. */
    private IEnumerator MoveGhostToNextSample(int ghostSampleIndex)
    {
        if (ghostSampleIndex < sliderFieldScript.GetEndSliderSampleIndex())
        {
            float t = 0f;
            while (t < 1)
            {
                t += Time.deltaTime / speedBandScript.GetSampleRate();
                transform.position = Vector3.Lerp(DMS.DS_GetSamplePosition(personalDummyIndex, ghostSampleIndex), DMS.DS_GetSamplePosition(personalDummyIndex, ghostSampleIndex + 1), t);
                transform.rotation = Quaternion.Lerp(DMS.DS_GetSampleRotation(personalDummyIndex, ghostSampleIndex), DMS.DS_GetSampleRotation(personalDummyIndex, ghostSampleIndex + 1), t);
                DMS.SFS_AdjustSlider("GhostSlider", ghostSampleIndex, t);
                yield return(null);
            }
            yield return(MoveGhostToNextSample(ghostSampleIndex + 1));
        }
        else
        {
            transform.position = DMS.DS_GetSamplePosition(personalDummyIndex, sliderFieldScript.GetStartSliderSampleIndex());
            transform.rotation = DMS.DS_GetSampleRotation(personalDummyIndex, sliderFieldScript.GetStartSliderSampleIndex());
            yield return(MoveGhostToNextSample(sliderFieldScript.GetStartSliderSampleIndex()));
        }
    }
Exemple #2
0
    public GameObject dummyIndicator;               // The dummy indicator game object

    private void Awake()
    {
        // Initialize all private scripts
        speedBandScript       = speedBand.GetComponent <SpeedBandScript>();
        playBandScript        = playBand.GetComponent <PlayBandScript>();
        undoBandScript        = undoBand.GetComponent <UndoBandScript>();
        sliderFieldScript     = sliderField.GetComponent <SliderFieldScript>();
        leftGloveScript       = leftGlove.GetComponent <GloveScript>();
        refineGuideScript     = refineGuide.GetComponent <RefineGuideScript>();
        leftOVRGrabberScript  = leftHandAnchor.GetComponent <OVRGrabber>();
        rightOVRGrabberScript = rightHandAnchor.GetComponent <OVRGrabber>();
        // Create arrays based on number of dummies in the scene
        dummies   = GameObject.FindGameObjectsWithTag("Dummy");
        startAids = new GameObject[dummies.Length];
        endAids   = new GameObject[dummies.Length];
        ghosts    = new GameObject[dummies.Length];

        for (int i = 0; i < dummies.Length; i++)
        {
            DummyManagerScript DMS = gameObject.GetComponent <DummyManagerScript>();
            // Instantiate aids and ghosts
            GameObject dummy         = dummies[i];
            GameObject startAid      = Instantiate(dummy);
            GameObject endAid        = Instantiate(dummy);
            GameObject ghost         = Instantiate(dummy);
            float      newScalar     = dummy.transform.localScale.x * 0.999f; // Prevents mesh clashing when overlaid
            Vector3    newLocalScale = new Vector3(newScalar, newScalar, newScalar);
            // Add components to each dummy
            dummy.AddComponent <DummyScript>();
            sampleCount = (int)Mathf.Ceil(animationSeconds / speedBandScript.GetSampleRate()); // Ceil to make a nice, even number
            dummy.GetComponent <DummyScript>().Initialize(ref DMS, sampleCount);
            dummy.AddComponent <Rigidbody>();
            dummy.GetComponent <Rigidbody>().useGravity  = false;
            dummy.GetComponent <Rigidbody>().isKinematic = true;
            dummy.AddComponent <BoxCollider>();
            // Edit start aid components
            startAid.name = dummy.name + "StartAid";
            startAid.transform.localScale = newLocalScale;
            startAid.GetComponent <Renderer>().material = startAidMaterial;
            startAids[i] = startAid;
            // Edit end aid components
            endAid.name = dummy.name + "EndAid";
            endAid.transform.localScale = newLocalScale;
            endAid.GetComponent <Renderer>().material = endAidMaterial;
            endAids[i] = endAid;
            // Edit ghost components
            ghost.AddComponent <GhostScript>();
            ghost.GetComponent <GhostScript>().Initialize(ref DMS, ref sliderFieldScript, ref speedBandScript, i);
            ghost.name = dummy.name + "Ghost";
            ghost.transform.localScale = newLocalScale;
            ghost.GetComponent <Renderer>().material = ghostMaterial;
            ghosts[i] = ghost;
        }
        // Set the selected dummy to the first dummy found, add the OVRGrabble script (so only the selected dummy can be grabbed),
        // and parent dummy indicator with the selected dummy and place it above the dummy
        selectedDummyIndex = 0;
        dummies[selectedDummyIndex].AddComponent <OVRGrabbable>();
        dummyIndicator.transform.localScale    = new Vector3(4.0f, 4.0f, 4.0f);
        dummyIndicator.transform.parent        = dummies[selectedDummyIndex].transform;
        dummyIndicator.transform.localPosition = new Vector3(0.0f, (dummies[selectedDummyIndex].GetComponent <BoxCollider>().size.y / 2.0f) + dummyIndicatorOffset, 0.0f);
        dummyIndicator.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f);
    }
Exemple #3
0
 public float SBS_GetSampleRate()
 {
     return(speedBandScript.GetSampleRate());
 }