Game Development Community

loading a .X object model as a skybox (sphere)

by Laurence Grant · in Torque X 3D · 02/18/2009 (9:16 am) · 6 replies

Hey all,

I'm doing some prototyping in TorqueX 2.0 with 3D.

I have a sphere from 3dsmax which I've pre-mapped a sky onto the inside of the sphere, along with a few other tidbits for my concept. I want to load and render the sphere centered on the players position, and with the Zbuffer disabled and no collision detection, so the player and all level items are inside the sphere. The trick is that I draw this first before anything else. I've done this before on my own (home grown) engine and it worked very well. Is there a way I can do this in TorqueX?

#1
02/19/2009 (11:03 am)
Cool trick, sounds like it would save loads of polys from making a giant sphere roof.

I don't really have any info on how to do this, just wanted to comment on the technique.

But taking a stab, if you have the source code maybe you could look into the rendering pipeline and manually render the sphere first like a background. Then 'disable/remove/set the Z to something uber far' so the z-ordering doesn't eliminate all the other objects.

I'm sure there's a way to do it, there's always a way.

#2
02/23/2009 (7:53 pm)
This sounds interesting. Very Unreal Engine sounding. If anyone solves this, I'd be interested to know.

Brian
#3
02/25/2009 (12:39 am)
The trick is in the shader you use. It's actually super simply you just need to draw the sphere first, with zwriteenabled set to false and zsort set to false.

You then re-enable them and draw everything else as normal.

Remember to rotate the sphere correctly though, so that the player is looking at the correct part of the sphere when you draw it.
#4
02/25/2009 (5:08 am)
Thanks Peter. Do you think you could provide a little more detail? I'm still trying to learn TX so I apologize if some of these details are rudimentary.

1. Can TX natively load .x files? It looks like its just dts models?
1a. If so, how? (I’m using the FPS demo as a baseline for my code)
2. Where in the code would I want to put this
3. How do I disable the sky from rendering? (I assume this is related to 2)

Thanks

#5
02/25/2009 (11:40 am)
TX can load any model that XNA supports with it's content pipeline. The problem isn't loading the models, it's manipulating them once they are loaded.

At present I believe that Torque doesn't handle collisions with fbx or .x models, though you will still be able to display them.

The sky is simply a setting in the TX world file. If you remove the reference to the sky in that file, it will not render.

I'm afraid I don't really have time to go into too much depth with this but, there was a good overview of TX on the TDN last time I looked. It went into a little bit of detail about the world xml file (look in the TX 3D builder section).
#6
03/23/2009 (10:53 am)
The best way to do this is to change the rendering code within the engine. But a next best option might be to do the following:

1. Create a new component, maybe SkyDomeComponent. Give a reference variable that points to the player's scenecomponent. On each tick, set the component's center position equal to the player's position.

2. Add the sphere to the scene and add the SkyDomeComponent, along with a scene component and a T3XNARenderComponent (but not a static render component).

3. Set the camera's far clipping plane equal to the radius of the sphere so that it is not clipped away. You can set this to a pretty big number, but it will affect performance. Just make sure your sphere is not too big. Remember, you can use fog to help fade away the edges.

That should approximate the effect. Also remember to take out the existing sky as mentioned earlier. ;)

John K.
www.envygames.com