python控制相机自动拍照_如何让VPython中的对象自动移动到相机中?

我有这个食品杂货小岛,而且我应该让它看起来好像这个人正在穿过小岛,但为了做到这一点,物体必须通过相机,并且每当它靠近时,它就会碰到窗户,它几乎看起来像退后一步,走向相反的方向。但是,如果我放大一点,那么它会经过但在中途放慢速度。有没有办法使物体自动移动通过相机?谢谢

from visual import *

sphere(pos=(0,0,0), radius = 0.5)

text(pos=(-2,1,0), text="Center")

rightside = box(pos=(10,0,-40), axis=(1,300,0), height=0.5, width=60, length=12, material=materials.emissive)

leftside = box(pos=(-10,0,-40), axis=(-1,300,0), height=0.5, width=60, length=12, material=materials.emissive)

bottomside = box(pos=(0,-5.8,-40), axis=(1,0,0), height=0.5, width=60, length=20, color=color.cyan, material=materials.emissive)

leftfirstshelf = box(pos=(8,0,-40), axis=(1,0,0), height=0.5, width=60, length=4, color=color.cyan, material=materials.emissive)

leftsecondshelf = box(pos=(-8,0,-40), axis=(1,0,0), height=0.5, width=60, length=4, color=color.white, material=materials.emissive)

leftthirdshelf = box(pos=(-8,-4,-40), axis=(1,0,0), height=0.5, width=60, length=4, color=color.cyan, material=materials.emissive)

rightfirstshelf = box(pos=(8,4,-40), axis=(1,0,0), height=0.5, width=60, length=4, color=color.white, material=materials.emissive)

rightsecondshelf = box(pos=(-8,4,-40), axis=(1,0,0), height=0.5, width=60, length=4, color=color.cyan, material=materials.emissive)

rightthirdshelf = box(pos=(8,-4,-40), axis=(1,0,0), height=0.5, width=60, length=4, color=color.white, material=materials.emissive)

cheeriosbox = box(pos=(8,6,-60), axis=(1,0,0), height=4, width=2.5, length=0.8, color=color.yellow, material=materials.emissive)

cheeriostext = text(pos=(7.7,7,-61), axis=(0,0,25), height=0.5, width=2.5, length=0.8, color=color.black, text='Cheerios')

watermelon = ellipsoid(pos=(8,2,-40), height=3, width=3.5, length=3, color=color.green, material=materials.emissive)

cokecan = cylinder(pos=(-8,-3.5,-60), height=0, width=0, length=3, color=color.red, material=materials.emissive, axis=(0,7,0))

cokecantext = text(pos=(-7.1,-2,-59), height=1, width=2, length=1, axis=(0,0,-25), color=color.black, text="Coke")

leftcarrotbody = cone(pos=(-8,0.5,-30), radius=0.2, color=color.orange, axis=(0,0,3), material=materials.emissive)

leftcarrottop = sphere(pos=(-8,0.5,-30),radius=0.3, color=color.green, material=materials.emissive)

middlecarrotbody = cone(pos=(-7.5,0.5,-30), radius=0.2, color=color.orange, axis=(0,0,3), material=materials.emissive)

middlecarrottop = sphere(pos=(-7.5,0.5,-30),radius=0.3, color=color.green, material=materials.emissive)

rightcarrotbody = cone(pos=(-7,0.5,-30), radius=0.2, color=color.orange, axis=(0,0,3), material=materials.emissive)

rightcarrottop = sphere(pos=(-7,0.5,-30),radius=0.3, color=color.green, material=materials.emissive)

orangefruit = sphere(pos=(-7.5,5.3,-15), radius=1, color=color.orange, material=materials.emissive)

bottomrowcupone = cylinder(pos=(8,-3.75,-15), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

bottomrowcuptwo = cylinder(pos=(8,-3.75,-14), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

bottomrowcupthree = cylinder(pos=(8,-3.75,-13), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

bottomrowcupfour = cylinder(pos=(8,-3.75,-12), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

thirdrowcupone = cylinder(pos=(8,-2.86,-14.5), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

thirdrowcuptwo = cylinder(pos=(8,-2.86,-13.5), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

thirdrowcupthree = cylinder(pos=(8,-2.86,-12.5), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

secondrowcupone = cylinder(pos=(8,-1.97,-14), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

secondrowcuptwo = cylinder(pos=(8,-1.97,-13), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

topcup = cylinder(pos=(8,-1.08,-13.5), radius=0.5, height=2, axis=(0,0.9,0),color=color.blue, material=materials.emissive)

a = vector(10,0,-40)

b = vector(-10,0,-40)

c = vector(0,-5.8,-40)

d = vector(8,0,-40)

e = vector(-8,0,-40)

f = vector(-8,-4,-40)

g = vector(8,4,-40)

h = vector(-8,4,-40)

i = vector(8,-4,-40)

j = vector(8,6,-60)

k = vector(7.7,7,-61.15)

l = vector(8,2,-40)

m = vector(-8,-3.5,-60)

n = vector(-7.1,-2,-59)

o = vector(-8,0.5,-30)

p = vector(-8,0.5,-30)

q = vector(-7.5,0.5,-30)

r = vector(-7.5,0.5,-30)

s = vector(-7,0.5,-30)

t = vector(-7,0.5,-30)

u = vector(-7.5,5.3,-15)

v = vector(8,-3.75,-15)

w = vector(8,-3.75,-14)

x = vector(8,-3.75,-13)

y = vector(8,-3.75,-12)

z = vector(8,-2.86,-14.5)

aia = vector(8,-2.86,-13.5)

bib = vector(8,-2.86,-12.5)

cic = vector(8,-1.97,-14)

did = vector(8,-1.97,-13)

eie = vector(8,-1.08,-13.5)

while a.z < 100:

rate(20)

rightside.pos = a

leftside.pos = b

bottomside.pos = c

leftfirstshelf.pos = d

leftsecondshelf.pos = e

leftthirdshelf.pos = f

rightfirstshelf.pos = g

rightsecondshelf.pos = h

rightthirdshelf.pos = i

cheeriosbox.pos = j

cheeriostext.pos = k

watermelon.pos = l

cokecan.pos = m

cokecantext.pos = n

leftcarrotbody.pos = o

leftcarrottop.pos = p

middlecarrotbody.pos = q

middlecarrottop.pos = r

rightcarrotbody.pos = s

rightcarrottop.pos = t

orangefruit.pos = u

bottomrowcupone.pos = v

bottomrowcuptwo.pos = w

bottomrowcupthree.pos = x

bottomrowcupfour.pos = y

thirdrowcupone.pos = z

thirdrowcuptwo.pos = aia

thirdrowcupthree.pos = bib

secondrowcupone.pos = cic

secondrowcuptwo.pos = did

topcup.pos = eie

a.z = a.z + 1

b.z = b.z + 1

c.z = c.z + 1

d.z = d.z +1

e.z = e.z + 1

f.z = f.z + 1

g.z = g.z + 1

h.z = h.z + 1

i.z = i.z + 1

j.z = j.z + 1

k.z = k.z + 1

l.z = l.z + 1

m.z = m.z + 1

n.z = n.z + 1

o.z = o.z + 1

p.z = p.z + 1

q.z = q.z + 1

r.z = r.z + 1

s.z = s.z + 1

t.z = t.z + 1

u.z = u.z + 1

v.z = v.z + 1

w.z = w.z + 1

x.z = x.z + 1

y.z = y.z + 1

z.z = z.z + 1

aia.z = aia.z + 1

bib.z = bib.z + 1

cic.z = cic.z + 1

did.z = did.z + 1

eie.z = eie.z + 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值