Sponsored By

Sponsored: How to simulate a tiny universe in Azure

Microsoft Azure is open to all kinds of open source code projects, so I thought it might be neat to try running my own OpenSim on an Azure server.

July 23, 2015

10 Min Read
Game Developer logo in a gray background | Game Developer

Author: by Amanda Lange, Technical Evangelist, Microsoft

This article is brought to you by Microsoft

If you need a quick getaway, why not try simulating and exploring your own little personal universe?

Microsoft Azure is open to all kinds of open source code projects, so I thought it might be neat to try running my own OpenSim on an Azure server.

OpenSim is a bit like Second Life, but open source. Anyone can create their own shard worlds to manipulate however they wish. It allows for a very private virtual world for use in role play gaming, education, or just to build out your own environment however you like and play with some 3D construction tools.

When you’re done with your OpenSim project, it will look like this: 

 

 

B4nLJE_CEAAnhP8

This is a virtual world that anyone can log into, provided they have an IP and login credentials. So this is a simple multiplayer environment that you can add additional game elements to if you want. And it really only takes a few hours to set up, if you know the steps.

This method requires minimal coding, but you’ll have to work in Visual Studio to compile the initial build. You’ll also have to work a little on the server side adjusting firewall settings, and make some basic adjustments in your configuration files before launching. I will show you where the settings are to adjust. Once your world is running, you can continue to write code to expand it, or do building from the inside using the interfaces provided by OpenSim and your view client.

Step 1. Download the OpenSim Software.

OpenSim is available at OpenSimulator.org. The download page is here: http://opensimulator.org/wiki/Download. For this build, you are going to want to download the sourcecode for the release, so scroll down to the bottom of the page for the zip file. I’m using release 0.8.0.3, the latest.

Step 2. Compile the sim using Visual Studio.

Instructions for how to compile are also on the OpenSim wiki, located here: http://opensimulator.org/wiki/Build_Instructions. All the files you’ll need to change are in the /bin folder of the source code. It looks like a complicated page, but in Visual Studio, the individual steps are easy, listed under the Microsoft Windows section:

Compiling in an IDE

1.     Run “runprebuild.bat” or “runprebuild2010.bat” (if using Visual Studio 2010 with OpenSimulator 0.7.6 source code or earlier).

2.     Open the resulting “OpenSim.sln” in any Visual Studio IDE.

3.     Build (or Debug) -> Build Solution.

That’s all you need to do in Visual Studio! This will work in any modern Visual Studio version. If you’re on an older version of Visual Studio such as 2010, the instructions may be different, but you can use the Community Edition of Visual Studio to get all the modern Visual Studio tools for free.

Step 3. Set up an Azure Virtual Machine.

Now go into your Azure account (free trial) and create a new Virtual Machine, running Windows Server 2012. I’m running 4 cores, but smaller might work too if you want to save some credits. You can do this by choosing the New symbol, using From Gallery, and selecting the Windows server experience.

windows-server

Wait for your Virtual Machine to boot up.

Step 4. Log into your Virtual Machine and do basic setup.

Here is how to log in to Virtual Desktop, via The Azure Blog. If you can’t get in using Virtual Desktop, you may need to open up port 3389 on your local Firewall, which is the Virtual Desktop port. (For an example, scroll down to step 6 of this tutorial.) When you initially set up your VM, you had to set up login credentials. Use these here to access the machine. These will be different from the login credentials for your virtual world, and are just to administrate the machine.

Once you are in, all you have to do there is the initial necessary setup for your new machine. Don’t worry too much, just follow the initial server tutorials and it will walk you through it.

Step 5. Upload your build of OpenSim into the Virtual Machine.

Now you have to move your OpenSim build onto your server. I did this by just rezipping the source code for OpenSim, uploading the .zip file to my OneDrive, and then copying it from the OneDrive into my VM. Note that the VM security settings will initially prevent you from downloading anything from Internet Explorer, so you’ll have to (temporarily) turn advanced browser security off if you want to use this method. You can turn it back on when you’re done, since we won’t be using Internet Explorer on this machine anymore after this.  (There’s other ways to upload stuff here; this is just the quick way that I did it.)

Step 6. Open up the firewall ports to connect to the Virtual Environment.

Now you will need to open up some Firewall ports on your VM to allow outside connections. The ports you need to open are 8000-8005, 8995, and 9000 in TCP, and also 9000 in UDP. To do that, you will need to add new rules to your Firewall which Allow these connections. Here’s an overview of how to create custom rules for a Firewall. You can open up the 8000-8005 connections as a range and the rest individually. Your Firewall rules will look like this:

allowedports

It doesn’t matter what you name the rules, just that you allow Inbound from all of those ports.

