This is the simplest way to do it:
minDistance = 30
maxDistance = 400
cy# = 150
make matrix 1, 1000, 1000, 40, 50
position camera 0, cy#, 0
point camera 100,0,100
sync on
sync rate 60
do
MZ = mousez()
if oldMouseZ <> MZ
rem update camera zoom amount
if oldMouseZ > MZ then inc cy#, 6
if oldMouseZ < MZ then dec cy#, 6
rem camera zoom constraints
if cy# < minDistance then cy# = minDistance
if cy# > maxDistance then cy# = maxDistance
rem update camera
position camera 0, cy#, 0
rem update old mouse z value
oldMouseZ = MZ
endif
sync
loop
Or you make it smoother by updating the zoom amount over time:
minDistance = 30
maxDistance = 400
cy# = 150
make matrix 1, 1000, 1000, 40, 50
position camera 0, cy#, 0
point camera 100,0,100
sync on
sync rate 60
do
MZ = mousez()
if oldMouseZ <> MZ
rem update camera zoom amount
if oldMouseZ > MZ then zoomCameraSpeedIn# = 6
if oldMouseZ < MZ then zoomCameraSpeedOut# = 6
rem update old mouse z value
oldMouseZ = MZ
endif
if zoomCameraSpeedIn# > 0 then dec cy#, zoomCameraSpeedIn# : dec zoomCameraSpeedIn#, 0.5
if zoomCameraSpeedOut# > 0 then inc cy#, zoomCameraSpeedOut# : dec zoomCameraSpeedOut#, 0.5
rem camera zoom constraints
if cy# < minDistance then cy# = minDistance
if cy# > maxDistance then cy# = maxDistance
position camera 0, cy#, 0
sync
loop
What this does is actually updates the camera's zoom 12 times for every wheel scroll, but the amount that it zooms in decreases. Flick the mouse wheel once, and the first speed value to zoom in/out by is 6. That value decreases by one and so the next time it zooms by 5.5, then 5, then 4.5, etc... Once it reaches 0 it'll stop zooming. Basically, it zooms it quick at first that gradually slows down.
"You're not going crazy. You're going sane in a crazy world!" ~Tick