by date
Space Sim in the Torque Game Engine - Setting up TGE and Using Sky Spheres
Space Sim in the Torque Game Engine - Setting up TGE and Using Sky Spheres
| Name: | Rob Evans | ![]() |
|---|---|---|
| Date Posted: | Jul 09, 2007 | |
| Rating: | 4.0 out of 5 | |
| Public: | YES | |
| Comments: | YES | |
| RSS Feed: | or Subscribe with . | |
| Profile Page: | View profile page for Rob Evans |
Blog post
This part of the guide uses resources submitted by Mike and the change-by-change details can be found here: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6644
I would like to take a quick moment to thank Mike for his insight and very useful resources on the space sim subject.
Now down to business...
----------------------------------------------------------------------------------------------------------------------------
SETTING UP TGE
----------------------------------------------------------------------------------------------------------------------------
During this guide it is important to remember that we are starting from scratch with a completely clean install of TGE 1.5.2.
I will be providing all of the altered files so that you don't need to make any manual changes because let's be honest, you want to get straight into making your game right? The reason I'm going to go through proper explanations of stuff rather than just complete the changes myself and then post the files in a big zip (which you can skip to if you really want) is so that whilst cutting all of the corners, you'll still have a firm understanding of what has changed within the engine and why we needed to change it.
Unpack TGE
So, let's unpack the TGE install to a new directory. I've chosen "c:\Torque\Clean1".
Make a Copy of tutorial.base
Once this is complete, you need to copy the directory "example\tutorial.base" and paste it in the same place "example\". Then rename the new directory to "SpaceSim1". So if you've done that correctly, you'll have a directory structure like this: "c:\Torque\Clean1\example\SpaceSim1".
Edit Tutorial Files
Now that we have our new game directory "SpaceSim1" we need to let the TorqueDemo.exe know we want to load files from there rather than the "tutorial.base" directory. All of these changes are explained in detail in the beginners tutorial that comes with TGE.
Open "example\main.cs" and change the line:
$defaultGame = "tutorial.base";
to
$defaultGame = "SpaceSim1";
Save the file and close it.
The rest of the changes are included in the zip for this part of the guide and will be included in the really big zip at the end, however, you MUST do this part (above) first as those changes will not be included in the zip package.
----------------------------------------------------------------------------------------------------------------------------
SKY SPHERES
----------------------------------------------------------------------------------------------------------------------------
In TGE (that's the Torque Game Engine you're probably using), the default sky setup allows the developer to create 6-sided sky boxes that display 6 individual textures to the player. Imagine a skybox like one giant cube that you as the player are floating inside, but wherever you go in the game, the skybox always stays centred around you. The problem with skyboxes is that if you imagine being inside one, the corners of the box will always be further away from you that the seams.
In contrast, imagine being inside a sphere. Wherever you look, the sphere is always the same distance away from you, so you end up with a much less distorted view of the sky. However, like Mike says in his post (link above), sky spheres often require polar mapped textures. This sounds complicated, but if you have Adobe Photoshop, it's TOTALLY easy! This part of the guide is a step-by-step tutorial on making polar-mapped textures from your normal square ones.
For our sim, we want to make the sky look like space so I'm going to refer to our sky-sphere as a space-sphere from now on (just to be different).
On top of the space-sphere, we also apply the patch mentioned in the link at the top (please read that link so you get an idea of the changes we're making) so that stars are generated on our space-sphere. This creates a nice background for us to use without too much work.
First, let's navigate to the correct folder for our clean installation of the TGE. I installed mine in C:\Torque\Clean1 and that is from where I will make all directory references. If I want you to look in C:\Torque\Clean1\engine\audio, I will simply say, "navigate to engine\audio". OK? Cool.
Your directory structure at this point will look like this:

For this part of the guide, the changed files are as follows:
engine\terrain\sky.cc
engine\terrain\sky.h
example\main.cs
You can simply unpack the zip and overwrite your current files and the changes will be applied!
So, now that we have the space-sphere code, lets go into Photoshop and make a sphere texture for our space-looking background. I'm not going to spend hours making amazing texture graphics, this will just show you how to make a spherical texture. Ready? OK...
Create a new file in Photoshop and set the width to 512 pixels and the height to 256 pixels. Make sure the colour mode is RGB and it's 8-bit too!

Next, select two colours in the colour picker. I've selected blue and black for a nice blue nebula effect, then click Filter -> Render -> Clouds.

You're almost done. Now we want our texture to wrap at all edges so that it doesn't have any seams. To do this, select Filter -> Other -> Offset. Then enter the value +15 for both horizontal and vertical. Make sure Wrap Around is selected. Click OK.

Next, we apply a spherical filter that turns our texture into one that looks cool when mapped to a sphere. Click Filter -> Distort -> Polar Coordinates. Then ensure that Polar to rectangle is selected.

Now, lastly we need to do a little editing. Select the top half of the image (0, 0 to 512, 128) and click Edit -> Copy. Then click Edit -> Paste. You should now have a second layer to play with. Move that layer to the bottom half of the image, then click Edit -> Transform -> Flip Vertical. This has basically mirrored the top half of our image to the bottom half.

Now that our texture has been created, save it as a png or jpeg - whatever works best for you (png is better).
Here's what it looks like in our game:

I imagine that this is not the best or most cool looking way to create this kind of texture, however, for our immediate needs, it will suffice. If anyone has a better way, please post the details!! :o)
I would like to take a quick moment to thank Mike for his insight and very useful resources on the space sim subject.
Now down to business...
----------------------------------------------------------------------------------------------------------------------------
SETTING UP TGE
----------------------------------------------------------------------------------------------------------------------------
During this guide it is important to remember that we are starting from scratch with a completely clean install of TGE 1.5.2.
I will be providing all of the altered files so that you don't need to make any manual changes because let's be honest, you want to get straight into making your game right? The reason I'm going to go through proper explanations of stuff rather than just complete the changes myself and then post the files in a big zip (which you can skip to if you really want) is so that whilst cutting all of the corners, you'll still have a firm understanding of what has changed within the engine and why we needed to change it.
Unpack TGE
So, let's unpack the TGE install to a new directory. I've chosen "c:\Torque\Clean1".
Make a Copy of tutorial.base
Once this is complete, you need to copy the directory "example\tutorial.base" and paste it in the same place "example\". Then rename the new directory to "SpaceSim1". So if you've done that correctly, you'll have a directory structure like this: "c:\Torque\Clean1\example\SpaceSim1".
Edit Tutorial Files
Now that we have our new game directory "SpaceSim1" we need to let the TorqueDemo.exe know we want to load files from there rather than the "tutorial.base" directory. All of these changes are explained in detail in the beginners tutorial that comes with TGE.
Open "example\main.cs" and change the line:
$defaultGame = "tutorial.base";
to
$defaultGame = "SpaceSim1";
Save the file and close it.
The rest of the changes are included in the zip for this part of the guide and will be included in the really big zip at the end, however, you MUST do this part (above) first as those changes will not be included in the zip package.
----------------------------------------------------------------------------------------------------------------------------
SKY SPHERES
----------------------------------------------------------------------------------------------------------------------------
In TGE (that's the Torque Game Engine you're probably using), the default sky setup allows the developer to create 6-sided sky boxes that display 6 individual textures to the player. Imagine a skybox like one giant cube that you as the player are floating inside, but wherever you go in the game, the skybox always stays centred around you. The problem with skyboxes is that if you imagine being inside one, the corners of the box will always be further away from you that the seams.
In contrast, imagine being inside a sphere. Wherever you look, the sphere is always the same distance away from you, so you end up with a much less distorted view of the sky. However, like Mike says in his post (link above), sky spheres often require polar mapped textures. This sounds complicated, but if you have Adobe Photoshop, it's TOTALLY easy! This part of the guide is a step-by-step tutorial on making polar-mapped textures from your normal square ones.
For our sim, we want to make the sky look like space so I'm going to refer to our sky-sphere as a space-sphere from now on (just to be different).
On top of the space-sphere, we also apply the patch mentioned in the link at the top (please read that link so you get an idea of the changes we're making) so that stars are generated on our space-sphere. This creates a nice background for us to use without too much work.
First, let's navigate to the correct folder for our clean installation of the TGE. I installed mine in C:\Torque\Clean1 and that is from where I will make all directory references. If I want you to look in C:\Torque\Clean1\engine\audio, I will simply say, "navigate to engine\audio". OK? Cool.
Your directory structure at this point will look like this:

For this part of the guide, the changed files are as follows:
engine\terrain\sky.cc
engine\terrain\sky.h
example\main.cs
You can simply unpack the zip and overwrite your current files and the changes will be applied!
So, now that we have the space-sphere code, lets go into Photoshop and make a sphere texture for our space-looking background. I'm not going to spend hours making amazing texture graphics, this will just show you how to make a spherical texture. Ready? OK...
Create a new file in Photoshop and set the width to 512 pixels and the height to 256 pixels. Make sure the colour mode is RGB and it's 8-bit too!

Next, select two colours in the colour picker. I've selected blue and black for a nice blue nebula effect, then click Filter -> Render -> Clouds.

You're almost done. Now we want our texture to wrap at all edges so that it doesn't have any seams. To do this, select Filter -> Other -> Offset. Then enter the value +15 for both horizontal and vertical. Make sure Wrap Around is selected. Click OK.

Next, we apply a spherical filter that turns our texture into one that looks cool when mapped to a sphere. Click Filter -> Distort -> Polar Coordinates. Then ensure that Polar to rectangle is selected.

Now, lastly we need to do a little editing. Select the top half of the image (0, 0 to 512, 128) and click Edit -> Copy. Then click Edit -> Paste. You should now have a second layer to play with. Move that layer to the bottom half of the image, then click Edit -> Transform -> Flip Vertical. This has basically mirrored the top half of our image to the bottom half.

Now that our texture has been created, save it as a png or jpeg - whatever works best for you (png is better).
Here's what it looks like in our game:

I imagine that this is not the best or most cool looking way to create this kind of texture, however, for our immediate needs, it will suffice. If anyone has a better way, please post the details!! :o)
Recent Blog Posts
| List: | 07/10/07 - Space Sim in the Torque Game Engine - Setting up the Gravity Mod 07/09/07 - Space Sim in the Torque Game Engine - Setting up TGE and Using Sky Spheres 07/04/07 - Space Sim in the Torque Game Engine - Introduction 07/02/07 - Creating Portals (doorways etc) in Constructor |
|---|
Submit your own resources!| Dave Young (Jul 09, 2007 at 18:14 GMT) |
| Jason Burch (Jul 09, 2007 at 20:28 GMT) |
Love the tutorial.
| Rob Evans (Jul 09, 2007 at 23:11 GMT) |
| Leroy Frederick (Jul 10, 2007 at 00:29 GMT) Resource Rating: 5 |
| Andy Hawkins (Jul 10, 2007 at 05:00 GMT) |
| Rob Evans (Jul 10, 2007 at 10:30 GMT) |
| James Laker (BurNinG) (Jul 10, 2007 at 11:16 GMT) |
What did you do for the stars, just dots?
| Leroy Frederick (Jul 10, 2007 at 11:17 GMT) Resource Rating: 5 |
Quote:Is that the annoying 'Do you want to do that/you must be administrator to process this action' constant message/question that keeps coming up every time you want to do anything of interest on vista? By the way, where do you turn that off?
I turned off user account control after a while.
| Rob Evans (Jul 10, 2007 at 11:22 GMT) |

