[osg-users] How to exclude nodes from a pick list

2007-11-08 Thread neil.hughes
Hi All,

I have a quick question. I'm playing with picking objects in a scene using the 
pickhandler example. The scene is essentially a big box whose faces face 
inwards. Within the box I have a smaller box whose faces face outwards. If I am 
outside both boxes, looking into the outer box, the pickhandler returns both 
the outer box, face that I have hit, and the inner box faces that I have hit. 
As the outer box face is actually facing away from me,  I want to exclude it. 
Is there an easy way to do this?

My thinking was that I essentially need to look at the normal of the face that 
I hit, and the direction of view vector for the camera, take the dot product, 
and if positive exclude it. Does this sound right? Is there an easier 
way/structure that I should use?

Many thanks for any help

Neil.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] How to exclude nodes from a pick list

2007-11-08 Thread neil.hughes
Hi All,

I have a quick question. I'm playing with picking objects in a scene using the 
pickhandler example. The scene is essentially a big box whose faces face 
inwards. Within the box I have a smaller box whose faces face outwards. If I am 
outside both boxes, looking into the outer box, the pickhandler returns both 
the outer box, face that I have hit, and the inner box faces that I have hit. 
As the outer box face is actually facing away from me,  I want to exclude it. 
Is there an easy way to do this?

My thinking was that I essentially need to look at the normal of the face that 
I hit, and the direction of view vector for the camera, take the dot product, 
and if positive exclude it. Does this sound right? Is there an easier 
way/structure that I should use?

Many thanks for any help

Neil.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to exclude nodes from a pick list

2007-11-08 Thread Robert Osfield
Hi Neil,

Use the Node::setNodeMask() to set which subgraphs you want to be
active, then set the TraversalMask on the IntersectionVisitor to pick
out the appropriate parts.

Robert.

On Nov 8, 2007 12:19 PM,  <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a quick question. I'm playing with picking objects in a scene using 
> the pickhandler example. The scene is essentially a big box whose faces face 
> inwards. Within the box I have a smaller box whose faces face outwards. If I 
> am outside both boxes, looking into the outer box, the pickhandler returns 
> both the outer box, face that I have hit, and the inner box faces that I have 
> hit. As the outer box face is actually facing away from me,  I want to 
> exclude it. Is there an easy way to do this?
>
> My thinking was that I essentially need to look at the normal of the face 
> that I hit, and the direction of view vector for the camera, take the dot 
> product, and if positive exclude it. Does this sound right? Is there an 
> easier way/structure that I should use?
>
> Many thanks for any help
>
> Neil.
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to exclude nodes from a pick list

2007-11-08 Thread neil.hughes
Hi Robert,

sorry, I didn't really explain myself very clearly. The issue isn't so much 
that I don't want the face from the outer box to be hit, I merely want to be 
able to identify that it is facing away from the camera, and hence I can ignore 
it when try to identify that the inner box has been hit. 

The outer box essentially represents the walls of a room. From outside the 
room, looking in, I can see the interrior walls which is correct. If I am 
outside my room looking in, when I click on the box that sits on the "floor" of 
my room, I get a pick list that includes the wall that I am "looking through". 
The difficulty is that I wish to discard this, and get the next item in the 
pick list which is the box that sits on the floor. I can't simply skip the 
first intersection, as if I were inside the room, then the box on the floor 
would be the first intersection and I would miss it. 

Given that I've got a hit on the wall that I'm looking through - which faces 
away from me and hence isn't visible as the culling gets rid of it for 
rendering purposes -what I need to do is essentially marry the culling that 
occurs for rendering with a pick handler so that the pick handler only 
considers faces that a rendering "cull" would want to render.

My thinking was that, rather than go to the headache of trying to do the 
"marry" it would be simpler to take my hit list, and perform the calculation 
that basically says whether the face is facing towards the camera, or away from 
it. 

The hit records gives me a world normal of the face that is hit. I thought that 
the simplest thing to do would be to get the vector of the direction of look 
for the camera, multiply the two vectors, and discard those with a positive 
component in the direction of the camera view. My difficulty is in getting the 
vector that represents the direction of view of the camera. I don't know how to 
do that, and I guess thats what I really need the help with. 

Could you tell me how I get this vector, or perhaps suggest an alternative 
approach ? Surely the node mask approach would prevent me "selecting" the 
interior wall that is facing towards me, which isn't right as I may wish to 
select this wall and put a really "cheesey" wall paper texture on it :-)

I would be grateful for any help on this.

Kind regards

Neil

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to exclude nodes from a pick list

2007-11-08 Thread Andreas Goebel
[EMAIL PROTECTED] schrieb:
> Hi Robert,
>
> sorry, I didn't really explain myself very clearly. The issue isn't so much 
> that I don't want the face from the outer box to be hit, I merely want to be 
> able to identify that it is facing away from the camera, and hence I can 
> ignore it when try to identify that the inner box has been hit. 
>
> The outer box essentially represents the walls of a room. From outside the 
> room, looking in, I can see the interrior walls which is correct. If I am 
> outside my room looking in, when I click on the box that sits on the "floor" 
> of my room, I get a pick list that includes the wall that I am "looking 
> through". The difficulty is that I wish to discard this, and get the next 
> item in the pick list which is the box that sits on the floor. I can't simply 
> skip the first intersection, as if I were inside the room, then the box on 
> the floor would be the first intersection and I would miss it. 
>
> Given that I've got a hit on the wall that I'm looking through - which faces 
> away from me and hence isn't visible as the culling gets rid of it for 
> rendering purposes -what I need to do is essentially marry the culling that 
> occurs for rendering with a pick handler so that the pick handler only 
> considers faces that a rendering "cull" would want to render.
>
> My thinking was that, rather than go to the headache of trying to do the 
> "marry" it would be simpler to take my hit list, and perform the calculation 
> that basically says whether the face is facing towards the camera, or away 
> from it. 
>
> The hit records gives me a world normal of the face that is hit. I thought 
> that the simplest thing to do would be to get the vector of the direction of 
> look for the camera, multiply the two vectors, and discard those with a 
> positive component in the direction of the camera view. My difficulty is in 
> getting the vector that represents the direction of view of the camera. I 
> don't know how to do that, and I guess thats what I really need the help 
> with. 
>
> Could you tell me how I get this vector, or perhaps suggest an alternative 
> approach ? Surely the node mask approach would prevent me "selecting" the 
> interior wall that is facing towards me, which isn't right as I may wish to 
> select this wall and put a really "cheesey" wall paper texture on it :-)
>   
Hi

void getViewMatrixAsLookAt 

 
(osg::Vec3 

 
&eye, osg::Vec3 

 
¢er, osg::Vec3 

 
&up, float lookDistance=1.0f)

will do the trick.

However, be aware that sides that face towards the camera in world space 
might not be doing so in the unit cube after projection (though this 
case is rare). If you need absolute accuracy you might want to test the 
projected normal against the camera, which is at (0,0,0) in the unit cube.


Regards,

Andreas
> I would be grateful for any help on this.
>
> Kind regards
>
> Neil
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>   

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to exclude nodes from a pick list

2007-11-09 Thread neil.hughes
Hi Andreas,

Many, many thanks for that. My problem is now sorted, and I can look forward to 
the "cheesey" wall paper decorating my walls.

Kind regards

Neil.

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org