hi all!
I have this problem: I have some far objects that aren't rendered 'cause are too far (and this is ok)....
If I suppose to add a billboard that represents the sun, and so I put it far from my camera...
is possible mantain the culling set to x and force the draw for the billboard like the skybox that is ever rendered??
thanks
ghiboz
culling problem
The skybox is actually very close to the camera. It is rendered first, centred around the camera (and so never actually moves, you can't get closer to it) and then everything else is rendered on top of it.
You could do something similar with your sun, don't actually render it at a far distance, but close up and small, rendered with a set offset from the camera's position (so it moves with the camera and you never get closer to it).
Or you could just stick a sun in your skybox...
You could do something similar with your sun, don't actually render it at a far distance, but close up and small, rendered with a set offset from the camera's position (so it moves with the camera and you never get closer to it).
Or you could just stick a sun in your skybox...
thanks, but how can I choose the render order of my nodes?JP wrote:The skybox is actually very close to the camera. It is rendered first, centred around the camera (and so never actually moves, you can't get closer to it) and then everything else is rendered on top of it.
You could do something similar with your sun, don't actually render it at a far distance, but close up and small, rendered with a set offset from the camera's position (so it moves with the camera and you never get closer to it).
Or you could just stick a sun in your skybox...
thanks in advance!
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Chip, chip. You could simply change the clip distance, and render the billboard yourself (having previously removed it from the scene).
Full example, the // commented bits are significant:
Full example, the // commented bits are significant:
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
IrrlichtDevice* device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480));
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT, true);
scene::ICameraSceneNode* camera =
smgr->addCameraSceneNodeFPS(0,100.0f,1200.f);
camera->setPosition(core::vector3df(1900*2,255*2,3700*2));
camera->setFarValue(12000.0f);
device->getCursorControl()->setVisible(false);
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
"../../media/terrain-heightmap.bmp",
0, // parent node
-1, // node id
core::vector3df(0.f, 0.f, 0.f), // position
core::vector3df(0.f, 0.f, 0.f), // rotation
core::vector3df(40.f, 4.4f, 40.f), // scale
video::SColor ( 255, 255, 255, 255 ), // vertexColor,
5, // maxLOD
scene::ETPS_17, // patchSize
4 // smoothFactor
);
terrain->setMaterialFlag(video::EMF_LIGHTING, false);
terrain->setMaterialTexture(0, driver->getTexture("../../media/terrain-texture.jpg"));
terrain->setMaterialTexture(1, driver->getTexture("../../media/detailmap3.jpg"));
terrain->setMaterialType(video::EMT_DETAIL_MAP);
terrain->scaleTexture(1.0f, 20.0f);
scene::ITriangleSelector* selector
= smgr->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector, camera, core::vector3df(60,100,60),
core::vector3df(0,0,0),
core::vector3df(0,50,0));
selector->drop();
camera->addAnimator(anim);
anim->drop();
// create skybox
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
scene::ISceneNode * skyBox = smgr->addSkyBoxSceneNode(
driver->getTexture("../../media/irrlicht2_up.jpg"),
driver->getTexture("../../media/irrlicht2_dn.jpg"),
driver->getTexture("../../media/irrlicht2_lf.jpg"),
driver->getTexture("../../media/irrlicht2_rt.jpg"),
driver->getTexture("../../media/irrlicht2_ft.jpg"),
driver->getTexture("../../media/irrlicht2_bk.jpg"));
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, true);
// This is the significant bit. Create a billboard beyond the camera's far clip
scene::IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
bill->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR );
bill->setMaterialTexture(0, driver->getTexture("../../media/particle.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
bill->setMaterialFlag(video::EMF_ZBUFFER, true);
bill->setSize(core::dimension2d<f32>(4000.0f, 4000.0f));
bill->setPosition(core::vector3df(0, 0, 20000)); // 20000 > camera far value
// Now the trick: grab a reference, then remove it from the scene - we'll render it ourselves
bill->grab();
bill->remove();
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
// draw the rest of the scene normally
smgr->drawAll();
// Now push the camera clip distance out
f32 const farClip = camera->getFarValue();
camera->setFarValue(50000); // 50000 > distance to billboard
camera->render(); // This actually sets the clip in the driver
// Then go through the render process for the billboard
bill->OnRegisterSceneNode();
bill->OnAnimate(0);
bill->render();
// And finally restore the normal clip distance
camera->setFarValue(farClip);
driver->endScene();
}
// Drop my reference to the billboard so that it's cleaned up properly.
bill->drop();
device->drop();
return 0;
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way