We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm a beginner who's trying to pick a 3D box with a mouse click using the Shapes 3D and PeasyCam libraries in Python mode.
I referred to this previous discussion: http://forum.processing.org/two/discussion/4066/peasycam-cursor-location-in-comparison-to-objects-shapes3d-#Item_9, but I'm getting a NullPointerException.
Here's the code:
add_library('Shapes3d') add_library('peasycam') clicked = False picked = None Boxes =  def setup(): size(400,400,P3D) cursor(CROSS) cam = PeasyCam(this, 150) cam.setMinimumDistance(50) cam.setMaximumDistance(300) cam.setYawRotationMode() b = Box(this,30,60,100) b.fill(0) b.stroke(color(0,255,0)) b.strokeWeight(2) b.drawMode(S3D.WIRE) Boxes.append(b) def draw(): background(0) rotateX(1.57) rotateZ(-.75) if clicked : clicked = False picked = Shape3D.pickShape(this, mouseX, mouseY) if picked != None: print 'preso!' Boxes.draw() def mouseClicked(): clicked = True
Can someone take a look over this?