Два тела(точки). Расположить третью точку камеру на векторе этих точек,за пределами точек,повернув камеру на объекты.
Нажатие Ctrl - следующий вариант. Можно и отключить закомент. последнюю строку.
Код:
number_demo = 10
pause_demo = 500
rnd_pos_min = [0.0,0.0,0.0]
rnd_pos_max = [70.0,70.0,70.0]
rnd_pos_saturn = random rnd_pos_min rnd_pos_max
rnd_pos_earth = random rnd_pos_min rnd_pos_max
min_distance = 15.0
coef=2.0
ca;ea;sa
app = dotNetclass "System.Windows.Forms.Application"
global escapeEnable = false
fn jstmr t = (
ts = timestamp()
te = ts+t
while (timestamp()) < te do (app.doEvents())
)
fn rotatecam2 f l = (
memsc = f.scale
mempos = f.pos
m_r = l.pos - f.pos
worldUpVector = [0,0,1]
rightVector = normalize ( cross worldUpVector m_r )
upVector = normalize ( cross rightVector m_r )
cam_rotate = matrix3 rightVector upVector m_r l.pos
memrot = cam_rotate.rotation
cam_rotate.scale = memsc
cam_rotate.rotation = memrot
cam_rotate.pos = mempos
return cam_rotate
)
fn antizavis=(
app.doEvents()
completeRedraw()
)
fn distance_points a b = (return sqrt (( a.x - b.x )^2 + ( a.y - b.y )^2 + ( a.z - b.z )^2))
clearlistener()
if getnodebyname "earth" == undefined or getnodebyname "saturn" == undefined or getnodebyname "camera" == undefined then
(
delete $*
ca = Freecamera fov:45 targetDistance:160 nearclip:1 farclip:1000 nearrange:0 farrange:1000 mpassEnabled:off mpassRenderPerPass:off transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0])
ca.name = "camera"
ea = Sphere radius:2 smooth:on segs:48 chop:0 slice:off sliceFrom:0 sliceTo:0 mapcoords:on recenter:off pos:[0,0,0]
ea.name = "earth"
sa = Sphere radius:8 smooth:on segs:48 chop:0 slice:off sliceFrom:0 sliceTo:0 mapcoords:on recenter:off pos:[0,0,0]
sa.name = "saturn"
ca.wirecolor = black; ea.wirecolor =(color 28 149 177); sa.wirecolor = (color 221 200 131)
)
select ca
for t = 1 to number_demo do
(
if keyboard.escPressed then exit
if viewport.numViews == 4 then
(
avport = viewport.activeViewport
viewport.activeViewport = 3
viewport.setType #view_camera
viewport.activeViewport = avport
)
rnd_pos_saturn = random rnd_pos_min rnd_pos_max
rnd_pos_earth = random rnd_pos_min rnd_pos_max
while distance_points rnd_pos_saturn rnd_pos_earth < min_distance do
(
if keyboard.escPressed then exit
rnd_pos_saturn = random rnd_pos_min rnd_pos_max
rnd_pos_earth = random rnd_pos_min rnd_pos_max
)
format "distance: %\n" (distance_points rnd_pos_saturn rnd_pos_earth)
sa.pos = rnd_pos_saturn
ea.pos = rnd_pos_earth
ca.pos = ea.pos + ( (ea.pos - sa.pos) * coef )
ca.transform = rotatecam2 ca ea
max tool zoomextents all; max tool zoomextents all; jstmr pause_demo; antizavis()
while not keyboard.controlPressed do (if keyboard.escPressed then exit; app.doEvents())
)