Find SceneNodes By Frustum
Find SceneNodes By Frustum
Hi
How can i get an array of sceneNodes witch are inside the Frustum of a camera ?
thanks
How can i get an array of sceneNodes witch are inside the Frustum of a camera ?
thanks
Re: Find SceneNodes By Frustum
create an array and traverse the scene from the root. call the method "isTrulyVisible()" for each scene node you find, and if it is visible, add it to your array. Just make sure that every node is linked to the root scene node somehow.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Re: Find SceneNodes By Frustum
isTrulyVisible() doesnt work , i debug getPrimitiveCountDrawn() and it goes down to 0 when node is behind camera but isTrulyVisible() still returns True ...
i also have another question , it seems that frustum culling is dependent on camera's far clipping value and not the actual frustum, see this picture :
http://s3.picofile.com/file/7537488274/awegwg.png
is it possible to make frustum culling use the actual camera's frustum ?
i also have another question , it seems that frustum culling is dependent on camera's far clipping value and not the actual frustum, see this picture :
http://s3.picofile.com/file/7537488274/awegwg.png
is it possible to make frustum culling use the actual camera's frustum ?
Re: Find SceneNodes By Frustum
ISceneNode::setAutomaticCulling can set different culling types: http://irrlicht.sourceforge.net/docu/na ... dc77fd9cce
And frustum far-plane is camera far-plane, there is no difference.
And frustum far-plane is camera far-plane, there is no difference.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Find SceneNodes By Frustum
thanks CuteAlien
"EAC_FRUSTUM_BOX" was what i looking for
but here is another not so important problem ( or mabye bug )
i added for example 10 meshSceneNode each has 20 triangle and set all of them to EAC_FRUSTUM_BOX ...
getPrimitiveCountDrawn() always show 20 primitive is rendering even if non of them are inside the frustum , i think the first meshSceneNode will never be culled ... however for the other 9 it works well.
i still have problem with my first question
"EAC_FRUSTUM_BOX" was what i looking for
but here is another not so important problem ( or mabye bug )
i added for example 10 meshSceneNode each has 20 triangle and set all of them to EAC_FRUSTUM_BOX ...
getPrimitiveCountDrawn() always show 20 primitive is rendering even if non of them are inside the frustum , i think the first meshSceneNode will never be culled ... however for the other 9 it works well.
i still have problem with my first question
Re: Find SceneNodes By Frustum
It's checking the boundingbox of meshes against the frustum - not the triangles (that would be too expensive).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Find SceneNodes By Frustum
yes i mean bounding box and not triangles , all sceneNodes ( bounding boxes ) are completely outside the frustum ... but getPrimitiveCountDrawn() shows 20 primitive ( one of those meshSceneNodes ) is rendering ...
Re: Find SceneNodes By Frustum
That shouldn't happen, can't really say much without a test-case.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Find SceneNodes By Frustum
I think sceneNodes with scale around 100 and above have problem with frustum culling
when i set scale around 50 and below everything is OK ...
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
int main()
{
IrrlichtDevice* device = createDevice(EDT_OPENGL, dimension2d<u32>(800,600),32,false,false,false);
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* scene = device->getSceneManager();
ICameraSceneNode* camera = scene->addCameraSceneNodeFPS(0 , 100.0 , 20.0);
camera->setFarValue(10000);
for (int i = 0; i < 10 ; ++i)
{
IMeshSceneNode* node = scene->addCubeSceneNode(2.0);
node->setPosition(vector3df(i * 500.0 , 0.0 , 500.0));
node->setAutomaticCulling(EAC_FRUSTUM_BOX);
node->setScale(vector3df(100 ,100 ,100));
}
while (device->run())
{
stringw primitiveCount(L"Primitive Count = ");
primitiveCount += driver->getPrimitiveCountDrawn();
device->setWindowCaption(primitiveCount.c_str());
driver->beginScene(true,true,SColor(255,128,64,255));
scene->drawAll();
driver->endScene();
}
device->drop();
return 0;
}
-
- Posts: 36
- Joined: Mon Jan 23, 2012 11:14 pm
- Location: Lancs, UK
Re: Find SceneNodes By Frustum
In my opinion if you decrease the placement from 500.0 to 5.0 would help,cause 1x500 = 500, 2x500 = 1000, 3 x 500 = 1500 etc... you get the picture
EDIT: sorry completely misunderstuded the question. ^_^
EDIT: sorry completely misunderstuded the question. ^_^
Last edited by jaworekplay on Wed Dec 19, 2012 4:10 am, edited 1 time in total.
Re: Find SceneNodes By Frustum
Thanks for the testcase. It's definitely a bug - and at least for that case it would even be easy to fix.
In CMatrix4<T>::getInverse(CMatrix4<T>& out) in line 1329 the iszero check needs to be replaced by:
From what I can see that looks correct and would make more sense - and it would fix the problem here.
There's just one problem now... before version 362 it looked exactly like that and then was changed. Unfortunately no commit message so I've got no idea why that was done. And the code used there is some asm code which I don't understand, so no idea if it maybe caused crashes with certain values or something *sigh*.
I would just revert that change, but moving it to bugforum now in case anyone else has some feedback before I mess something up. And I try if I can reach the author of that change (not certain if he's still around...).
In CMatrix4<T>::getInverse(CMatrix4<T>& out) in line 1329 the iszero check needs to be replaced by:
Code: Select all
if( d == 0 )
return false;
There's just one problem now... before version 362 it looked exactly like that and then was changed. Unfortunately no commit message so I've got no idea why that was done. And the code used there is some asm code which I don't understand, so no idea if it maybe caused crashes with certain values or something *sigh*.
I would just revert that change, but moving it to bugforum now in case anyone else has some feedback before I mess something up. And I try if I can reach the author of that change (not certain if he's still around...).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Find SceneNodes By Frustum
Ok, original patch writer is still reading the forum and gave me permission to change this stuff :-) Check-out newest irrlicht svn trunk version (r4343), it will work there.
Thanks for reporting.
Thanks for reporting.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm