Hi all,
I’ve been trying to display a 3D stimulus from a Wavefront(.obj) using ObjMeshStim. I used the ‘rigidBodyTransform.py’ demo (in ‘psychopy/demos/coder/misc/’) as a template. Psychopy is not throwing any errors, it’s just that the object won’t display. The object I’m trying to display is Blender’s Monkey (aka Suzanne). As a sanity check, I kept one of the objects in the demo visible (a red sphere), which displays correctly. Any help would be appreciated.
This is my code:
from psychopy import core, event
import psychopy.visual as visual
from psychopy.visual import SphereStim, LightSource, RigidBodyPose
from psychopy.visual.stim3d import ObjMeshStim
win = visual.Window((600, 600), monitor='testMonitor')
# create a rigid body defining the pivot point of objects in the scene
pivotPose = RigidBodyPose((0, 0, -5))
# text to display
instr = visual.TextStim(win, text="Any key to quit", pos=(0, -.7))
# create scene light at the pivot point
win.lights = [
LightSource(win, pos=pivotPose.pos, lightType='point',
diffuseColor=(0, 0, 0), specularColor=(1, 1, 1))
]
# create some sphere stim objects
myStim = ObjMeshStim(win, 'monkey.obj')
spherePose1 = RigidBodyPose((0.1, -0.1, 0.1))
sphere1 = SphereStim(win, radius=0.05, color='red')
angle = 0.0
while not event.getKeys():
# rotate the pivot pose
pivotPose.setOriAxisAngle((0, 1, 0), angle)
# setup drawing
win.setPerspectiveView()
# call after drawing `lightSphere` since we don't want it being shaded
win.useLights = True
sphere1.thePose = spherePose1 * pivotPose
sphere1.draw()
myStim.draw()
# reset transform to draw text correctly
win.resetEyeTransform()
instr.draw()
win.flip()
angle += 0.5
win.close()
core.quit()