Rotating skybox
Posted: Sat Dec 04, 2004 11:28 am
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:
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.
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);
}
}