Example #1
0
    //Gets non suvat based inputs from the UI and sassigns values to the particle instance
    private static void getMisc(ref newParticle values)
    {
        //Reference to the UI instance that being used
        Suvat_UiController controller = Suvat_UiController.instance;

        //Radius cannot be empty text or 0
        if (controller.Radius.text != "" && controller.Radius.text != "0")
        {
            //converts text to float from the input field
            values.diameter = float.Parse(controller.Radius.text);
        }
        else
        {
            //If the radius has not been stated or =0 then a default value of 1 is assigned.
            values.diameter = 1;
        }
        try
        {
            //If the gravity toggle has been enabled
            if (controller.Gravity.isOn == true)
            {
                //gravity must be added.Gravity is negative therefore a vector subtraction occurs of the magnitude of gravity.
                //Y component only
                values.acceleration -= new Vector3(0, Gravity, 0);
            }
        }
        catch (NullReferenceException) { }
    }
Example #2
0
    //Gets the inputs from the user for each Suvat quantitity in the X dimention
    //If the input is not NULL then Key is updated for the dimention and element
    private static void GetInput_Suvat_x(ref newParticle values, int dimentions)
    {
        //float.parse converts a string to float type

        //Reference to the UI element
        Suvat_UiController controller = Suvat_UiController.instance;

        if (controller.S_x.text != "")
        {
            Vector3 temp = values.displacement;
            temp[0]             = float.Parse(controller.S_x.text);
            values.displacement = temp;
            values.key[0]       = ReplaceAtIndex(0, '1', values.key[0]);
        }
        if (controller.U_x.text != "")
        {
            Vector3 temp = values.initialVelocity;
            temp[0] = float.Parse(controller.U_x.text);
            values.initialVelocity = temp;
            values.key[0]          = ReplaceAtIndex(1, '1', values.key[0]);
        }
        if (controller.V_x.text != "")
        {
            Vector3 temp = values.currentVelocity;
            temp[0] = float.Parse(controller.V_x.text);
            values.currentVelocity = temp;
            values.key[0]          = ReplaceAtIndex(2, '1', values.key[0]);
        }
        if (controller.A_x.text != "")
        {
            Vector3 temp = values.acceleration;
            temp[0]             = float.Parse(controller.A_x.text);
            values.acceleration = temp;
            values.key[0]       = ReplaceAtIndex(3, '1', values.key[0]);
        }
        if (controller.Time.text != "")
        {
            values.motionTime = float.Parse(controller.Time.text);
            //Time shared between all dimentions
            values.key[0] = ReplaceAtIndex(4, '1', values.key[0]);
            values.key[1] = ReplaceAtIndex(4, '1', values.key[1]);
            values.key[2] = ReplaceAtIndex(4, '1', values.key[2]);
        }
        if (controller.R_x.text != "")
        {
            Vector3 temp = values.initialPosition;
            temp[0] = float.Parse(controller.R_x.text);
            values.initialPosition = temp;
        }
    }
Example #3
0
    //unity method ran when the object is first instatiated
    //This occurs when the scene is first loaded in the case of the UIController
    public void Start()
    {
        //Creates reference for all methods to access.
        instance = this;

        //begins program with Particle infomation selected
        //Enabled Particle infomation panel
        //Disables Particle graphs panel
        OnParticleInfomationButtonClicked();
        //Turns all dimention inputs on.
        SetDimention_X(true);
        SetDimention_Y(true);
        SetDimention_Z(true);
    }
Example #4
0
    //Gets the inputs from the user for each Suvat quantitity in the Y dimention
    //If the input is not NULL then Key is updated for the dimention and element
    private static void GetInput_Suvat_y(ref newParticle values, int dimentions)
    {
        //float.parse converts a string to float type

        //Reference to the UI element
        Suvat_UiController controller = Suvat_UiController.instance;

        if (controller.S_y.text != "")
        {
            Vector3 temp = values.displacement;
            temp[1]             = float.Parse(controller.S_y.text);
            values.displacement = temp;
            values.key[1]       = ReplaceAtIndex(0, '1', values.key[1]);
        }
        if (controller.U_y.text != "")
        {
            Vector3 temp = values.initialVelocity;
            temp[1] = float.Parse(controller.U_y.text);
            values.initialVelocity = temp;
            values.key[1]          = ReplaceAtIndex(1, '1', values.key[1]);
        }
        if (controller.V_y.text != "")
        {
            Vector3 temp = values.currentVelocity;
            temp[1] = float.Parse(controller.V_y.text);
            values.currentVelocity = temp;
            values.key[1]          = ReplaceAtIndex(2, '1', values.key[1]);
        }
        if (controller.A_y.text != "")
        {
            //+= because gravity may be added by the toggle , thus cannot be strickly equal
            Vector3 temp = values.acceleration;
            temp[1]            += float.Parse(controller.A_y.text);
            values.acceleration = temp;
            values.key[1]       = ReplaceAtIndex(3, '1', values.key[1]);
        }
        if (controller.R_y.text != "")
        {
            Vector3 temp = values.initialPosition;
            temp[1] = float.Parse(controller.R_y.text);
            values.initialPosition = temp;
        }
    }