View Full Version : SpaceGame : Sphere for game area
10-13-2008, 02:32 AM
Hi, I want to make a 3d space invader type game. I was thinking of making a massive sphere with a texture mapped sky ( e.g stars nebula e.t.c) . Is this the way to achieve this , I.E are the spheres hollow and would i be able to see the texture on the outside of the sphere? Then I can just set boundaries of the game by radius from origin
10-13-2008, 03:31 AM
Not sure what you're trying to achieve.
If you want to be inside this sphere and see stars all around you, then you don't need large sphere.
Actually it doesn't matter if it's big or not. All that matters it that it should travel with the camera.
When rendering you should first clear your screen, then disable depth testing, draw your sphere around the camera, enable depth testing and draww all other objects.
Because sphere was rendered without depth testing, it will get overlapped by other objects, even if sphere is small, because it was drawn first and it didn't leave any trace of itself in depth buffer.
10-13-2008, 12:35 PM
What you describe is called a skybox or skydome (depending on the geometry used, box or sphere/hemisphere), which is in essence a background image dependent on your viewing direction.
If you have a fixed viewing direction, you will be easier off using a textured full screen quad at maximum distance (far clipping plane) to draw a background.
If you want do implement a skydome, your approach of using an appropriate sized sphere is preferable for two reasons:
First, you don't need to disable and re-enable the depth test (state changes are potentially costly).
Second, if your scene does not include semi-transparent object, you can draw your background last, so your early-z hardware is able to discard fragments behind your scene geometry.
A sphere is made up of triangles, as is every object, at least when it comes to raster graphics (which is what opengl is about).
So yes, a sphere is hollow.
But you typically will distinguish both sides of said triangles, and draw only those facing the camera, a process called backface culling.
So if you place your camera inside a sphere and backface culling is enabled, your sphere will not show up at all. You need to flip in- and outside, which is easily done by scaling your sphere with a negative factor on one axis.
10-14-2008, 01:32 AM
hi thanks for your great replies!
I've also been wondering about how we allow the camera to be moved around an object whilst mouse click ( e.g like WoW around the character).
Do we change gluLookat or do we rotate the whole world? Also is this best method for this to say, when user clicks start a listener that takes uses curr mouse position and position upon click and uses the difference between then on X & Y axis. Then it assigns the new EyeXYZ vector from a rotation about an angle theta which increases for each pixel displaced by the mouse..
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.