Beispiel #1
0
    def generateCog(self, isLose = 0, nameTag = True):
        self.cleanup()
        if not isLose:
            if self.variant == Variant.SKELETON or self.variant == Variant.ZOMBIE:
                self.loadModel('phase_5/models/char/cog%s_robot-zero.bam' % (str(self.suit)), 'body')
            else:
                self.loadModel('phase_3.5/models/char/suit%s-mod.bam' % (str(self.suit)), 'body')
            animations = SuitGlobals.animations
            anims = {}
            for anim in animations:
                if not self.suit in anim.getSuitTypes():
                    continue
                path = 'phase_%s/models/char/suit%s-%s.bam' % (anim.getPhase(), self.suit, anim.getFile())
                anims[anim.getName()] = path
            self.loadAnims(anims, 'body')
            self.generateHealthBar()

            if self.suitPlan.suitType == SuitType.A:
                self.footstepSound = base.audio3d.loadSfx("phase_5/audio/sfx/ENC_cogafssm.ogg")
            elif self.suitPlan.suitType == SuitType.B:
                self.footstepSound = base.audio3d.loadSfx("phase_5/audio/sfx/ENC_cogbfssm.ogg")
            elif self.suitPlan.suitType == SuitType.C:
                self.footstepSound = base.audio3d.loadSfx("phase_5/audio/sfx/ENC_cogcfssm.ogg")
            if self.footstepSound:
                base.audio3d.attachSoundToObject(self.footstepSound, self)

        else:
            if self.variant == Variant.SKELETON or self.variant == Variant.ZOMBIE:
                self.loadModel('phase_5/models/char/cog%s_robot-lose-mod.bam' % (str(self.suit)), 'body')
            else:
                self.loadModel('phase_4/models/char/suit%s-lose-mod.bam' % (str(self.suit)), 'body')
            self.loadAnims({'lose' : 'phase_4/models/char/suit%s-lose.bam' % (str(self.suit))}, 'body')
        if self.variant != Variant.SKELETON:
            self.headModel = self.head.generate()
            self.headModel.reparentTo(self.find("**/joint_head"))
        if self.suitPlan.getName() == SuitGlobals.VicePresident:
            self.headModel.setScale(0.35)
            self.headModel.setHpr(270, 0, 270)
            self.headModel.setZ(-0.10)
            self.headModel.loop('neutral')
        self.setClothes()

        classScale = 1.0#self.suitPlan.getCogClassAttrs().scaleMod
        self.setAvatarScale((self.suitPlan.getScale() / SuitGlobals.scaleFactors[self.suit]) * classScale)
        #self.setHeight(self.suitPlan.getHeight())
        if nameTag:
            self.setupNameTag()

        Avatar.initShadow(self)

        # We've already done all manipulating to the cog, we can just flatten it.
        self.getPart('body').flattenStrong()
        self.postFlatten()
        self.headModel.flattenStrong()
        if isinstance(self.headModel, Actor):
            self.headModel.postFlatten()
Beispiel #2
0
    def generateCog(self, isLose=0, nameTag=True):
        #startTime = globalClock.getRealTime()

        generateCollector.start()

        cleanupCollector.start()
        self.cleanup()
        cleanupCollector.stop()

        if not isLose:

            if self.suitPlan in SuitBank.suitSetups:
                setup = SuitBank.suitSetups[self.suitPlan]
            else:
                setup = SuitBank.SuitSetup()
                SuitBank.suitSetups[self.suitPlan] = setup

            if not self.variant in setup.actor:
                setupActor = Actor()
                if self.variant == Variant.SKELETON or self.variant == Variant.ZOMBIE:
                    setupActor.loadModel(
                        'phase_5/models/char/cog%s_robot-zero.bam' %
                        (str(self.suit)), 'body')
                else:
                    setupActor.loadModel(
                        'phase_3.5/models/char/suit%s-mod.bam' %
                        (str(self.suit)), 'body')
                animations = SuitGlobals.animations
                anims = {}
                for anim in animations:
                    if not self.suit in anim.getSuitTypes():
                        continue
                    path = 'phase_%s/models/char/suit%s-%s.bam' % (
                        anim.getPhase(), self.suit, anim.getFile())
                    anims[anim.getName()] = path
                setupActor.loadAnims(anims, 'body')
                setup.actor[self.variant] = setupActor

            actorCollector.start()
            self.copyActor(setup.actor[self.variant])
            actorCollector.stop()

            healthBarCollector.start()
            self.generateHealthBar()
            healthBarCollector.stop()

            footstepCollector.start()
            if self.suitPlan.suitType == SuitType.A:
                self.footstepSound = base.audio3d.loadSfx(
                    "phase_5/audio/sfx/ENC_cogafssm.ogg")
            elif self.suitPlan.suitType == SuitType.B:
                self.footstepSound = base.audio3d.loadSfx(
                    "phase_5/audio/sfx/ENC_cogbfssm.ogg")
            elif self.suitPlan.suitType == SuitType.C:
                self.footstepSound = base.audio3d.loadSfx(
                    "phase_5/audio/sfx/ENC_cogcfssm.ogg")
            if self.footstepSound:
                base.audio3d.attachSoundToObject(self.footstepSound, self)
                self.footstepSound.setVolume(0.0)
                self.footstepSound.setLoop(True)
                self.footstepSound.play()
            footstepCollector.stop()

        else:
            if self.variant == Variant.SKELETON or self.variant == Variant.ZOMBIE:
                self.loadModel(
                    'phase_5/models/char/cog%s_robot-lose-mod.bam' %
                    (str(self.suit)), 'body')
            else:
                self.loadModel(
                    'phase_4/models/char/suit%s-lose-mod.bam' %
                    (str(self.suit)), 'body')
            self.loadAnims(
                {
                    'lose':
                    'phase_4/models/char/suit%s-lose.bam' % (str(self.suit))
                }, 'body')

        genHeadCollector.start()
        if self.variant != Variant.SKELETON:
            self.headModel = self.head.generate()
            self.headModel.reparentTo(self.find("**/joint_head"))
        if self.suitPlan.getName() == SuitGlobals.VicePresident:
            self.headModel.setScale(0.35)
            self.headModel.setHpr(270, 0, 270)
            self.headModel.setZ(-0.10)
            self.headModel.loop('neutral')
        if self.variant == Variant.SKELETON:
            self.headModel = self.find("**/joint_head")
        #antenna = loader.loadModel("models/police_antenna.bam")
        ##antenna.reparentTo(self.find("**/joint_head"))
        #antenna.setPos(0.5, -0.5, 0)
        #antenna.setScale(1.25)
        #antenna.clearModelNodes()
        #antenna.flattenStrong()
        genHeadCollector.stop()

        self.setClothes()

        classScale = 1.0  #self.suitPlan.getCogClassAttrs().scaleMod
        self.setAvatarScale(
            (self.suitPlan.getScale() / SuitGlobals.scaleFactors[self.suit]) *
            classScale)
        self.setHeight(self.suitPlan.getHeight())

        nametagCollector.start()
        if nameTag:
            self.setupNameTag()
        nametagCollector.stop()

        Avatar.initShadow(self)

        if self.variant != Variant.SKELETON:
            # We've already done all manipulating to the cog, we can just flatten it.
            self.getPart('body').flattenStrong()
            self.postFlatten()
            self.headModel.flattenStrong()
            if isinstance(self.headModel, Actor):
                self.headModel.postFlatten()

        #endTime = globalClock.getRealTime()
        #print("GenerateCog took {0} seconds".format(endTime - startTime))

        generateCollector.stop()