star field, and some ideas to implement

View previous topic View next topic Go down

star field, and some ideas to implement

Post  Blamm! on Tue Nov 18, 2008 12:51 am

Newbers here....

Id like to model a star field that I can then place a simple model on and move about the starfield. Should I go the route of a sky box? If so will it will be possible to reach the end of the sky box, what then are my options. Mainly I want to be able to fly away from static objects for a very long time with a star field in the background, and then be able to turn back and reach those same points. A 2d camera point of view/or orthagonal(diablo style) will be fine. Any conceptual answers and also methods of creating this with the blender/sio2 workflow will be much appreciated! Will be using a waypoint method to move my flying object ( click on screen, object and camera move till object is at waypoint, object then sits)

Blamm!

Posts : 23
Join date : 2008-11-18

View user profile

Back to top Go down

Re: star field, and some ideas to implement

Post  sio2interactive on Tue Nov 18, 2008 4:48 am

To create the illusion that the stars are far far away, simply disable the depth buffer when you render your stars (skybox or 2D background). To do in 3D simply call:

glDisable( GL_DEPTH_TEST );
glDepthMask( GL_FALSE );
...
...
render the sky
...
...
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );
...
...
render the rest of your scene
...
...
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: star field, and some ideas to implement

Post  matt on Tue Nov 18, 2008 3:53 pm

I asked the same question some time ago while I was wondering whether SIO2 offers something like that. Here's the idea a little bit more detailled:

1. Get the SIO2object* which represents your skybox from the resources.
Code:
SIO2object* skybox = (SIO2object*) sio2ResourceGet( sio2->_SIO2resource, SIO2_OBJECT, "object/skybox" );

2. In your render-loop, right after you've applied the camera (sio2CameraRender, sio2CameraUpdateFrustum) and culled the scene (sio2ResourceCull), disable Z-buffer writing and testing as sio2interactive suggested.
Code:
glDisable( GL_DEPTH_TEST );
glDepthMask( GL_FALSE );

3. Render the sky. One particular thing to remember is to set the "dst" attribute of the object in question to a value above 0, otherwise it won't become rendered (this value is filled by the culling implementation, 0 means that the object is currently out of sight). This fact of course becomes handy when rendering the rest of the world below, so we're setting it to 0.0f right after we rendered it.
Code:
skybox->dst = 1.0f;
sio2ObjectRender( skybox, sio2->_SIO2camera, 1 );
skybox->dst = 0.0f;

4. Reenable Z-buffer writing and testing.
Code:
glEnable( GL_DEPTH_TEST );
glDepthMask( GL_TRUE );

5. Render the rest of your scene.
Code:
sio2ResourceRender( sio2->_SIO2resource, sio2->_SIO2window, sio2->_SIO2camera, SIO2_RENDER_SOLID_OBJECT | SIO2_RENDER_EMITTER );

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

View user profile http://elfrun.net

Back to top Go down

thanks!

Post  Blamm! on Wed Nov 19, 2008 12:33 am

thanks, Ill look into this, right now however i am struggling with my crashing blender and my macbook which i dumbly upgraded to 10.5.5

Blamm!

Posts : 23
Join date : 2008-11-18

View user profile

Back to top Go down

Re: star field, and some ideas to implement

Post  meteors on Thu Nov 20, 2008 12:56 pm

Hey,

Would anyone care to share code to display a 2D background image?


Thanks in advance,
-joshua
avatar
meteors

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

View user profile

Back to top Go down

Re: star field, and some ideas to implement

Post  Blamm! on Sun Dec 14, 2008 7:19 pm

yes that would be helpful if anyone has code that I could look over.

Blamm!

Posts : 23
Join date : 2008-11-18

View user profile

Back to top Go down

Re: star field, and some ideas to implement

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum