Rotating skybox

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Rush
Posts: 14
Joined: Wed Nov 24, 2004 11:00 am
Location: Hell

Rotating skybox

Post by Rush »

It's not a bug, but a missing feature. I can't find any reason why the skybox node can't be rotated (or scaled), so I'm posting here the code to fix it. It's just changing one line in CSkyBoxSceneNode.cpp:

Code: Select all

void CSkyBoxSceneNode::render()
{
	video::IVideoDriver* driver = SceneManager->getVideoDriver();
	scene::ICameraSceneNode* camera = SceneManager->getActiveCamera();

	if (!camera || !driver)
		return;
        // this line. previous was simply core::matrix4 mat; 
	core::matrix4 mat = AbsoluteTransformation; 
	mat.setTranslation(camera->getAbsolutePosition());

	driver->setTransform(video::ETS_WORLD, mat);
	
	for (s32 i=0; i<6; ++i)
	{
		driver->setMaterial(Material[i]);
		driver->drawIndexedTriangleList(&Vertices[i*4], 4, Indices, 2);
	}
}
Of course you could achieve the same effect by rotating all the other nodes in the opposite direction, but rotating only the skybox seems simpler. I saw rotating skyboxes in many games (remember the space station level from Unreal Tournament?), so I think it should be implemented into the next version of Irrlicht.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

:D Thanks,
I just playing this night with that. I got:
- rotating skybox /moving clouds/ with Irrlicht rotation animator
- changing of sizes of the skybox
- with appropriate size I got very good fog effect on the skybox.

Very useful! Just one line of code :lol
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

etcaptor, do you have screenshots/an example program of those effects? They seem to be really nice :).
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Hi bal,
I'll will post tonight, but cannot post rotation :lol:
When good options for fog and sizes for the skybox are used, you can get more realistic scene. I will post some options for example.
I use my visual editor at now for testing, because I,m so lazy to write example program, but can say that you can get this with only several lines of code.

OK, posted. You can see pictures here:

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=4470
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

BUG IN CSkyboxSceneNode with fix

Post by etcaptor »

There is a bug in ScyBoxSceneNode. Exactly tis is a displacement. Materials and textures are displace towar constructor parameters.

Code: Select all

addSkyBoxSceneNode  (  video::ITexture *    top,  
  video::ITexture *    bottom,  
  video::ITexture *    left,  
  video::ITexture *    right,  
  video::ITexture *    front,  
  video::ITexture *    back,  
  ISceneNode *    parent = 0,  
  s32    id = -1 
 ) 
But we get

Code: Select all

 video::ITexture *    front,  
  video::ITexture *    left,  
  video::ITexture *    back,  
  video::ITexture *    right,  
  video::ITexture *    top,  
  video::ITexture *    bottom,  
instead.

FIX:

Code: Select all

	// create top side

	Material[0] = mat;
	Material[0].Texture1 = top;

	Vertices[0] = video::S3DVertex( l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, o);
	Vertices[1] = video::S3DVertex(-l, l, l, 0,-1,0, video::SColor(255,255,255,255), o, t);
	Vertices[2] = video::S3DVertex(-l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, t);
	Vertices[3] = video::S3DVertex( l, l,-l, 0,-1,0, video::SColor(255,255,255,255), t, o);

	// create bottom side

	Material[1] = mat;
	Material[1].Texture1 = bottom;

	Vertices[4] = video::S3DVertex(-l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, o);
	Vertices[5] = video::S3DVertex( l,-l, l, 0,1,0, video::SColor(255,255,255,255), o, t);
	Vertices[6] = video::S3DVertex( l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, t);
	Vertices[7] = video::S3DVertex(-l,-l,-l, 0,1,0, video::SColor(255,255,255,255), t, o);

	// create left side

	Material[2] = mat;
	Material[2].Texture1 = left;

	Vertices[8] = video::S3DVertex( l,-l,-l, -1,0,0, video::SColor(255,255,255,255), o, t);
	Vertices[9] = video::S3DVertex( l,-l, l, -1,0,0, video::SColor(255,255,255,255), t, t);
	Vertices[10] = video::S3DVertex( l, l, l, -1,0,0, video::SColor(255,255,255,255), t, o);
	Vertices[11] = video::S3DVertex( l, l,-l, -1,0,0, video::SColor(255,255,255,255), o, o);


	// create right side


	Material[3] = mat;
	Material[3].Texture1 = right;

	Vertices[12] = video::S3DVertex(-l,-l, l, 1,0,0, video::SColor(255,255,255,255), o, t);
	Vertices[13] = video::S3DVertex(-l,-l,-l, 1,0,0, video::SColor(255,255,255,255), t, t);
	Vertices[14] = video::S3DVertex(-l, l,-l, 1,0,0, video::SColor(255,255,255,255), t, o);
	Vertices[15] = video::S3DVertex(-l, l, l, 1,0,0, video::SColor(255,255,255,255), o, o);

   // create front side

	Material[4] = mat;  
	Material[4].Texture1 = front;    

 	Vertices[16] = video::S3DVertex(-l,-l,-l, 0,0,1, video::SColor(255,255,255,255), o, t);
	Vertices[17] = video::S3DVertex( l,-l,-l, 0,0,1, video::SColor(255,255,255,255), t, t);
	Vertices[18] = video::S3DVertex( l, l,-l, 0,0,1, video::SColor(255,255,255,255), t, o);
	Vertices[19] = video::S3DVertex(-l, l,-l, 0,0,1, video::SColor(255,255,255,255), o, o);


	// create back side

	Material[5] = mat;               
 	Material[5].Texture1 = back;   

	Vertices[20]  = video::S3DVertex( l,-l, l, 0,0,-1, video::SColor(255,255,255,255), o, t);
	Vertices[21]  = video::S3DVertex(-l,-l, l, 0,0,-1, video::SColor(255,255,255,255), t, t);
	Vertices[22] = video::S3DVertex(-l, l, l, 0,0,-1, video::SColor(255,255,255,255), t, o);
	Vertices[23] = video::S3DVertex( l, l, l, 0,0,-1, video::SColor(255,255,255,255), o, o);
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Well, I was going to post all my code for how I implemented a SkyDome ( actually a sphere ), completely in irrlicht, with the option of either loading a texture on it, or shading the sphere based on times of day with plain colors. Also with the ability to add a rotating cloud "layer" as well as automatic rotation of the SkyDome based on time, however since these shitty forums keep timing out on me, I lost the post and I'm not going to re-type it. If anyone's interested in the code, email me and I can show it to you.

