Example #1
0
    def stickParts(self):
        if not hasattr(self, 'signModel'):
            self.needToPlant = 1
            return Task.done
        if self.signModel.isEmpty():
            return Task.done
        testPath = NodePath('testPath')
        testPath.reparentTo(render)
        cRay = CollisionRay(0.0, 0.0, 40000.0, 0.0, 0.0, -1.0)
        cRayNode = CollisionNode(self.uniqueName('estate-FloorRay'))
        cRayNode.addSolid(cRay)
        cRayNode.setFromCollideMask(OTPGlobals.FloorBitmask)
        cRayNode.setIntoCollideMask(BitMask32.allOff())
        cRayNodePath = testPath.attachNewNode(cRayNode)
        queue = CollisionHandlerQueue()
        picker = CollisionTraverser()
        picker.addCollider(cRayNodePath, queue)
        testPath.setPos(self.signModel.getX(render),
                        self.signModel.getY(render), 0)
        picker.traverse(render)
        if queue.getNumEntries() > 0:
            queue.sortEntries()
            for index in range(queue.getNumEntries()):
                entry = queue.getEntry(index)
                if DistributedLawnDecor.recurseParent(entry.getIntoNode(),
                                                      'terrain_DNARoot'):
                    self.signModel.wrtReparentTo(render)
                    self.signModel.setZ(
                        entry.getSurfacePoint(render)[2] + self.stickUp + 0.1)
                    self.signModel.wrtReparentTo(self.rotateNode)
                    self.signHasBeenStuck2Ground = True
                    self.createBackupFruits()
                    return Task.done

        return Task.done
    def stickParts(self):
        if not hasattr(self, 'signModel'):
            self.needToPlant = 1
            return Task.done
        if self.signModel.isEmpty():
            return Task.done
        testPath = NodePath('testPath')
        testPath.reparentTo(render)
        cRay = CollisionRay(0.0, 0.0, 40000.0, 0.0, 0.0, -1.0)
        cRayNode = CollisionNode(self.uniqueName('estate-FloorRay'))
        cRayNode.addSolid(cRay)
        cRayNode.setFromCollideMask(OTPGlobals.FloorBitmask)
        cRayNode.setIntoCollideMask(BitMask32.allOff())
        cRayNodePath = testPath.attachNewNode(cRayNode)
        queue = CollisionHandlerQueue()
        picker = CollisionTraverser()
        picker.addCollider(cRayNodePath, queue)
        testPath.setPos(self.signModel.getX(render), self.signModel.getY(render), 0)
        picker.traverse(render)
        if queue.getNumEntries() > 0:
            queue.sortEntries()
            for index in xrange(queue.getNumEntries()):
                entry = queue.getEntry(index)
                if DistributedLawnDecor.recurseParent(entry.getIntoNode(), 'terrain_DNARoot'):
                    self.signModel.wrtReparentTo(render)
                    self.signModel.setZ(entry.getSurfacePoint(render)[2] + self.stickUp + 0.1)
                    self.signModel.wrtReparentTo(self.rotateNode)
                    self.signHasBeenStuck2Ground = True
                    self.createBackupFruits()
                    return Task.done

        return Task.done