Exemplo n.º 1
0
    void UpdateCoulombVectorInteraction()
    {
        foreach (InteractionInfo iI in interactionInfos)
        {
            int     vectorIndex = iI.interactionVector.transform.GetSiblingIndex();
            Vector2 vectorOrigin;
            if (attachAllVectorAtOrigin)   //sceneSettingsManager.allVectorsAtOrigin) {
            {
                vectorOrigin = iI.charge2Transform.position;
            }
            else
            {
                if (vectorIndex > 0)
                {
                    VectorController previousVector = iI.interactionVector.transform.parent.GetChild(vectorIndex - 1).GetComponent <VectorController>();
                    vectorOrigin = previousVector.origin + previousVector.vector;
                }
                else
                {
                    vectorOrigin = iI.charge2Transform.position;
                }
            }

            iI.interactionVector.SetVector(vectorOrigin,
                                           CoulombForce.Fab(iI.charge2Transform.position, iI.charge1Transform.position, iI.q2, iI.q1), iI.arrowColor);
        }
    }
Exemplo n.º 2
0
 public void CheckSize(VectorController changingVectorController)
 {
     if (count > 0)
     {
         var temp = changingVectorController.LineRenderer.GetPosition(1);
         for (int i = 0; i < Mathf.Abs(count); i++)
         {
             temp *= sizeController;
         }
         changingVectorController.LineRenderer.SetPosition(1, temp);
     }
     else if (count < 0)
     {
         var temp = changingVectorController.LineRenderer.GetPosition(1);
         for (int i = 0; i < Mathf.Abs(count); i++)
         {
             temp /= sizeController;
         }
         changingVectorController.LineRenderer.SetPosition(1, temp);
     }
     else if (count == 0)
     {
         //Debug.Log("not must to resize");
     }
     //Debug.Log(count + " COUNT");
 }
Exemplo n.º 3
0
    public void voidCreateVectors(Vector3 point1, Vector3 point2)
    {
        var temp = Instantiate(_gameController._line, Vector3.zero, Quaternion.identity);

        temp.transform.parent = _vectorsTransform;
        _vectorController     = temp.GetComponent <VectorController>();
        tempStartPoint        = point1;
        tempEndPoint          = point2;
        CreateVectors();
    }
Exemplo n.º 4
0
    // Start is called before the first frame update
    void Awake()
    {
        rb = GetComponent <Rigidbody>();
        //rb.velocity = initialVelocity;

        forceVector    = Instantiate <GameObject>(vectorPrefab).GetComponent <VectorController>();
        velocityVector = Instantiate <GameObject>(vectorPrefab).GetComponent <VectorController>();

        forceVector.transform.SetParent(transform);
        velocityVector.transform.SetParent(transform);

        forceVector.transform.localPosition    = Vector3.zero;
        velocityVector.transform.localPosition = Vector3.zero;


        forceVector.setVectorColor(forceVectorColor);
        velocityVector.setVectorColor(velocityVectorColor);
    }
Exemplo n.º 5
0
        public InteractionVectorContainerOrientations(InteractionVectorContainer interactionVectorContainer)
        {
            InteractionVectorContainerUnchanged = new PaddedInteractionVectorContainers(new InteractionVectorContainer(interactionVectorContainer));
            AdaptedInteractionVectorContainersList.Add("InteractionVectorContainerUnchanged", InteractionVectorContainerUnchanged);

            InteractionVectorContainerReversedChainA = new PaddedInteractionVectorContainers(VectorController.AdaptVectorsReverseBitOrder(interactionVectorContainer, StaticValues.ChainA));
            AdaptedInteractionVectorContainersList.Add("InteractionVectorContainerReversedChainA", InteractionVectorContainerReversedChainA);

            InteractionVectorContainerReversedChainB = new PaddedInteractionVectorContainers(VectorController.AdaptVectorsReverseBitOrder(interactionVectorContainer, StaticValues.ChainB));
            AdaptedInteractionVectorContainersList.Add("InteractionVectorContainerReversedChainB", InteractionVectorContainerReversedChainB);

            InteractionVectorContainerReversedChainAAndB = new PaddedInteractionVectorContainers(VectorController.AdaptVectorsReverseBitOrder(interactionVectorContainer));
            AdaptedInteractionVectorContainersList.Add("InteractionVectorContainerReversedChainAAndB", InteractionVectorContainerReversedChainAAndB);
        }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     //UpdateVectorList ();
     netForceVector = Instantiate(vectorObjectPrefab, Vector3.zero, Quaternion.identity, this.transform).GetComponent <VectorController>();
 }
Exemplo n.º 7
0
    void SelectVector(VectorController v)
    {
        Debug.Log(v.LineRenderer.GetPosition(1));


        #region GetCurrentGradient

        previosColorKey = new GradientColorKey[2];

        previosColorKey[0].color = v.LineRenderer.startColor;
        previosColorKey[0].time  = 0.0f;
        previosColorKey[1].color = v.LineRenderer.endColor;
        previosColorKey[1].time  = 1.0f;

        //alpha gradient
        previosAlphaKey          = new GradientAlphaKey[2];
        previosAlphaKey[0].alpha = 1.0f;
        previosAlphaKey[0].time  = 0.0f;
        previosAlphaKey[1].alpha = 1.0f;
        previosAlphaKey[1].time  = 1.0f;

        #endregion

        #region NewGradient

        GradientColorKey[] colorKey;
        GradientAlphaKey[] alphaKey;

        colorKey          = new GradientColorKey[2];
        colorKey[0].color = Color.black;
        colorKey[0].time  = 0.0f;
        colorKey[1].color = Color.black;
        colorKey[1].time  = 1.0f;

        //gradient alpha
        alphaKey          = new GradientAlphaKey[2];
        alphaKey[0].alpha = 1.0f;
        alphaKey[0].time  = 0.0f;
        alphaKey[1].alpha = 1.0f;
        alphaKey[1].time  = 1.0f;

        Gradient _gradient = new Gradient();

        _gradient.SetKeys(colorKey, alphaKey);

        v.LineRenderer.colorGradient = _gradient;

        #endregion

        #region SetGradient

        if (changeCount > 0)
        {
            Gradient _mGradient = new Gradient();
            _mGradient.SetKeys(previosColorKey, previosAlphaKey);

            _previosVectorController.LineRenderer.colorGradient = _mGradient;
        }

        #endregion

        changeCount += 1;
        _previosVectorController = v;
    }