Mouse picking requires the collision system, so we'll be using collision solids and all that again. Take a look back to Chapter 6, The World in Action: Handling Collisions as we go, if it's needed.
Have a look in the
Chapter10
folder and open up theInputMangaer_00.py
file there.A new import comes first. Add this line to our imports section:
from pandac.PandaModules import *
Next, we'll add a call to a new method to the bottom of
__init__
method:self.setupMouseAim()
Now, let's go ahead and add that new method to the bottom of the class:
def setupMouseAim(self): self.CN = CollisionNode("RayCN") self.cRay = CollisionRay() self.CN.addSolid(self.cRay) self.CN.setFromCollideMask(BitMask32.bit(8)) self.CN.setIntoCollideMask(BitMask32.allOff()) self.CN = base.camera.attachNewNode(self.CN) self.aimPlaneCN = CollisionNode("aimPlaneCN") self.aimPlane = CollisionPlane(Plane(Vec3(0,-1,0), Point3(0,30,0))) self.aimPlaneCN...