Inheritance: MonoBehaviour
 void Start()
 {
     if (GetComponent <VelocityEstimator>())
     {
         VelocityEstimator = GetComponent <VelocityEstimator>();
     }
 }
Esempio n. 2
0
        // Use this for initialization
        public virtual void Awake()
        {
            transform.tag = tagToSet;

            vEstimator = gameObject.GetComponent <VelocityEstimator>();

            rb = gameObject.GetComponent <Rigidbody>();

            originalIsKinematic = rb.isKinematic;
            originalUseGravity  = rb.useGravity;
            originalMask        = gameObject.layer;


            if (transform.parent != null)
            {
                originalParent = transform.parent;
            }

            foreach (Collider col in gameObject.GetComponentsInChildren <Collider>())
            {
                if (col != GetComponent <Collider>())
                {
                    col.gameObject.AddComponent <BKI_PickupableObjectChild>();
                    col.tag = tag;
                }
            }
        }
        public override void OnInteract(XRNode hand, GameObject handObject = null, AnimationController handAnimation = null, XRNodeHandController handController = null)
        {
            inUse = true;

            currentHandController = handController;
            currentHandAnimation  = handAnimation;

            this.transform.SetParent(handObject.transform.parent);
            rb.isKinematic = true;

            VelocityEstimator estimator = this.GetComponent <VelocityEstimator>();

            if (estimator == null)
            {
                estimator = this.gameObject.AddComponent <VelocityEstimator>();
            }
            estimator.BeginEstimatingVelocity();

            if (dataReader != null)
            {
                dataReader.ApplyData(hand, currentHandAnimation, currentHandController);
            }

            OnGrab.Invoke();
        }
Esempio n. 4
0
    public Vector3 GetControllerVelocity()
    {
        //Debug.Log("测量速度的obj: " + controllerAttachPoint.gameObject.name);
        VelocityEstimator vs = GetComponent <VelocityEstimator>();

        return(vs.GetVelocityEstimate());
    }
Esempio n. 5
0
    //-------------------------------------------------
    protected virtual void Awake()
    {
        velocityEstimator = GetComponent <VelocityEstimator>();
        interactable      = GetComponent <Interactable>();

        rigidbody = GetComponent <Rigidbody>();
        rigidbody.maxAngularVelocity = 50.0f;
        rigidbody.useGravity         = awakeEnableGravity;

        djScript = interactable.GetComponent <VRItemDimensionJump>();

        if (djScript == null)
        {
            return;
        }

        if (!djScript.inFuture)
        {
            initMass = djScript.normalObjectMass;
            altMass  = djScript.agedObjectMass;
        }
        else
        {
            initMass = djScript.agedObjectMass;
            altMass  = djScript.normalObjectMass;
        }

        rigidbody.mass = initMass;
    }
 /// <summary>
 /// Compares velocity estimations of two velocity estimators. Returns true if EITHER is above threshold.
 /// </summary>
 /// <param name="threshold"></param>
 /// <param name="thisEstimator"></param>
 /// <param name="otherEstimator"></param>
 /// <returns></returns>
 bool CompareVelocityEstimations(float threshold, VelocityEstimator thisEstimator, VelocityEstimator otherEstimator)
 {
     if (thisEstimator.GetVelocityEstimate().magnitude > threshold || otherEstimator.GetVelocityEstimate().magnitude > threshold)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 7
0
 void Start()
 {
     ownCollider = GetComponent <CapsuleCollider>();
     rb          = GetComponent <Rigidbody>();
     ve          = GetComponent <VelocityEstimator>();
     ve.BeginEstimatingVelocity();
     BeginDirection();
 }
Esempio n. 8
0
    protected virtual void Awake()
    {
        velocityEstimator = GetComponent <VelocityEstimator>();
        potteryM          = transform.GetChild(0).GetComponent <PotteryManager>();
        interactable      = GetComponent <Interactable>();

        rigidbody = GetComponent <Rigidbody>();
        rigidbody.maxAngularVelocity = 50.0f;
    }
Esempio n. 9
0
    // Start is called before the first frame update
    void Start()
    {
        roomba  = this.GetComponent <RoombaControllerScript>();
        manager = GameObject.Find("Manager").GetComponent <ExperimentManager>();

        controller = GameObject.FindGameObjectWithTag("Controller");
        VC         = controller.GetComponent <VIVEController>();
        VE         = controller.GetComponent <VelocityEstimator>();
    }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     rb                = GetComponent <Rigidbody>();
     audioSource       = GetComponent <AudioSource>();
     interactable      = GetComponent <Interactable>();
     velocityEstimator = GetComponent <VelocityEstimator>();
     interactable.onDetachedFromHand += OnDetachedFromHand;
     interactable.onAttachedToHand   += OnAttachedToHand;
     animator = GetComponent <Animator>();
 }
