Showing posts with label fun. Show all posts
Showing posts with label fun. Show all posts

Monday, March 9, 2020

Path Smoothing

Very simple implementation of path smoothing algorithm.



private void GenerateSmoothedPaths()
{
    smoothedPaths.Clear();       
    smoothedPaths.Add(paths[0].transform.position);

    int index = 1;
    while(index < paths.Length-1)
    {
        Vector3 fromPos = smoothedPaths[smoothedPaths.Count - 1];
        Vector3 toPos = paths[index].transform.position;

        Ray ray = new Ray(fromPos, (toPos - fromPos).normalized);
        RaycastHit hitInfo;
        if ( Physics.Raycast(ray, out hitInfo, Vector3.Distance(fromPos, toPos)) )
        {  
            smoothedPaths.Add(paths[index-1].transform.position);
        }
           
        index++;
    }

    smoothedPaths.Add(paths[paths.Length-1].transform.position);
}


Friday, November 1, 2019

Time Calculator

I don't know why there is no program, which is able to set source time and based on the time difference calculate destination's time.

LA is -16 hours slower than South Korea. To make comfortable time for each others, I had to calculate -16 hours but as you know I'm a programmer and lazy.

So I created a program to calculate for me.




Source is really simple.

===================================

public partial class frmTimeCalculator : Form
{
    public frmTimeCalculator()
    {
        InitializeComponent();
    }


    private void frmTimeCalculator_Load(object sender, EventArgs e)
    {
        sourceTime.CustomFormat = "MM/dd/yyyy hh:mm:ss tt";
        sourceTime.Format = DateTimePickerFormat.Custom;

        destTime.CustomFormat = "MM/dd/yyyy hh:mm:ss tt";
        destTime.Format = DateTimePickerFormat.Custom;
    }

    private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
    {
        DateTime laTime = sourceTime.Value.AddHours(-16);
        destTime.Value = laTime;
    }
}

Task in UnrealEngine

 https://www.youtube.com/watch?v=1lBadANnJaw