View.guess_target algorithem?
-
I was wondering if anybody knows how the View.guess_target works? What is the algorithm of guessing the target?
-
I haven't studies it, but maybe a ray shot from the camera eye?
-
If you take a random
view=model.active_view
and get itsview.camera
, and then get itsview.camera.target
it returns a Point3d.
If you useview.guess_target
it return a different Point3d [probably calculated from geometry hit in the line of sight? no one knows ].
If you now make anew_camera
based on the original variousview.camera
values BUT with 'view.guess_target
' used as thetarget
[2nd] value, and then changeview.camera=new_camera
nothing changes! BUT theview.camera.target
is now equivalent to the earlierview.guess_target
- so it has sort of 'optimized' the eye/target relationship - I can see no practical value -
An intersection with a geometry and a ray shot from the camera eye seems like a reasonable assumption. There are several possible uses for a guess target. I think some of the Camera tools in sketchup (zoom, orbit and such) are using the guessed target to know where to zoom or to figure out the vertical axis of rotation.
-
Zoom zooms to where the mouse cursor is, not where the camera is looking.
Orbit orbits around an object, and I think it feels like is is using the center of the object. Maybe a simple bounding box center, but I'm pretty sure its more than that because the view does not skip around if the center of the object in sight is off the screen. So it must be something more. But if it were merely where the view line intersects the model, then I think that point would appear to stay fixed in place, which it does not, its more fluid than that.
So I'm afraid the guessed target is not what's used in those tools.
-
The zoom tool (magnifying glass invoked by the Z shortcut) does not zoom to where the mouse courser is, it zooms to the guessed target.
The orbit has a vertical and a horizontal axis of rotation. The vertical axis is always in the z direction going through the origin. The horizontal axis is always in the camera x axis direction going through a point which is new every time a mouse is clicked...that point is the guess target I think...that said, the guess target might be a function of some bounding box.
-
Oh yes, that zoom tool. I forgot about that one. I never use it, I'm a scroll wheel only person. And the scroll wheel does zoom to where the mouse cursor is.
The actual zoom tool though yes, that also uses the mouse pointer to some degree. If you hold it over something close, you zoom quickly. hold it over something far and you zoom slower. Even if your mouse goes from being on top of something close to not on top of something int he same dragging event, the speed of zoom will vary. I'd never noticed that before.
The orbit tool (again, my scroll wheel) doesn't do what I was thinking it does. It does seem to just orbit around the center of the screen, and the distance of the z axis seems to be based on some sort of target. I'm wondering if it has to do with the near and far culling planes? Perhaps evenly spaced between them?
Chris
Advertisement