Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        motionSetup = gameObject.GetComponent <MotionSetup>();

        motionSetup.instantTime = MathsFunctions.linspace(0, Settings.duration - (Settings.duration / (Settings.duration * Settings.FPS)), (int)(Settings.duration * Settings.FPS));

        for (int i = 0; i < (int)(Settings.duration * Settings.FPS); i++)
        {
            float theta = Mathf.PI / 180 * (((endEl - startEl) / motionSetup.instantTime[motionSetup.instantTime.Length - 1] * motionSetup.instantTime[i]) + startEl);
            float phi   = Mathf.PI / 180 * (((endAz - startAz) / motionSetup.instantTime[motionSetup.instantTime.Length - 1] * motionSetup.instantTime[i]) + startAz);

            if (movementIsClockwise == false)
            {
                motionSetup.instantX[i] = (Mathf.Sin(theta) * Mathf.Cos(phi) * radiusMultiplier) + centrePoint.x;
                motionSetup.instantY[i] = (Mathf.Cos(theta) * Mathf.Abs(height)) + centrePoint.y;
                motionSetup.instantZ[i] = (Mathf.Sin(theta) * Mathf.Sin(phi) * radiusMultiplier) + centrePoint.z;
            }
            else
            {
                motionSetup.instantX[i] = -(Mathf.Sin(theta) * Mathf.Cos(phi) * radiusMultiplier) + centrePoint.x;
                motionSetup.instantY[i] = (Mathf.Cos(theta) * Mathf.Abs(height)) + centrePoint.y;
                motionSetup.instantZ[i] = (Mathf.Sin(theta) * Mathf.Sin(phi) * radiusMultiplier) + centrePoint.z;
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        motionSetup = gameObject.GetComponent <MotionSetup>();

        motionSetup.instantTime = MathsFunctions.linspace(0, Settings.duration - (Settings.duration / (Settings.duration * Settings.FPS)), (int)(Settings.duration * Settings.FPS));

        for (int i = 0; i < (int)(Settings.duration * Settings.FPS); i++)
        {
            if (oscillationInXAxis == true)
            {
                motionSetup.instantX[i] = (Mathf.Sin(motionSetup.instantTime[i] * Mathf.Abs(speed)) * Mathf.Abs(xDisplacement)) + centrePoint.x;
            }
            if (oscillationInYAxis == true)
            {
                motionSetup.instantY[i] = (Mathf.Sin(motionSetup.instantTime[i] * Mathf.Abs(speed)) * Mathf.Abs(yDisplacement)) + centrePoint.y;
            }
            if (oscillationInZAxis == true)
            {
                motionSetup.instantZ[i] = (Mathf.Sin(motionSetup.instantTime[i] * Mathf.Abs(speed)) * Mathf.Abs(zDisplacement)) + centrePoint.z;
            }
            if (oscillationInXAxis == false)
            {
                motionSetup.instantX[i] = 0 + centrePoint.x;
            }
            if (oscillationInYAxis == false)
            {
                motionSetup.instantY[i] = 0 + centrePoint.y;
            }
            if (oscillationInZAxis == false)
            {
                motionSetup.instantZ[i] = 0 + centrePoint.z;
            }
        }
    }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        motionSetup = gameObject.GetComponent <MotionSetup>();

        motionSetup.instantTime = MathsFunctions.linspace(0, Settings.duration - (Settings.duration / (Settings.duration * Settings.FPS)), (int)(Settings.duration * Settings.FPS));
        motionSetup.instantX    = MathsFunctions.linspace(startCoordinates.x, endCoordinates.x, motionSetup.instantTime.Length);
        motionSetup.instantY    = MathsFunctions.linspace(startCoordinates.y, endCoordinates.y, motionSetup.instantTime.Length);
        motionSetup.instantZ    = MathsFunctions.linspace(startCoordinates.z, endCoordinates.z, motionSetup.instantTime.Length);
    }
Beispiel #4
0
    // Start is called before the first frame update
    void Start()
    {
        motionSetup = gameObject.GetComponent <MotionSetup>();

        motionSetup.instantTime = MathsFunctions.linspace(0, Settings.duration - (Settings.duration / (Settings.duration * Settings.FPS)), (int)(Settings.duration * Settings.FPS));

        for (int i = 0; i < (int)(Settings.duration * Settings.FPS); i++)
        {
            motionSetup.instantX[i] = transform.position.x;
            motionSetup.instantY[i] = transform.position.y;
            motionSetup.instantZ[i] = transform.position.z;
        }
    }
