Use algebra...
As you'll be zooming, the values you know are the following:
h - > hypothenus or something like that. Its the real distance in a 2d plane between your object and the camera, and it's along the x and z axis in this case.
90° -> this always the same and not used....
a or b -> if YOU are to use this angles, then yes, one or the other you should know it, if not, no worries, we can figure them out.
values to discover...
x and z -> the distance in x and z from the object to the camera, basically it would be object position x(o)+x and object position z(o)+z to find the position of the camera.
How to solve it... many ways, specially depending of wich angle a or b you using. If none, then its the same but with 1 more calculation before it.
x = cos(a)*h or x = sin(b)*h
z = sin(a)*h or z = cos(b)*h
If a and b are unknown values, then do this before the x and z calcs...
a = atanfull( object position x(o)-camera position x(c) , object position z(o)-camera position z(c))
b = 90 - a
A little example...
sync on
sync rate 50
make object cube 1,10
global h#
global a#
do
camera(1)
sync
loop
Function camera(obj)
obj_x#=object position x(obj)
obj_y#=object position y(obj)
obj_z#=object position z(obj)
cam_x#=camera position x()
cam_z#=camera position z()
mx#=mousemovex()
mz#=mousemovez()
`!!!! h# is global not local, remember that!!!!
h#=h#+mz#
a#=a#+mx#
cam_x#=obj_x#-sin(a#)*h#
cam_z#=obj_z#-cos(a#)*h#
position camera cam_x#,obj_y#,cam_z#
point camera obj_x#,obj_y#,obj_z#
endfunction
As you can see, a# represents the angle an it's independient from the cameras angle, even thought i told the camera to point to the object, it shows that you can change the camera's angles and it will still zoom to the object. To this you can also work around to also include the Y axis, it's basically the same...
Further on my stuff at...