Better yet, I'll get the code posted on my website and I'll link to it. I'll post here when I get the code up..
Guest

Post by Guest »

Sounds very interesting. I'll be waiting for the link to your site.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

:oops: Sorry forgot to login.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Here's the link to the page -

My code here at home is not as up to date as the code I have at work for my engine. This code doesn't yet have the rotation in or the option to fade colors of the sky by a day/nite ratio.

http://www.spintz.com/irrlicht/irrlichtskydome.php

Email me or PM me to report bugs, request features, or curse me out for it just plain not working!

Hope it helps you all! Looks a million times better than a SkyBox!
Last edited by Spintz on Fri Dec 10, 2004 2:35 am, edited 1 time in total.
etcaptor
Posts: 871
Joined: Fri Apr 09, 2004 10:32 pm
Location: Valhalla
Contact:

Post by etcaptor »

Thanks, looking promising. I will test it this weekend. And of course we will waiting for any changes if you update your code.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I added a screenshot to that page ( and changed the location or it, put it all in an irrlicht directoy on my webpage ) so that you can see how it looks, with a very quickly generated texture.

It looks really, really nice with the clouds and rotation added to it! I'll try and get that updated tomorrow!
Rush
Posts: 14
Joined: Wed Nov 24, 2004 11:00 am
Location: Hell

Post by Rush »

I took a look at your code. Wouldn't it be faster to write a single drawIndexedTriangleList call in the render() method, instead of calling it for each single quad?
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Yes, however, in the future versions, you will be allowed to change the resolution of the skybox, and then you cannot have static indices. As they will change based on the resolution of the skybox.
angel80
Posts: 22
Joined: Mon Feb 07, 2005 1:37 pm
Location: Paris (France)

About Skydome

Post by angel80 »

Hi,
I'm an irrlicht begginer user. I'd like to make a outdoor scene, to do I'd like to make a skydome instead of skybox. Can u post your code of skydome because I can't reach your link..
Thank a lot
.: Franck :.
cartoonit
Posts: 286
Joined: Mon Nov 15, 2004 6:36 pm

Post by cartoonit »

This might be just the version of the engine that I am using 0.7, but where's this wrong construction of the skybox??

Code: Select all

virtual ISceneNode* addSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom,
video::ITexture* left, video::ITexture* right, video::ITexture* front,
video::ITexture* back, ISceneNode* parent = 0, s32 id=-1);
Then in the call I have the following sent over to the constructor

Code: Select all

CSkyBoxSceneNode(video::ITexture* top, video::ITexture* bottom, video::ITexture* left,
video::ITexture* right, video::ITexture* front, video::ITexture* back, ISceneNode* parent, ISceneManager* mgr, s32 id)
What I don't understand is:

Code: Select all

But we get

    code:  video::ITexture *    front, 
      video::ITexture *    left, 
      video::ITexture *    back, 
      video::ITexture *    right, 
      video::ITexture *    top, 
      video::ITexture *    bottom, 
Post Reply