3

After looking around a bit in a (few) documentations of VPython, I haven't found a simple way to make a face from three points, but I think I might be missing something. I'm imagining something like this:

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

Perhaps I should just use a different library.

nebuch
  • 6,475
  • 4
  • 20
  • 39

1 Answers1

2

Here is a quick example:

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)
Hugh Bothwell
  • 55,315
  • 8
  • 84
  • 99