Esempio n. 1
0
    public void UpdateCloneDistance(AirSticks.Hand hand, GameObject clone, int cloneNumber)
    {
        var distance = cloneDistance;

        if (ControlCloneDistanceWithAirSticks)
        {
            switch (hand)
            {
            case AirSticks.Hand.Left:
                distance = cloneDistance * AirSticks.Right.Position.z.Map(AirSticksPositionMap.x, AirSticksPositionMap.y, AirSticksPositionMap.z, AirSticksPositionMap.w);
                break;

            case AirSticks.Hand.Right:
                distance = cloneDistance * AirSticks.Left.Position.z.Map(AirSticksPositionMap.x, AirSticksPositionMap.y, AirSticksPositionMap.z, AirSticksPositionMap.w);
                break;
            }
        }

        // multiply the x axis offset based on what number clone it is
        var xOffset = distance * cloneNumber;

        if (hand == AirSticks.Hand.Right)
        {
            xOffset = -xOffset;
        }

        // an a slight z offset to ensure the new clones are rendered behind
        // (just using render queue isn't working)
        var zOffset = 0.01f * cloneNumber;

        clone.transform.localPosition = new Vector3(xOffset, 0, zOffset);

        clone.transform.localRotation = Quaternion.Euler(Vector3.zero);
    }
Esempio n. 2
0
    public void InstantiateClone(AirSticks.Hand hand)
    {
        List <GameObject> clones;

        if (hand == AirSticks.Hand.Left)
        {
            clones = LeftHandClones;
        }
        else
        {
            clones = RightHandClones;
        }

        // if the clone doesn't exist, create it
        // if it does exist, set it active and add it to the visible clones list
        var        cloneName = gameObject.name + hand.ToString() + "Clone (" + clones.Count + ")";
        GameObject clone     = gameObject.FindChild(cloneName);

        if (!clone)
        {
            clone = Instantiate(gameObject);
        }
        else
        {
            clone.SetActive(true);
        }
        clones.Add(clone);

        // don't clone the children
        for (int i = 0; i < clone.transform.childCount; i++)
        {
            Destroy(clone.transform.GetChild(i).gameObject);
        }

        // set it up
        clone.name             = cloneName;
        clone.transform.parent = gameObject.transform;

        // instance the material for editing
        clone.InstanceMaterial();
        var renderer = clone.GetComponent <Renderer>();

        if (CloneColors.Count != 0)
        {
            int colorIndex = clones.Count % CloneColors.Count;
            var cloneColor = CloneColors[colorIndex];
            renderer.material.SetColor("_TintColor", cloneColor);
        }

        // change the renderQueue order so that the newest clones are on the bottom
        var parentRenderer      = gameObject.GetComponent <Renderer>();
        var renderQueuePosition = parentRenderer.material.renderQueue - clones.Count;

        renderer.material.renderQueue = renderQueuePosition;

        // make sure to remove this script from the clone so it's not recursive
        Destroy(clone.GetComponent <TrackerOutputEffector>());

        UpdateCloneDistance(hand, clone, clones.Count);
    }
Esempio n. 3
0
 void GranRelatedOn(AirSticks.Hand hand)
 {
     GranRelatedExplode(hand);
     if (!EnableGranRelatedTransition)
     {
         GranControl = true;
     }
 }
Esempio n. 4
0
 void GranRelatedExplode(AirSticks.Hand hand)
 {
     if (!EnableGranRelatedExplode)
     {
         return;
     }
     if (!EnableGranRelatedTransition)
     {
         if (hand == AirSticks.Hand.Left)
         {
             Noise.NewNoiseIntensity  = 0.01f;
             Noise.NoiseIntensity     = GranRelatedLeftExplodeIntensity;
             Noise.NoiseChangeDamping = GranRelatedLeftExplodeDamping;
         }
         else if (hand == AirSticks.Hand.Right)
         {
             Noise.NewNoiseIntensity  = 0.01f;
             Noise.NoiseIntensity     = GranRelatedRightExplodeIntensity;
             Noise.NoiseChangeDamping = GranRelatedRightExplodeDamping;
         }
         if (ActivateGranRelatedColourCycle)
         {
             var   material = OutputQuadToTint.GetComponent <Renderer>().material;
             var   currentColor = material.GetColor("_TintColor");
             float h, s, v;
             Color.RGBToHSV(currentColor, out h, out s, out v);
             s = TintSaturation;
             h = (h + Random.value.Map(0, 1, TintCycleDistance.x, TintCycleDistance.y)) % 1;
             material.SetColor("_TintColor", Color.HSVToRGB(h, s, 1));
         }
     }
     else
     {
         if (WhiteBlockoutController.Full || WhiteBlockoutController.FadingIn)
         {
             WhiteBlockoutController.FadeOut(WhiteBlockoutFadeOutTime);
         }
         UserMeshVisualizer.BlockKinectUpdate = false;
         UserMeshVisualizer.ControlRotationSliderByAirsticks = true;
         UserMeshVisualizer.StartRotateAnimation             = true;
         Noise.NewNoiseIntensity  = GranRelatedTransitionBaseNoiseIntensity;
         Noise.NoiseIntensity     = GranRelatedTransitionExplodeIntensity;
         Noise.SmoothingTimes     = 6;
         Noise.NoiseChangeDamping = GranRelatedTransitionExplodeDamping;
     }
 }
