Game Development Community

SkySphere for TSE

by Chris Schletter · in Torque Game Engine Advanced · 10/20/2005 (2:04 pm) · 40 replies

Ok,

Let me preface this with the assertion that I am a novice at 3D programming; I've spent my entire career in the business software development world. That being said...

I have been looking at doing space environments in Torque, and originally started with TGE, but since I wasn't too far along I decided to go ahead and just do everything with TSE. Originally I wasn't too worried about the skybox as I was just going to use a black skybox and dynamically place stars based on known stars and deep space object positions; however that is a lot of stars that need to be accounted for based on where you are looking in the night sky and I felt for background it probably wasn't the ideal situation; at least to start with.

I decided that I needed some type of skybox, so I started to convert the www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3007 "space"box over to TSE. I was successful at this, as it wasn't too hard, however I did decide to go ahead and create a skysphere after reading as much stuff as I could (and could understand, since all my hard fought for math skills have evaporated in the years since college). I did find the www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6644 but attempts to convert it met with unsatisfactory results. I ended up creating a skysphere based on the alogrithm found at astronomy.swin.edu.au/~pbourke/opengl/sphere to produce the Space class as a sphere with . At this point it only uses a single texture that is, a power of 2 of course, 2x1 in dimensions. It of course has the issue with scrunching the texture at the poles.

To use the code, you'll need to do the following:

a) Install the starter.fps for TSE from www.garagegames.com/mg/forums/result.thread.php?qt=33640.
b) Unzip the space.zip to your root TSE folder. The zip can be gotten from www.thzero.com/programming/torque/TSESkySphere.zip
c) Add the space.cpp and space.h files to your TorqueShaderEngine project in the Source Files\terrain folder.
d) Recompile the TorqueShaderEngine project.
e) Start up TSE with starter.fps and open the mission editor and load the space.mis. It should successfully load the mission, without terrain, and a skysphere with the MilkyWay galaxy displayed in all its glory.

There are a couple issues:
a) the poles are not north/south oriented. I am not sure why, nor can I seemingly get it to rotate. Kinda frustrating, since I originally wrote this in a simple OpenGL app and it was oriented correctly. If anyone has any ideas on this....
b) The fore-mentioned scrunching of the texture around the poles.

If anyone knows of a solid algo for doing a textured geosphere, please let me know, as I have not found one in scouring the 'net. This would solve the issue with the textures as all the triangles that make up the sphere are the same size.

Also, if you have any comments or suggestions for alpha blending of variety of textures, performance enhancements, etc. let me know.

www.thzero.com/OrcInSpace.jpg
Page «Previous 1 2
#1
10/20/2005 (3:26 pm)
I have a functioning TSE SkySphere based loosely off my my earlier TGE code, however, I believe you probably have a third issue that you are not yet realizing, or have not noticed...


a) the poles are not north/south oriented. I am not sure why, nor can I seemingly get it to rotate. Kinda frustrating, since I originally wrote this in a simple OpenGL app and it was oriented correctly. If anyone has any ideas on this....

Because Torque uses the Z axis as Up and Down, and most apps use Y.

b) The fore-mentioned scrunching of the texture around the poles.

You have you handle this in the texture itself, clean up the poles.

The third issue is that on where the 'prime meridian' of the sphere would be, you will probably notice, if you use nebular skyspheres like myself, that you get a clamping error of around 1px in size on that meridian.

--BTW--, my skysphere resource used that same algorithm to generate the sphere array in the first place :)
#2
10/20/2005 (4:44 pm)
Odd, since I converted yours to TSE and it would never display a full sphere correctly. Probably something I converted wrong with the graphics calls I suppose. Yes I did realize the error on the meridian, I'd just forgotten to mention it. Whats the best way to account for that?

If I read your code right, it looks like you were doing 20 triangle strips of 40 triangles, correct? If so, is there a performance benefit to doing that rather than doing it as a single strip of triangles?
#3
10/20/2005 (5:18 pm)
No, it's just easier to set up. I have no idea how to account for the meridian error.

My new skysphere for TSE is a milkshape model exported into pure vertices for use in TSE, and has around 5000 triangles :o .
#4
10/21/2005 (12:28 pm)
Ok,

