Ray casting and multiple Objects
Ray casting and multiple Objects
Hey
I think I'm posting to much. Hope you guys aren't saying, "Ahh, not Mr_Ridd again." Anyway, I'm here to learn.
Ok, ray casting. It works fine except if one object is in front of another object. I've tried to hide the foremost object and then test again but it doesn't work. I've also tried to remove it and that didn't work.
What could I do to solve this problem?
Thanks
I think I'm posting to much. Hope you guys aren't saying, "Ahh, not Mr_Ridd again." Anyway, I'm here to learn.
Ok, ray casting. It works fine except if one object is in front of another object. I've tried to hide the foremost object and then test again but it doesn't work. I've also tried to remove it and that didn't work.
What could I do to solve this problem?
Thanks
well what exactly is your problem? Something to do with raycasting and objects being in front of other objects obviously, but what exactly are u trying to do?
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars
Well, basically I'm writing a level editor. In short, if one object is in front of another object and it is locked then I don't want to test it for an intersection with the cast. I know you are probably saying that I could just rotate the camera but in some instances that won't work.
All models are in a array. Thats how I do my testing. I run through the array and test every model untill one hits. If one hits but it is locked, I hide that model, redo the test and then show it again.
Sometimes it works and sometimes it doesn't.
All models are in a array. Thats how I do my testing. I run through the array and test every model untill one hits. If one hits but it is locked, I hide that model, redo the test and then show it again.
Sometimes it works and sometimes it doesn't.
Did you try using the SceneNode-IDs ?
For example group your scenenodes in two groups :
Enabled : (0x0001)
Disabled : (0x0010)
check this post too :
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2859
For example group your scenenodes in two groups :
Enabled : (0x0001)
Disabled : (0x0010)
check this post too :
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2859
Hardwarespecs in signatures suck !
Well, that whole discussion confused my brain.
One thing I did see was how they did the tests.
if( current->isVisible() ) etc...
As I said in an earlier post, I hide the locked objects and then redo the test. It's odd because sometimes it works and sometimes it doesn't work. The reason why I hide, test, unhide is so that you can still see the object even though it is locked.
Take this for example:
I load a tree, at 0,0,0. I then add another tree at 0,0,0. So I can only see one tree even though there are two. I then click on one, it doesn't matter which one gets selected and I lock it. This leaves one tree selectable. Now this is the confusing part. If I click on the tree I can't select it, if I rotate the camera a bit and click on it I can. How does this work? It's not like the one tree is a bit off centre.
One thing I did see was how they did the tests.
if( current->isVisible() ) etc...
As I said in an earlier post, I hide the locked objects and then redo the test. It's odd because sometimes it works and sometimes it doesn't work. The reason why I hide, test, unhide is so that you can still see the object even though it is locked.
Take this for example:
I load a tree, at 0,0,0. I then add another tree at 0,0,0. So I can only see one tree even though there are two. I then click on one, it doesn't matter which one gets selected and I lock it. This leaves one tree selectable. Now this is the confusing part. If I click on the tree I can't select it, if I rotate the camera a bit and click on it I can. How does this work? It's not like the one tree is a bit off centre.
Bru, what's up with this
I'm not here to make enemies, I'm sorry if you took offence. I do apologise.
Now to erSitzt and Tyn, so I don't get my head bitten off again. How do you set the id's, and then of couse get them. Is it with node->setID() and node->getID().
Once again... I'm sorry erSitzt
Where did you think I got isVisible() thing from. I don't know anything about Scenenode ID's. So saying "No I havn't tried it", wouldn't help. I didn't ignore your post.Sry for posting...
i'll ignore your answers too if you post some...
I'm not here to make enemies, I'm sorry if you took offence. I do apologise.
Now to erSitzt and Tyn, so I don't get my head bitten off again. How do you set the id's, and then of couse get them. Is it with node->setID() and node->getID().
Once again... I'm sorry erSitzt
-
Guest
That's the one, yep. If you set the id bit mask to 2 and then set all nodes that you want to display at 2, the rest set to 1 and it will work fine. It works by masking any node that's ID has the masked figure inside it. So if you had the bitmask set to 2 then the following ID's would all be tested:Mr_Ridd wrote: Now to erSitzt and Tyn, so I don't get my head bitten off again. How do you set the id's, and then of couse get them. Is it with node->setID() and node->getID().
0x0010 = 2
0x0110 = 6
0x0111 = 7
0x1111 = 15
The following are examples of one's that would not be tested:
0x0000 = 0
0x0100 = 4
0x0101 = 5
0x1101 = 13
I'm not biting your head off but all the information is either in the API or in that link that was posted, you could have checked it out and tried to do it on your own steam.
I'm still a bit confused. I've read the link but I'm still confused about what you said. In the quote above it appears that I have to set two things. Ok, I know I must use node->setID(), I presume that refers to , "and then set all nodes that you want to display at 2". But then how do I set the bit mask?If you set the id bit mask to 2 and then set all nodes that you want to display at 2, the rest set to 1 and it will work fine.
I'm still quite new the engine.
Edit: I just found this now... getSceneNodeFromScreenCoordinatesBB(). I can pass a bit mask into it. Is this how I set the bit mask?
Thanks
Assume you have only two stati for SceneNodes :
Enabled (0x0001)
Disabled (0x0010)
1. ) Whenever you create a SceneNode use a ID (Enabled) in the constructor ( Have a look at the API which param it is )
2. ) Create a ray that selects all SceneNode with a specific ID.
Thats it.
To disable SceneNodes you can do this :
mynode->setID(0x0010)
P.S.
This is from the API
virtual ISceneNode * getSceneNodeFromRayBB (core::line3d< f32 > ray, s32 idBitMask=0)=0
and you would use :
YourCollMgr->getSceneNodeFromRayBB(yourline, 0x0001)
as you can see
0x0001 and
0x0010
do not match , so disabled nodes are not selected...
Got it ?
Enabled (0x0001)
Disabled (0x0010)
1. ) Whenever you create a SceneNode use a ID (Enabled) in the constructor ( Have a look at the API which param it is )
2. ) Create a ray that selects all SceneNode with a specific ID.
Thats it.
To disable SceneNodes you can do this :
mynode->setID(0x0010)
P.S.
This is from the API
virtual ISceneNode * getSceneNodeFromRayBB (core::line3d< f32 > ray, s32 idBitMask=0)=0
and you would use :
YourCollMgr->getSceneNodeFromRayBB(yourline, 0x0001)
as you can see
0x0001 and
0x0010
do not match , so disabled nodes are not selected...
Got it ?
Hardwarespecs in signatures suck !
I have copied some functions from Irrlicht, include in my code and modified some parameters. Well, some results are more experimental then clean fundamentalpuh wrote:etcaptor, how did you resolve this problem in your world editor? Could you explain a little bit?
In function
getSceneNodeFromRayBB(core::line3d<f32> ray, s32 idBitMask)
i add one parameter
getSceneNodeFromRayBB(core::line3d<f32> ray, s32 idBitMask, bool OtrhoView)
after then change some of parameters
Code: Select all
ISceneNode* getSceneNodeFromRayBB(core::line3d<f32> ray, s32 idBitMask, bool OtrhoView)
{
ISceneNode* best = 0;
f32 dist = 9999999999.0f;
if(OtrhoView)
getPickedNodeBB(smgr->getRootSceneNode(), ray.getVector(),//ray.getVector() instead ray.getMiddle()
ray.start , ray.end, (f32)(ray.getLength() * 0.5),
idBitMask, dist, best);
else
getPickedNodeBB(smgr->getRootSceneNode(), ray.getMiddle(),
ray.getVector().normalize() , ray.start, (f32)(ray.getLength() * 0.5),
idBitMask, dist, best);
return best;
}in function getPickedNodeBB
remove those row
//if (dist < outbestdistance)