| James Laker (BurNinG) (Jul 10, 2007 at 11:23 GMT) |
| Rob Evans (Jul 10, 2007 at 11:23 GMT) |
| Rob Evans (Jul 10, 2007 at 11:26 GMT) |
Quote:
Add these type of posts as resources. Blog really isn't the place. ;)
It's all one big project that's supposed to be in order so I figured my blog was best...
| Leroy Frederick (Jul 10, 2007 at 11:36 GMT) Resource Rating: 5 |
Quote:I prefer this type of post in the blogs (mistakenly or otherwise) then some of the many stupid ones that have been posted recently, a better problem to have in my opinion! Besides, the resource section seems to only support one screenshot, which means this post may have been less effective as a step by step tute... ;)
add these type of posts as resources. Blog really isn't the place. ;)
| Rob Evans (Jul 10, 2007 at 11:41 GMT) |
| Jacob Williams (Jul 15, 2007 at 18:33 GMT) |
| Torianaos (Feb 06, 2008 at 15:37 GMT) |
Edited on Feb 06, 2008 17:36 GMT
| Zac Crites (Jul 07, 2008 at 23:20 GMT) |
| Rob Evans (Jul 09, 2008 at 12:16 GMT) |
| Rob Evans (Jul 09, 2008 at 12:26 GMT) |
| Zac Crites (Jul 10, 2008 at 11:37 GMT) |
| Rob Evans (Jul 10, 2008 at 11:44 GMT) |
| Rob Evans (Jul 10, 2008 at 11:54 GMT) |
| Rob Evans (Jul 10, 2008 at 11:55 GMT) |
| Zac Crites (Jul 11, 2008 at 10:27 GMT) |
| Rob Evans (Jul 12, 2008 at 12:18 GMT) |
| Zac Crites (Jul 13, 2008 at 14:10 GMT) |
| Zac Crites (Jul 14, 2008 at 12:08 GMT) |
| Rob Evans (Jul 14, 2008 at 12:15 GMT) |
| Rob Evans (Jul 14, 2008 at 12:50 GMT) |
| Zac Crites (Jul 14, 2008 at 19:35 GMT) |
| Zac Crites (Jul 17, 2008 at 01:14 GMT) |
| Rob Evans (Jul 17, 2008 at 12:07 GMT) |
| Zac Crites (Jul 17, 2008 at 19:08 GMT) |
| Rob Evans (Jul 17, 2008 at 19:11 GMT) |
| Zac Crites (Jul 17, 2008 at 20:39 GMT) |
| Rob Evans (Jul 17, 2008 at 20:41 GMT) |
You must be a member and be logged in to either append comments or rate this resource.



4.0 out of 5


