Hi guys,

I am so new to osg and I'm totally stucked on this problem.

Situation - Having a character in a space. I want to point with character's 
hand to some object ( just ShapeDrawable or something like that )..

Character is called Skeleton ( derived from osg::Group )
What I have:

Code:

    while ( !viewer.done() )
    {
        {
            osg::Vec3 from = skeleton.getHand(0)->getFrom(); //start vector 
from shoulder
            osg::Vec3 to = skeleton.getHand(0)->getTo(); // end vector from hand
            osg::Vec3 diff = to - from; // vector to make start to end longer
            diff = diff * 5;

            osg::ref_ptr<osgUtil::LineSegmentIntersector> ins = new 
osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, from , to + 
diff );
            osgUtil::IntersectionVisitor visitor( ins.get()) ;
            viewer.getCamera()->accept( visitor );

            if  ( ins->containsIntersections() )
            {
                osgUtil::LineSegmentIntersector::Intersection result = *( 
ins->getIntersections().begin());
                (result.drawable.get())->setShape( new osg::Box );
            }
        }

        viewer.frame();
    }
}




To be honest I dont really understand what is going on there with all these 
functions. I found some examples on google, so I basically just put them 
together.

Output is like :

Warning:: Picked up error in TriangleIntersect
   (-1.60915e-07 2.54861e-08 1, 0.154508 -0.0244714 0.987688,   -1.62921e-07 0 
1)
   (-nan,       -nan,   -nan)

What I would like to achieve is:
Having vector  which starts at character's shoulder and ends in his hands, with 
that vector he would point to some object in a space. If he points at something 
( just some ShapeDrawable Box ), I would like to have a pointer to that object 
to change its parameters ( color etc.)

Is this even good attitude to achieve this or should I just use something 
totally different?
 
Thank you,

Cheers,
P

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=57762#57762





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

Reply via email to