Space field

Started by
9 comments, last by Hog 20 years, 2 months ago
Ok just trying to get me head round this If I had a space ship model located at the origin and I wanted to allow the user to use the keys to move the camera around the space ship in any direction then this I believe would be quite simply. But if I wanted the background to display a space scene all the time how would I go about this? Would it be something like this?? The space ship remains static at the origin. The camera does all the moving. The space ship and the camera are inside a large sphere which has a space image texture loaded to its interior, thus no matter where the camaera moves within the confine of the sphere the background would be space. Is this how it is done? Is it possible to put a texture indise a sphere and actually display it?
(Visual Basic .NET) www.elpuerco.co.uk
Advertisement
Okay - imagine your world is a box with all the normals pointing inwards.

Just texture this cuboid with some neat space backdrop and you''re there
OK lost me

Point or the normals inward? Can u clarify?
(Visual Basic .NET) www.elpuerco.co.uk
Okay..

Imagine that your ''universe'' is contained within the walls of a giant cuboid.

The 6 faces of the cuboids are the sides of your univserse, if they face inwards (normals pointing in) then the textures you apply will be reversed. If you point them inwards then the textures you apply will be mapped correctly and the surfaces won''t be culled by your renderer
budder bing budder boom

thnX I shall have a play
(Visual Basic .NET) www.elpuerco.co.uk
Does this method/approach only hold true if I create the cuboid with a list of vertices?

for example would this work...

If I created a cubiod in anim8or, converted to x format then when I loaded the mesh scaled it to say 1000 square and placed the camera at the origin. Would I be able to load a texture to int inside faces?
(Visual Basic .NET) www.elpuerco.co.uk
Should do, if you have each face with inward pointing normals.

It''s no different to modelling a room in MS3d and having the camera inside it.

have a look at the low-poly tutorials on Psionic3D; he explains how to create a FPS style room in a modeller and have it used as a ''level'' in a game.

The principle is the same as what you''re trying to do.
A cube who's inside is textured with some kind of background image is called a skybox. If you try to make a skybox a particular size, then when you place the objects of your game inside this skybox, you're going to have to always keep in mind that you can't place objects outside the limits of the skybox.

To get around this, what you do is just make your skybox a reasonable size (could be anything. 2x2x2, 10x10x10, etc...) and just disable the z-buffer right before you draw the skybox. At the beginning of your render method, you turn off the z-buffer (using SetRenderState), draw your skybox at the position of the camera, then turn the z-buffer back on (again, using SetRenderState). Then you draw the rest of your world as normal.

Turning off the z-buffer and drawing the skybox first basically initializes the background for the scene. Everyting that you draw afterword will be drawn on top of the skybox background reguardless of how far away it actually is. This creates the illusion that the background is really far away.

neneboricua

[edited by - neneboricua19 on January 20, 2004 4:10:15 PM]
Kool

However, this puzzles me...

Say I have my skybox and I have scaled it 1000*1000*1000, (I think this should create a nice world?), and place the camera in it.

So if I have the camera at the origin, how would I know where to set the position of the skybox?

I mean, which vertex decides the starting location of the skybox, or am I showing an incedible ignorance here
(Visual Basic .NET) www.elpuerco.co.uk
There was a point when all This is the idea: you build your skybox about the origin. So if you want the length of the sides to be, say 100, then the vertices of your box are at (-50, 50, 50), (50, 50, 50), etc...

In your code, you then translate the box to the location of your camera. It would look something like this:
D3DXMATRIX matTranslate;D3DXMatrixTranslation( &matTranslate, m_pCamera->GetPosition().x, m_pCamera->GetPosition().y, m_pCamera->GetPosition().z );m_pd3dDevice->SetTransform( D3DTS_WORLD, &matTranslate );m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );m_pSkyBox->Render()m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); 

This will place the center of the skybox at the position of the camera.

Hope this helps,
neneboricua

This topic is closed to new replies.

Advertisement