Esempio n. 11
0
    void OnTriggerEnter(Collider other)
    {
        velocityEstimator = playerWeapon.GetComponent <VelocityEstimator>();
        playerWeaponSpeed = velocityEstimator.GetVelocityEstimate().magnitude;

        if (other.gameObject.tag == "Player")
        {
            playerScript.health--;
            playerScript.healthSlider.value = playerScript.health;
        }
    }
Esempio n. 12
0
        protected void MakeThrowable()
        {
            //TODO: Fill
            GameObject        AttachedObj = this.gameObject;
            Interactable      addInteract = AttachedObj.AddComponent <Interactable> () as Interactable;
            VelocityEstimator addVelEst   = AttachedObj.AddComponent <VelocityEstimator> () as VelocityEstimator;
            Throwable         addThrow    = AttachedObj.AddComponent <Throwable> () as Throwable;

            addThrow.releaseVelocityStyle  = ReleaseStyle.ShortEstimation;
            addThrow.restoreOriginalParent = true;
        }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("controller reference");
        RightController = transform.Find("RightController").gameObject;
        LeftController  = transform.Find("LeftController").gameObject;

        RightFist = RightController.transform.Find("Right Fist").gameObject;
        LeftFist  = LeftController.transform.Find("Left Fist").gameObject;

        rightVelocityEstimator = RightFist.GetComponent <VelocityEstimator>();
        leftVelocityEstimator  = LeftFist.GetComponent <VelocityEstimator>();
    }
Esempio n. 14
0
        public void negative_accelerations_decrease_velocity()
        {
            var accelerationSampler = CreateSampler(
                Acceleration.FromMetersPerSecondSquared(2),
                Acceleration.FromMetersPerSecondSquared(-2),
                Acceleration.FromMetersPerSecondSquared(0));
            var scheduler = new TestScheduler();

            using var sensor = new VelocityEstimator(TimeSpan.FromSeconds(1), accelerationSampler, scheduler);

            scheduler.AdvanceBy(TimeSpan.FromSeconds(3).Ticks);
            sensor.Velocity.Should().Be(Speed.Zero);
        }
Esempio n. 15
0
        public void single_sample_calculates_zero()
        {
            var accelerationSampler = CreateSampler(
                Acceleration.FromMetersPerSecondSquared(2),
                Acceleration.FromMetersPerSecondSquared(2),
                Acceleration.FromMetersPerSecondSquared(0));
            var scheduler = new TestScheduler();

            using var sensor = new VelocityEstimator(TimeSpan.FromSeconds(1), accelerationSampler, scheduler);

            scheduler.AdvanceBy(TimeSpan.FromSeconds(1.1).Ticks);
            sensor.Velocity.Should().Be(Speed.Zero);
        }
Esempio n. 16
0
        public void can_integrate_speed()
        {
            var scheduler           = new TestScheduler();
            var accelerationSampler = CreateSampler(
                Acceleration.FromMetersPerSecondSquared(2),
                Acceleration.FromMetersPerSecondSquared(2),
                Acceleration.FromMetersPerSecondSquared(0));

            using var sensor = new VelocityEstimator(TimeSpan.FromSeconds(1), accelerationSampler, scheduler);

            scheduler.AdvanceBy(TimeSpan.FromSeconds(3).Ticks);
            sensor.Velocity.Should().Be(Speed.FromMetersPerSecond(4));
        }
Esempio n. 17
0
    // Use this for initialization

    void Start()
    {
        ownCollider = GetComponent <CapsuleCollider>();
        rb          = GetComponent <Rigidbody>();
        ve          = GetComponent <VelocityEstimator>();
        hj          = GetComponent <HingeJoint>();
        print("HINGE JOINT: " + hj.name);
        hj.connectedBody = hand.GetComponent <Rigidbody>();
        print("Hand Position : x" + hand.transform.position.x + ", y" + hand.transform.position.y + ", z" + hand.transform.position.z);
        transform.position = hand.transform.position;

        ve.BeginEstimatingVelocity();
    }
    void Start()
    {
        VE     = this.GetComponent <VelocityEstimator>();
        SBP    = this.GetComponent <SteamVR_Behaviour_Pose>();
        target = GameObject.Find("Target").GetComponent <Target>();

        //再生と同時にコントローラー速度の計測を開始
        if (!VE.estimateOnAwake)
        {
            VE.estimateOnAwake = true;
        }

        frameCount = 0;
    }
Esempio n. 19
0
    void Awake()
    {
        velEst   = GetComponent <VelocityEstimator>();
        fishtank = transform.parent;
        GameObject fishtankGO = GameObject.Find("fishtank");

        fishtankScript = fishtankGO.GetComponent <Fishtank>();

        if (!fishtankScript.gameSettingsManager.transitionMaterials)
        {
            dimerRenderer.material        = legacyMaterial;
            dimerRenderer.material.shader = legacyShader;
        }
    }
