Reputation: 31
I tried to draw a set of octahedra by vpython, it showed, however, the scene looks don't like a 3D object, it looks just like a colored shadow, whatever how I rotate it. I have no idea how to fix this problem.
from vpython import *
from itertools import *
import numpy as np
faces = [[vertex(pos=vec(*v)) for v in np.diag(i)]
for i in product(*[(-1,1)]*3)]
octa = compound([triangle(vs=i) for i in faces])
octa.visible=False
centers = [vec(*i) for i in product(*[(-1,0,1)]*3) if sum(i)%2==0]
octa_group = compound([octa.clone(pos=i) for i in centers])
octa_group.color = vec(0.5,0.9,1)
#octa_group.opacity = 0.5
while True:
rate(30)
It shows the scene as follows.
I expect an effect like this (It seems no problem with built-in 3D objects like box)
Upvotes: 1
Views: 142