Archive for Projects

The Thing About Raycasts

Raycasts are extremely versatile. With raycasts you can see if there is something under the mouse, in the path of a straight shooting object, or just about anything else regarding something being in the path of something else. As far as calculations go, raycasts are probably one of the most expensive (in terms of computational time) things that you can do. But how expensive are they? Well, let's put things into perspective about just how expensive raycasts are. We'll look at the basics of raycasting and how it is used with great frequency in a standard setting.

Raycast Basics

What exactly is a raycast, how does it work, why is it so expensive? A raycast has an origin and a direction, like any vector, and is literally cast, or thrown if you will, into the scene. The process basically involves going through every object, then checking ever vertex, face, and edge, for an intersection. Even with rigorous optimization this can be checking against hundreds of elements, and this is what makes it computationally expensive.

How it's Used

While it is relatively expensive, it is exactly how the scene is rendered. On my desktop that means 1680 x 1050 = 1,764,000 raycasts per frame just to display what is going on. On my tablet it's 1920 x 1200 = 2,304,000 raycasts per frame and 960 x 540 = 518,400 for my phone. So while it is an expensive calculation, remember that it is happening half a million to two million times a frame just to render, so doing it another 30 or so times is no worse than a 6 x 5 grid of extra pixels.

Unity Android Key Mappings

If you are using Unity to develop for Android platforms, you may be wondering what keys the different buttons map to. I happened to find the answer in a location unrelated to Unity, but the information is still valid. In order to make touch devices generally compatible, touch and key inputs are directly mapped to mouse and keyboard buttons respectively. Below is a short table snagged from a Google Group

  • One finger tap = left mouse button
  • Two finger tap = right mouse button
  • Menu key =
    • Middle mouse
    • Windows key
  • Home button = HOME key
  • Back button = ESC key
  • Power button = END key

Note:

After testing with my tablet, I could not confirm any other keys besides the back button. The menu key did not even show up.

Particular Problems with Public Variables in Unity

The Unity documentation it indicates that all public variables are made available in the inspector for direct editing. While this is handy, it is also dangerous. This article will cover a few things regarding public variables, and how to avoid them in Unity.

Read more

Avoiding Long Compile Times

Long compile times are a real chore when it comes to testing things. It is especially cumbersome when all you are doing is making small edits resulting in 2 seconds worth of editing, and 2 minutes waiting for compiling.

Read more

Important Notes on Touch Input in Unity

There are a few things that you will want to keep in mind when working with touch in Unity. Mobile devices pass click events with their touch events, platform dependent compilation, rotations are a special type all their own, sometimes Unity hands back one thing when you need another, collisions are odd, and much more. This is the first of many posts on the quirks of Unity.

Read more

Windows + DirectX + Minecraft Server Automation = Wat

    A little while back I made mention of some Minecraft Server Automation programs that I would be working on. They were nearly finished when I had some data loss on my development machine. Sadly my backups were not very current. Fortunately this gives me the opportunity to rework the programs in a more interesting manner.

Read more

File System Library

After doing some looking around, and trying to get the Boost File System library to work I realized that had I spent the same amount of time and energy into writing my own file system library, it'd be done and usable by now.

Don't get me wrong, the Boost libraries are very comprehensive, I just had trouble building the extra libraries, getting them properly integrated, and when all was said and done it didn't even work properly due to "Improper Permissions" (despite running my .exe as an administrator).

So I'm going to make a library/dll combo to manage some basic file operations (copy, move, delete, rename).

If there's a file op you want just comment and I'll work it into the C++ source.

Minecraft Server Automation

I've been working on some executables to automate plugin downloading, server updating, server world backup, map rendering, and world restoration processes. The idea is to make it so you will not need to touch your Minecraft server except for major changes. This way even when Minecraft releases a new version, you will be as current as it within 24 hours (depending on compatible plugin release times).

Read more