Beispiel #5
0
    // Start is called before the first frame update
    void Start()
    {
        motionSetup = gameObject.GetComponent <MotionSetup>();

        motionSetup.instantTime = MathsFunctions.linspace(0, Settings.duration - (Settings.duration / (Settings.duration * Settings.FPS)), (int)(Settings.duration * Settings.FPS));
        motionSetup.instantY    = MathsFunctions.linspace(-height / 2, height / 2, (int)(Settings.duration * Settings.FPS));

        for (int i = 0; i < (int)(Settings.duration * Settings.FPS); i++)
        {
            if (movementIsClockwise == false)
            {
                motionSetup.instantX[i] = (Mathf.Cos(motionSetup.instantTime[i] * Mathf.Abs(radialSpeed)) * Mathf.Abs(width) * radiusMultiplier) + centrePoint.x;
                motionSetup.instantY[i] = motionSetup.instantY[i] + centrePoint.y;
                motionSetup.instantZ[i] = (Mathf.Sin(motionSetup.instantTime[i] * Mathf.Abs(radialSpeed)) * Mathf.Abs(depth) * radiusMultiplier) + centrePoint.z;
            }
            else
            {
                motionSetup.instantX[i] = -(Mathf.Cos(motionSetup.instantTime[i] * Mathf.Abs(radialSpeed)) * Mathf.Abs(width) * radiusMultiplier) + centrePoint.x;
                motionSetup.instantY[i] = motionSetup.instantY[i] + centrePoint.y;
                motionSetup.instantZ[i] = (Mathf.Sin(motionSetup.instantTime[i] * Mathf.Abs(radialSpeed)) * Mathf.Abs(depth) * radiusMultiplier) + centrePoint.z;
            }
        }
    }
Beispiel #6
0
    void Start()
    {
        motionSetup = gameObject.GetComponent <MotionSetup>();
        InstantPosition[] instantPosition = new InstantPosition[(int)(Settings.duration * Settings.FPS)];

        for (int i = 0; i < (int)(Settings.duration * Settings.FPS); i++)
        {
            var vec = new Vector3(motionSetup.instantX[i], motionSetup.instantY[i], motionSetup.instantZ[i]);
            vec = rotateAxis(vec);

            instantPosition[i]      = new InstantPosition();
            instantPosition[i].time = motionSetup.instantTime[i];
            instantPosition[i].x    = vec.x;
            instantPosition[i].y    = vec.y;
            instantPosition[i].z    = vec.z;

            objectName = gameObject.name;
        }

        Debug.Log("JSONWriter works up to here");

        //Convert to JSON
        string instantPositionToJson = JsonHelper.ToJson(instantPosition, true);

        string pathString = System.IO.Path.Combine(Application.dataPath, "JSONFiles");

        Debug.Log(pathString);

        // You can extend the depth of your path if you want to.
        //pathString = System.IO.Path.Combine(pathString, "SubSubFolder");

        // Create the subfolder. You can verify in File Explorer that you have this
        // structure in the C: drive.
        //    Local Disk (C:)
        //        Top-Level Folder
        //            SubFolder
        System.IO.Directory.CreateDirectory(pathString);

        // Create a file name for the file you want to create.
        objectName += ".json";

        // This example uses a random string for the name, but you also can specify
        // a particular name.
        //string fileName = "MyNewFile.txt";

        // Use Combine again to add the file name to the path.
        pathString = System.IO.Path.Combine(pathString, objectName);

        // Verify the path that you have constructed.
        Console.WriteLine("Path to my file: {0}\n", pathString);

        // Check that the file doesn't already exist. If it doesn't exist, create
        // the file and write the JSON.
        // DANGER: System.IO.File.Create will overwrite the file if it already exists.
        // This could happen even with random file names, although it is unlikely.
        if (!System.IO.File.Exists(pathString))
        {
            StreamWriter sr = File.CreateText(pathString);
            sr.WriteLine(instantPositionToJson);
            sr.Close();
        }
        else
        {
            Console.WriteLine("File \"{0}\" already exists.", objectName);
            return;
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     motionSetup = gameObject.GetComponent <MotionSetup>();
 }