Step 7. Run Initial Virtual World setup.

Now, run OpenSim.exe from your Virtual Machine. (It’s in the /bin/ folder like most of the stuff you’ve adjusted.)

OpenSim will walk you through some basic questions in a command prompt. For the most part, you can leave things as default, but, you will need to choose a name for your world, and a name and password for your initial user to log in. Write down the username and password that you choose (the format is “first and last name, plus password”) because you will need them later to log in. Also, when OpenSim asks for the Internal IP address, you should provide the correct internal IP provided by Azure. It should be easily visible on the desktop wallpaper of your new VM.

There are more details about the questions that OpenSim asks when running at OpenSim Configuration. Scroll down to “Running for the first time.”

Step 8. Close your World temporarily to adjust any world settings.

Now, sadly, you will have to close your world for a moment, since what you just did adjusted the configuration files slightly, and you will need to doublecheck to make absolutely sure they are right before anyone can log in. Just close the OpenSim.exe window.

Step 9. Go to your config and regions config file, and set the correct IP addresses.

Open up the OpenSim code and make sure it’s all extracted to your new machine. There are three files you will need to adjust: OpenSim.ini, Regions.ini, and StandaloneCommon.ini. OpenSim.ini is in the /bin folder, and the regions configuration is in /bin/regions. The StandaloneCommon.ini file is in /bin/config-include.

Azure will provide you with two IP addresses. For the most part, you’ll need the external IP address, but you’ll also need to set the internal IP address at one spot in your /Regions/Regions.ini file.

In OpenSim.ini, I found the fastest thing to do was just to open it up in WordPad and do a find->replace, replacing the string “127.0.0.1” (default home IP) with your VM’s IP anywhere it appears. Don’t change the port numbers.

In the Regions file, set the internal IP provided by Azure under the Internal IP header, and set the Public IP under ExternalHostName.

Finally, in the StandaloneCommon.ini folder, you set some information about your grid to log in.  Under the [GridInfoService] header, you want to change the login URI to your IP (or later, if you get a DNS entry, you can use that). Give your grid its own unique name (the default to replace is “the lost continent of hippo.”)

Step 10. Go to your Azure Dashboard and open up the necessary ports to allow exterior connections.

There’s a step you need to do in the Azure Dashboard to make sure your world is open to outside logins. Remember those ports that you opened up with the firewall? You also need to open these ports up in the Azure Portal. You will need to do them one by one, since that’s the only way that the portal allows this setup.

Go to your machine in the Azure portal and click on Endpoints. Then add new, and individually add endpoints for every port that you opened on the firewall. Unfortunately you can’t do ranges, so you must add these endpoints one at at time.

In this graphic, I highlighted what Step One and Two are here, as well as showing what your endpoint screen will look like when you are done.

openendpoints

Step 11. Go back to your Virtual Machine and run your world sim again.

Run the OpenSim.exe file again. It shouldn’t take as long this time. Just make sure there are no errors on your VM. Wait until it says “logins enabled” and you are now ready to view your world from the inside! I circled the important part here:

loginsenabled

Step 12. Download a client to view your world.

To actually explore your tiny world, you will need a client to log in to the server. I’m using the Firestorm viewer, which you can download and install from here: http://www.firestormviewer.org/

Step 13. Set your world settings into your client using the IP address for your Virtual Machine.

Every client is a little bit different, but whatever client you use, you’ll need to set the IP address of your own VM. In Firestorm, go to Preferences, and go to the OpenSim tab. You will see a place to enter the IP address for your world. Follow it up with :9000 for the connecting port. I’ve blanked out my IP here; just enter yours and click “apply.”

http://ajlange.azurewebsites.net/wp-content/uploads/2014/12/youriphere1-300x234.png

If everything was set up correctly, you’ll see the name you chose for your world appear in the box. (If you see “the lost continent of hippo,” it found your world, but you didn’t set up a unique name. It will still work, but you might want to give your world a unique name later!)

Step 14. Log into your virtual world with the login credentials you set up during your initial setup.

Enter the username and password you created before into your client.

And ta-da! You have a tiny island all of your own! Here’s another shot of mine, with a rosy sunset. It’s not much yet but it’s mine.

myworldpink

From here, you can add additional user accounts, or do more expanded work with the database setup, but the first thing you’ll probably want to do is is set up your avatar. Whatever you do, have fun with it!

Special thanks to Chris Gomez for helping me with the Azure endpoints. Want to see more cool stuff like this? Leave your comments and questions, and if you’re in the Philly area, come see us next year at Philly Game Works!

Are you a beginner with Unity? Check out the Microsoft Virtual Academy course done by some of my friends at Microsoft for some starter files and another neat tutorial.

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like