Virtual pigs

Fly, pig. Rattle your blubber and yield coins. Here it is in my virtual world:

It is lit by a point light in the den. Shiny pink skin. But first, let me remove the Oculus Rift virtual reality headset and explain how it works.

I have created a virtual world using a C++ Microsoft Visual Studio application with OpenGL graphics library and the Oculus SDK for Windows.

The virtual world is split into zones, such as the floor of a building, an island or a den. As I stroll through a door from one zone to another it is the perfect time to load the models of the next zone. That way, I don’t have to load all the models at application start-up. A model may be my pig, or a tree, or a TV set.

But what happens if we have too much stuff loaded? Well, I introduced areas, which are a collection of zones. When I stroll through a door from one area to another I discard all the models of the previous area, wipe the co-ordinates, and start again. I can still stroll back to the previous area, just means I’ll start loading the models for that area over again, zone by zone (and some base stuff for the area too).

Turns out to be a fairly clean and powerful approach, where I can trash everything on my journey through the virtual landscape and never clog up my PC’s memory. We’ll see how it goes. Maybe I will repurpose some models rather than reloading? Or duplicate models that have already loaded?

Anyway, with that in mind, I design my pig in Blender (the 3D creation suite) ready to load into zones of my virtual world. We’ve already seen the pig that lives in the den. Here’s the pig that lives in on the island, hiding behind some trees:

This little piggy has some directional light upon it’s back, from a low-lying sun.

And here’s another pig on the first floor of my building. I’ve caught it in the spotlight attached to my head:

I use some basic Axis-Aligned Bounding Box collision detection to collect the piggy banks. When I bump into the hog it yields a coin for my purse. It also makes a pig snort sound courtesy of yottasounds on Freesound. And then we disable the meshes of the pig and it disappears. We can collect no more coins from it.

With use of a calculator I can confirm that three little piggies with one coin each grants three coins. The door to get from the first area of my virtual world to the second area requires a single coin, so no problems there. And going back into the first area requires no coin, so I am free to retrace my steps.

Ciao!

P.S. you’ll notice from the pig in the spotlight that my Oculus Touch controllers have granted me virtual hands, which come in handy when ringing the doorbell of my doors.

And for the 3D audio pig snort I use the FMOD API.

https://myspace.com/rdmilligan/music/album/bones-ep-19172460