The TSESkySphere.zip has been updated. The sphere is now oriented with its poles on the z-axis (edit) instead of being on the y-axis.
#5
10/21/2005 (12:47 pm)
The poles should be oriented on the Z axis. If you figure out how to fix the meridian clamping error, let me know. I had to convert my sphere-map textures into cube textures.
#6
11/03/2005 (12:55 pm)
This would be better called StarSphere than skysphere...

Implying your in space instead of in a sky or atmosphere.
#7
11/03/2005 (1:38 pm)
You can always change the texture to make it as if you were in an atmosphere... (also, my skyspheres for Kuiper do not have stars -- those are rendered separately.)
#8
02/14/2006 (2:16 pm)
Can you repost the link to the TSE Space Skybox??

Toby.
#9
02/14/2006 (7:00 pm)
Should be back available.
#10
02/15/2006 (2:45 pm)
I keep getting the following error when trying to compile this, am I missing something somewhere?
\tse space\engine\sim\sceneobject.cpp(28) : error C2039: 'csmVisibleDistance' : is not a member of 'SceneObject'
\tse space\engine\sim\sceneobject.h(232) : see declaration of 'SceneObject'
#11
02/21/2006 (1:09 pm)
I got that error too, so I commented out the lines of code that used the csmVisibleDistance variable:
Space::Space()
{
	mTypeMask |= EnvironmentObjectType;
	mNetFlags.set(Ghostable | ScopeAlways);

	mFirstRun = 0;

//	mVisibleDistance = SceneObject::csmVisibleDistance;

	mGravity = -20;

	mLastForce16Bit = false;
	mLastForcePaletted = false;
}

I also had to comment out a reference to a "Spacetexture" that wasnt defined: (in bool Space::loadDml()

else
   {// !!!!!TBD dhc - there's no fricking error checking here or in materialList.read!!!!
      mMaterialList.read(*stream);
      ResourceManager->closeStream(stream);
	  //Spacetexture
    //  if(!mMaterialList.load(Spacetexture, path))
      //   return false;

	  // Currently only using the first
      for(S32 x = 0; x < 6; ++x)
         mSpaceHandle[x] = mMaterialList.getMaterial(x);

It compiles with no errors or warnings, but when I load the space mission I get no skybox at all, the whole thing is just completly pink. There are no errors or warnings in the console, and the same thing happens when I try to add a new skysphere to an existing mission.
I tried defining both csmVisibleDistance and SpaceTexture, but I couldnt get it to work. It compiled, but I must not have defined it right in sceneobject.h. Its quite difficult to find where to add it in, and what data type to use. (F32, U32?)
It might help if I could see your changes to sceneobject.h? You include sceneobject.cpp in your .zip, but the changes in that dont have any effect, even when I uncomment const F32 SceneObject::csmVisibleDistance = 3400.0f;
Thanks for any advice,
JS
#12
02/22/2006 (4:33 pm)
Ok I put F32 csmVisibleDistance; in my SceneObject class, and I have it compiling with no errors or warnings with the csmVisibleDistance code uncommented from space.cpp, but I still get the pink skybox.
I have still commented out he "SpaceTexture" lines.
JS
#13
03/06/2006 (9:52 am)
Ok,

I re-uploaded the zip with the missing sceneObject.h file.

Sorry, been busy with other projects and moving, so haven't been dealing with Torque at all in some time.
#14
03/10/2006 (10:29 am)
Ok,

I re-loaded the archive after updating to the latest TSE build. It does all work, but do check the http://www.garagegames.com/mg/forums/result.thread.php?qt=33640 for a fix with the starter.fps.

If you are using this, making changes to it, please post back to it or send me the changes and I can update the archive so that everyone benefits!
#15
03/10/2006 (1:20 pm)
I get this error when trying to compile for TSE ..\engine\terrain\space.cpp(214) : error C2065: 'SpaceTexture' : undeclared identifier
Thanks
#16
03/10/2006 (1:29 pm)
More than likely you don't have the material.h properly compiling.
#17
03/10/2006 (1:43 pm)
Humm, thats not in your download. Is that something that is already into TSE sorce?
Thanks
#18
03/10/2006 (2:05 pm)
That would explain it. Ok, archive has been updated.
#19
03/10/2006 (2:46 pm)
Humm, same error.
#20
03/10/2006 (2:51 pm)
This is the line with the error. if(!mMaterialList.load(SpaceTexture, path))
Page «Previous 1 2