3

在浏览了一些 VPython 的文档之后,我还没有找到一种简单的方法来从三点做一张脸,但我想我可能会遗漏一些东西。我在想象这样的事情:

f = face(pts=[(x,y,z), (x,y,z), (x,y,z)], color=red... etc)

也许我应该只使用不同的库。

4

1 回答 1

2

这是一个简单的例子:

from visual import *

scene.title = "Faces example"
scene.width = 600
scene.height = 400

f = frame()
tri = faces(
    pos = [
        [0.,0.,0.], [1.,0.,0.], [0.,1.,0.],   # first tri - vertices
        [0.,0.,0.], [-1.,0.,0.], [0.,-1.,0.]  # second tri - vertices
    ],
    color = [
        [1.,0.,0.], [0.5,0.5,0.], [0.,1.,0.], # first tri - colors
        [0.,0.,1.], [0.,0.5,0.5], [0.,1.,0.]  # second tri - colors
    ],
    frame = f
)

tri.make_normals()
tri.make_twosided()

while True:
    rate(100)
    f.rotate(angle=0.01)
于 2012-05-28T20:52:01.267 回答