Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Andrew Grace
- #12/5/18
- import viz
- import vizshape
- from PIL import Image
- viz.go(viz.ANAGLYPHIC)
- view = viz.MainView.setPosition([0, 1, -1])
- #This snippet is only for viewing in CAVE:
- #------------------------------------------
- # import vizconnect
- # CONFIG_FILE = "E:\\VizardProjects\\_CaveConfigFiles\\vizconnect_config_CaveFloor+ART_headnode.py"
- # #CONFIG_FILE = "E:\\VizardProjects\\_CaveConfigFiles\\vizconnect_config_CaveCeiling+ART_headnode.py"
- # vizconnect.go(CONFIG_FILE)
- #------------------------------------------
- viewPoint = vizconnect.addViewpoint(pos=[0,1,-1]) #inside the sphere
- viewPoint.add(vizconnect.getDisplay())
- vizconnect.resetViewpoints()
- viz.clearcolor(viz.GRAY)
- #Open a 3D 360 image. Left eye is top half of image, right eye is bottom half
- image = Image.open("render_het_0005_3d_2to1_4k.jpg")
- image_size = list(image.size)
- w, h = image_size
- print(image_size)
- #Cropping photo to get images corresponding to left and right eyes
- #These are both half-height
- image_left = image.crop ( (0, 0, w, h//2) )
- image_right = image.crop ( (0, h//2, w, h) )
- #Resize to full height
- image_left = image_left.resize ( image_size, Image.ANTIALIAS)
- image_right = image_right.resize ( image_size, Image.ANTIALIAS)
- def setupSphereForEye(image, eye=None):
- image_size = list(image.size)
- sphere = vizshape.addSphere(radius=20, pos=[0,0,0])
- tex = viz.addBlankTexture (size=image_size, type=viz.TEX_2D, format=viz.TEX_RGB)
- tex.setImageData(data=image.tobytes(), size=image_size, format=viz.TEX_RGB)
- #Additional hints for Vizard about the sphere object
- sphere.cullFace(viz.GL_BACK)
- sphere.disable(viz.LIGHTING) #Show texture at full color, no shadows or shading
- sphere.enable(viz.FLIP_POLYGON_ORDER) #NORMALS FLIPPED
- sphere.setEuler([0,0,180]) #fix upside down texture
- sphere.texture(tex)
- sphere.renderToEye(eye)
- return sphere
- sphere_left = setupSphereForEye (image=image_left, eye=viz.LEFT_EYE)
- sphere_right = setupSphereForEye (image=image_right, eye=viz.RIGHT_EYE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement