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
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.
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.
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…