[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 
<http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01059.html#a46>
 
(osg::Vec3 
<http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01802.html>
 
&eye, osg::Vec3 
<http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01802.html>
 
&center, osg::Vec3 
<http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01802.html>
 
&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
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>   

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to