Esempio n. 5
0
    void DestroyClones(AirSticks.Hand hand)
    {
        List <GameObject> clones;

        if (hand == AirSticks.Hand.Left)
        {
            clones = LeftHandClones;
        }
        else
        {
            clones = RightHandClones;
        }

        for (int i = 0; i < clones.Count; i++)
        {
            Destroy(clones[i]);
        }

        clones.Clear();
    }
Esempio n. 6
0
    public void HideClones(AirSticks.Hand hand)
    {
        List <GameObject> clones;

        if (hand == AirSticks.Hand.Left)
        {
            clones = LeftHandClones;
        }
        else
        {
            clones = RightHandClones;
        }

        for (int i = 0; i < clones.Count; i++)
        {
            clones[i].SetActive(false);
        }

        clones.Clear();
    }
Esempio n. 7
0
    void Update()
    {
        if (SetColor)
        {
            Renderer.material.SetColor("_Color", NewParticleColor);
            SetColor = false;
        }

        if (ConstantEmission)
        {
            EmissionEnabled = true;
        }
        if (TrackAirsticks)
        {
            Vector3 modulatedScale = BaseHandScale;

            Vector3 pos = Vector3.zero;

            switch (TrackingHand)
            {
            case AirSticks.Hand.Left:
            {
                // move to hand position
                pos = ParticlesObject.transform.position = new Vector3(
                    (-AirSticks.Left.Position.x * LeftMultiplier.x) + LeftHandOffset.x,
                    (AirSticks.Left.Position.y * LeftMultiplier.y) + LeftHandOffset.y,
                    (AirSticks.Left.Position.z * LeftMultiplier.z) + LeftHandOffset.z);
                // set shape scale
                var mappedX = AirSticks.Left.EulerAngles.z.Map(AirsticksRotationMinMax.x, AirsticksRotationMinMax.y, AirsticksScaleMapX.x, AirsticksScaleMapX.y);
                var mappedY = AirSticks.Left.EulerAngles.z.Map(AirsticksRotationMinMax.x, AirsticksRotationMinMax.y, AirsticksScaleMapY.x, AirsticksScaleMapY.y);
                var mappedZ = AirSticks.Left.EulerAngles.z.Map(AirsticksRotationMinMax.x, AirsticksRotationMinMax.y, AirsticksScaleMapZ.x, AirsticksScaleMapZ.y);
                modulatedScale.Scale(new Vector3(mappedX, mappedY, mappedZ));
                // and swap to other hand for next frame
                TrackingHand = AirSticks.Hand.Right;
                break;
            }

            case AirSticks.Hand.Right:
            {
                pos = ParticlesObject.transform.position = new Vector3(
                    (-AirSticks.Right.Position.x * RightMultiplier.x) + RightHandOffset.x,
                    (AirSticks.Right.Position.y * RightMultiplier.y) + RightHandOffset.y,
                    (AirSticks.Right.Position.z * RightMultiplier.z) + RightHandOffset.z);
                // set shape scale
                var mappedX = AirSticks.Right.EulerAngles.z.Map(AirsticksRotationMinMax.x, AirsticksRotationMinMax.y, AirsticksScaleMapX.x, AirsticksScaleMapX.y);
                var mappedY = AirSticks.Right.EulerAngles.z.Map(AirsticksRotationMinMax.x, AirsticksRotationMinMax.y, AirsticksScaleMapY.x, AirsticksScaleMapY.y);
                var mappedZ = AirSticks.Right.EulerAngles.z.Map(AirsticksRotationMinMax.x, AirsticksRotationMinMax.y, AirsticksScaleMapZ.x, AirsticksScaleMapZ.y);
                modulatedScale.Scale(new Vector3(mappedX, mappedY, mappedZ));
                TrackingHand = AirSticks.Hand.Left;
                break;
            }
            }

            if (ContainWithinCircle)
            {
                var scaledPos = new Vector2(pos.x * CircleDistanceMultiplier, pos.y * CircleDistanceMultiplier);
                var distance  = Mathf.Sqrt(Mathf.Pow(scaledPos.x, 2) + Mathf.Pow(scaledPos.y, 2));
                var radius    = MembraneController.Instance.Radius.x;

                if (distance > radius)
                {
                    var positionAlongLine = radius / distance;
                    pos.x = positionAlongLine * (pos.x);
                    pos.y = positionAlongLine * (pos.y);
                    ParticlesObject.transform.position = pos;
                }
            }

            // Set the scale of the emission shape
            var shapeModule = ParticleSystem.shape;
            if (AirsticksScalingEnabled)
            {
                shapeModule.scale = modulatedScale;
            }
            else
            {
                shapeModule.scale = BaseHandScale;
            }

            if (EmissionEnabled)
            {
                ParticleSystem.Emit(ParticleEmissionCount);
            }
        }
    }