I’ve found some time to dig up my old portfolio site from my dusty laptop’s hard drive and put it online again on this new web server. You can access it here or through the links on the right.

It contains download links to binaries and source code to most of my past hobby and university projects, so it may interest some of you.

 

Several people have been contacting me to put my water simulation demo source up for download again. This was a real-time 3D project I did while at the University of Teesside a few years ago, and got featured as screenshot of the day on gamedev.net.

 

I’ve been asked how to get a 3D world position from the mouse cursor’s current position on the screen. Here’s he a code snippet on how to convert a screen-space position to a world-space position:

Vector3 ScreenToWorld( Vector2 screenPos )
{
    // Create a ray going into the scene starting 
    // from the screen position provided 
    Ray ray = Camera.main.ScreenPointToRay( screenPos );
    RaycastHit hit;

    // ray hit an object, return intersection point
    if( Physics.Raycast( ray, out hit ) )
       return hit.point;

    // ray didn't hit any solid object, so return the 
    // intersection point between the ray and 
    // the Y=0 plane (horizontal plane)
    float t = -ray.origin.y / ray.direction.y;
    return ray.GetPoint( t );
}

Now you can simply pass the mouse cursor’s current position to get its equivalent world-space position like this:

Vector worldPos = ScreenToWorld( Input.mousePosition );
© 2012 Fatal Frog Software Suffusion theme by Sayontan Sinha