Esempio n. 20
0
        private void InheritVelocity()
        {
            VelocityEstimator estimator = this.GetComponent <VelocityEstimator>();

            if (estimator != null)
            {
                estimator.FinishEstimatingVelocity();
                HandVelocity        = estimator.GetVelocityEstimate();
                HandAngularVelocity = estimator.GetAngularVelocityEstimate();

                rb.velocity        = HandVelocity;
                rb.angularVelocity = HandAngularVelocity;
            }
        }
Esempio n. 21
0
    // Use this for initialization
    void Start()
    {
        controllerInHand  = Controller.GetComponent <SteamVR_TrackedObject>();
        velocityEstimator = ControllerTip.GetComponent <VelocityEstimator>();
        velocityEstimator.BeginEstimatingVelocity();
        if (mainManager._currentControllers == null)
        {
            mainManager._currentControllers = new List <controller>();
        }

        if (mainManager._currentControllers.Count >= 2)
        {
            return;
        }

        mainManager._currentControllers.Add(this);
    }
Esempio n. 22
0
 bool IsHandConfigured()
 {
     if (hand != null)
     {
         return(true);
     }
     if (Player.instance == null)
     {
         return(false);
     }
     foreach (var availableHand in Player.instance.hands)
     {
         if (availableHand.handType == handType)
         {
             hand = availableHand;
             handVelocityEstimator = hand.GetComponent <VelocityEstimator>();
             return(true);
         }
     }
     return(false);
 }
Esempio n. 23
0
    void OnCollisionEnter(Collision collision)
    {
        velocityEstimator = playerWeapon.GetComponent <VelocityEstimator>();
        playerWeaponSpeed = velocityEstimator.GetVelocityEstimate().magnitude;
        Debug.Log(playerWeaponSpeed);

        if (collision.gameObject.tag == "Weapon" && playerWeaponSpeed > 2)
        {
            if (state == State.Exposed)
            {
                health--;
                healthSlider.value = health;
            }

            else
            {
                health             = health - (1 * 0.5f);
                healthSlider.value = health;
            }
        }
    }
Esempio n. 24
0
    void Awake()
    {
        velocityEstimator = GetComponent <VelocityEstimator>();
        fishtank          = transform.parent;
        GameObject fishtankGO = GameObject.Find("fishtank");

        fishTank = fishtankGO.GetComponent <Fishtank>();

        var myElectric01 = Instantiate(goElectric01, gameObject.transform);

        psElectric01 = myElectric01.GetComponentInChildren <ParticleSystem>();
        psElectric01.transform.localScale = fishTank.nanowireFxScale * fishtankGO.transform.localScale;

        if (true)
        {
            var myAccretion01 = Instantiate(goAccretion01, gameObject.transform);

            psAccretion01 = myAccretion01.GetComponentInChildren <ParticleSystem>();
            psAccretion01.transform.localScale = fishTank.nanowireFxScale * fishtankGO.transform.localScale;

            psAccretion01Emission = psAccretion01.emission;
            psAccretion01Emission.rateOverTime = psAccretion01EmissionRateInit;
        }

        if (true)         //(fishtankScript.ringsUseSpringConstraints)
        {
            // warrick: disabled for now
            // InitialiseSpringJoints();
        }

        ringAudioSource      = GetComponent <AudioSource>();
        ringAudioSource.clip = sfxRingSpawn;
        ringAudioSource.loop = false;
        ringAudioSource.Play();

        if (!fishTank.gameSettingsManager.transitionMaterials)
        {
            SetMaterialAndShadersToLegacy();
        }
    }
Esempio n. 25
0
 protected void Awake()
 {
     ThrowSound        = GetComponent <SoundPlayOneshot>();
     VelocityEstimator = GetComponent <VelocityEstimator>();
 }
Esempio n. 26
0
 void Start()
 {
     ve = GetComponent <VelocityEstimator>();
     ve.BeginEstimatingVelocity();
 }
Esempio n. 27
0
    public Vector3 GetControllerAngularVelocity()
    {
        VelocityEstimator vs = GetComponent <VelocityEstimator>();

        return(vs.GetAngularVelocityEstimate());
    }
 void Awake()
 {
     velocityEstimator = GetComponent <VelocityEstimator> ();
 }
Esempio n. 29
0
 // Start is called before the first frame update
 void Start()
 {
     GetComponentsInChildren <Rigidbody>(rigidBodies);
     velocityEstimator = GetComponent <VelocityEstimator>();
 }
Esempio n. 30
0
 private void Awake()
 {
     velocityEstimator = ControllerTip.GetComponent <VelocityEstimator>();
     velocityEstimator.BeginEstimatingVelocity();
 }
	void Awake()
	{
		velocityEstimator = GetComponent<VelocityEstimator>();
	}