PDA

View Full Version : setViewpoint not working?



Moon Wizard
October 30th, 2009, 21:44
Has anyone had any luck getting the setViewpoint to work correctly on imagecontrols?

I built a script that captured the image window getViewpoint() information on window close, and tries to use setViewpoint() with the same values when the image window is opened again.

I've verified that the data points are being saved correctly to the Campaign Registry, and that they are loaded correctly. However, when I call setViewpoint, it doesn't seem to restore the original viewpoint.

When testing, remember that FG saves the image viewpoint between opening/closing the window during the course of a session as well as between ruleset reloads. It doesn't remember the image viewpoint when FG loads up the ruleset initially, which was what I was trying to solve.

Thanks,
JPG

Moon Wizard
November 9th, 2009, 21:25
Anybody else tried to use setViewpoint before?

I've left the feature in my ruleset to save off the viewpoint and restore on open. However, when I open the image and the call is made, I get a different viewpoint almost every time.

For those interested in trying this out, add this code:

windowmanager.lua, Line 57:


if User.isHost() and window.image and window.image.getViewpoint then
local nImageX, nImageY, nImageZoom = window.image.getViewpoint();
pos.imagex = nImageX;
pos.imagey = nImageY;
pos.imagezoom = nImageZoom;
end


windowmanager.lua, Line 25:


if User.isHost() and window.image and window.image.setViewpoint then
if pos.imagex and pos.imagey and pos.imagezoom then
window.image.setViewpoint(pos.imagex, pos.imagey, pos.imagezoom);
end
end


Thanks,
JPG