Ejemplo n.º 1
0
 def startDrop(self, entity):
     if entity and self.dropLoc:
         endPos = self.dropLoc
         dropMdl = entity.find('**/DropMdl')
         startPos = Point3(endPos.getX(), endPos.getY(), endPos.getZ() + 20)
         entity.setPos(startPos.getX(),
                       startPos.getY() + 2, startPos.getZ())
         dropMdl.setScale(5 * 0.85)
         entity.node().setBounds(OmniBoundingVolume())
         entity.node().setFinal(1)
         entity.headsUp(self.avatar)
         self.buildCollisions(entity)
         objectTrack = Sequence()
         animProp = LerpPosInterval(entity,
                                    self.fallDuration,
                                    endPos,
                                    startPos=startPos)
         bounceProp = Effects.createZBounce(entity, 2, endPos, 0.5, 1.5)
         objAnimShrink = Sequence(Func(dropMdl.setScale, 5), Wait(0.5),
                                  Func(entity.reparentTo, render), animProp,
                                  bounceProp)
         objectTrack.append(objAnimShrink)
         dropShadow = CIGlobals.makeDropShadow(1.0)
         dropShadow.reparentTo(hidden)
         dropShadow.setPos(endPos)
         shadowTrack = Sequence(
             Func(dropShadow.reparentTo, render),
             LerpScaleInterval(dropShadow,
                               self.fallDuration + 0.1, (1, 1, 1),
                               startScale=Point3(0.01, 0.01, 0.01)),
             Wait(0.8), Func(dropShadow.removeNode))
         Parallel(
             Sequence(Wait(self.fallDuration), Func(self.completeDrop)),
             objectTrack, shadowTrack).start()
         self.dropLoc = None
Ejemplo n.º 2
0
 def startDrop(self, entity):
     if entity and self.dropLoc:
         x, y, z = self.dropLoc
         startPos = Point3(x, y, z + 20)
         entity.setPos(startPos)
         entity.node().setBounds(OmniBoundingVolume())
         entity.node().setFinal(1)
         entity.headsUp(self.avatar)
         entity.setPythonTag('EntityRoot', entity)
         if self.rotate90:
             entity.setH(entity.getH() - 90)
         self.buildCollisions(entity)
         objectTrack = Sequence()
         animProp = LerpPosInterval(entity,
                                    self.fallDuration,
                                    self.dropLoc,
                                    startPos=startPos)
         bounceProp = Effects.createZBounce(entity, 2, self.dropLoc, 0.5,
                                            1.5)
         objAnimShrink = Sequence(Wait(0.5), Func(entity.reparentTo,
                                                  render), animProp,
                                  bounceProp)
         objectTrack.append(objAnimShrink)
         dropShadow = CIGlobals.makeDropShadow(1.0)
         dropShadow.reparentTo(hidden)
         dropShadow.setPos(self.dropLoc)
         if self.name == GagGlobals.FlowerPot:
             dropShadow.setZ(dropShadow.getZ() - 3.5)
         dropShadow.setScale(0.01)
         shadowTrack = Sequence(
             Func(dropShadow.reparentTo, render),
             LerpScaleInterval(dropShadow,
                               self.fallDuration + 0.1,
                               self.getShadowScale(),
                               startScale=Point3(0.01, 0.01, 0.01)),
             Wait(0.8), Func(dropShadow.removeNode))
         self.objTrack = Parallel(
             Sequence(Wait(self.fallDuration), Func(self.completeDrop)),
             objectTrack, shadowTrack)
         self.objTrack.start()
         self.dropLoc = None
    def load(self):
        self.model = loader.loadModel("phase_5/models/props/snowball.bam")
        self.model.reparentTo(self)

        self.shadow = CIGlobals.makeDropShadow(0.1)
        self.shadow.reparentTo(self)

        base.audio3d.attachSoundToObject(self.impactSound, self)

        # Setup collisions
        sphere = CollisionSphere(0, 0, 0, 0.35)
        sphere.setTangible(0)
        node = CollisionNode('snowball-coll-' + str(id(self)))
        node.addSolid(sphere)
        node.setFromCollideMask(CIGlobals.WallBitmask | CIGlobals.FloorBitmask)
        self.collNP = self.attachNewNode(node)
        self.collNP.setCollideMask(BitMask32(0))
        #self.collNP.show()
        self.collNP.setZ(0.35)

        event = CollisionHandlerEvent()
        event.set_in_pattern("%fn-into")
        event.set_out_pattern("%fn-out")
        base.cTrav.add_collider(self.collNP, event)