On Fri, May 23, 2008 at 12:18 PM, Alejandro Segovia <[EMAIL PROTECTED]>
wrote:

>
>
> On Fri, May 23, 2008 at 11:02 AM, Robert Osfield <[EMAIL PROTECTED]>
> wrote:
>
>> Hi Alejandro,
>>
>> On Fri, May 23, 2008 at 2:31 PM, Alejandro Segovia
>> <[EMAIL PROTECTED]> wrote:
>> > Actually, I am using a TrackballManipulator and replacing its ref_ptr
>> with a
>> > new NodeTrackerManupulator when I have to enter "node tracking mode".
>> I'm
>> > not using the KeySwitchMatrixManipulator, but simply changing back and
>> > forth, overwriting the ref_ptr... Maybe sometimes I get one handler and
>> > sometimes the other? It shouldn't be the case...
>>
>> I'm afraid I can't really help, you.  There is plenty of stuff you are
>> doing at your end that I am not party to.  You'll need to step through
>> with a debugger and work out yourself what you are doing wrong.
>>
>
> Yes, you are absolutely right, I'm sorry if the topic went too much into my
> own application. I'm trying to understand how the NodeTrackerManipulator
> works so I can adjust the way I'm using it.
>
> Following you advice, I added a couple of printf's to see what the
> computeNodeCenterAndRotation call was returning (had to make it public in
> order to call it from my app), and got the following for an non-moving node
> at 0,0,0:
>
> Tracked object is at: (0.000000,0.000000,7.660254) with rotation:
> (0.000000,0.000000,0.000000,1.000000)
> Tracked object is at: (0.000000,0.000000,-8.660254) with rotation:
> (0.000000,0.000000,0.000000,1.000000)
>
> for two consecutive frames.
>
> Now, thinking about it, I wonder, if the world coordinates are indeed
> affected by the camera position, then it kind of makes sense to have the
> object's center changing.
>
> The first time the camera is at certain position and the nodetracker
> determines it has to be moved away in the Z+ direction, then the next frame
> the center is recalculated and now , since the camera is further away, the Z
> of the object changed and the tracker determines it has to move closer in
> the Z- direction. The consecutive application of this steps makes the camera
> ping-pong back and forth.
>
> I guess my question is, does the camera position affect the calculation of
> the node's center? If so, how can I prevent it? And also, how come the
> center's Z is never  0? can the tracking "step" be adjusted somehow?
>

Okay as I was suspecting, the problem had to do with the camera's
coordinates affecting the "world" coordinates of the node I was tracking.
Since calculating the world coordinates for the node is done in the
getInverseMatrix() method, what I did was just set the camera's view matrix
to an identity right before calling the getInverseMatrix() method.

This seems more of a hack than a solution, but I guess it's the cost of
using SceneView instead of osgViewer, which does not seem to have this
problem as the osgsimulation example runs exemplary.

Best regards,
Alejandro.-

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

Reply via email to