class GameTest(ShowBase): def __init__(self): ShowBase.__init__(self) self.FlairDirector = Actor( 'phase_3.5/models/char/suitC-mod.bam', { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.FlairDirector.reparentTo(render) self.FlairDirector.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg') self.FlairDirector.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg') self.FlairDirector.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg') self.FlairDirector.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/FlairDirector.egg') self.headTexture = loader.loadTexture( "phase_3.5/maps/flair-director.jpg") self.Head.reparentTo(self.FlairDirector.find('**/joint_head')) self.FlairDirector.findAllMatches('**/joint_head').setTexture( self.headTexture, 1) self.icon = loader.loadModel('phase_3/models/gui/SourcebotIcon.bam') self.icon.reparentTo(render) self.iconTexture = loader.loadTexture('phase_3/maps/SourcebotIcon.png') self.icon.setTexture(self.iconTexture, 1) self.icon.setHpr(180, 0, 0) self.icon.setPos(0.1, 0, -0.30) self.icon.setScale(1.00) self.icon.reparentTo(self.FlairDirector.find('**/joint_attachMeter')) self.FlairDirector.setScale(1.70)
def make_skelecog(suit_style, suit_name, path=""): """Return a skelecog version of any traditional cog as an Actor. Args: suit_style (str): The letter representing the suit style ("A", "B" or "C"). suit_name (str): The name of the boss' suit. path (str, optional): The file path to the Toontown phase files. Defaults to Panda3D's search path. Examples: from toontown import make_skelecog skelecog = make_skelecog("A", "cash") skelecog.loop("neutral") Returns: An instance of Panda3D's Actor class. """ if path: path = pfile.fromOsSpecific("%s/" % path).getFullpath() icon_dict = { "sell": ("Sales", (0.843, 0.745, 0.745, 1.0)), "cash": ("Money", (0.749, 0.769, 0.749, 1.0)), "law": ("Legal", (0.749, 0.776, 0.824, 1.0)), "boss": ("Corp", (0.863, 0.776, 0.769, 1.0)) } animation_dict = cog_animation(suit_style, path) skelecog = Actor( "%sphase_5/models/char/cog%s_robot-zero.bam" % (path, suit_style), animation_dict ) if icon_dict[suit_name.lower()][0] == "Corp": tie = loader.loadTexture( "%sphase_5/maps/cog_robot_tie_boss.jpg" % path ) else: idict = icon_dict[suit_name][0].lower() tie = loader.loadTexture( "%sphase_5/maps/cog_robot_tie_%s.jpg" % (path, idict) ) skelecog.findAllMatches("**/tie").setTexture(tie, 1) icons = loader.loadModel("%sphase_3/models/gui/cog_icons.bam" % path) icon = icons.find( "**/%sIcon" % icon_dict[suit_name][0] ).copyTo(skelecog.find("**/joint_attachMeter")) icon.setPosHprScale(0.02, 0.05, 0.04, 180.0, 0.0, 0.0, 0.51, 0.51, 0.51) icon.setColor(icon_dict[suit_name.lower()][1]) icons.removeNode() skelecog.reparentTo(render) return skelecog
def make_skelecog(suit_style, suit_name, path=""): """Return a skelecog version of any traditional cog as an Actor. Args: suit_style (str): The letter representing the suit style ("A", "B" or "C"). suit_name (str): The name of the boss' suit. path (str, optional): The file path to the Toontown phase files. Defaults to Panda3D's search path. Examples: from toontown import make_skelecog skelecog = make_skelecog("A", "cash") skelecog.loop("neutral") Returns: An instance of Panda3D's Actor class. """ if path: path = pfile.fromOsSpecific("%s/" % path).getFullpath() icon_dict = { "sell": ("Sales", (0.843, 0.745, 0.745, 1.0)), "cash": ("Money", (0.749, 0.769, 0.749, 1.0)), "law": ("Legal", (0.749, 0.776, 0.824, 1.0)), "boss": ("Corp", (0.863, 0.776, 0.769, 1.0)) } animation_dict = cog_animation(suit_style, path) skelecog = Actor( "%sphase_5/models/char/cog%s_robot-zero.bam" % (path, suit_style), animation_dict) if icon_dict[suit_name.lower()][0] == "Corp": tie = loader.loadTexture("%sphase_5/maps/cog_robot_tie_boss.jpg" % path) else: idict = icon_dict[suit_name][0].lower() tie = loader.loadTexture("%sphase_5/maps/cog_robot_tie_%s.jpg" % (path, idict)) skelecog.findAllMatches("**/tie").setTexture(tie, 1) icons = loader.loadModel("%sphase_3/models/gui/cog_icons.bam" % path) icon = icons.find("**/%sIcon" % icon_dict[suit_name][0]).copyTo( skelecog.find("**/joint_attachMeter")) icon.setPosHprScale(0.02, 0.05, 0.04, 180.0, 0.0, 0.0, 0.51, 0.51, 0.51) icon.setColor(icon_dict[suit_name.lower()][1]) icons.removeNode() skelecog.reparentTo(render) return skelecog
def loadModel(file, collision=None, animation=None): model=None if animation: model=Actor(file, animation) #default anim if 'default' in animation: model.loop('default') elif 'idle' in animation: model.loop('idle') else: #some random anim model.loop(animation.items()[0]) else: model=loader.loadModel(file) model.setPythonTag('model_file', file) #load shaders for geom in model.findAllMatches('**/+GeomNode'): if geom.hasTag('light'): model.setPythonTag('hasLight', True) if geom.hasTag('particle'): file='particle/'+geom.getTag('particle') if os.path.exists(file): with open(file) as f: values=json.load(f) p=createEffect(values) model.setPythonTag('particle', p) p.start(parent=model, renderParent=render) if geom.hasTag('cg_shader'): geom.setShader(loader.loadShader("shaders/"+geom.getTag('cg_shader'))) elif geom.hasTag('glsl_shader'): glsl_shader=geom.getTag('glsl_shader') geom.setShader(Shader.load(Shader.SLGLSL, "shaders/{0}_v.glsl".format(glsl_shader),"shaders/{0}_f.glsl".format(glsl_shader))) else: #geom.setShader(loader.loadShader("shaders/default.cg")) geom.setShader(Shader.load(Shader.SLGLSL, "shaders/default_v.glsl","shaders/default_f.glsl")) #collisions model.setCollideMask(BitMask32.allOff()) if collision: coll=loader.loadModel(collision) coll.reparentTo(model) coll.find('**/collision').setCollideMask(BitMask32.bit(2)) coll.find('**/collision').setPythonTag('object', model) if animation: model.setPythonTag('actor_files', [file,animation,coll]) else: try: model.find('**/collision').setCollideMask(BitMask32.bit(2)) model.find('**/collision').setPythonTag('object', model) except: print "WARNING: Model {0} has no collision geometry!\nGenerating collision sphere...".format(file) bounds=model.getBounds() radi=bounds.getRadius() cent=bounds.getCenter() coll_sphere=model.attachNewNode(CollisionNode('collision')) coll_sphere.node().addSolid(CollisionSphere(cent[0],cent[1],cent[2], radi)) coll_sphere.setCollideMask(BitMask32.bit(2)) coll_sphere.setPythonTag('object', model) #coll_sphere.show() if animation: model.setPythonTag('actor_files', [file,animation,None]) return model
def loadModel(file, collision=None, animation=None): model = None if animation: model = Actor(file, animation) #default anim if 'default' in animation: model.loop('default') elif 'idle' in animation: model.loop('idle') else: #some random anim model.loop(list(animation.items())[0]) else: model = loader.loadModel(file) model.setPythonTag('model_file', file) #load shaders for geom in model.findAllMatches('**/+GeomNode'): if geom.hasTag('cg_shader'): geom.setShader( loader.loadShader("shaders/" + geom.getTag('cg_shader'))) elif geom.hasTag('glsl_shader'): glsl_shader = geom.getTag('glsl_shader') geom.setShader( Shader.load(Shader.SLGLSL, "shaders/{0}_v.glsl".format(glsl_shader), "shaders/{0}_f.glsl".format(glsl_shader))) else: #geom.setShader(loader.loadShader("shaders/default.cg")) geom.setShader( Shader.load(Shader.SLGLSL, "shaders/default_v.glsl", "shaders/default_f.glsl")) #collisions model.setCollideMask(BitMask32.allOff()) if collision: coll = loader.loadModel(collision) coll.reparentTo(model) coll.find('**/collision').setCollideMask(BitMask32.bit(2)) coll.find('**/collision').setPythonTag('object', model) if animation: model.setPythonTag('actor_files', [file, animation, coll]) else: try: model.find('**/collision').setCollideMask(BitMask32.bit(2)) model.find('**/collision').setPythonTag('object', model) except: print( "WARNING: Model {0} has no collision geometry!\nGenerating collision sphere..." .format(file)) bounds = model.getBounds() radi = bounds.getRadius() cent = bounds.getCenter() coll_sphere = model.attachNewNode(CollisionNode('collision')) coll_sphere.node().addSolid( CollisionSphere(cent[0], cent[1], cent[2], radi)) coll_sphere.setCollideMask(BitMask32.bit(2)) coll_sphere.setPythonTag('object', model) #coll_sphere.show() if animation: model.setPythonTag('actor_files', [file, animation, None]) return model
#Offsetting camera cameraOffset = 3.2375 #Binding animations to actor Player = Actor("phase_2/models/char/mp_2000.bam", {"running-jump-idle":"phase_2/models/char/mp_jump.bam", "walk":"phase_2/models/char/mp_walk.bam", "turnLeft1":"phase_2/models/char/mp_spin_left.bam", "turnRight2":"phase_2/models/char/mp_spin_right.bam", "neutral":"phase_2/models/char/mp_idle_centered.bam", "run":"phase_2/models/char/mp_run.bam"}) #Hiding clothing layers Player.reparentTo(render) Player.findAllMatches("**/clothing_layer1*").hide() Player.findAllMatches("**/clothing_layer2*").hide() Player.findAllMatches("**/clothing_layer3*").hide() Player.findAllMatches("**/hair*").hide() Player.findAllMatches("**/acc*").hide() Player.findAllMatches("**/beard*").hide() Player.findAllMatches("**/mustache*").hide() Player.findAllMatches("**/gh_master_face*").hide() Player.findAllMatches("**/body_armpit*").hide() Player.findAllMatches("**/body_forearm*").hide() Player.findAllMatches("**/body_foot*").hide() Player.findAllMatches("**/body_shoulder*").hide() Player.findAllMatches("**/body_torso*").hide() Player.findAllMatches("**/body_waist*").hide() Player.findAllMatches("**/body_knee*").hide() Player.findAllMatches('**/body_belt').hide()
def make_cog(head, head_style, suit_style, suit_name, head_text="", path=""): """Return a skelecog version of any traditional cog as an Actor. Args: head (str): The name of the cog. head_style (str): The letter representing the suit style ("A", "B" or "C"). suit_style (str): The letter representing the suit style ("A", "B" or "C"). suit_name (str): The name of the suit. head_text (str, optional): The name of a head texture. path (str, optional): The file path to the Toontown phase files. Defaults to Panda3D's search path. Examples: from toontown import make_cog Hollywood = make_cog("yesman", "A", "A", "sell") Hollywood.loop("landing") RobberBaron = make_cog("yesman", "A", "A", "cash", "robber-baron") RobberBaron.loop("walk") SpinDoctor = make_cog("telemarketer", "B", "B", "law", "spin-doctor") SpinDoctor.loop("throw-paper") Returns: An instance of Panda3D's Actor class. """ if path: path = pfile.fromOsSpecific("%s/" % path).getFullpath() abrv = { "sell": ( "s", (0.95, 0.75, 0.95, 1.0), "Sales", (0.843, 0.745, 0.745, 1.0) ), "cash": ( "m", (0.65, 0.95, 0.85, 1.0), "Money", (0.749, 0.769, 0.749, 1.0) ), "law": ( "l", (0.75, 0.75, 0.95, 1.0), "Legal", (0.749, 0.776, 0.824, 1.0) ), "boss": ( "c", (0.95, 0.75, 0.75, 1.0), "Corp", (0.863, 0.776, 0.769, 1.0) ) } cog_color = { "coldcaller": ((0.75, 0.75, 0.95, 1.0), ""), "pennypincher": ((1.0, 0.5, 0.6, 1.0), ""), "legaleagle": ((0.25, 0.25, 0.5, 1.0), ""), "telemarketer": ((0.5, 0.8, 0.75, 1.0), "spin-doctor"), "movershaker": ((0.95, 0.95, 1.0, 1.0), "blood-sucker"), "bigcheese": ((0.75, 0.95, 0.75, 1.0), ""), "flunky": ((0.85, 0.55, 0.55, 1.0), "corporate-raider") } blazer = loader.loadTexture( "%sphase_3.5/maps/%s_blazer.jpg" % (path, abrv[suit_name][0]) ) sleeve = loader.loadTexture( "%sphase_3.5/maps/%s_sleeve.jpg" % (path, abrv[suit_name][0]) ) leg = loader.loadTexture( "%sphase_3.5/maps/%s_leg.jpg" % (path, abrv[suit_name][0]) ) animation_dict = cog_animation(suit_style, path) if suit_style in ("A", "B"): cog = Actor( "%sphase_3.5/models/char/suit%s-mod.bam" % (path, suit_style), animation_dict ) else: cog = Actor( "%sphase_3.5/models/char/suitC-mod.bam" % path, animation_dict ) if head_style in ("A", "B"): head_model = loader.loadModel( "%sphase_4/models/char/suit%s-heads.bam" % (path, head_style) ) else: head_model = loader.loadModel( "%sphase_3.5/models/char/suitC-heads.bam" % path ) cog_head = head_model.find("**/%s" % head) joint_head = cog.find("**/joint_head") cog_head.reparentTo(joint_head) if head in cog_color.keys() and head_text == cog_color[head][1]: cog.find("**/hands").setColor(cog_color[head][0]) else: cog.find("**/hands").setColor(abrv[suit_name][1]) if head_text and head_text not in ("bottom-feeder", "corporate-raider"): head_texture = loader.loadTexture( "%sphase_4/maps/%s.jpg" % (path, head_text) ) cog.findAllMatches("**/%s" % head).setTexture(head_texture, 1) elif head_text in ("bottom-feeder", "corporate-raider"): head_texture = loader.loadTexture( "%sphase_3.5/maps/%s.jpg" % (path, head_text) ) cog.findAllMatches("**/%s" % head).setTexture(head_texture, 1) if head == "flunky" and not head_text: head_model.find("**/glasses").reparentTo(cog_head) icons = loader.loadModel("%sphase_3/models/gui/cog_icons.bam" % path) icon = icons.find( "**/%sIcon" % abrv[suit_name][2] ).copyTo(cog.find("**/joint_attachMeter")) icon.setPosHprScale(0.02, 0.05, 0.04, 180.0, 0.0, 0.0, 0.51, 0.51, 0.51) icon.setColor(abrv[suit_name][3]) icons.removeNode() cog.find("**/legs").setTexture(leg, 1) cog.find("**/torso").setTexture(blazer, 1) cog.find("**/arms").setTexture(sleeve, 1) cog.reparentTo(render) return cog
class landWalker(ShowBase): def __init__(self): ShowBase.__init__(self) base.disableMouse() font = self.loader.loadFont( "phase_3/models/fonts/vtRemingtonPortable.ttf") self.land = self.loader.loadModel( "phase_11/models/lawbotHQ/LawbotPlaza.bam") self.land.reparentTo(self.render) self.Sourcebot = Actor( 'phase_3.5/models/char/suitC-mod.bam', { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.Sourcebot.reparentTo(render) self.Sourcebot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg') self.Sourcebot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg') self.Sourcebot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg') self.Sourcebot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel( 'phase_3.5/models/char/suitC-heads.bam').find('**/tightwad') self.headTexture = loader.loadTexture( "phase_3.5/maps/payroll-converter.jpg") self.Head.reparentTo(self.Sourcebot.find('**/joint_head')) self.Sourcebot.findAllMatches('**/joint_head').setTexture( self.headTexture, 1) self.icon = loader.loadModel('phase_3/models/gui/SourcebotIcon.bam') self.icon.reparentTo(render) self.iconTexture = loader.loadTexture('phase_3/maps/SourcebotIcon.png') self.icon.setTexture(self.iconTexture, 1) self.icon.setHpr(180, 0, 0) self.icon.setPos(0.1, 0, -0.30) self.icon.setScale(1.00) self.icon.reparentTo(self.Sourcebot.find('**/joint_attachMeter')) Name = TextNode("nametag") Name.setText("Prof. Bill\nPayroll Converter\nSourcebot\nLevel 1") Name.setFont(font) self.nameTag = render.attachNewNode(Name) self.nameTag.setBillboardAxis() self.nameTag.reparentTo(self.Sourcebot.find('**/joint_nameTag')) self.nameTag.setZ(7.51) Name.setAlign(TextNode.ACenter) Name.setCardColor(0.8, 0.8, 0.8, 0.5) Name.setCardAsMargin(0.1, 0, 0, -0.2) Name.setCardDecal(True) Name.setTextColor(0, 0, 0, 1.0) self.nameTag.setScale(0.33) #____________________________LANDWALKER___________________# self.collisions() def collisions(self): self.keyMap = { "left": 0, "right": 0, "forward": 0, "backward": 0, "up": 0, "side-left": 0, "side-right": 0 } self.isMoving_forward = False self.isMoving_side = False base.cTrav = CollisionTraverser() self.colEV = CollisionHandlerEvent() self.groundHandler = CollisionHandlerFloor() self.wallHandler = CollisionHandlerPusher() self.FLOOR_MASK = BitMask32.bit(1) self.WALL_MASK = BitMask32.bit(2) self.TRIGGER_MASK = BitMask32.bit(3) self.HITBOX_MASK = BitMask32.bit(4) self.Sourcebot.setCollideMask(BitMask32.allOff()) self.LEGSNP = NodePath('toonlegsnp') self.LEGSNP.reparentTo(self.Sourcebot) self.LEGSNP.setZ(5) self.avatarCollider = self.Sourcebot.attachNewNode( CollisionNode('LEGSCNODE')) self.avatarCollider.node().addSolid(CollisionSphere(0, 0, 0, 1)) self.avatarCollider.node().setFromCollideMask(self.WALL_MASK) self.avatarCollider.node().setIntoCollideMask(BitMask32.allOff()) self.avatarCollider.setSz(5) self.avatarCollider2 = self.Sourcebot.attachNewNode( CollisionNode('LEGSCHIT')) self.avatarCollider2.node().addSolid(CollisionSphere(0, 0, 0, 1)) self.avatarCollider2.node().setFromCollideMask(BitMask32.allOff()) self.avatarCollider2.node().setIntoCollideMask(self.HITBOX_MASK) self.avatarCollider2.setSz(6) self.avatarSensor = self.Sourcebot.attachNewNode( CollisionNode('avatarSensor')) self.avatarSensor.node().addSolid(CollisionSphere(0, 0, 0, 1.2)) self.avatarSensor.node().setFromCollideMask(self.WALL_MASK | self.TRIGGER_MASK) self.avatarSensor.node().setIntoCollideMask(BitMask32.allOff()) self.raygeometry = CollisionRay(0, 0, 2, 0, 0, -1) self.avatarRay = self.LEGSNP.attachNewNode(CollisionNode('avatarRay')) self.avatarRay.node().addSolid(self.raygeometry) self.avatarRay.node().setFromCollideMask(self.FLOOR_MASK) self.avatarRay.node().setIntoCollideMask(BitMask32.allOff()) self.groundHandler.addCollider(self.avatarRay, self.Sourcebot) self.wallHandler.addCollider(self.avatarCollider, self.Sourcebot) self.wallHandler.addCollider(self.avatarCollider2, self.Sourcebot) base.cTrav.addCollider(self.avatarRay, self.groundHandler) base.cTrav.addCollider(self.avatarCollider, self.wallHandler) base.cTrav.addCollider(self.avatarCollider2, self.wallHandler) base.cTrav.addCollider(self.avatarSensor, self.colEV) #---------------------------------------------------------------# #-----------------WALK-CODE-----------------# base.accept("arrow_left", self.setKey, ["left", 1]) base.accept("arrow_right", self.setKey, ["right", 1]) base.accept("arrow_up", self.setKey, ["forward", 1]) base.accept("arrow_down", self.setKey, ["backward", 1]) base.accept("arrow_left-up", self.setKey, ["left", 0]) base.accept("arrow_right-up", self.setKey, ["right", 0]) base.accept("arrow_up-up", self.setKey, ["forward", 0]) base.accept("arrow_down-up", self.setKey, ["backward", 0]) base.accept("arrow_down-arrow_up", self.setKey, ["backward", 1]) base.accept("arrow_up-arrow_down", self.setKey, ["forward", 1]) #-------------wasd--------------------# base.accept("a", self.setKey, ["side-left", 1]) base.accept("d", self.setKey, ["side-right", 1]) base.accept("w", self.setKey, ["forward", 1]) base.accept("s", self.setKey, ["backward", 1]) base.accept("a-up", self.setKey, ["side-left", 0]) base.accept("d-up", self.setKey, ["side-right", 0]) base.accept("w-up", self.setKey, ["forward", 0]) base.accept("s-up", self.setKey, ["backward", 0]) base.accept("s-w", self.setKey, ["backward", 1]) base.accept("w-s", self.setKey, ["forward", 1]) taskMgr.add(self.move, "movetask") self.cameraJoint() self.camera.setPos(0, -16.5, 3.89) self.accept("alt-o", self.oobe) def setKey(self, key, value): self.keyMap[key] = value def move(self, task): try: if (self.keyMap["left"] != 0): self.Sourcebot.setH(self.Sourcebot.getH() + 75 * globalClock.getDt()) if (self.keyMap["right"] != 0): self.Sourcebot.setH(self.Sourcebot.getH() - 75 * globalClock.getDt()) if (self.keyMap["side-right"] != 0): self.Sourcebot.setX(self.Sourcebot, 24 * globalClock.getDt()) if (self.keyMap["side-left"] != 0): self.Sourcebot.setX(self.Sourcebot, -24 * globalClock.getDt()) if (self.keyMap["forward"] != 0): self.Sourcebot.setY(self.Sourcebot, 24 * globalClock.getDt()) if (self.keyMap["backward"] != 0): self.Sourcebot.setY(self.Sourcebot, -12.5 * globalClock.getDt()) except: pass if (self.keyMap["forward"] != 0): if self.isMoving_forward is False: self.isMoving_side = False self.AVATAR_MOTION = 'MOVING' self.Sourcebot.stop("neutral") self.Sourcebot.play("walk") self.Sourcebot.setPlayRate(1, 'walk') self.Sourcebot.loop("walk") self.isMoving_forward = True elif (self.keyMap["left"] != 0) or (self.keyMap["right"] != 0) or ( self.keyMap["backward"] != 0): if self.isMoving_side is False: self.isMoving_forward = False self.AVATAR_MOTION = 'MOVING' self.Sourcebot.play("walk") self.Sourcebot.setPlayRate(-1.0, 'walk') self.Sourcebot.stop("neutral") self.Sourcebot.loop("walk") self.isMoving_side = True else: if self.isMoving_forward or self.isMoving_side: self.AVATAR_MOTION = 'NORMAL' self.Sourcebot.stop("walk") self.Sourcebot.loop("neutral") self.Sourcebot.loop("neutral") self.Sourcebot.loop("neutral") self.isMoving_side = False self.isMoving_forward = False return task.cont def cameraJoint(self): self.camera.reparentTo(self.Sourcebot.find('**/joint_nameTag'))
class Cog(): def __init__(self): #Define variables to keep track of the current head, body, and department self.currentBody = 0 self.currentHead = 0 self.currentDept = 0 #Define a boolean to determine if the cog is in view self.isInView = False #Establish current file path location self.currentDirectory = os.path.abspath(sys.path[0]) self.pandaDirectory = Filename.fromOsSpecific( self.currentDirectory).getFullpath() #Create the cog head and body (mainly to allow it to be #destroyed later in replacement of the proper body) self.cog = Actor( self.pandaDirectory + '/resources/cogs/models/tt_a_ene_cga_zero.bam', { 'neutral': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_neutral.bam'), 'walk': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_walk.bam') }) self.head = loader.loadModel(self.pandaDirectory + '/resources/cogs/models/suitA-heads.bam') #Determine the body type and set the head self.determineBody() def determineBody(self): #Destroy the current body to unrender it self.cog.delete() self.cog.removeNode() #Determine the new cog body type if self.currentBody == 0: self.cog = Actor( self.pandaDirectory + '/resources/cogs/models/tt_a_ene_cga_zero.bam', { 'neutral': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_neutral.bam'), 'walk': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_walk.bam'), 'victory': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_victory.bam') }) elif self.currentBody == 1: self.cog = Actor( self.pandaDirectory + '/resources/cogs/models/tt_a_ene_cgb_zero.bam', { 'neutral': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_neutral.bam'), 'walk': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_walk.bam'), 'victory': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_victory.bam') }) elif self.currentBody == 2: self.cog = Actor( self.pandaDirectory + '/resources/cogs/models/tt_a_ene_cgc_zero.bam', { 'neutral': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_neutral.bam'), 'walk': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_walk.bam'), 'victory': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_victory.bam') }) else: raise Exception( 'UH OH! currentBody is not between 0 and 2! The value of currentBody is {}' .format(self.currentBody)) self.cog.reparentTo(render) if self.isInView: self.cog.loop('neutral') self.cog.setPos(6, 2, 0) self.cog.setHpr(180, 0, 0) else: self.resetCogPos() #Define the lerp for the cog's movement and animations self.walkIn = self.cog.posInterval(2, pos=(6, 2, 0)) self.walkOut = self.cog.posInterval(2, pos=(15, 2, 0)) self.turnToCam = self.cog.hprInterval(1, hpr=(180, 0, 0)) self.turnAway = self.cog.hprInterval(1, hpr=(270, 0, 0)) #Define the sequences #Note: If you want to loop an animation after a sequence plays, #you have to append the Func(self.actor.loop, 'animName') to the end of the function. self.enterView = Sequence(self.walkIn, self.turnToCam, Func(self.cog.loop, 'neutral')) self.exitView = Sequence(Func(self.cog.loop, 'walk'), self.turnAway, self.walkOut) #Call the other methods to reattach and reapply the head and department textures self.determineHead() self.determineDept() def determineHead(self): #Destroy the current head to unrender it self.head.removeNode() #Set up a boolean to make sure the cog is or isn't a flunky hasGlasses = False #Determine the cog head type if self.currentHead <= 12: self.headList = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/suitA-heads.bam') if self.currentHead == 0: self.head = self.headList.find('**/backstabber') elif self.currentHead == 1: self.head = self.headList.find('**/bigcheese') elif self.currentHead == 2: self.head = self.headList.find('**/bigwig') elif self.currentHead == 3: self.head = self.headList.find('**/headhunter') elif self.currentHead == 4: self.head = self.headList.find('**/legaleagle') elif self.currentHead == 5: self.head = self.headList.find('**/numbercruncher') elif self.currentHead == 6: #name dropper self.head = self.headList.find('**/numbercruncher') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/name-dropper.jpg'), 1) elif self.currentHead == 7: self.head = self.headList.find('**/pennypincher') elif self.currentHead == 8: self.head = self.headList.find('**/yesman') elif self.currentHead == 9: #robber baron self.head = self.headList.find('**/yesman') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/robber-baron.jpg'), 1) elif self.currentHead == 10: self.head = self.headList.find('**/twoface') elif self.currentHead == 11: #mingler self.head = self.headList.find('**/twoface') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/mingler.jpg'), 1) else: #double talker self.head = self.headList.find('**/twoface') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/double-talker.jpg'), 1) elif self.currentHead <= 20: self.headList = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/suitB-heads.bam') if self.currentHead == 13: self.head = self.headList.find('**/ambulancechaser') elif self.currentHead == 14: self.head = self.headList.find('**/beancounter') elif self.currentHead == 15: self.head = self.headList.find('**/loanshark') elif self.currentHead == 16: self.head = self.headList.find('**/movershaker') elif self.currentHead == 17: #bloodsucker self.head = self.headList.find('**/movershaker') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/blood-sucker.jpg'), 1) elif self.currentHead == 18: self.head = self.headList.find('**/pencilpusher') elif self.currentHead == 19: self.head = self.headList.find('**/telemarketer') else: #spin doctor self.head = self.headList.find('**/telemarketer') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/spin-doctor.jpg'), 1) elif self.currentHead <= 29: self.headList = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/suitC-heads.bam') if self.currentHead == 21: #actually a short change self.head = self.headList.find('**/coldcaller') elif self.currentHead == 22: #cold caller needs to be recolored self.head = self.headList.find('**/coldcaller') self.head.setColor(0, 0, 255, 1) elif self.currentHead == 23: self.head = self.headList.find('**/flunky') hasGlasses = True elif self.currentHead == 24: #corporate raider self.head = self.headList.find('**/flunky') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/corporate-raider.jpg'), 1) elif self.currentHead == 25: self.head = self.headList.find('**/gladhander') elif self.currentHead == 26: self.head = self.headList.find('**/micromanager') elif self.currentHead == 27: self.head = self.headList.find('**/moneybags') elif self.currentHead == 28: self.head = self.headList.find('**/tightwad') else: #bottom feeder self.head = self.headList.find('**/tightwad') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/bottom-feeder.jpg'), 1) else: raise Exception( 'UH OH! currentHead is not between 0 and 31! The value of currentBody is {}' .format(self.currentHead)) #Attach the head to the model self.head.reparentTo(self.cog.find('**/def_head')) if hasGlasses: self.glasses = self.headList.find('**/glasses') self.glasses.reparentTo(self.head) def determineDept(self): #Determine the cog department and set the textures of the suit if self.currentDept == 0: self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/s_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/s_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/s_leg.jpg'), 1) elif self.currentDept == 1: self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/m_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/m_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/m_leg.jpg'), 1) elif self.currentDept == 2: self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/l_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/l_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/l_leg.jpg'), 1) elif self.currentDept == 3: self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/c_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/c_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/c_leg.jpg'), 1) elif self.currentDept == 4: self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture( self.pandaDirectory + '/resources/cogs/textures/waiter_m_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture( self.pandaDirectory + '/resources/cogs/textures/waiter_m_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture( self.pandaDirectory + '/resources/cogs/textures/waiter_m_leg.jpg'), 1) else: raise Exception( 'UH OH! currentDept is not between 0 and 4! The value of currentDept is {}' .format(self.currentDept)) def nextHead(self): #Keep the head variable within the range and switch to the next head if self.currentHead >= 29: self.currentHead = 0 else: self.currentHead += 1 self.determineHead() def previousHead(self): #Keep the head variable within the range and switch to the previous head if self.currentHead <= 0: self.currentHead = 29 else: self.currentHead -= 1 self.determineHead() def nextBody(self): #Keep the head variable within the range and switch to the next body if self.currentBody >= 2: self.currentBody = 0 else: self.currentBody += 1 self.determineBody() def previousBody(self): #Keep the head variable within the range and switch to the previous body if self.currentBody <= 0: self.currentBody = 2 else: self.currentBody -= 1 self.determineBody() def nextDept(self): #Keep the head variable within the range and switch to the next department if self.currentDept >= 4: self.currentDept = 0 else: self.currentDept += 1 self.determineDept() def previousDept(self): #Keep the head variable within the range and switch to the previous department if self.currentDept <= 0: self.currentDept = 4 else: self.currentDept -= 1 self.determineDept() def resetCogPos(self): #Sets the cog's position to its starting location outside the scene self.cog.loop('walk') self.cog.setHpr(90, 0, 0) self.cog.setPos(15, 2, 0) def enterScene(self): #Establish the sequence for the cog to walk in the scene self.resetCogPos() self.enterView.start() self.isInView = True def exitScene(self): #Establish the sequence for the cog to walk out of the scene self.exitView.start() self.isInView = False def playNeutral(self): #Makes the neutral animation available to the GUI class self.cog.loop('neutral') def playVictory(self): #Makes the victory animation available to the GUI class self.cog.loop('victory') def getAnimPlaying(self): #returns the animation playing for the GUI class return self.cog.getCurrentAnim()
'**/shoes') for partNum in range(0, otherParts.getNumPaths()): otherParts.getPath(partNum).removeNode() DuckBody = Actor({ 'head': DuckHead, 'torso': DuckTorso, 'legs': DuckLegs }, { 'torso': torsoAnimDict, 'legs': legsAnimDict }) DuckBody.attach('head', 'torso', 'def_head') DuckBody.attach('torso', 'legs', 'joint_hips') gloves = DuckBody.findAllMatches('**/hands') ears = DuckBody.findAllMatches('**/*ears*') head = DuckBody.findAllMatches('**/head-*') sleeves = DuckBody.findAllMatches('**/sleeves') shirt = DuckBody.findAllMatches('**/torso-top') shorts = DuckBody.findAllMatches('**/torso-bot') neck = DuckBody.findAllMatches('**/neck') arms = DuckBody.findAllMatches('**/arms') legs = DuckBody.findAllMatches('**/legs') feet = DuckBody.findAllMatches('**/feet') bodyNodes = [] bodyNodes += [gloves] bodyNodes += [head, ears] bodyNodes += [sleeves, shirt, shorts] bodyNodes += [neck, arms, legs, feet]
class RandomCog(): def __init__(self, taskMgr, enemyMaskBit, wallMaskBit, player, maxHealth, speed): #Initialize variables for the cog's health, speed, and scale self.maxHealth = maxHealth self.currentHealth = self.maxHealth self.speed = speed self.scale = 1 #Set masks self.enemyMaskBit = enemyMaskBit self.wallMaskBit = wallMaskBit self.ENEMY_MASK = BitMask32.bit(self.enemyMaskBit) self.WALL_MASK = BitMask32.bit(self.wallMaskBit) #Establish current file path location self.currentDirectory = os.path.abspath(sys.path[0]) self.pandaDirectory = Filename.fromOsSpecific( self.currentDirectory).getFullpath() #Set object variable to point to the global task manager self.taskMgr = taskMgr #Define location of the toon node self.player = player #Select the cog from random self.pickRandomCog() #Render the head and actor self.cog.reparentTo(render) self.head.reparentTo(self.cog.find('**/def_head')) #Scale the model self.cog.setScale(self.scale) ''' After doing some research into using the life meter, I found a class from Toontown Empire that was particularly helpful. https://github.com/AnonymousDeveloper13/Toontown-Empire/blob/master/src/toontown/suit/SuitHealthBar.py ''' #Set up life meter self.lifeMeter = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/matching_game_gui.bam').find( '**/minnieCircle') self.lifeMeter.reparentTo(self.cog.find('**/def_joint_attachMeter')) self.lifeMeter.setHpr(180, 0.8, 0) self.lifeMeter.setY(0.02) self.lifeMeter.setScale(3) self.lifeMeter.setColor(0, 1, 0) self.lifeMeterGlow = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/glow.bam') self.lifeMeterGlow.reparentTo(self.lifeMeter) self.lifeMeterGlow.setScale(0.25) self.lifeMeterGlow.setPos(-0.01, 0.01, 0.02) #Get the sizes of the head, torso, and legs min, max = self.head.getTightBounds() self.headSize = max - min min, max = self.cog.find('**/torso').getTightBounds() self.torsoSize = max - min min, max = self.cog.find('**/legs').getTightBounds() self.legSize = max - min #Set up box collider for cog head self.cogHeadBox = self.head.attachNewNode(CollisionNode('cogHeadBox')) self.cogHeadBox.node().addSolid( CollisionBox(self.head.getBounds().getCenter(), (self.headSize.getX() / 2), (self.headSize.getY() / 2), (self.headSize.getZ() / 2))) self.cogHeadBox.node().setFromCollideMask(self.ENEMY_MASK) self.cogHeadBox.node().setIntoCollideMask(self.ENEMY_MASK) #self.cogHeadBox.show() #Set up box collider for cog torso self.cogTorsoBox = self.cog.find('**/torso').attachNewNode( CollisionNode('cogTorsoBox')) self.cogTorsoBox.node().addSolid( CollisionBox( self.cog.find('**/torso').getBounds().getCenter(), (self.torsoSize.getX() / 2) + (self.torsoSize.getX() / 5), (self.torsoSize.getY() / 2), (self.torsoSize.getZ() / 2))) self.cogTorsoBox.node().setFromCollideMask(self.WALL_MASK) self.cogTorsoBox.node().setIntoCollideMask(self.WALL_MASK) #self.cogTorsoBox.show() #Set up box collider for cog legs self.cogLegsBox = self.cog.find('**/torso').attachNewNode( CollisionNode('cogLegsBox')) self.cogLegsBox.node().addSolid( CollisionBox( self.cog.find('**/legs').getBounds().getCenter(), (self.legSize.getX() / 2), (self.legSize.getY() / 2), (self.legSize.getZ() / 2))) self.cogLegsBox.node().setFromCollideMask(self.ENEMY_MASK) self.cogLegsBox.node().setIntoCollideMask(self.ENEMY_MASK) #self.cogLegsBox.show() #Set up propeller self.propeller = Actor( self.pandaDirectory + '/resources/cogs/models/propeller-mod.bam', { 'fly': self.pandaDirectory + '/resources/cogs/models/propeller-chan.bam' }) self.propeller.loop('fly', fromFrame=0, toFrame=5) self.propeller.setP(5) self.propeller.reparentTo(self.head) #Put the cog in a random position on the map self.cog.setPos(5, 5, 20) #Establish the flying movement self.cog.pose('landing', 0) self.flyDown = LerpPosInterval(self.cog, duration=4, pos=(self.cog.getX(), self.cog.getY(), 2)) self.land = LerpPosInterval(self.cog, duration=1, pos=(self.cog.getX(), self.cog.getY(), 0)) self.entranceAnim = Sequence(self.flyDown, Func(self.cog.play, ['landing']), Func(self.propeller.play, ['fly']), self.land, Wait(2.8), Func(self.startWalk)) #Start flying down! self.entranceAnim.start() def startWalk(self): #Set the cog to walk, then call the task manager to have the cog walk towards the player self.cog.loop('walk') self.walkingTask = self.taskMgr.add(self.walkingCog, 'walking cog') #Establish the hit, then walk animation self.hitThenWalk = Sequence( Func(self.taskMgr.remove, [self.walkingTask]), Func(self.cog.play, ['hit']), Wait(2.5), Func(self.startWalk)) #Establish the hit, then destruct animation self.hitThenDestroy = Sequence( Func(self.taskMgr.remove, [self.walkingTask]), Func(self.cog.play, ['hit']), Wait(2.5), Func(self.destruct)) def walkingCog(self, task): #Make the cog look at the toon... self.cog.lookAt(self.player.toon) #Then walk towards them! self.cog.setY(self.cog, self.speed) return task.cont def updateHealth(self): #Update the life meter, depending on the cog's health if (self.currentHealth / self.maxHealth) >= 0.95: self.lifeMeter.setColor(0, 1, 0) elif (self.currentHealth / self.maxHealth) >= 0.65: self.lifeMeter.setColor(1, 1, 0) elif (self.currentHealth / self.maxHealth) >= 0.35: self.lifeMeter.setColor(1, 0.5, 0) elif (self.currentHealth / self.maxHealth) >= 0.05: self.lifeMeter.setColor(1, 0, 0) elif (self.currentHealth / self.maxHealth) > 0: self.taskMgr.add(self.blink, 'blink', extraArgs=[1.0], appendTask=True) else: #Destroy cog self.taskMgr.add(self.blink, 'blink', extraArgs=[0.5], appendTask=True) self.hitThenDestroy.start() return #If the cog is still alive, have him get hit then walk self.hitThenWalk.start() def blink(self, delayTime, task): #If the current color is red... (getColor need to be compared to an LColor) if self.lifeMeter.getColor() == LColor(1, 0, 0, 1): #Change color to grey and set delay time self.lifeMeter.setColor(0.45, 0.45, 0.45) self.lifeMeterGlow.hide() task.delayTime = 0.1 else: #Change color to red and set delay time self.lifeMeter.setColor(1, 0, 0) self.lifeMeterGlow.show() task.delayTime = delayTime return task.again def destruct(self): #Remove the light animation from the task manager self.taskMgr.remove(self.walkingTask) self.taskMgr.remove('blink') self.lifeMeter.hide() #Play the destruction animation, then remove the model print('BOOM!') def pickRandomCog(self): #Generate a random number between 0 and 31 inclusive to select a cog self.randomNumber = random.randint(0, 31) #Num cogs in suits #A - 14 #B - 9 #C - 9 #Determine which cog the random number generator picked and set its properties if self.randomNumber <= 13: #Render the suit A type cogs self.cog = Actor( self.pandaDirectory + '/resources/cogs/models/tt_a_ene_cga_zero.bam', { 'neutral': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_neutral.bam'), 'walk': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_walk.bam'), 'finger wag': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_finger-wag.bam'), 'landing': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_landing.bam'), 'hit': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cga_pie-small.bam') }) self.headList = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/suitA-heads.bam') if self.randomNumber == 0: self.head = self.headList.find('**/backstabber') self.cog.find('**/hands').setColorScale(0.75, 0.75, 0.95, 1) self.scale = 0.9 self.setLawTexture() elif self.randomNumber == 1: self.head = self.headList.find('**/bigcheese') self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1.3 self.setBossTexture() elif self.randomNumber == 2: self.head = self.headList.find('**/bigwig') self.cog.find('**/hands').setColor(0.75, 0.75, 0.95, 1) self.scale = 1.3 self.setLawTexture() elif self.randomNumber == 3: self.head = self.headList.find('**/headhunter') self.cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1) self.scale = 1.2 self.setBossTexture() elif self.randomNumber == 4: self.head = self.headList.find('**/legaleagle') self.cog.find('**/hands').setColor(0.3, 0.3, 0.55, 1) self.scale = 1.3 self.setLawTexture() elif self.randomNumber == 5: self.head = self.headList.find('**/numbercruncher') self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1 self.setCashTexture() elif self.randomNumber == 6: #name dropper self.head = self.headList.find('**/numbercruncher') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/name-dropper.jpg'), 1) self.cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1) self.scale = 0.9 self.setSellTexture() elif self.randomNumber == 7: self.head = self.headList.find('**/pennypincher') self.cog.find('**/hands').setColor(0.98, 0.55, 0.56, 1) self.scale = 0.8 self.setCashTexture() elif self.randomNumber == 8: self.head = self.headList.find('**/yesman') self.cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1) self.scale = 0.9 self.setBossTexture() elif self.randomNumber == 9: #robber baron self.head = self.headList.find('**/yesman') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/robber-baron.jpg'), 1) self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1.3 self.setCashTexture() elif self.randomNumber == 10: #mr. hollywood self.head = self.headList.find('**/yesman') self.cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1) self.scale = 1.3 self.setSellTexture() elif self.randomNumber == 11: self.head = self.headList.find('**/twoface') self.cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1) self.scale = 1 self.setSellTexture() elif self.randomNumber == 12: #mingler self.head = self.headList.find('**/twoface') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/mingler.jpg'), 1) self.cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1) self.scale = 1.1 self.setSellTexture() else: #double talker self.head = self.headList.find('**/twoface') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/double-talker.jpg'), 1) self.cog.find('**/hands').setColor(0.75, 0.75, 0.95, 1) self.scale = 0.9 self.setLawTexture() elif self.randomNumber <= 22: #Render the suit B type cogs self.cog = Actor( self.pandaDirectory + '/resources/cogs/models/tt_a_ene_cgb_zero.bam', { 'neutral': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_neutral.bam'), 'walk': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_walk.bam'), 'finger wag': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_finger-wag.bam'), 'landing': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_landing.bam'), 'hit': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgb_pie-small.bam') }) self.headList = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/suitB-heads.bam') if self.randomNumber == 14: self.head = self.headList.find('**/ambulancechaser') self.cog.find('**/hands').setColor(0.75, 0.75, 0.95, 1) self.scale = 1 self.setLawTexture() elif self.randomNumber == 15: self.head = self.headList.find('**/beancounter') self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 0.9 self.setCashTexture() elif self.randomNumber == 16: #downsizer self.head = self.headList.find('**/beancounter') self.cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1) self.scale = 0.9 self.setBossTexture() elif self.randomNumber == 17: self.head = self.headList.find('**/loanshark') self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1.3 self.setCashTexture() elif self.randomNumber == 18: self.head = self.headList.find('**/movershaker') self.cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1) self.scale = 1 self.setSellTexture() elif self.randomNumber == 19: #bloodsucker self.head = self.headList.find('**/movershaker') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/blood-sucker.jpg'), 1) self.scale = 0.8 self.setLawTexture() elif self.randomNumber == 20: self.head = self.headList.find('**/pencilpusher') self.cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1) self.scale = 0.8 self.setBossTexture() elif self.randomNumber == 21: self.head = self.headList.find('**/telemarketer') self.cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1) self.scale = 0.8 self.setSellTexture() else: #spin doctor self.head = self.headList.find('**/telemarketer') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/spin-doctor.jpg'), 1) self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1.1 self.setLawTexture() elif self.randomNumber <= 31: #Render the suit C type cogs self.cog = Actor( self.pandaDirectory + '/resources/cogs/models/tt_a_ene_cgc_zero.bam', { 'neutral': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_neutral.bam'), 'walk': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_walk.bam'), 'finger wag': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_finger-wag.bam'), 'landing': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_landing.bam'), 'hit': (self.pandaDirectory + '/resources/cogs/animations/tt_a_ene_cgc_pie-small.bam') }) self.headList = loader.loadModel( self.pandaDirectory + '/resources/cogs/models/suitC-heads.bam') if self.randomNumber == 23: #actually a short change self.head = self.headList.find('**/coldcaller') self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1.1 self.setCashTexture() elif self.randomNumber == 24: #cold caller needs to be recolored self.head = self.headList.find('**/coldcaller') self.head.setColor(0, 0, 255, 1) self.cog.find('**/hands').setColor(0.09, 0.48, 0.95, 1) self.scale = 1.1 self.setSellTexture() elif self.randomNumber == 25: self.head = self.headList.find('**/flunky') self.glasses = self.headList.find('**/glasses') self.glasses.reparentTo(self.head) self.cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1) self.scale = 1.1 self.setBossTexture() elif self.randomNumber == 26: #corporate raider self.head = self.headList.find('**/flunky') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/corporate-raider.jpg'), 1) self.cog.find('**/hands').setColor(0.98, 0.55, 0.56, 1) self.scale = 1.7 self.setBossTexture() elif self.randomNumber == 27: self.head = self.headList.find('**/gladhander') self.cog.find('**/hands').setColor(0.95, 0.75, 0.95, 1) self.scale = 1.2 self.setSellTexture() elif self.randomNumber == 28: self.head = self.headList.find('**/micromanager') self.cog.find('**/hands').setColor(0.95, 0.75, 0.75, 1) self.scale = 0.7 self.setBossTexture() elif self.randomNumber == 29: self.head = self.headList.find('**/moneybags') self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1.5 self.setCashTexture() elif self.randomNumber == 30: self.head = self.headList.find('**/tightwad') self.cog.find('**/hands').setColor(0.65, 0.95, 0.85, 1) self.scale = 1.3 self.setCashTexture() else: #bottom feeder self.head = self.headList.find('**/tightwad') self.head.setTexture(loader.loadTexture(self.pandaDirectory + \ '/resources/cogs/textures/bottom-feeder.jpg'), 1) self.cog.find('**/hands').setColor(0.75, 0.75, 0.95, 1) self.scale = 1.1 self.setLawTexture() else: raise Exception( 'UH OH! randomNumber is not between 0 and 31! The value of randomNumber is {}' .format(self.randomNumber)) def setSellTexture(self): #Set the suit texture to the Sellbot texture self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/s_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/s_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/s_leg.jpg'), 1) def setCashTexture(self): #Set the suit texture to the Cashbot texture self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/m_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/m_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/m_leg.jpg'), 1) def setLawTexture(self): #Set the suit texture to the Lawbot texture self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/l_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/l_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/l_leg.jpg'), 1) def setBossTexture(self): #Set the suit texture to the Bossbot texture self.cog.findAllMatches('**/torso').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/c_blazer.jpg'), 1) self.cog.findAllMatches('**/arms').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/c_sleeve.jpg'), 1) self.cog.findAllMatches('**/legs').setTexture( loader.loadTexture(self.pandaDirectory + '/resources/cogs/textures/c_leg.jpg'), 1)
class GameTest(ShowBase): def __init__(self): ShowBase.__init__(self) base.disableMouse() self.makeAcog = loader.loadModel( "phase_5/models/cogdominium/tt_m_ara_cbr_barrelRoom.bam") self.makeAcog.reparentTo(render) self.stomper1 = (self.makeAcog.find('**/stomper_GRP_01')) self.stomper2 = (self.makeAcog.find('**/stomper_GRP_02')) self.stomper3 = (self.makeAcog.find('**/stomper_GRP_03')) self.stomper4 = (self.makeAcog.find('**/stomper_GRP_04')) self.stomper5 = (self.makeAcog.find('**/stomper_GRP_05')) self.stomper6 = (self.makeAcog.find('**/stomper_GRP_06')) self.stomper7 = (self.makeAcog.find('**/stomper_GRP_07')) self.stomper8 = (self.makeAcog.find('**/stomper_GRP_08')) self.stomper9 = (self.makeAcog.find('**/stomper_GRP_09')) self.stomper10 = (self.makeAcog.find('**/stomper_GRP_10')) self.stomper11 = (self.makeAcog.find('**/stomper_GRP_11')) self.stomper12 = (self.makeAcog.find('**/stomper_GRP_12')) self.stomper3.setPos(0, 0, 18.00) self.stomper5.setPos(0, 0, 10.00) self.stomper4.setPos(0, 0, 22.00) self.stomper2.setPos(0, 0, 7.00) self.stomper7.setPos(0, 0, 0) self.stomper8.setPos(0, 0, 5.00) self.stomper9.setPos(0, 0, 13.00) self.stomper10.setPos(0, 0, 10.00) self.stomper11.setPos(0, 0, 22.00) self.stomper12.setPos(0, 0, 7.00) self.lStomper = loader.loadModel( 'phase_9/models/cogHQ/square_stomper.bam') self.lStomper.setHpr(-90, 0, 180) self.lStomper.reparentTo(render) self.lStomper.setScale(3) self.lStomper.setPos(-12.5, 0, 3) self.rStomper = loader.loadModel( 'phase_9/models/cogHQ/square_stomper.bam') self.rStomper.setHpr(90, 0, 0) self.rStomper.reparentTo(render) self.rStomper.setScale(3) self.rStomper.setPos(12.5, 0, 3) self.lStomper.find('**/shaft').setScale(1, 3, 1) self.rStomper.find('**/shaft').setScale(1, 3, 1) self.lStomper.hide() self.rStomper.hide() self.music = loader.loadMusic( "phase_3/audio/bgm/cc_make-a-cog-theme.wav") self.music.play() self.music.setLoop(True) font = self.loader.loadFont( "phase_3/models/fonts/vtRemingtonPortable.ttf") self.elevator = loader.loadModel( "phase_5/models/cogdominium/cogdominiumElevator.bam") self.elevator.reparentTo(self.render) self.elevator.setY(25.37) self.elevator.find('**/floor_light_buttons').removeNode() self.rightDoor = (self.elevator.find('**/right_door')) self.leftDoor = (self.elevator.find('**/left_door')) self.leftDoor.setX(3.50) self.rightDoor.setX(-3.50) self.skelCog = Actor( "phase_5/models/char/cogC_robot-zero.bam", { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.skelCog.reparentTo(self.render) self.skelCog.setPos(-16, 0, -4.76) self.skelCog.loop('neutral') self.skelCog.setH(180) self.explosion = self.loader.loadModel( "phase_3.5/models/props/explosion.bam") self.explosion.reparentTo(self.render) self.explosion.setPos(0, -2, 3) self.explosion.hide() self.flyThru = self.loader.loadModel( "phase_5/models/cogdominium/tt_m_gui_csa_flyThru.bam") self.flyThru.reparentTo(self.render) self.flyThru.setScale(15.42) self.flyThru.setPos(-2.90, -8.61, 7.60) self.flyThru.find('**/blankScreen_locator').removeNode() self.flyThru.find('**/buttonUp_locator').removeNode() self.flyThru.find('**/buttonDown_locator').removeNode() self.flyThru.find('**/buttonHover_locator').removeNode() self.flyThru.hide() self.Lawbot = Actor( 'phase_3.5/models/char/suitC-mod.bam', { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.Lawbot.reparentTo(render) self.Lawbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/l_blazer.jpg') self.Lawbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/l_sleeve.jpg') self.Lawbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/l_leg.jpg') self.Lawbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel( 'phase_3.5/models/char/suitC-heads.bam').find('**/flunky') self.headTexture = loader.loadTexture( "phase_3.5/maps/bottom-feeder.jpg") self.Head.reparentTo(self.Lawbot.find('**/joint_head')) self.Lawbot.findAllMatches('**/joint_head').setTexture( self.headTexture, 1) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Lawbot.find('**/joint_attachMeter')) self.icon.find('**/MoneyIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/SalesIcon').removeNode() self.icon.find('**/CorpIcon').removeNode() self.icon.setH(180) self.icon.setScale(0.70) self.Lawbot.setH(180.00) self.Lawbot.setTransparency(TransparencyAttrib.MAlpha) self.Lawbot.setColor(0.0, 0.0, 1.0, 0.7) self.Lawbot.find('**/hands').setColor(0.0, 0.0, 0.0, 0.0) self.Lawbot.hide() Name = TextNode("nametag") Name.setText("Bottem Feeder\nLawbot\nLevel 1") Name.setFont(font) self.nameTag = render.attachNewNode(Name) self.nameTag.setBillboardAxis() self.nameTag.reparentTo(self.Lawbot.find('**/joint_nameTag')) self.nameTag.setZ(7.51) Name.setAlign(TextNode.ACenter) Name.setCardColor(0.8, 0.8, 0.8, 0.5) Name.setCardAsMargin(0.1, 0, 0, -0.2) Name.setCardDecal(True) Name.setTextColor(0, 0, 0, 1.0) self.nameTag.setScale(0.33) self.Cashbot = Actor( 'phase_3.5/models/char/suitC-mod.bam', { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.Cashbot.reparentTo(render) self.Cashbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/m_blazer.jpg') self.Cashbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/m_sleeve.jpg') self.Cashbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/m_leg.jpg') self.Cashbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel( 'phase_3.5/models/char/suitC-heads.bam').find('**/coldcaller') self.Head.reparentTo(self.Cashbot.find('**/joint_head')) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Cashbot.find('**/joint_attachMeter')) self.icon.find('**/SalesIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/LegalIcon').removeNode() self.icon.find('**/CorpIcon').removeNode() self.icon.setH(180) self.icon.setScale(0.70) self.Cashbot.setH(180.00) self.Cashbot.setTransparency(TransparencyAttrib.MAlpha) self.Cashbot.setColor(0.0, 1.0, 0.0, 0.5) self.Cashbot.find('**/hands').setColor(0.0, 0.0, 0.0, 0.0) self.Cashbot.hide() Name = TextNode("nametag") Name.setText("Short Change\nCashbot\nLevel 1") Name.setFont(font) self.nameTag = render.attachNewNode(Name) self.nameTag.setBillboardAxis() self.nameTag.reparentTo(self.Cashbot.find('**/joint_nameTag')) self.nameTag.setZ(7.51) Name.setAlign(TextNode.ACenter) Name.setCardColor(0.8, 0.8, 0.8, 0.5) Name.setCardAsMargin(0.1, 0, 0, -0.2) Name.setCardDecal(True) Name.setTextColor(0, 0, 0, 1.0) self.nameTag.setScale(0.33) self.Cashbot.hide() self.Sellbot = Actor( 'phase_3.5/models/char/suitC-mod.bam', { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.Sellbot.reparentTo(render) self.Sellbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/s_blazer.jpg') self.Sellbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/s_sleeve.jpg') self.Sellbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/s_leg.jpg') self.Sellbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel( 'phase_3.5/models/char/suitC-heads.bam').find('**/coldcaller') self.Head.reparentTo(self.Sellbot.find('**/joint_head')) self.Head.reparentTo(self.Sellbot.find('**/joint_head')) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Sellbot.find('**/joint_attachMeter')) self.icon.find('**/MoneyIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/LegalIcon').removeNode() self.icon.find('**/CorpIcon').removeNode() self.Head.setColor(0, 0, 1, 0.4) self.icon.setH(180) self.icon.setScale(0.70) self.Sellbot.setH(180.00) self.Sellbot.setTransparency(TransparencyAttrib.MAlpha) self.Sellbot.setColor(0.352, 0.227, 0.419, 0.7) self.Sellbot.find('**/hands').setColor(0.0, 0.0, 0.0, 0.0) Name = TextNode("nametag") Name.setText("Cold Caller\nSellbot\nLevel 1") Name.setFont(font) self.nameTag = render.attachNewNode(Name) self.nameTag.setBillboardAxis() self.nameTag.reparentTo(self.Sellbot.find('**/joint_nameTag')) self.nameTag.setZ(7.51) Name.setAlign(TextNode.ACenter) Name.setCardColor(0.8, 0.8, 0.8, 0.5) Name.setCardAsMargin(0.1, 0, 0, -0.2) Name.setCardDecal(True) Name.setTextColor(0, 0, 0, 1.0) self.nameTag.setScale(0.33) self.Sellbot.hide() self.Sellbot.setBlend(frameBlend=True) self.Bossbot = Actor( 'phase_3.5/models/char/suitC-mod.bam', { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.Bossbot.reparentTo(render) self.Bossbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/c_blazer.jpg') self.Bossbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/c_sleeve.jpg') self.Bossbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/c_leg.jpg') self.Bossbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam') self.Head.find('**/coldcaller').hide() self.Head.find('**/gladhander').hide() self.Head.find('**/micromanager').hide() self.Head.find('**/moneybags').hide() self.Head.find('**/tightwad').hide() self.Head.reparentTo(self.Bossbot.find('**/joint_head')) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Bossbot.find('**/joint_attachMeter')) self.icon.find('**/MoneyIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/LegalIcon').removeNode() self.icon.find('**/SalesIcon').removeNode() self.icon.setH(180) self.icon.setScale(0.70) self.Bossbot.setH(180.00) self.Bossbot.setTransparency(TransparencyAttrib.MAlpha) self.Bossbot.setColor(0.466, 0.0, 1.0, 0.7) self.Bossbot.find('**/hands').setColor(0.0, 0.0, 0.0, 0.0) Name = TextNode("nametag") Name.setText("Flunky\nBossbot\nLevel 1") Name.setFont(font) self.nameTag = render.attachNewNode(Name) self.nameTag.setBillboardAxis() self.nameTag.reparentTo(self.Bossbot.find('**/joint_nameTag')) self.nameTag.setZ(7.51) Name.setAlign(TextNode.ACenter) Name.setCardColor(0.8, 0.8, 0.8, 0.5) Name.setCardAsMargin(0.1, 0, 0, -0.2) Name.setCardDecal(True) Name.setTextColor(0, 0, 0, 1.0) self.nameTag.setScale(0.33) self.Bossbot.hide() self.Sourcebot = Actor( 'phase_3.5/models/char/suitC-mod.bam', { 'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam' }) self.Sourcebot.reparentTo(render) self.Sourcebot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg') self.Sourcebot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg') self.Sourcebot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg') self.Sourcebot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel( 'phase_3.5/models/char/suitC-heads.bam').find('**/tightwad') self.headTexture = loader.loadTexture( "phase_3.5/maps/payroll-converter.jpg") self.Head.reparentTo(self.Sourcebot.find('**/joint_head')) self.Sourcebot.findAllMatches('**/joint_head').setTexture( self.headTexture, 1) self.icon = loader.loadModel('phase_3/models/gui/SourcebotIcon.bam') self.icon.reparentTo(render) self.iconTexture = loader.loadTexture('phase_3/maps/SourcebotIcon.png') self.icon.setTexture(self.iconTexture, 1) self.icon.setHpr(180, 0, 0) self.icon.setPos(0.1, 0, -0.30) self.icon.setScale(1.00) self.icon.reparentTo(self.Sourcebot.find('**/joint_attachMeter')) self.Sourcebot.setTransparency(TransparencyAttrib.MAlpha) self.Sourcebot.setColor(0.9, 0.6, 0.8, 0.7) self.Sourcebot.find('**/hands').setColor(0.0, 0.0, 0.0, 0.0) Name = TextNode("nametag") Name.setText("Payroll Converter\nSourcebot\nLevel 1") Name.setFont(font) self.nameTag = render.attachNewNode(Name) self.nameTag.setBillboardAxis() self.nameTag.reparentTo(self.Sourcebot.find('**/joint_nameTag')) self.nameTag.setZ(7.51) Name.setAlign(TextNode.ACenter) Name.setCardColor(0.8, 0.8, 0.8, 0.5) Name.setCardAsMargin(0.1, 0, 0, -0.2) Name.setCardDecal(True) Name.setTextColor(0, 0, 0, 1.0) self.nameTag.setScale(0.33) self.Sourcebot.setH(180) self.Sourcebot.hide() #------sfx------# self.cameraMoveSfx = self.loader.loadSfx( "phase_9/audio/sfx/CHQ_FACT_elevator_up_down_loop.ogg") self.cameraMoveSfx.setVolume(5.0) self.click = self.loader.loadSfx("phase_3/audio/sfx/cc_click.ogg") self.hover = self.loader.loadSfx( "phase_3/audio/sfx/cc_hover-over-button.ogg") self.poof = self.loader.loadSfx( "phase_4/audio/sfx/firework_distance_02.ogg") self.largeSmash = self.loader.loadSfx( "phase_9/audio/sfx/CHQ_FACT_stomper_large.ogg") self.largeSmashExec = SoundInterval(self.largeSmash, duration=5.5) self.conveyorBeltSfx = self.loader.loadSfx( "phase_12/audio/sfx/CHQ_FACT_conveyor_belt.ogg") self.cogDialSHORT = self.loader.loadSfx( "phase_3.5/audio/dial/COG_VO_grunt.ogg") self.cogDialMED = self.loader.loadSfx( "phase_3.5/audio/dial/COG_VO_statement.ogg") self.cogDialLONG = self.loader.loadSfx( "phase_3.5/audio/dial/COG_VO_murmur.ogg") self.cogDialQUESTION = self.loader.loadSfx( "phase_3.5/audio/dial/COG_VO_question.ogg") #-----Sequences------# Walk1 = self.stomper1.posInterval(9.50, Point3(0, 0, 18.00)) Walk2 = self.stomper1.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound1 = Sequence(Walk1, Walk2) self.stomperPound1.loop() Walk1 = self.stomper6.posInterval(9.50, Point3(0, 0, 18.00)) Walk2 = self.stomper6.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound2 = Sequence(Walk1, Walk2) self.stomperPound2.loop() Walk1 = self.stomper3.posInterval(9.50, Point3(0, 0, 0)) Walk2 = self.stomper3.posInterval(9.50, Point3(0, 0, 18.00)) self.stomperPound3 = Sequence(Walk1, Walk2) self.stomperPound3.loop() Walk1 = self.stomper5.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper5.posInterval(5.50, Point3(0, 0, 10.00)) self.stomperPound4 = Sequence(Walk1, Walk2) self.stomperPound4.loop() Walk1 = self.stomper4.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper4.posInterval(5.50, Point3(0, 0, 22.00)) self.stomperPound5 = Sequence(Walk1, Walk2) self.stomperPound5.loop() Walk1 = self.stomper2.posInterval(3.50, Point3(0, 0, 0)) Walk2 = self.stomper2.posInterval(3.50, Point3(0, 0, 7.00)) self.stomperPound6 = Sequence(Walk1, Walk2) self.stomperPound6.loop() Walk1 = self.stomper7.posInterval(9.50, Point3(0, 0, 18.00)) Walk2 = self.stomper7.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound7 = Sequence(Walk1, Walk2) self.stomperPound7.loop() Walk1 = self.stomper8.posInterval(5.50, Point3(0, 0, 5.00)) Walk2 = self.stomper8.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound8 = Sequence(Walk1, Walk2) self.stomperPound8.loop() Walk1 = self.stomper9.posInterval(6.50, Point3(0, 0, 0)) Walk2 = self.stomper9.posInterval(6.50, Point3(0, 0, 13.00)) self.stomperPound9 = Sequence(Walk1, Walk2) self.stomperPound9.loop() Walk1 = self.stomper10.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper10.posInterval(5.50, Point3(0, 0, 10.00)) self.stomperPound10 = Sequence(Walk1, Walk2) self.stomperPound10.loop() Walk1 = self.stomper11.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper11.posInterval(5.50, Point3(0, 0, 22.00)) self.stomperPound11 = Sequence(Walk1, Walk2) self.stomperPound11.loop() Walk1 = self.stomper12.posInterval(3.50, Point3(0, 0, 0)) Walk2 = self.stomper12.posInterval(3.50, Point3(0, 0, 7.00)) self.stomperPound12 = Sequence(Walk1, Walk2) self.stomperPound12.loop() Walk1 = self.camera.posInterval(1.50, Point3(0, -77.48, 3.42)) Spin1 = self.camera.hprInterval(1.00, Vec3(0, 0, 0)) Walk2 = self.camera.posInterval(2.50, Point3(0, -77.48, 3.42)) Walk3 = self.camera.posInterval(3.00, Point3(0, -22.48, 3.42)) self.cameraStart = Sequence(Walk1, Spin1, Walk2, Walk3) Walk1 = self.camera.posInterval(3.00, Point3(0, -22.48, 3.42)) Spin1 = self.camera.hprInterval(0.00, Vec3(0, 0, 0)) self.cameraStartAgain = Sequence(Walk1, Spin1) skelMove1 = self.skelCog.posInterval(0.50, Point3(-16, -0, 0)) skelMove2 = self.skelCog.posInterval(2.00, Point3(0, -0, 0)) self.skelMove = Sequence(skelMove1, skelMove2) Walk1 = self.camera.posInterval(15.50, Point3(6.31, -45.31, 9.27)) Spin1 = self.camera.hprInterval(0.00, Vec3(337.52, 0, 0)) Walk2 = self.camera.posInterval(0.00, Point3(6.08, -100.53, 9.27)) Walk3 = self.camera.posInterval(12.00, Point3(14.07, -77.33, 9.27)) Walk4 = self.camera.posInterval(0.00, Point3(18.93, -82.36, 25.51)) Spin2 = self.camera.hprInterval(0.00, Vec3(30.26, 347.91, 0)) Walk5 = self.camera.posInterval(15.00, Point3(0.44, -51.38, 21.411)) Spin3 = self.camera.hprInterval(0.00, Vec3(337.52, 0, 0)) self.cameraIntro = Sequence(Walk1, Spin1, Walk2, Walk3, Walk4, Spin2, Walk5, Spin3) self.cameraIntro.loop() rotate1 = self.camera.hprInterval(3.00, Vec3(-25, 0, 0)) self.cameraRotate = Sequence(rotate1) fly = self.flyThru.hprInterval(1.00, Vec3(180, 0, 0)) self.flyThruDONE = Sequence(fly) move1 = self.Sellbot.hprInterval(1.50, Vec3(196.26, 0, 0)) move2 = self.Sellbot.posInterval(2.00, Point3(12.43, -5.09, 0)) move3 = self.Sellbot.hprInterval(2.00, Vec3(140.91, 0, 0)) self.SellbotMove = Sequence(move1, move2, move3) move1 = self.Lawbot.hprInterval(1.50, Vec3(196.26, 0, 0)) move2 = self.Lawbot.posInterval(2.00, Point3(12.43, -5.09, 0)) move3 = self.Lawbot.hprInterval(2.00, Vec3(140.91, 0, 0)) self.LawbotMove = Sequence(move1, move2, move3) move1 = self.Cashbot.hprInterval(1.50, Vec3(196.26, 0, 0)) move2 = self.Cashbot.posInterval(2.00, Point3(12.43, -5.09, 0)) move3 = self.Cashbot.hprInterval(2.00, Vec3(140.91, 0, 0)) self.CashbotMove = Sequence(move1, move2, move3) move1 = self.Bossbot.hprInterval(1.50, Vec3(196.26, 0, 0)) move2 = self.Bossbot.posInterval(2.00, Point3(12.43, -5.09, 0)) move3 = self.Bossbot.hprInterval(2.00, Vec3(140.91, 0, 0)) self.BossbotMove = Sequence(move1, move2, move3) move1 = self.Sourcebot.hprInterval(1.50, Vec3(196.26, 0, 0)) move2 = self.Sourcebot.posInterval(2.00, Point3(12.43, -5.09, 0)) move3 = self.Sourcebot.hprInterval(2.00, Vec3(140.91, 0, 0)) self.SourcebotMove = Sequence(move1, move2, move3) rotate1 = self.camera.hprInterval(1.00, Vec3(-21, 0, 0)) move1 = self.camera.posInterval(1.00, Vec3(-2.24, -22.97, 5.02)) self.toPro = Sequence(rotate1, move1) move1 = self.leftDoor.posInterval(1.50, Point3(0, 0, 0)) self.elevatorOpenLeft = Sequence(move1) move1 = self.rightDoor.posInterval(1.50, Point3(0, 0, 0)) self.elevatorOpenRight = Sequence(move1) lSmashB = self.lStomper.posInterval(0.125, Point3(0.01, 0, 3)) lSmashE = self.lStomper.posInterval(1, Point3(-15, 0, 3)) rSmashB = self.rStomper.posInterval(0.125, Point3(-0.01, 0, 3)) rSmashE = self.rStomper.posInterval(1, Point3(15, 0, 3)) lemmeSmashL = Sequence(lSmashB, Wait(1.25), lSmashE) lemmeSmashR = Sequence(rSmashB, Wait(1.25), rSmashE) self.lemmeSmash = \ Parallel( lemmeSmashL, self.largeSmashExec, lemmeSmashR, name="Lemme Smash" ) #----camera---# self.camera.setPos(6.31, -82.36, 9.27) self.camera.setHpr(35.71, 0, 0) #-----buttons-------# ButtonImage = self.loader.loadModel( "phase_3/models/gui/cc_icon_gui_check_x.bam") self.finish = DirectButton(frameSize=None, image=(ButtonImage.find('**/check_up'), ButtonImage.find('**/check_down'), ButtonImage.find('**/check_up')), relief=None, clickSound=self.click, command=self.moveCameraToNameTag, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.5, 0, -0.8), borderWidth=(0.13, 0.01), scale=.3) self.finish.hide() ButtonImage = self.loader.loadModel( "phase_3/models/gui/cc_icon_gui_check_x.bam") self.finish2 = DirectButton(frameSize=None, image=(ButtonImage.find('**/check_up'), ButtonImage.find('**/check_down'), ButtonImage.find('**/check_up')), relief=None, clickSound=self.click, command=self.intoPro, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.5, 0, -0.8), borderWidth=(0.13, 0.01), scale=.3) self.finish2.hide() ButtonImage = self.loader.loadModel( "phase_3/models/gui/cc_icon_gui_check_x.bam") self.exit = DirectButton(frameSize=None, image=(ButtonImage.find('**/close_up'), ButtonImage.find('**/close_down'), ButtonImage.find('**/close_up')), relief=None, command=self.goBack, clickSound=self.click, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(-1.5, 0, -0.8), borderWidth=(0.13, 0.01), scale=.3) self.exit.hide() self.folder = OnscreenImage(image='phase_3.5/maps/cc_metal-plate.png', pos=(1.50, 0, 0.4), scale=(0.6)) self.folder.setTransparency(TransparencyAttrib.MAlpha) self.folder.hide() ButtonImage = loader.loadModel( "phase_3/models/gui/cc_icon_gui_buttons_departments.bam") self.systems = DirectButton( frameSize=None, image=(ButtonImage.find('**/button_up'), ButtonImage.find('**/button_down'), ButtonImage.find('**/button_hover')), relief=None, command=self.systemGUIpopup, clickSound=self.click, rolloverSound=self.hover, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.3, 0, 0.8), borderWidth=(0.13, 0.01), scale=0.5) self.systems.hide() ButtonImage = loader.loadModel( "phase_3/models/gui/cc_icon_gui_buttons_arrow_skip.bam") self.SellbotButton = DirectButton( frameSize=None, image=(ButtonImage.find('**/click_up'), ButtonImage.find('**/click_down'), ButtonImage.find('**/click_hover')), relief=None, command=self.spawnSellbot, clickSound=self.click, rolloverSound=self.hover, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.5, 0, 0.6), borderWidth=(0.13, 0.01), scale=0.4) self.SellbotButton.hide() ButtonImage = loader.loadModel( "phase_3/models/gui/cc_icon_gui_buttons_arrow_skip.bam") self.LawbotButton = DirectButton( frameSize=None, image=(ButtonImage.find('**/click_up'), ButtonImage.find('**/click_down'), ButtonImage.find('**/click_hover')), relief=None, command=self.spawnLawbot, clickSound=self.click, rolloverSound=self.hover, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.5, 0, 0.5), borderWidth=(0.13, 0.01), scale=0.4) self.LawbotButton.hide() ButtonImage = loader.loadModel( "phase_3/models/gui/cc_icon_gui_buttons_arrow_skip.bam") self.CashbotButton = DirectButton( frameSize=None, image=(ButtonImage.find('**/click_up'), ButtonImage.find('**/click_down'), ButtonImage.find('**/click_hover')), relief=None, command=self.spawnCashbot, clickSound=self.click, rolloverSound=self.hover, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.5, 0, 0.4), borderWidth=(0.13, 0.01), scale=0.4) self.CashbotButton.hide() ButtonImage = loader.loadModel( "phase_3/models/gui/cc_icon_gui_buttons_arrow_skip.bam") self.BossbotButton = DirectButton( frameSize=None, image=(ButtonImage.find('**/click_up'), ButtonImage.find('**/click_down'), ButtonImage.find('**/click_hover')), relief=None, command=self.spawnBossbot, clickSound=self.click, rolloverSound=self.hover, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.5, 0, 0.3), borderWidth=(0.13, 0.01), scale=0.4) self.BossbotButton.hide() ButtonImage = loader.loadModel( "phase_3/models/gui/cc_icon_gui_buttons_arrow_skip.bam") self.SourcebotButton = DirectButton( frameSize=None, image=(ButtonImage.find('**/click_up'), ButtonImage.find('**/click_down'), ButtonImage.find('**/click_hover')), relief=None, command=self.spawnSourcebot, clickSound=self.click, rolloverSound=self.hover, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(1.5, 0, 0.2), borderWidth=(0.13, 0.01), scale=0.4) self.SourcebotButton.hide() ButtonImage = loader.loadModel( "phase_5/models/cogdominium/tt_m_gui_csa_flyThru.bam") self.flyThruButton = DirectButton( frameSize=None, image=(ButtonImage.find('**/buttonUp'), ButtonImage.find('**/buttonDown'), ButtonImage.find('**/buttonHover')), relief=None, command=self.setText, geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(-0.2, 0, 0.75), clickSound=self.click, rolloverSound=self.hover, borderWidth=(0.13, 0.01), scale=4) self.flyThruButton.hide() #-----texts-------# self.logoLeft = OnscreenImage( image='phase_3/maps/cogcitycodeaffix-logo-hor-left[OLD].png', pos=(-0.46, 0, 0.2), scale=(0.7)) self.logoLeft.setTransparency(TransparencyAttrib.MAlpha) self.logoRight = OnscreenImage( image='phase_3/maps/cogcitycodeaffix-logo-hor-right[OLD].png', pos=(0.56, 0, 0.18), scale=(0.7)) self.logoRight.setTransparency(TransparencyAttrib.MAlpha) self.nameType = OnscreenImage( image='phase_3.5/maps/cc_type-a-name.png', pos=(-0.49, 0, 0.1), scale=0.8) self.nameType.setTransparency(TransparencyAttrib.MAlpha) self.nameType.hide() b = DirectEntry(text="", scale=.08, pos=(-0.9, 0, 0.08), numLines=2, focus=3) b.hide() text = TextNode("play") text.setText("Press ENTER to play") text.setFont(font) self.textNodePath = aspect2d.attachNewNode(text) self.textNodePath.setScale(0.09) self.textNodePath.setPos(-0.5, 0, -0.7) self.text2 = TextNode("play") self.text2.setText( "Hello, I am The Big Cheese, one of your superiors...") self.text2.setFont(font) self.text2.setWordwrap(25) self.textNodePath2 = aspect2d.attachNewNode(self.text2) self.textNodePath2.setScale(0.05) self.textNodePath2.setPos(-1.2, 0, 0.6) self.textNodePath2.setColor(0, 0, 0) self.textNodePath2.hide() #-----collisions-----# self.collblock = self.loader.loadModel( "phase_4/models/modules/collisionBlock.bam") self.collblock = self.collblock.attachNewNode( CollisionNode('block_collision')) self.collblock.node().addSolid(CollisionSphere(0, 0, 0, 0.3)) self.collblock.node().setIntoCollideMask(BitMask32.allOff()) #-------times-----# self.t = Sequence(Func(self.finish.hide), Wait(9), Func(self.flyThru.show), Func(self.flyThruButton.show), Func(self.textNodePath2.show), Func(self.cogDialMED.play)) self.t2 = Sequence(Func(self.explosion.show), Wait(0.30), Func(self.explosion.hide)) self.t3 = Sequence(Func(self.cameraMoveSfx.play), Wait(2.60), Func(self.cameraMoveSfx.stop), Wait(2.50), Func(self.cameraMoveSfx.play), Wait(2.78), Func(self.cameraMoveSfx.stop), Wait(0.20)) self.t4 = Sequence(Func(self.flyThruButton.hide), Wait(2.00), Func(self.flyThruButton.show)) self.t5 = Sequence(Func(self.conveyorBeltSfx.play), Wait(2.50), Func(self.conveyorBeltSfx.stop)) self.t6 = Sequence(Func(self.flyThruDONE.start), Wait(2.50), Func(self.flyThru.hide)) self.t7 = Sequence(Func(self.moveINT), Func(self.cameraMoveSfx.play), Wait(5.50), Func(self.moveINTSTOP), Func(self.cameraMoveSfx.stop), Func(b.show), Func(self.finish2.show)) self.t8 = Sequence(Func(self.cameraMoveSfx.play), Wait(2.00), Func(self.cameraMoveSfx.stop), Wait(0.70), Func(self.elevatorOpenLeft.start), Func(self.elevatorOpenRight.start)) #----------key/click-events-------# self.acceptOnce("enter-up", self.play) self.accept("alt-o", self.oobe) #------func-------# def setText(self): self.text2.setText( "As the co-leader of COGS, Inc., i would like to introduce you to..." ) self.cogDialLONG.play() self.flyThruButton["command"] = self.setText2 def setText2(self): self.text2.setText("Cogcity: CodeAffix!") self.cogDialSHORT.play() self.cogDialLONG.stop() self.flyThruButton["command"] = self.setText3 def setText3(self): self.text2.setText( "Before we get started, you need to create a cog first!") self.cogDialMED.play() self.cogDialSHORT.stop() self.flyThruButton["command"] = self.setText4 def setText4(self): self.text2.setText( "Here, i will send out a skelecog so that you can start making your new cog!" ) self.cogDialLONG.play() self.cogDialMED.stop() self.t4.start() self.skelMove.start() self.t5.start() self.flyThruButton["command"] = self.setText5 def setText5(self): self.text2.setText( "Here at Cogcity, we make sure that each of our cogs are fully functional." ) self.cogDialMED.play() self.cogDialLONG.stop() self.flyThruButton["command"] = self.setText6 def setText6(self): self.text2.setText( "We call these special robots: Cogs, because of the file type named: .cog" ) self.cogDialLONG.play() self.flyThruButton["command"] = self.setText7 def setText7(self): self.text2.setText( ".cog is the file type for cogs which is in the departments folder." ) self.cogDialMED.play() self.cogDialLONG.stop() self.flyThruButton["command"] = self.setText8 def setText8(self): self.text2.setText( "Just start by selecting your own .cog type in the departments folder." ) self.cogDialLONG.play() self.cogDialMED.stop() self.flyThruButton["command"] = self.setText9 def setText9(self): self.text2.setText("After that, type or choose your own cog name!") self.cogDialSHORT.play() self.cogDialLONG.stop() self.flyThruButton["command"] = self.setText10 def setText10(self): self.text2.setText( "Simple, right? I will be down in a second for the rest of the steps." ) self.cogDialQUESTION.play() self.cogDialSHORT.stop() self.flyThruButton["command"] = self.setText11 def setText11(self): self.text2.setText( "Also, you might wanna hurry up... Our boss dose not like waiting." ) self.cogDialMED.play() self.cogDialQUESTION.stop() self.flyThruButton["command"] = self.setTextFINAL def setTextFINAL(self): self.GUIpopup() self.textNodePath2.hide() self.flyThruButton.hide() self.t6.start() def play(self): if self.logoRight: self.logoRight.hide() self.logoLeft.hide() self.t3.start() self.t.start() self.textNodePath.hide() self.cameraIntro.pause() self.cameraStart.start() def playAgain(self): if self.logoRight: self.logoRight.hide() self.logoLeft.hide() self.textNodePath.hide() self.systems.show() self.finish.show() self.exit.show() self.cameraIntro.pause() self.cameraStartAgain.start() def GUIpopup(self): self.exit.show() self.systems.show() def goBack(self): self.acceptOnce("enter", self.playAgain) self.logoLeft.show() self.logoRight.show() self.SellbotButton.hide() self.LawbotButton.hide() self.CashbotButton.hide() self.BossbotButton.hide() self.SourcebotButton.hide() self.exit.hide() self.systems.hide() self.finish.hide() self.textNodePath.show() self.cameraIntro.finish() self.cameraIntro.start() self.cameraIntro.loop() def systemGUIpopup(self): if self.systems: self.SellbotButton.show() self.LawbotButton.show() self.CashbotButton.show() self.BossbotButton.show() self.SourcebotButton.show() else: self.SellbotButton.hide() self.LawbotButton.hide() self.CashbotButton.hide() self.BossbotButton.hide() self.SourcebotButton.hide() def spawnSellbot(self): if self.Sellbot: self.poof.play() self.Sellbot.show() self.t2.start() self.Cashbot.hide() self.Lawbot.hide() self.Bossbot.hide() self.Sourcebot.hide() self.finish.show() else: self.Sellbot.hide() def spawnLawbot(self): if self.Lawbot: self.poof.play() self.Sellbot.hide() self.t2.start() self.Cashbot.hide() self.Lawbot.show() self.Bossbot.hide() self.Sourcebot.hide() self.finish.show() else: self.Lawbot.hide() def spawnCashbot(self): if self.Cashbot: self.poof.play() self.Sellbot.hide() self.t2.start() self.Cashbot.show() self.Lawbot.hide() self.Bossbot.hide() self.Sourcebot.hide() self.finish.show() else: self.Cashbot.hide() def spawnBossbot(self): if self.Bossbot: self.poof.play() self.t2.start() self.Sellbot.hide() self.Cashbot.hide() self.Lawbot.hide() self.Bossbot.show() self.Sourcebot.hide() self.finish.show() else: self.Bossbot.hide() def spawnSourcebot(self): if self.Sourcebot: self.t2.start() self.poof.play() self.Sellbot.hide() self.Cashbot.hide() self.Lawbot.hide() self.Bossbot.hide() self.Sourcebot.show() self.finish.show() else: self.Sourcebot.hide() def switchToSolidBody(self, task): self.skelCog.hide() if self.Sellbot: self.Sellbot.setTransparency(TransparencyAttrib.MNone) self.Sellbot.clearColor() self.Sellbot.find('**/hands').setColor(0.55, 0.65, 1.0, 1.0) if self.Lawbot: self.Lawbot.setTransparency(TransparencyAttrib.MNone) self.Lawbot.clearColor() self.Lawbot.find('**/hands').setColor(0.75, 0.75, 0.95, 1.0) if self.Cashbot: self.Cashbot.setTransparency(TransparencyAttrib.MNone) self.Cashbot.clearColor() self.Cashbot.find('**/hands').setColor(1.0, 0.5, 0.6, 1.0) if self.Bossbot: self.Bossbot.setTransparency(TransparencyAttrib.MNone) self.Bossbot.clearColor() self.Bossbot.find('**/hands').setColor(0.95, 0.75, 0.75, 1.0) if self.Sourcebot: self.Sourcebot.setTransparency(TransparencyAttrib.MNone) self.Sourcebot.clearColor() self.Sourcebot.find('**/hands').setColor(0.53, 0.59, 0.66, 1.0) return Task.done def walkToNameTag(self, task): self.cameraMoveSfx.play() self.cameraRotate.start() self.SellbotMove.start() self.LawbotMove.start() self.CashbotMove.start() self.BossbotMove.start() self.SourcebotMove.start() self.lStomper.hide() self.rStomper.hide() self.t7.start() self.Cashbot.loop('walk') self.Sellbot.loop('walk') self.Lawbot.loop('walk') self.Bossbot.loop('walk') self.Sourcebot.loop('walk') return Task.done def moveCameraToNameTag(self): if self.camera: self.SellbotButton.hide() self.LawbotButton.hide() self.CashbotButton.hide() self.BossbotButton.hide() self.SourcebotButton.hide() self.finish.hide() self.exit.hide() self.systems.hide() self.lStomper.show() self.rStomper.show() self.lemmeSmash.start() self.smashDelay = Parallel(self.largeSmashExec) self.smashDelay.start() taskMgr.doMethodLater( .75, self.switchToSolidBody, 'Make Cogs With Hologram Bodies Have Solid Ones') taskMgr.doMethodLater(3.5, self.walkToNameTag, 'Make Cogs Walk To Type-A-Name') def moveINT(self): if self.moveCameraToNameTag: self.Sellbot.play('walk') self.Lawbot.play('walk') self.Cashbot.play('walk') self.Bossbot.play('walk') self.Sourcebot.play('walk') self.Sellbot.loop('walk') self.Lawbot.loop('walk') self.Cashbot.loop('walk') self.Bossbot.loop('walk') self.Sourcebot.loop('walk') def moveINTSTOP(self): if self.moveCameraToNameTag: self.Sellbot.stop('walk') self.Lawbot.stop('walk') self.Cashbot.stop('walk') self.Bossbot.stop('walk') self.Sourcebot.stop('walk') self.Sellbot.play('neutral') self.Lawbot.play('neutral') self.Cashbot.play('neutral') self.Bossbot.play('neutral') self.Sourcebot.play('neutral') self.Sellbot.loop('neutral') self.Lawbot.loop('neutral') self.Cashbot.loop('neutral') self.Bossbot.loop('neutral') self.Sourcebot.loop('neutral') def intoPro(self): if self.makeAcog: self.toPro.start() self.t8.start()
def loadModel(file, collision=None, animation=None): model=None if animation: collision=file+'/collision' anims={} dirList=listdir(file+'/animation') for fname in dirList: anims[fname[:-4]]=file+'/animation/'+fname #print anims model=Actor(file+'/model', anims) #default anim if 'default' in anims: model.loop('default') elif 'idle' in animation: model.loop('idle') else: #some first, random anim model.loop(anims.items()[0]) else: model=loader.loadModel(file) model.setPythonTag('model_file', file) #load shaders for geom in model.findAllMatches('**/+GeomNode'): if geom.hasTag('light'): model.setPythonTag('hasLight', True) if geom.hasTag('particle'): file='particle/'+geom.getTag('particle') if exists(file): with open(file) as f: values=json.load(f) p=createEffect(values) model.setPythonTag('particle', p) p.start(parent=model, renderParent=render) if geom.hasTag('cg_shader'): geom.setShader(loader.loadShader("shaders/"+geom.getTag('cg_shader'))) elif geom.hasTag('glsl_shader'): glsl_shader=geom.getTag('glsl_shader') model.setShader(Shader.load(Shader.SLGLSL, "shaders/{0}_v.glsl".format(glsl_shader),"shaders/{0}_f.glsl".format(glsl_shader))) else: #geom.setShader(loader.loadShader("shaders/default.cg")) model.setShader(Shader.load(Shader.SLGLSL, "shaders/default_v.glsl","shaders/default_f.glsl"), 1) print "default shader!" #collisions model.setCollideMask(BitMask32.allOff()) if collision: coll=loader.loadModel(collision) coll.reparentTo(model) coll.find('**/collision').setCollideMask(BitMask32.bit(2)) coll.find('**/collision').setPythonTag('object', model) if animation: model.setPythonTag('actor_files', [file,anims,coll]) else: try: model.find('**/collision').setCollideMask(BitMask32.bit(2)) model.find('**/collision').setPythonTag('object', model) except: print "WARNING: Model {0} has no collision geometry!\nGenerating collision sphere...".format(file) bounds=model.getBounds() radi=bounds.getRadius() cent=bounds.getCenter() coll_sphere=model.attachNewNode(CollisionNode('collision')) coll_sphere.node().addSolid(CollisionSphere(cent[0],cent[1],cent[2], radi)) coll_sphere.setCollideMask(BitMask32.bit(2)) coll_sphere.setPythonTag('object', model) #coll_sphere.show() if animation: model.setPythonTag('actor_files', [file,animation,None]) if ConfigVariableBool('framebuffer-srgb',False).getValue(): fixSrgbTextures(model) return model
from direct.actor.Actor import Actor from panda3d.core import DirectionalLight, KeyboardButton s = ShowBase() s.accept('escape', sys.exit) s.cam.setPos(0, -5, 5) s.cam.lookAt(0, 0, 0) a = Actor('assets/cars/Ricardeaut_Magnesium.bam') a.reparentTo(s.render) puppet = s.loader.loadModel('assets/cars/Ricardeaut_Magnesium.bam') puppet.find("armature").hide() puppet.reparentTo(a) repulsors = a.findAllMatches('**/fz_repulsor*') print(repulsors) for r, repulsor in enumerate(repulsors): repulsor.setPos(0, 0, 0) repulsor.setP(-90) joint = a.exposeJoint(None, "modelRoot", "repulsor_bone:" + str(r)) repulsor.reparentTo(joint) #a.enableBlend() animations = ["gems", "accelerate", "turn", "strafe", "hover"] for animation in animations: a.setControlEffect(animation, 1) a.play(animation) def pingPong(animation, d, min=0, mid=10, max=20):
class SnapshotRenderer: def __init__(self, dnaString): self.dnaString = dnaString loadModels() compileGlobalAnimList() self.makeFromNetString(dnaString) self.toon = Actor() self.generateToon() self.renderSnapshot() def makeFromNetString(self, string): dg = PyDatagram(string) dgi = PyDatagramIterator(dg) self.type = dgi.getFixedString(1) if self.type == 't': headIndex = dgi.getUint8() torsoIndex = dgi.getUint8() legsIndex = dgi.getUint8() self.head = toonHeadTypes[headIndex] self.torso = toonTorsoTypes[torsoIndex] self.legs = toonLegTypes[legsIndex] gender = dgi.getUint8() if gender == 1: self.gender = 'm' else: self.gender = 'f' self.topTex = dgi.getUint8() self.topTexColor = dgi.getUint8() self.sleeveTex = dgi.getUint8() self.sleeveTexColor = dgi.getUint8() self.botTex = dgi.getUint8() self.botTexColor = dgi.getUint8() self.armColor = dgi.getUint8() self.gloveColor = dgi.getUint8() self.legColor = dgi.getUint8() self.headColor = dgi.getUint8() else: notify.error('unknown avatar type: ', self.type) def getAnimal(self): if self.head[0] == 'd': return 'dog' elif self.head[0] == 'c': return 'cat' elif self.head[0] == 'm': return 'mouse' elif self.head[0] == 'h': return 'horse' elif self.head[0] == 'r': return 'rabbit' elif self.head[0] == 'f': return 'duck' elif self.head[0] == 'p': return 'monkey' elif self.head[0] == 'b': return 'bear' elif self.head[0] == 's': return 'pig' else: notify.error('unknown headStyle: ', self.head[0]) def getArmColor(self): try: return allColorsList[self.armColor] except: return allColorsList[0] def getLegColor(self): try: return allColorsList[self.legColor] except: return allColorsList[0] def getHeadColor(self): try: return allColorsList[self.headColor] except: return allColorsList[0] def getGloveColor(self): try: return allColorsList[self.gloveColor] except: return allColorsList[0] def getGender(self): return self.gender def generateToon(self): self.setLODs() self.generateToonLegs() self.generateToonHead(1, ('1000', '500', '250')) self.generateToonTorso() self.generateToonColor() self.parentToonParts() # self.rescaleToon() # self.resetHeight() # self.setupToonNodes() self.toon.reparentTo(render) self.toon.setPos(0, 5, -3) self.toon.setH(180) self.toon.getPart('head', '1000').setR(10) self.toon.pose('neutral', 0) def generateToonLegs(self, copy=1): global Preloaded legStyle = self.legs filePrefix = LegDict.get(legStyle) if filePrefix is None: print('unknown leg style: %s' % legStyle) self.toon.loadModel(Preloaded[filePrefix + '-1000'], 'legs', '1000', True) self.toon.loadModel(Preloaded[filePrefix + '-500'], 'legs', '500', True) self.toon.loadModel(Preloaded[filePrefix + '-250'], 'legs', '250', True) if not copy: self.toon.showPart('legs', '1000') self.toon.showPart('legs', '500') self.toon.showPart('legs', '250') self.toon.loadAnims(LegsAnimDict[legStyle], 'legs', '1000') self.toon.loadAnims(LegsAnimDict[legStyle], 'legs', '500') self.toon.loadAnims(LegsAnimDict[legStyle], 'legs', '250') self.toon.findAllMatches('**/boots_short').stash() self.toon.findAllMatches('**/boots_long').stash() self.toon.findAllMatches('**/shoes').stash() return def generateToonTorso(self, copy=1, genClothes=1): global Preloaded torsoStyle = self.torso filePrefix = TorsoDict.get(torsoStyle) if filePrefix is None: self.notify.error('unknown torso style: %s' % torsoStyle) self.toon.loadModel(Preloaded[filePrefix + '-1000'], 'torso', '1000', True) if len(torsoStyle) == 1: self.toon.loadModel(Preloaded[filePrefix + '-1000'], 'torso', '500', True) self.toon.loadModel(Preloaded[filePrefix + '-1000'], 'torso', '250', True) else: self.toon.loadModel(Preloaded[filePrefix + '-500'], 'torso', '500', True) self.toon.loadModel(Preloaded[filePrefix + '-250'], 'torso', '250', True) if not copy: self.toon.showPart('torso', '1000') self.toon.showPart('torso', '500') self.toon.showPart('torso', '250') self.toon.loadAnims(TorsoAnimDict[torsoStyle], 'torso', '1000') self.toon.loadAnims(TorsoAnimDict[torsoStyle], 'torso', '500') self.toon.loadAnims(TorsoAnimDict[torsoStyle], 'torso', '250') if genClothes == 1 and not len(torsoStyle) == 1: self.generateToonClothes() return def generateToonClothes(self, fromNet=0): swappedTorso = 0 if self.toon.hasLOD(): if self.getGender() == 'f' and fromNet == 0: try: bottomPair = GirlBottoms[self.botTex] except: bottomPair = GirlBottoms[0] try: texName = Shirts[self.topTex] except: texName = Shirts[0] shirtTex = loader.loadTexture(texName, okMissing=True) if shirtTex is None: shirtTex = loader.loadTexture(Shirts[0]) shirtTex.setMinfilter(Texture.FTLinearMipmapLinear) shirtTex.setMagfilter(Texture.FTLinear) try: shirtColor = ClothesColors[self.topTexColor] except: shirtColor = ClothesColors[0] try: texName = Sleeves[self.sleeveTex] except: texName = Sleeves[0] sleeveTex = loader.loadTexture(texName, okMissing=True) if sleeveTex is None: self.sendLogSuspiciousEvent('failed to load texture %s' % texName) sleeveTex = loader.loadTexture(Sleeves[0]) sleeveTex.setMinfilter(Texture.FTLinearMipmapLinear) sleeveTex.setMagfilter(Texture.FTLinear) try: sleeveColor = ClothesColors[self.sleeveTexColor] except: sleeveColor = ClothesColors[0] if self.getGender() == 'm': try: texName = BoyShorts[self.botTex] except: texName = BoyShorts[0] else: try: texName = GirlBottoms[self.botTex][0] except: texName = GirlBottoms[0][0] bottomTex = loader.loadTexture(texName, okMissing=True) if bottomTex is None: self.sendLogSuspiciousEvent('failed to load texture %s' % texName) if self.getGender() == 'm': bottomTex = loader.loadTexture(BoyShorts[0]) else: bottomTex = loader.loadTexture(GirlBottoms[0][0]) bottomTex.setMinfilter(Texture.FTLinearMipmapLinear) bottomTex.setMagfilter(Texture.FTLinear) try: bottomColor = ClothesColors[self.botTexColor] except: bottomColor = ClothesColors[0] darkBottomColor = bottomColor * 0.5 darkBottomColor.setW(1.0) for lodName in self.toon.getLODNames(): thisPart = self.toon.getPart('torso', lodName) top = thisPart.find('**/torso-top') top.setTexture(shirtTex, 1) top.setColor(shirtColor) sleeves = thisPart.find('**/sleeves') sleeves.setTexture(sleeveTex, 1) sleeves.setColor(sleeveColor) bottoms = thisPart.findAllMatches('**/torso-bot') for bottomNum in xrange(0, bottoms.getNumPaths()): bottom = bottoms.getPath(bottomNum) bottom.setTexture(bottomTex, 1) bottom.setColor(bottomColor) caps = thisPart.findAllMatches('**/torso-bot-cap') caps.setColor(darkBottomColor) return swappedTorso def generateToonColor(self): parts = self.toon.findAllMatches('**/head*') parts.setColor(self.getHeadColor()) animalType = self.getAnimal() if animalType == 'cat' or animalType == 'rabbit' or animalType == 'bear' or animalType == 'mouse' or animalType == 'pig': parts = self.toon.findAllMatches('**/ear?-*') parts.setColor(self.getHeadColor()) armColor = self.getArmColor() gloveColor = self.getGloveColor() legColor = self.getLegColor() for lodName in self.toon.getLODNames(): torso = self.toon.getPart('torso', lodName) if len(self.torso) == 1: parts = torso.findAllMatches('**/torso*') parts.setColor(armColor) for pieceName in ('arms', 'neck'): piece = torso.find('**/' + pieceName) piece.setColor(armColor) hands = torso.find('**/hands') hands.setColor(gloveColor) legs = self.toon.getPart('legs', lodName) for pieceName in ('legs', 'feet'): piece = legs.find('**/%s;+s' % pieceName) piece.setColor(legColor) def generateToonHead(self, copy, lods): headStyle = self.head fix = None if headStyle == 'dls': filePrefix = HeadDict['dls'] headHeight = 0.75 elif headStyle == 'dss': filePrefix = HeadDict['dss'] headHeight = 0.5 elif headStyle == 'dsl': filePrefix = HeadDict['dsl'] headHeight = 0.5 elif headStyle == 'dll': filePrefix = HeadDict['dll'] headHeight = 0.75 elif headStyle == 'cls': filePrefix = HeadDict['c'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'css': filePrefix = HeadDict['c'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'csl': filePrefix = HeadDict['c'] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == 'cll': filePrefix = HeadDict['c'] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == 'hls': filePrefix = HeadDict['h'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'hss': filePrefix = HeadDict['h'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'hsl': filePrefix = HeadDict['h'] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == 'hll': filePrefix = HeadDict['h'] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == 'mls': filePrefix = HeadDict['m'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'mss': filePrefix = HeadDict['m'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'rls': filePrefix = HeadDict['r'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'rss': filePrefix = HeadDict['r'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'rsl': filePrefix = HeadDict['r'] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == 'rll': filePrefix = HeadDict['r'] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == 'fls': filePrefix = HeadDict['f'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'fss': filePrefix = HeadDict['f'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'fsl': filePrefix = HeadDict['f'] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == 'fll': filePrefix = HeadDict['f'] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == 'pls': filePrefix = HeadDict['p'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'pss': filePrefix = HeadDict['p'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'psl': filePrefix = HeadDict['p'] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == 'pll': filePrefix = HeadDict['p'] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == 'bls': filePrefix = HeadDict['b'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'bss': filePrefix = HeadDict['b'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'bsl': filePrefix = HeadDict['b'] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == 'bll': filePrefix = HeadDict['b'] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == 'sls': filePrefix = HeadDict['s'] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == 'sss': filePrefix = HeadDict['s'] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == 'ssl': filePrefix = HeadDict['s'] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == 'sll': filePrefix = HeadDict['s'] fix = self.__fixHeadLongLong headHeight = 0.75 else: ToonHead.notify.error('unknown head style: %s' % headStyle) if len(lods) == 1: self.toon.loadModel(filePrefix + lods[0], 'head', 'lodRoot', copy) if not copy: self.toon.showAllParts('head') if fix != None: fix(None, copy) self.__lods = lods self.__headStyle = headStyle self.__copy = copy else: for lod in lods: self.toon.loadModel(filePrefix + lod, 'head', lod, copy) if not copy: self.toon.showAllParts('head', lod) if fix != None: fix(lod, copy) self.__lods = lods self.__headStyle = headStyle self.__copy = copy # self.setupEyelashes() self.setupMuzzles() return headHeight def setupMuzzles(self): self.__muzzles = [] self.__surpriseMuzzles = [] self.__angryMuzzles = [] self.__sadMuzzles = [] self.__smileMuzzles = [] self.__laughMuzzles = [] def hideAddNonEmptyItemToList(item, list): if not item.isEmpty(): item.hide() list.append(item) def hideNonEmptyItem(item): if not item.isEmpty(): item.hide() if self.toon.hasLOD(): for lodName in self.toon.getLODNames(): animal = self.getAnimal() if animal != 'dog': muzzle = self.toon.find('**/' + lodName + '/**/muzzle*neutral') else: muzzle = self.toon.find('**/' + lodName + '/**/muzzle*') if lodName == '1000' or lodName == '500': filePrefix = DogMuzzleDict[self.head] muzzles = self.toon.loadModel(filePrefix + lodName) if base.config.GetBool('want-new-anims', 1): if not self.toon.find( '**/' + lodName + '/**/__Actor_head/def_head').isEmpty(): muzzles.reparentTo( self.toon.find( '**/' + lodName + '/**/__Actor_head/def_head')) else: muzzles.reparentTo( self.toon.find('**/' + lodName + '/**/joint_toHead')) elif self.toon.find('**/' + lodName + '/**/joint_toHead'): muzzles.reparentTo( self.toon.find('**/' + lodName + '/**/joint_toHead')) surpriseMuzzle = self.toon.find('**/' + lodName + '/**/muzzle*surprise') angryMuzzle = self.toon.find('**/' + lodName + '/**/muzzle*angry') sadMuzzle = self.toon.find('**/' + lodName + '/**/muzzle*sad') smileMuzzle = self.toon.find('**/' + lodName + '/**/muzzle*smile') laughMuzzle = self.toon.find('**/' + lodName + '/**/muzzle*laugh') self.__muzzles.append(muzzle) hideAddNonEmptyItemToList(surpriseMuzzle, self.__surpriseMuzzles) hideAddNonEmptyItemToList(angryMuzzle, self.__angryMuzzles) hideAddNonEmptyItemToList(sadMuzzle, self.__sadMuzzles) hideAddNonEmptyItemToList(smileMuzzle, self.__smileMuzzles) hideAddNonEmptyItemToList(laughMuzzle, self.__laughMuzzles) def setupEyelashes(self): animal = self.head[0] model = self.toon.loadModel(EyelashDict[animal]) if self.toon.hasLOD(): head = self.toon.getPart('head', '1000') else: head = self.toon.getPart('head', 'lodRoot') length = self.head[1] if length == 'l': openString = 'open-long' closedString = 'closed-long' else: openString = 'open-short' closedString = 'closed-short' self.__eyelashOpen = model.find('**/' + openString).copyTo(head) self.__eyelashClosed = model.find('**/' + closedString).copyTo(head) model.removeNode() return def parentToonParts(self): if self.toon.hasLOD(): for lodName in self.toon.getLODNames(): if base.config.GetBool('want-new-anims', 1): if not self.toon.getPart( 'torso', lodName).find('**/def_head').isEmpty(): self.toon.attach('head', 'torso', 'def_head', lodName) else: self.toon.attach('head', 'torso', 'joint_head', lodName) else: self.toon.attach('head', 'torso', 'joint_head', lodName) self.toon.attach('torso', 'legs', 'joint_hips', lodName) else: self.toon.attach('head', 'torso', 'joint_head') self.toon.attach('torso', 'legs', 'joint_hips') def __fixHeadLongLong(self, lodName=None, copy=1): if lodName == None: searchRoot = self.toon else: searchRoot = self.toon.find('**/' + str(lodName)) otherParts = searchRoot.findAllMatches('**/*short*') for partNum in xrange(0, otherParts.getNumPaths()): if copy: otherParts.getPath(partNum).removeNode() else: otherParts.getPath(partNum).stash() return def __fixHeadLongShort(self, lodName=None, copy=1): animalType = self.getAnimal() headStyle = self.head if lodName == None: searchRoot = self.toon else: searchRoot = self.toon.find('**/' + str(lodName)) if animalType != 'duck' and animalType != 'horse': if animalType == 'rabbit': if copy: searchRoot.find('**/ears-long').removeNode() else: searchRoot.find('**/ears-long').hide() elif copy: searchRoot.find('**/ears-short').removeNode() else: searchRoot.find('**/ears-short').hide() if animalType != 'rabbit': if copy: searchRoot.find('**/eyes-short').removeNode() else: searchRoot.find('**/eyes-short').hide() if animalType != 'dog': if copy: searchRoot.find('**/joint_pupilL_short').removeNode() searchRoot.find('**/joint_pupilR_short').removeNode() else: searchRoot.find('**/joint_pupilL_short').stash() searchRoot.find('**/joint_pupilR_short').stash() if animalType != 'rabbit': muzzleParts = searchRoot.findAllMatches('**/muzzle-long*') for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() else: muzzleParts = searchRoot.findAllMatches('**/muzzle-short*') for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() return def __fixHeadShortLong(self, lodName=None, copy=1): animalType = self.getAnimal() headStyle = self.head if lodName == None: searchRoot = self.toon else: searchRoot = self.toon.find('**/' + str(lodName)) if animalType != 'duck' and animalType != 'horse': if animalType == 'rabbit': if copy: searchRoot.find('**/ears-short').removeNode() else: searchRoot.find('**/ears-short').hide() elif copy: searchRoot.find('**/ears-long').removeNode() else: searchRoot.find('**/ears-long').hide() if animalType != 'rabbit': if copy: searchRoot.find('**/eyes-long').removeNode() else: searchRoot.find('**/eyes-long').hide() if animalType != 'dog': if copy: searchRoot.find('**/joint_pupilL_long').removeNode() searchRoot.find('**/joint_pupilR_long').removeNode() else: searchRoot.find('**/joint_pupilL_long').stash() searchRoot.find('**/joint_pupilR_long').stash() if copy: searchRoot.find('**/head-long').removeNode() searchRoot.find('**/head-front-long').removeNode() else: searchRoot.find('**/head-long').hide() searchRoot.find('**/head-front-long').hide() if animalType != 'rabbit': muzzleParts = searchRoot.findAllMatches('**/muzzle-short*') for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() else: muzzleParts = searchRoot.findAllMatches('**/muzzle-long*') for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() return def __fixHeadShortShort(self, lodName=None, copy=1): if lodName == None: searchRoot = self else: searchRoot = self.toon.find('**/' + str(lodName)) otherParts = searchRoot.findAllMatches('**/*long*') for partNum in xrange(0, otherParts.getNumPaths()): if copy: otherParts.getPath(partNum).removeNode() else: otherParts.getPath(partNum).stash() return def setLODs(self): self.toon.setLODNode() levelOneIn = base.config.GetInt('lod1-in', 20) levelOneOut = base.config.GetInt('lod1-out', 0) levelTwoIn = base.config.GetInt('lod2-in', 80) levelTwoOut = base.config.GetInt('lod2-out', 20) levelThreeIn = base.config.GetInt('lod3-in', 280) levelThreeOut = base.config.GetInt('lod3-out', 80) self.toon.addLOD(1000, levelOneIn, levelOneOut) self.toon.addLOD(500, levelTwoIn, levelTwoOut) self.toon.addLOD(250, levelThreeIn, levelThreeOut) def loadPhaseAnims(self, phaseStr='phase_3', loadFlag=1): if phaseStr == 'phase_3': animList = Phase3AnimList elif phaseStr == 'phase_3.5': animList = Phase3_5AnimList elif phaseStr == 'phase_4': animList = Phase4AnimList elif phaseStr == 'phase_5': animList = Phase5AnimList elif phaseStr == 'phase_5.5': animList = Phase5_5AnimList elif phaseStr == 'phase_6': animList = Phase6AnimList elif phaseStr == 'phase_9': animList = Phase9AnimList elif phaseStr == 'phase_10': animList = Phase10AnimList elif phaseStr == 'phase_12': animList = Phase12AnimList else: self.notify.error('Unknown phase string %s' % phaseStr) for key in LegDict.keys(): for anim in animList: if loadFlag: pass elif anim[0] in LegsAnimDict[key]: if self.legs == key: self.toon.unloadAnims([anim[0]], 'legs', None) for key in TorsoDict.keys(): for anim in animList: if loadFlag: pass elif anim[0] in TorsoAnimDict[key]: if self.torso == key: self.toon.unloadAnims([anim[0]], 'torso', None) for key in HeadDict.keys(): if key.find('d') >= 0: for anim in animList: if loadFlag: pass elif anim[0] in HeadAnimDict[key]: if self.head == key: self.toon.unloadAnims([anim[0]], 'head', None) def renderSnapshot(self): print 'Rendering Snapshot...' base.graphicsEngine.renderFrame() base.screenshot(namePrefix='snapshot-render', defaultFilename=1, source=None, imageComment="")
for partNum in range(0, otherParts.getNumPaths()): otherParts.getPath(partNum).removeNode() mouseBody = Actor({ 'head': mouseHead, 'torso': mouseTorso, 'legs': mouseLegs }, { 'torso': torsoAnimDict, 'legs': legsAnimDict }) mouseBody.attach('head', 'torso', 'def_head') mouseBody.attach('torso', 'legs', 'joint_hips') #Gloves gloves = mouseBody.findAllMatches('**/hands') #Ears ears = mouseBody.findAllMatches('**/*ears*') #Head head = mouseBody.findAllMatches('**/head-*') #Sleeves sleeves = mouseBody.findAllMatches('**/sleeves') #Shirt shirt = mouseBody.findAllMatches('**/torso-top') #Shorts shorts = mouseBody.findAllMatches('**/torso-bot') #Neck neck = mouseBody.findAllMatches('**/neck') #Arms arms = mouseBody.findAllMatches('**/arms') #Legs
class GameTest(ShowBase): def __init__(self): ShowBase.__init__(self) base.disableMouse() self.makeAcog = loader.loadModel("phase_5/models/cogdominium/tt_m_ara_cbr_barrelRoom.bam") self.makeAcog.reparentTo(render) self.stomper1 = (self.makeAcog.find('**/stomper_GRP_01')) self.stomper2 = (self.makeAcog.find('**/stomper_GRP_02')) self.stomper3 = (self.makeAcog.find('**/stomper_GRP_03')) self.stomper4 = (self.makeAcog.find('**/stomper_GRP_04')) self.stomper5 = (self.makeAcog.find('**/stomper_GRP_05')) self.stomper6 = (self.makeAcog.find('**/stomper_GRP_06')) self.stomper7 = (self.makeAcog.find('**/stomper_GRP_07')) self.stomper8 = (self.makeAcog.find('**/stomper_GRP_08')) self.stomper9 = (self.makeAcog.find('**/stomper_GRP_09')) self.stomper10 = (self.makeAcog.find('**/stomper_GRP_10')) self.stomper11 = (self.makeAcog.find('**/stomper_GRP_11')) self.stomper12 = (self.makeAcog.find('**/stomper_GRP_12')) self.stomper3.setPos(0, 0, 18.00) self.stomper5.setPos(0, 0, 10.00) self.stomper4.setPos(0, 0, 22.00) self.stomper2.setPos(0, 0, 7.00) self.stomper7.setPos(0, 0, 0) self.stomper8.setPos(0, 0, 5.00) self.stomper9.setPos(0, 0, 13.00) self.stomper10.setPos(0, 0, 10.00) self.stomper11.setPos(0, 0, 22.00) self.stomper12.setPos(0, 0, 7.00) self.music = loader.loadMusic("phase_3/audio/bgm/cco_make_a_cog.wav") self.music.play() self.music.setLoop(True) self.elevator = loader.loadModel("phase_5/models/cogdominium/cogdominiumElevator.bam") self.elevator.reparentTo(self.render) self.elevator.setY(25.37) self.elevator.find('**/floor_light_buttons').removeNode() self.rightDoor = (self.elevator.find('**/right_door')) self.leftDoor = (self.elevator.find('**/left_door')) self.leftDoor.setX(3.50) self.rightDoor.setX(-3.50) self.skelCog = Actor("phase_5/models/char/cogC_robot-lose-mod.bam", {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.skelCog.reparentTo(self.render) self.skelCog.setPos(-16, 0, -4.76) self.skelCog.setH(180) self.Lawbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.Lawbot.reparentTo(render) self.Lawbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/l_blazer.jpg') self.Lawbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/l_sleeve.jpg') self.Lawbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/l_leg.jpg') self.Lawbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam').find('**/flunky') self.headTexture = loader.loadTexture("phase_3.5/maps/bottom-feeder.jpg") self.Head.reparentTo(self.Lawbot.find('**/joint_head')) self.Lawbot.findAllMatches('**/joint_head').setTexture(self.headTexture, 1) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Lawbot.find('**/joint_attachMeter')) self.icon.find('**/MoneyIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/SalesIcon').removeNode() self.icon.find('**/CorpIcon').removeNode() self.icon.setH(180) self.icon.setScale(0.70) self.Lawbot.setH(180.00) self.Lawbot.hide() self.Cashbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.Cashbot.reparentTo(render) self.Cashbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/m_blazer.jpg') self.Cashbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/m_sleeve.jpg') self.Cashbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/m_leg.jpg') self.Cashbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam').find('**/coldcaller') self.Head.reparentTo(self.Cashbot.find('**/joint_head')) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Cashbot.find('**/joint_attachMeter')) self.icon.find('**/SalesIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/LegalIcon').removeNode() self.icon.find('**/CorpIcon').removeNode() self.icon.setH(180) self.icon.setScale(0.70) self.Cashbot.setH(180.00) self.Cashbot.hide() self.Sellbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.Sellbot.reparentTo(render) self.Sellbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/s_blazer.jpg') self.Sellbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/s_sleeve.jpg') self.Sellbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/s_leg.jpg') self.Sellbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam').find('**/coldcaller') self.Head.reparentTo(self.Sellbot.find('**/joint_head')) self.Head.reparentTo(self.Sellbot.find('**/joint_head')) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Sellbot.find('**/joint_attachMeter')) self.icon.find('**/MoneyIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/LegalIcon').removeNode() self.icon.find('**/CorpIcon').removeNode() self.icon.setH(180) self.icon.setScale(0.70) self.Sellbot.setH(180.00) self.Sellbot.hide() self.Bossbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.Bossbot.reparentTo(render) self.Bossbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/c_blazer.jpg') self.Bossbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/c_sleeve.jpg') self.Bossbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/c_leg.jpg') self.Bossbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/suitC-heads.bam') self.Head.find('**/coldcaller').hide() self.Head.find('**/gladhander').hide() self.Head.find('**/micromanager').hide() self.Head.find('**/moneybags').hide() self.Head.find('**/tightwad').hide() self.Head.reparentTo(self.Bossbot.find('**/joint_head')) self.icon = loader.loadModel('phase_3/models/gui/cog_icons.bam') self.icon.reparentTo(render) self.icon.reparentTo(self.Bossbot.find('**/joint_attachMeter')) self.icon.find('**/MoneyIcon').removeNode() self.icon.find('**/cog').removeNode() self.icon.find('**/LegalIcon').removeNode() self.icon.find('**/SalesIcon').removeNode() self.icon.setH(180) self.icon.setScale(0.70) self.Bossbot.setH(180.00) self.Bossbot.hide() self.Sourcebot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.Sourcebot.reparentTo(render) self.Sourcebot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg') self.Sourcebot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg') self.Sourcebot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg') self.Sourcebot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/FlairDirector.egg') self.headTexture = loader.loadTexture("phase_3.5/maps/flair-director.jpg") self.Head.reparentTo(self.Sourcebot.find('**/joint_head')) self.Sourcebot.findAllMatches('**/joint_head').setTexture(self.headTexture, 1) self.Sourcebot.setH(180.00) self.Sourcebot.hide() self.Techbot = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.Techbot.reparentTo(render) self.Techbot.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg') self.Techbot.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg') self.Techbot.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg') self.Techbot.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/PayrollConvertor.egg') self.headTexture = loader.loadTexture("phase_3.5/maps/PayrollConvertor.png") self.Head.reparentTo(self.Techbot.find('**/joint_head')) self.Head.setPos(0, 0, -0.15) self.Head.setScale(0.93) self.Techbot.findAllMatches('**/joint_head').setTexture(self.headTexture, 1) self.Techbot.setH(180.00) self.Techbot.hide() self.Pilotbots = Actor('phase_3.5/models/char/suitC-mod.bam', {'neutral': 'phase_3.5/models/char/suitC-neutral.bam', 'victory': 'phase_4/models/char/suitC-victory.bam', 'walk': 'phase_3.5/models/char/suitC-walk.bam'}) self.Pilotbots.reparentTo(render) self.Pilotbots.loop('neutral') self.TorsoTex = loader.loadTexture('phase_3.5/maps/t_blazer.jpg') self.Pilotbots.find('**/torso').setTexture(self.TorsoTex, 1) self.ArmTex = loader.loadTexture('phase_3.5/maps/t_sleeve.jpg') self.Pilotbots.find('**/arms').setTexture(self.ArmTex, 1) self.LegTex = loader.loadTexture('phase_3.5/maps/t_leg.jpg') self.Pilotbots.find('**/legs').setTexture(self.LegTex, 1) self.Head = loader.loadModel('phase_3.5/models/char/ConstructionBot.egg') self.headTexture = loader.loadTexture("phase_3.5/maps/Buildbot.png") self.Head.reparentTo(self.Pilotbots.find('**/joint_head')) self.Head.setPos(0, 0, -0.15) self.icon.setH(180) self.Pilotbots.findAllMatches('**/joint_head').setTexture(self.headTexture, 1) self.Pilotbots.setH(180.00) self.Pilotbots.hide() #-----Sequences------# Walk1 = self.stomper1.posInterval(9.50, Point3(0, 0, 18.00)) Walk2 = self.stomper1.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound1 = Sequence(Walk1, Walk2) self.stomperPound1.loop() Walk1 = self.stomper6.posInterval(9.50, Point3(0, 0, 18.00)) Walk2 = self.stomper6.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound2 = Sequence(Walk1, Walk2) self.stomperPound2.loop() Walk1 = self.stomper3.posInterval(9.50, Point3(0, 0, 0)) Walk2 = self.stomper3.posInterval(9.50, Point3(0, 0, 18.00)) self.stomperPound3 = Sequence(Walk1, Walk2) self.stomperPound3.loop() Walk1 = self.stomper5.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper5.posInterval(5.50, Point3(0, 0, 10.00)) self.stomperPound4 = Sequence(Walk1, Walk2) self.stomperPound4.loop() Walk1 = self.stomper4.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper4.posInterval(5.50, Point3(0, 0, 22.00)) self.stomperPound5 = Sequence(Walk1, Walk2) self.stomperPound5.loop() Walk1 = self.stomper2.posInterval(3.50, Point3(0, 0, 0)) Walk2 = self.stomper2.posInterval(3.50, Point3(0, 0, 7.00)) self.stomperPound6 = Sequence(Walk1, Walk2) self.stomperPound6.loop() Walk1 = self.stomper7.posInterval(9.50, Point3(0, 0, 18.00)) Walk2 = self.stomper7.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound7 = Sequence(Walk1, Walk2) self.stomperPound7.loop() Walk1 = self.stomper8.posInterval(5.50, Point3(0, 0, 5.00)) Walk2 = self.stomper8.posInterval(9.50, Point3(0, 0, 0)) self.stomperPound8 = Sequence(Walk1, Walk2) self.stomperPound8.loop() Walk1 = self.stomper9.posInterval(6.50, Point3(0, 0, 0)) Walk2 = self.stomper9.posInterval(6.50, Point3(0, 0, 13.00)) self.stomperPound9 = Sequence(Walk1, Walk2) self.stomperPound9.loop() Walk1 = self.stomper10.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper10.posInterval(5.50, Point3(0, 0, 10.00)) self.stomperPound10 = Sequence(Walk1, Walk2) self.stomperPound10.loop() Walk1 = self.stomper11.posInterval(5.50, Point3(0, 0, 0)) Walk2 = self.stomper11.posInterval(5.50, Point3(0, 0, 22.00)) self.stomperPound11 = Sequence(Walk1, Walk2) self.stomperPound11.loop() Walk1 = self.stomper12.posInterval(3.50, Point3(0, 0, 0)) Walk2 = self.stomper12.posInterval(3.50, Point3(0, 0, 7.00)) self.stomperPound12 = Sequence(Walk1, Walk2) self.stomperPound12.loop() Walk1 = self.camera.posInterval(2.50, Point3(-20.98, -14.61, 9.74)) Spin1 = self.camera.hprInterval(1.00, Vec3(321.34, 348.11, 0)) cogSpin = self.Sellbot.hprInterval(1.50, Vec3(0, 0, 0)) Walk2 = self.camera.posInterval(5.0, Point3(-20.98, -14.61, 9.74)) Walk3 = self.camera.posInterval(1.50, Point3(-20.98, 1.40, 7.97)) Spin2 = self.camera.hprInterval(1.00, Vec3(281.31, 348.11, 0)) Walk4 = self.camera.posInterval(8.50, Point3(-20.98, 1.40, 7.97)) Walk5 = self.camera.posInterval(2.50, Point3(0, -19.61, 2.61)) Spin3 = self.camera.hprInterval(1.00, Vec3(0, 0, 0)) self.cameraMove = Sequence(Walk1, Spin1, cogSpin, Walk2, Walk3, Spin2, Walk4, Walk5, Spin3) Walk1 = self.camera.posInterval(1.50, Point3(0, -77.48, 3.42)) Spin1 = self.camera.hprInterval(1.00, Vec3(0, 0, 0)) Walk2 = self.camera.posInterval(2.50, Point3(0, -77.48, 3.42)) Walk3 = self.camera.posInterval(3.00, Point3(0, -22.48, 3.42)) Walk4 = self.camera.posInterval(2.00, Point3(0, -22.48, 3.42)) skelMove1 = self.skelCog.posInterval(0.50, Point3(-16, -0, 0)) skelMove2 = self.skelCog.posInterval(2.00, Point3(0, -0, 0)) self.cameraStart = Sequence(Walk1, Spin1, Walk2, Walk3, Walk4, skelMove1, skelMove2) Walk1 = self.camera.posInterval(15.50, Point3(6.31, -45.31, 9.27)) Spin1 = self.camera.hprInterval(0.00, Vec3(337.52, 0, 0)) Walk2 = self.camera.posInterval(0.00, Point3(6.08, -100.53, 9.27)) Walk3 = self.camera.posInterval(12.00, Point3(14.07, -77.33, 9.27)) Walk4 = self.camera.posInterval(0.00, Point3(18.93, -82.36, 25.51)) Spin2 = self.camera.hprInterval(0.00, Vec3(30.26, 347.91, 0)) Walk5 = self.camera.posInterval(15.00, Point3(0.44, -51.38, 21.411)) Spin3 = self.camera.hprInterval(0.00, Vec3(337.52, 0, 0)) self.cameraIntro = Sequence(Walk1, Spin1, Walk2, Walk3, Walk4, Spin2, Walk5, Spin3) self.cameraIntro.loop() #----camera---# self.camera.setPos(6.31, -82.36, 9.27) self.camera.setHpr(35.71, 0, 0) #--------Start-up-Menu--------# #-----buttons-------# #-----texts-------# self.logoLeft = OnscreenImage(image='phase_3/maps/cogcitycodeaffix-logo-hor-left[OLD].png', pos=(-0.46, 0, 0.2), scale=(0.7)) self.logoLeft.setTransparency(TransparencyAttrib.MAlpha) self.logoRight = OnscreenImage(image='phase_3/maps/cogcitycodeaffix-logo-hor-right[OLD].png', pos=(0.56, 0, 0.18), scale=(0.7)) self.logoRight.setTransparency(TransparencyAttrib.MAlpha) font = self.loader.loadFont("phase_3/models/fonts/vtRemingtonPortable.ttf") text = TextNode("play") text.setText("Press F1 to play") text.setFont(font) self.textNodePath = aspect2d.attachNewNode(text) self.textNodePath.setScale(0.09) self.textNodePath.setPos(-0.5, 0, -0.7) #-----optionText-----------# fps = "Show FPS: f2" self.textObject1 = OnscreenText(text=fps, pos=(-1.4, -0.97), scale=0.09, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1) self.textObject1.setFont(font) fullscreen = "Fullscreen: f2" self.textObject2 = OnscreenText(text=fullscreen, pos=(-1.34, -0.88), scale=0.09, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1) self.textObject2.setFont(font) audio = "Audio: f4" self.textObject3 = OnscreenText(text=audio, pos=(-1.48, -0.78), scale=0.09, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1) self.textObject3.setFont(font) #------doneButton--------# font = self.loader.loadFont("phase_3/models/fonts/vtRemingtonPortable.ttf") bk_text = "" textObject = OnscreenText(text=bk_text, pos=(0.00, 0.73), scale=0.16, fg=(1, 0.5, 0.5, 1), align=TextNode.ACenter, mayChange=1) textObject.setFont(font) textObject.setColor(0.3, 0.3, 0.35, 1.0) def setText(status): if (status): bk_text = "Do you want to continue?" else: bk_text = "" textObject.setText(bk_text) self.DoneButton = DirectCheckButton(text="Continue", scale=0.12, pos=(0, 0, -0.80), command=setText) self.DoneButton.hide() #----------key/click-events-------# self.acceptOnce("f1-up", self.play) self.accept("f2-up", self.frameRate) def moveCamera(self): if self.camera: self.cameraMove.start() else: self.cameraMove.stop() def popupGUI(self): if self.DoneButton: self.DoneButton.show() def frameRate(self): if self.textObject1: self.setFrameRateMeter(True) else: self.setFrameRateMeter(False) def play(self): if self.logoRight: self.logoRight.destroy() self.logoLeft.destroy() self.textObject3.hide() self.textObject2.hide() self.textObject1.hide() self.textNodePath.hide() self.cameraIntro.pause() self.cameraStart.start()
for partNum in range(0, otherParts.getNumPaths()): part = otherParts.getPath(partNum) if part != ntrlMuzzle: otherParts.getPath(partNum).removeNode() catTorso = loader.loadModel('phase_3/models/char/tt_a_chr_dgl_skirt_torso_1000.bam') catLegs = loader.loadModel('phase_3/models/char/tt_a_chr_dgs_shorts_legs_1000.bam') otherParts = catLegs.findAllMatches('**/boots*')+catLegs.findAllMatches('**/shoes') for partNum in range(0, otherParts.getNumPaths()): otherParts.getPath(partNum).removeNode() catBody = Actor({'head':catHead, 'torso':catTorso, 'legs':catLegs}, {'torso':torsoAnimDict, 'legs':legsAnimDict}) catBody.attach('head', 'torso', 'def_head') catBody.attach('torso', 'legs', 'joint_hips') gloves = catBody.findAllMatches('**/hands') ears = catBody.findAllMatches('**/*ears*') head = catBody.findAllMatches('**/head-*') sleeves = catBody.findAllMatches('**/sleeves') shirt = catBody.findAllMatches('**/torso-top') skirt = catBody.findAllMatches('**/torso-bot') neck = catBody.findAllMatches('**/neck') arms = catBody.findAllMatches('**/arms') legs = catBody.findAllMatches('**/legs') feet = catBody.findAllMatches('**/feet') bodyNodes = [] bodyNodes += [gloves] bodyNodes += [head, ears] bodyNodes += [sleeves, shirt, skirt] bodyNodes += [neck, arms, legs, feet]
def loadModel(file, collision=None, animation=None): model = None if animation: collision = file + '/collision' anims = {} dirList = listdir(file + '/animation') for fname in dirList: anims[fname[:-4]] = file + '/animation/' + fname #print anims model = Actor(file + '/model', anims) #default anim if 'default' in anims: model.loop('default') elif 'idle' in animation: model.loop('idle') else: #some first, random anim model.loop(anims.items()[0]) else: model = loader.loadModel(file) model.setPythonTag('model_file', file) #load shaders for geom in model.findAllMatches('**/+GeomNode'): if geom.hasTag('light'): model.setPythonTag('hasLight', True) if geom.hasTag('particle'): file = 'particle/' + geom.getTag('particle') if exists(file): with open(file) as f: values = json.load(f) p = createEffect(values) model.setPythonTag('particle', p) p.start(parent=model, renderParent=render) if geom.hasTag('cg_shader'): geom.setShader( loader.loadShader("shaders/" + geom.getTag('cg_shader'))) elif geom.hasTag('glsl_shader'): glsl_shader = geom.getTag('glsl_shader') model.setShader( Shader.load(Shader.SLGLSL, "shaders/{0}_v.glsl".format(glsl_shader), "shaders/{0}_f.glsl".format(glsl_shader))) else: #geom.setShader(loader.loadShader("shaders/default.cg")) model.setShader( Shader.load(Shader.SLGLSL, "shaders/default_v.glsl", "shaders/default_f.glsl"), 1) print "default shader!" #collisions model.setCollideMask(BitMask32.allOff()) if collision: coll = loader.loadModel(collision) coll.reparentTo(model) coll.find('**/collision').setCollideMask(BitMask32.bit(2)) coll.find('**/collision').setPythonTag('object', model) if animation: model.setPythonTag('actor_files', [file, anims, coll]) else: try: model.find('**/collision').setCollideMask(BitMask32.bit(2)) model.find('**/collision').setPythonTag('object', model) except: print "WARNING: Model {0} has no collision geometry!\nGenerating collision sphere...".format( file) bounds = model.getBounds() radi = bounds.getRadius() cent = bounds.getCenter() coll_sphere = model.attachNewNode(CollisionNode('collision')) coll_sphere.node().addSolid( CollisionSphere(cent[0], cent[1], cent[2], radi)) coll_sphere.setCollideMask(BitMask32.bit(2)) coll_sphere.setPythonTag('object', model) #coll_sphere.show() if animation: model.setPythonTag('actor_files', [file, animation, None]) if ConfigVariableBool('framebuffer-srgb', False).getValue(): fixSrgbTextures(model) return model
def make_cog(head, head_style, suit_style, suit_name, head_text="", path=""): """Return a skelecog version of any traditional cog as an Actor. Args: head (str): The name of the cog. head_style (str): The letter representing the suit style ("A", "B" or "C"). suit_style (str): The letter representing the suit style ("A", "B" or "C"). suit_name (str): The name of the suit. head_text (str, optional): The name of a head texture. path (str, optional): The file path to the Toontown phase files. Defaults to Panda3D's search path. Examples: from toontown import make_cog Hollywood = make_cog("yesman", "A", "A", "sell") Hollywood.loop("landing") RobberBaron = make_cog("yesman", "A", "A", "cash", "robber-baron") RobberBaron.loop("walk") SpinDoctor = make_cog("telemarketer", "B", "B", "law", "spin-doctor") SpinDoctor.loop("throw-paper") Returns: An instance of Panda3D's Actor class. """ if path: path = pfile.fromOsSpecific("%s/" % path).getFullpath() abrv = { "sell": ("s", (0.95, 0.75, 0.95, 1.0), "Sales", (0.843, 0.745, 0.745, 1.0)), "cash": ("m", (0.65, 0.95, 0.85, 1.0), "Money", (0.749, 0.769, 0.749, 1.0)), "law": ("l", (0.75, 0.75, 0.95, 1.0), "Legal", (0.749, 0.776, 0.824, 1.0)), "boss": ("c", (0.95, 0.75, 0.75, 1.0), "Corp", (0.863, 0.776, 0.769, 1.0)) } cog_color = { "coldcaller": ((0.75, 0.75, 0.95, 1.0), ""), "pennypincher": ((1.0, 0.5, 0.6, 1.0), ""), "legaleagle": ((0.25, 0.25, 0.5, 1.0), ""), "telemarketer": ((0.5, 0.8, 0.75, 1.0), "spin-doctor"), "movershaker": ((0.95, 0.95, 1.0, 1.0), "blood-sucker"), "bigcheese": ((0.75, 0.95, 0.75, 1.0), ""), "flunky": ((0.85, 0.55, 0.55, 1.0), "corporate-raider") } blazer = loader.loadTexture("%sphase_3.5/maps/%s_blazer.jpg" % (path, abrv[suit_name][0])) sleeve = loader.loadTexture("%sphase_3.5/maps/%s_sleeve.jpg" % (path, abrv[suit_name][0])) leg = loader.loadTexture("%sphase_3.5/maps/%s_leg.jpg" % (path, abrv[suit_name][0])) animation_dict = cog_animation(suit_style, path) if suit_style in ("A", "B"): cog = Actor( "%sphase_3.5/models/char/suit%s-mod.bam" % (path, suit_style), animation_dict) else: cog = Actor("%sphase_3.5/models/char/suitC-mod.bam" % path, animation_dict) if head_style in ("A", "B"): head_model = loader.loadModel( "%sphase_4/models/char/suit%s-heads.bam" % (path, head_style)) else: head_model = loader.loadModel( "%sphase_3.5/models/char/suitC-heads.bam" % path) cog_head = head_model.find("**/%s" % head) joint_head = cog.find("**/joint_head") cog_head.reparentTo(joint_head) if head in cog_color.keys() and head_text == cog_color[head][1]: cog.find("**/hands").setColor(cog_color[head][0]) else: cog.find("**/hands").setColor(abrv[suit_name][1]) if head_text and head_text not in ("bottom-feeder", "corporate-raider"): head_texture = loader.loadTexture("%sphase_4/maps/%s.jpg" % (path, head_text)) cog.findAllMatches("**/%s" % head).setTexture(head_texture, 1) elif head_text in ("bottom-feeder", "corporate-raider"): head_texture = loader.loadTexture("%sphase_3.5/maps/%s.jpg" % (path, head_text)) cog.findAllMatches("**/%s" % head).setTexture(head_texture, 1) if head == "flunky" and not head_text: head_model.find("**/glasses").reparentTo(cog_head) icons = loader.loadModel("%sphase_3/models/gui/cog_icons.bam" % path) icon = icons.find("**/%sIcon" % abrv[suit_name][2]).copyTo( cog.find("**/joint_attachMeter")) icon.setPosHprScale(0.02, 0.05, 0.04, 180.0, 0.0, 0.0, 0.51, 0.51, 0.51) icon.setColor(abrv[suit_name][3]) icons.removeNode() cog.find("**/legs").setTexture(leg, 1) cog.find("**/torso").setTexture(blazer, 1) cog.find("**/arms").setTexture(sleeve, 1) cog.reparentTo(render) return cog
puppet = s.loader.loadModel('assets/cars/Ricardeaut_Magnesium.bam') puppet.find("armature").hide() puppet.reparentTo(a) beam = s.loader.loadModel('assets/effect/beam.bam') # convert all nodes called "sequence_node:N" into a SequenceNode sequence_nodes = beam.findAllMatches("**/sequence_node:*") for sequence_node in sequence_nodes: framerate = sequence_node.get_tag("sequence_fps") SequenceNode("sequence").replace_node(sequence_node.node()) sequence_node.node().setFrameRate(int(framerate)) sequence_node.node().loop(1) # instance the animated beam to all fz_beam nodes (just one for magnesium) beam_nodes = a.findAllMatches("**/*fz_beam*") beams = [] for beam_node in beam_nodes: beams.append(beam.instanceTo(beam_node)) thrust = 0 def update(task): global thrust if thrust > 0: thrust -= 1 if s.mouseWatcherNode.is_button_down(KeyboardButton.space()): if thrust < 15: thrust += 2
for partNum in range(0, otherParts.getNumPaths()): part = otherParts.getPath(partNum) if part != ntrlMuzzle: otherParts.getPath(partNum).removeNode() duckTorso = loader.loadModel('phase_3/models/char/tt_a_chr_dgl_shorts_torso_1000.bam') duckLegs = loader.loadModel('phase_3/models/char/tt_a_chr_dgs_shorts_legs_1000.bam') otherParts = duckLegs.findAllMatches('**/boots*')+duckLegs.findAllMatches('**/shoes') for partNum in range(0, otherParts.getNumPaths()): otherParts.getPath(partNum).removeNode() duckBody = Actor({'head':duckHead, 'torso':duckTorso, 'legs':duckLegs}, {'torso':torsoAnimDict, 'legs':legsAnimDict}) duckBody.attach('head', 'torso', 'def_head') duckBody.attach('torso', 'legs', 'joint_hips') gloves = duckBody.findAllMatches('**/hands') ears = duckBody.findAllMatches('**/*ears*') head = duckBody.findAllMatches('**/head-*') sleeves = duckBody.findAllMatches('**/sleeves') shirt = duckBody.findAllMatches('**/torso-top') shorts = duckBody.findAllMatches('**/torso-bot') neck = duckBody.findAllMatches('**/neck') arms = duckBody.findAllMatches('**/arms') legs = duckBody.findAllMatches('**/legs') feet = duckBody.findAllMatches('**/feet') bodyNodes = [] bodyNodes += [gloves] bodyNodes += [head, ears] bodyNodes += [sleeves, shirt, shorts] bodyNodes += [neck, arms, legs, feet]
class SnapshotRenderer: def __init__(self, dnaString): self.dnaString = dnaString loadModels() compileGlobalAnimList() self.makeFromNetString(dnaString) self.toon = Actor() self.generateToon() self.renderSnapshot() def makeFromNetString(self, string): dg = PyDatagram(string) dgi = PyDatagramIterator(dg) self.type = dgi.getFixedString(1) if self.type == "t": headIndex = dgi.getUint8() torsoIndex = dgi.getUint8() legsIndex = dgi.getUint8() self.head = toonHeadTypes[headIndex] self.torso = toonTorsoTypes[torsoIndex] self.legs = toonLegTypes[legsIndex] gender = dgi.getUint8() if gender == 1: self.gender = "m" else: self.gender = "f" self.topTex = dgi.getUint8() self.topTexColor = dgi.getUint8() self.sleeveTex = dgi.getUint8() self.sleeveTexColor = dgi.getUint8() self.botTex = dgi.getUint8() self.botTexColor = dgi.getUint8() self.armColor = dgi.getUint8() self.gloveColor = dgi.getUint8() self.legColor = dgi.getUint8() self.headColor = dgi.getUint8() else: notify.error("unknown avatar type: ", self.type) def getAnimal(self): if self.head[0] == "d": return "dog" elif self.head[0] == "c": return "cat" elif self.head[0] == "m": return "mouse" elif self.head[0] == "h": return "horse" elif self.head[0] == "r": return "rabbit" elif self.head[0] == "f": return "duck" elif self.head[0] == "p": return "monkey" elif self.head[0] == "b": return "bear" elif self.head[0] == "s": return "pig" else: notify.error("unknown headStyle: ", self.head[0]) def getArmColor(self): try: return allColorsList[self.armColor] except: return allColorsList[0] def getLegColor(self): try: return allColorsList[self.legColor] except: return allColorsList[0] def getHeadColor(self): try: return allColorsList[self.headColor] except: return allColorsList[0] def getGloveColor(self): try: return allColorsList[self.gloveColor] except: return allColorsList[0] def getGender(self): return self.gender def generateToon(self): self.setLODs() self.generateToonLegs() self.generateToonHead(1, ("1000", "500", "250")) self.generateToonTorso() self.generateToonColor() self.parentToonParts() # self.rescaleToon() # self.resetHeight() # self.setupToonNodes() self.toon.reparentTo(render) self.toon.setPos(0, 5, -3) self.toon.setH(180) self.toon.getPart("head", "1000").setR(10) self.toon.pose("neutral", 0) def generateToonLegs(self, copy=1): global Preloaded legStyle = self.legs filePrefix = LegDict.get(legStyle) if filePrefix is None: print ("unknown leg style: %s" % legStyle) self.toon.loadModel(Preloaded[filePrefix + "-1000"], "legs", "1000", True) self.toon.loadModel(Preloaded[filePrefix + "-500"], "legs", "500", True) self.toon.loadModel(Preloaded[filePrefix + "-250"], "legs", "250", True) if not copy: self.toon.showPart("legs", "1000") self.toon.showPart("legs", "500") self.toon.showPart("legs", "250") self.toon.loadAnims(LegsAnimDict[legStyle], "legs", "1000") self.toon.loadAnims(LegsAnimDict[legStyle], "legs", "500") self.toon.loadAnims(LegsAnimDict[legStyle], "legs", "250") self.toon.findAllMatches("**/boots_short").stash() self.toon.findAllMatches("**/boots_long").stash() self.toon.findAllMatches("**/shoes").stash() return def generateToonTorso(self, copy=1, genClothes=1): global Preloaded torsoStyle = self.torso filePrefix = TorsoDict.get(torsoStyle) if filePrefix is None: self.notify.error("unknown torso style: %s" % torsoStyle) self.toon.loadModel(Preloaded[filePrefix + "-1000"], "torso", "1000", True) if len(torsoStyle) == 1: self.toon.loadModel(Preloaded[filePrefix + "-1000"], "torso", "500", True) self.toon.loadModel(Preloaded[filePrefix + "-1000"], "torso", "250", True) else: self.toon.loadModel(Preloaded[filePrefix + "-500"], "torso", "500", True) self.toon.loadModel(Preloaded[filePrefix + "-250"], "torso", "250", True) if not copy: self.toon.showPart("torso", "1000") self.toon.showPart("torso", "500") self.toon.showPart("torso", "250") self.toon.loadAnims(TorsoAnimDict[torsoStyle], "torso", "1000") self.toon.loadAnims(TorsoAnimDict[torsoStyle], "torso", "500") self.toon.loadAnims(TorsoAnimDict[torsoStyle], "torso", "250") if genClothes == 1 and not len(torsoStyle) == 1: self.generateToonClothes() return def generateToonClothes(self, fromNet=0): swappedTorso = 0 if self.toon.hasLOD(): if self.getGender() == "f" and fromNet == 0: try: bottomPair = GirlBottoms[self.botTex] except: bottomPair = GirlBottoms[0] try: texName = Shirts[self.topTex] except: texName = Shirts[0] shirtTex = loader.loadTexture(texName, okMissing=True) if shirtTex is None: shirtTex = loader.loadTexture(Shirts[0]) shirtTex.setMinfilter(Texture.FTLinearMipmapLinear) shirtTex.setMagfilter(Texture.FTLinear) try: shirtColor = ClothesColors[self.topTexColor] except: shirtColor = ClothesColors[0] try: texName = Sleeves[self.sleeveTex] except: texName = Sleeves[0] sleeveTex = loader.loadTexture(texName, okMissing=True) if sleeveTex is None: self.sendLogSuspiciousEvent("failed to load texture %s" % texName) sleeveTex = loader.loadTexture(Sleeves[0]) sleeveTex.setMinfilter(Texture.FTLinearMipmapLinear) sleeveTex.setMagfilter(Texture.FTLinear) try: sleeveColor = ClothesColors[self.sleeveTexColor] except: sleeveColor = ClothesColors[0] if self.getGender() == "m": try: texName = BoyShorts[self.botTex] except: texName = BoyShorts[0] else: try: texName = GirlBottoms[self.botTex][0] except: texName = GirlBottoms[0][0] bottomTex = loader.loadTexture(texName, okMissing=True) if bottomTex is None: self.sendLogSuspiciousEvent("failed to load texture %s" % texName) if self.getGender() == "m": bottomTex = loader.loadTexture(BoyShorts[0]) else: bottomTex = loader.loadTexture(GirlBottoms[0][0]) bottomTex.setMinfilter(Texture.FTLinearMipmapLinear) bottomTex.setMagfilter(Texture.FTLinear) try: bottomColor = ClothesColors[self.botTexColor] except: bottomColor = ClothesColors[0] darkBottomColor = bottomColor * 0.5 darkBottomColor.setW(1.0) for lodName in self.toon.getLODNames(): thisPart = self.toon.getPart("torso", lodName) top = thisPart.find("**/torso-top") top.setTexture(shirtTex, 1) top.setColor(shirtColor) sleeves = thisPart.find("**/sleeves") sleeves.setTexture(sleeveTex, 1) sleeves.setColor(sleeveColor) bottoms = thisPart.findAllMatches("**/torso-bot") for bottomNum in xrange(0, bottoms.getNumPaths()): bottom = bottoms.getPath(bottomNum) bottom.setTexture(bottomTex, 1) bottom.setColor(bottomColor) caps = thisPart.findAllMatches("**/torso-bot-cap") caps.setColor(darkBottomColor) return swappedTorso def generateToonColor(self): parts = self.toon.findAllMatches("**/head*") parts.setColor(self.getHeadColor()) animalType = self.getAnimal() if ( animalType == "cat" or animalType == "rabbit" or animalType == "bear" or animalType == "mouse" or animalType == "pig" ): parts = self.toon.findAllMatches("**/ear?-*") parts.setColor(self.getHeadColor()) armColor = self.getArmColor() gloveColor = self.getGloveColor() legColor = self.getLegColor() for lodName in self.toon.getLODNames(): torso = self.toon.getPart("torso", lodName) if len(self.torso) == 1: parts = torso.findAllMatches("**/torso*") parts.setColor(armColor) for pieceName in ("arms", "neck"): piece = torso.find("**/" + pieceName) piece.setColor(armColor) hands = torso.find("**/hands") hands.setColor(gloveColor) legs = self.toon.getPart("legs", lodName) for pieceName in ("legs", "feet"): piece = legs.find("**/%s;+s" % pieceName) piece.setColor(legColor) def generateToonHead(self, copy, lods): headStyle = self.head fix = None if headStyle == "dls": filePrefix = HeadDict["dls"] headHeight = 0.75 elif headStyle == "dss": filePrefix = HeadDict["dss"] headHeight = 0.5 elif headStyle == "dsl": filePrefix = HeadDict["dsl"] headHeight = 0.5 elif headStyle == "dll": filePrefix = HeadDict["dll"] headHeight = 0.75 elif headStyle == "cls": filePrefix = HeadDict["c"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "css": filePrefix = HeadDict["c"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "csl": filePrefix = HeadDict["c"] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == "cll": filePrefix = HeadDict["c"] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == "hls": filePrefix = HeadDict["h"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "hss": filePrefix = HeadDict["h"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "hsl": filePrefix = HeadDict["h"] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == "hll": filePrefix = HeadDict["h"] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == "mls": filePrefix = HeadDict["m"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "mss": filePrefix = HeadDict["m"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "rls": filePrefix = HeadDict["r"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "rss": filePrefix = HeadDict["r"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "rsl": filePrefix = HeadDict["r"] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == "rll": filePrefix = HeadDict["r"] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == "fls": filePrefix = HeadDict["f"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "fss": filePrefix = HeadDict["f"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "fsl": filePrefix = HeadDict["f"] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == "fll": filePrefix = HeadDict["f"] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == "pls": filePrefix = HeadDict["p"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "pss": filePrefix = HeadDict["p"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "psl": filePrefix = HeadDict["p"] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == "pll": filePrefix = HeadDict["p"] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == "bls": filePrefix = HeadDict["b"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "bss": filePrefix = HeadDict["b"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "bsl": filePrefix = HeadDict["b"] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == "bll": filePrefix = HeadDict["b"] fix = self.__fixHeadLongLong headHeight = 0.75 elif headStyle == "sls": filePrefix = HeadDict["s"] fix = self.__fixHeadLongShort headHeight = 0.75 elif headStyle == "sss": filePrefix = HeadDict["s"] fix = self.__fixHeadShortShort headHeight = 0.5 elif headStyle == "ssl": filePrefix = HeadDict["s"] fix = self.__fixHeadShortLong headHeight = 0.5 elif headStyle == "sll": filePrefix = HeadDict["s"] fix = self.__fixHeadLongLong headHeight = 0.75 else: ToonHead.notify.error("unknown head style: %s" % headStyle) if len(lods) == 1: self.toon.loadModel(filePrefix + lods[0], "head", "lodRoot", copy) if not copy: self.toon.showAllParts("head") if fix != None: fix(None, copy) self.__lods = lods self.__headStyle = headStyle self.__copy = copy else: for lod in lods: self.toon.loadModel(filePrefix + lod, "head", lod, copy) if not copy: self.toon.showAllParts("head", lod) if fix != None: fix(lod, copy) self.__lods = lods self.__headStyle = headStyle self.__copy = copy # self.setupEyelashes() self.setupMuzzles() return headHeight def setupMuzzles(self): self.__muzzles = [] self.__surpriseMuzzles = [] self.__angryMuzzles = [] self.__sadMuzzles = [] self.__smileMuzzles = [] self.__laughMuzzles = [] def hideAddNonEmptyItemToList(item, list): if not item.isEmpty(): item.hide() list.append(item) def hideNonEmptyItem(item): if not item.isEmpty(): item.hide() if self.toon.hasLOD(): for lodName in self.toon.getLODNames(): animal = self.getAnimal() if animal != "dog": muzzle = self.toon.find("**/" + lodName + "/**/muzzle*neutral") else: muzzle = self.toon.find("**/" + lodName + "/**/muzzle*") if lodName == "1000" or lodName == "500": filePrefix = DogMuzzleDict[self.head] muzzles = self.toon.loadModel(filePrefix + lodName) if base.config.GetBool("want-new-anims", 1): if not self.toon.find("**/" + lodName + "/**/__Actor_head/def_head").isEmpty(): muzzles.reparentTo(self.toon.find("**/" + lodName + "/**/__Actor_head/def_head")) else: muzzles.reparentTo(self.toon.find("**/" + lodName + "/**/joint_toHead")) elif self.toon.find("**/" + lodName + "/**/joint_toHead"): muzzles.reparentTo(self.toon.find("**/" + lodName + "/**/joint_toHead")) surpriseMuzzle = self.toon.find("**/" + lodName + "/**/muzzle*surprise") angryMuzzle = self.toon.find("**/" + lodName + "/**/muzzle*angry") sadMuzzle = self.toon.find("**/" + lodName + "/**/muzzle*sad") smileMuzzle = self.toon.find("**/" + lodName + "/**/muzzle*smile") laughMuzzle = self.toon.find("**/" + lodName + "/**/muzzle*laugh") self.__muzzles.append(muzzle) hideAddNonEmptyItemToList(surpriseMuzzle, self.__surpriseMuzzles) hideAddNonEmptyItemToList(angryMuzzle, self.__angryMuzzles) hideAddNonEmptyItemToList(sadMuzzle, self.__sadMuzzles) hideAddNonEmptyItemToList(smileMuzzle, self.__smileMuzzles) hideAddNonEmptyItemToList(laughMuzzle, self.__laughMuzzles) def setupEyelashes(self): animal = self.head[0] model = self.toon.loadModel(EyelashDict[animal]) if self.toon.hasLOD(): head = self.toon.getPart("head", "1000") else: head = self.toon.getPart("head", "lodRoot") length = self.head[1] if length == "l": openString = "open-long" closedString = "closed-long" else: openString = "open-short" closedString = "closed-short" self.__eyelashOpen = model.find("**/" + openString).copyTo(head) self.__eyelashClosed = model.find("**/" + closedString).copyTo(head) model.removeNode() return def parentToonParts(self): if self.toon.hasLOD(): for lodName in self.toon.getLODNames(): if base.config.GetBool("want-new-anims", 1): if not self.toon.getPart("torso", lodName).find("**/def_head").isEmpty(): self.toon.attach("head", "torso", "def_head", lodName) else: self.toon.attach("head", "torso", "joint_head", lodName) else: self.toon.attach("head", "torso", "joint_head", lodName) self.toon.attach("torso", "legs", "joint_hips", lodName) else: self.toon.attach("head", "torso", "joint_head") self.toon.attach("torso", "legs", "joint_hips") def __fixHeadLongLong(self, lodName=None, copy=1): if lodName == None: searchRoot = self.toon else: searchRoot = self.toon.find("**/" + str(lodName)) otherParts = searchRoot.findAllMatches("**/*short*") for partNum in xrange(0, otherParts.getNumPaths()): if copy: otherParts.getPath(partNum).removeNode() else: otherParts.getPath(partNum).stash() return def __fixHeadLongShort(self, lodName=None, copy=1): animalType = self.getAnimal() headStyle = self.head if lodName == None: searchRoot = self.toon else: searchRoot = self.toon.find("**/" + str(lodName)) if animalType != "duck" and animalType != "horse": if animalType == "rabbit": if copy: searchRoot.find("**/ears-long").removeNode() else: searchRoot.find("**/ears-long").hide() elif copy: searchRoot.find("**/ears-short").removeNode() else: searchRoot.find("**/ears-short").hide() if animalType != "rabbit": if copy: searchRoot.find("**/eyes-short").removeNode() else: searchRoot.find("**/eyes-short").hide() if animalType != "dog": if copy: searchRoot.find("**/joint_pupilL_short").removeNode() searchRoot.find("**/joint_pupilR_short").removeNode() else: searchRoot.find("**/joint_pupilL_short").stash() searchRoot.find("**/joint_pupilR_short").stash() if animalType != "rabbit": muzzleParts = searchRoot.findAllMatches("**/muzzle-long*") for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() else: muzzleParts = searchRoot.findAllMatches("**/muzzle-short*") for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() return def __fixHeadShortLong(self, lodName=None, copy=1): animalType = self.getAnimal() headStyle = self.head if lodName == None: searchRoot = self.toon else: searchRoot = self.toon.find("**/" + str(lodName)) if animalType != "duck" and animalType != "horse": if animalType == "rabbit": if copy: searchRoot.find("**/ears-short").removeNode() else: searchRoot.find("**/ears-short").hide() elif copy: searchRoot.find("**/ears-long").removeNode() else: searchRoot.find("**/ears-long").hide() if animalType != "rabbit": if copy: searchRoot.find("**/eyes-long").removeNode() else: searchRoot.find("**/eyes-long").hide() if animalType != "dog": if copy: searchRoot.find("**/joint_pupilL_long").removeNode() searchRoot.find("**/joint_pupilR_long").removeNode() else: searchRoot.find("**/joint_pupilL_long").stash() searchRoot.find("**/joint_pupilR_long").stash() if copy: searchRoot.find("**/head-long").removeNode() searchRoot.find("**/head-front-long").removeNode() else: searchRoot.find("**/head-long").hide() searchRoot.find("**/head-front-long").hide() if animalType != "rabbit": muzzleParts = searchRoot.findAllMatches("**/muzzle-short*") for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() else: muzzleParts = searchRoot.findAllMatches("**/muzzle-long*") for partNum in xrange(0, muzzleParts.getNumPaths()): if copy: muzzleParts.getPath(partNum).removeNode() else: muzzleParts.getPath(partNum).hide() return def __fixHeadShortShort(self, lodName=None, copy=1): if lodName == None: searchRoot = self else: searchRoot = self.toon.find("**/" + str(lodName)) otherParts = searchRoot.findAllMatches("**/*long*") for partNum in xrange(0, otherParts.getNumPaths()): if copy: otherParts.getPath(partNum).removeNode() else: otherParts.getPath(partNum).stash() return def setLODs(self): self.toon.setLODNode() levelOneIn = base.config.GetInt("lod1-in", 20) levelOneOut = base.config.GetInt("lod1-out", 0) levelTwoIn = base.config.GetInt("lod2-in", 80) levelTwoOut = base.config.GetInt("lod2-out", 20) levelThreeIn = base.config.GetInt("lod3-in", 280) levelThreeOut = base.config.GetInt("lod3-out", 80) self.toon.addLOD(1000, levelOneIn, levelOneOut) self.toon.addLOD(500, levelTwoIn, levelTwoOut) self.toon.addLOD(250, levelThreeIn, levelThreeOut) def loadPhaseAnims(self, phaseStr="phase_3", loadFlag=1): if phaseStr == "phase_3": animList = Phase3AnimList elif phaseStr == "phase_3.5": animList = Phase3_5AnimList elif phaseStr == "phase_4": animList = Phase4AnimList elif phaseStr == "phase_5": animList = Phase5AnimList elif phaseStr == "phase_5.5": animList = Phase5_5AnimList elif phaseStr == "phase_6": animList = Phase6AnimList elif phaseStr == "phase_9": animList = Phase9AnimList elif phaseStr == "phase_10": animList = Phase10AnimList elif phaseStr == "phase_12": animList = Phase12AnimList else: self.notify.error("Unknown phase string %s" % phaseStr) for key in LegDict.keys(): for anim in animList: if loadFlag: pass elif anim[0] in LegsAnimDict[key]: if self.legs == key: self.toon.unloadAnims([anim[0]], "legs", None) for key in TorsoDict.keys(): for anim in animList: if loadFlag: pass elif anim[0] in TorsoAnimDict[key]: if self.torso == key: self.toon.unloadAnims([anim[0]], "torso", None) for key in HeadDict.keys(): if key.find("d") >= 0: for anim in animList: if loadFlag: pass elif anim[0] in HeadAnimDict[key]: if self.head == key: self.toon.unloadAnims([anim[0]], "head", None) def renderSnapshot(self): print "Rendering Snapshot..." base.graphicsEngine.renderFrame() base.screenshot(namePrefix="snapshot-render", defaultFilename=1, source=None, imageComment="")
class Toon: notify = DirectNotifyGlobal.directNotify.newCategory("Toon") def __init__(self): self.name = "Flippy" legsAnimDict = {'right-hand-start': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_right-hand-start.bam', 'firehose': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_firehose.bam', 'rotateL-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_rotateL-putt.bam', 'slip-forward': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_slip-forward.bam', 'catch-eatnrun': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_eatnrun.bam', 'tickle': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_tickle.bam', 'water-gun': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_water-gun.bam', 'leverNeutral': 'phase_10/models/char/tt_a_chr_dgs_shorts_legs_leverNeutral.bam', 'swim': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_swim.bam', 'catch-run': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_gamerun.bam', 'sad-neutral': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_sad-neutral.bam', 'pet-loop': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_petloop.bam', 'jump-squat': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_jump-zstart.bam', 'wave': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_wave.bam', 'reel-neutral': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_reelneutral.bam', 'pole-neutral': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_poleneutral.bam', 'bank': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_jellybeanJar.bam', 'scientistGame': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_scientistGame.bam', 'right-hand': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_right-hand.bam', 'lookloop-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_lookloop-putt.bam', 'victory': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_victory-dance.bam', 'lose': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_lose.bam', 'cringe': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_cringe.bam', 'right': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_right.bam', 'headdown-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_headdown-putt.bam', 'conked': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_conked.bam', 'jump': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_jump.bam', 'into-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_into-putt.bam', 'fish-end': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_fishEND.bam', 'running-jump-land': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_leap_zend.bam', 'shrug': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_shrug.bam', 'sprinkle-dust': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_sprinkle-dust.bam', 'hold-bottle': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_hold-bottle.bam', 'takePhone': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_takePhone.bam', 'melt': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_melt.bam', 'pet-start': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_petin.bam', 'look-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_look-putt.bam', 'loop-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_loop-putt.bam', 'good-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_good-putt.bam', 'juggle': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_juggle.bam', 'run': 'phase_3/models/char/tt_a_chr_dgs_shorts_legs_run.bam', 'pushbutton': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_press-button.bam', 'sidestep-right': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_jump-back-right.bam', 'water': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_water.bam', 'right-point-start': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_right-point-start.bam', 'bad-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_bad-putt.bam', 'struggle': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_struggle.bam', 'running-jump': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_running-jump.bam', 'callPet': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_callPet.bam', 'throw': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_pie-throw.bam', 'catch-eatneutral': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_eat_neutral.bam', 'tug-o-war': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_tug-o-war.bam', 'bow': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_bow.bam', 'swing': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_swing.bam', 'climb': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_climb.bam', 'scientistWork': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_scientistWork.bam', 'think': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_think.bam', 'catch-intro-throw': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_gameThrow.bam', 'walk': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_walk.bam', 'down': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_down.bam', 'pole': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_pole.bam', 'periscope': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_periscope.bam', 'duck': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_duck.bam', 'curtsy': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_curtsy.bam', 'jump-land': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_jump-zend.bam', 'loop-dig': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_loop_dig.bam', 'angry': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_angry.bam', 'bored': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_bored.bam', 'swing-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_swing-putt.bam', 'pet-end': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_petend.bam', 'spit': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_spit.bam', 'right-point': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_right-point.bam', 'start-dig': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_into_dig.bam', 'castlong': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_castlong.bam', 'confused': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_confused.bam', 'neutral': 'phase_3/models/char/tt_a_chr_dgs_shorts_legs_neutral.bam', 'jump-idle': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_jump-zhang.bam', 'reel': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_reel.bam', 'slip-backward': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_slip-backward.bam', 'sound': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_shout.bam', 'sidestep-left': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_sidestep-left.bam', 'up': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_up.bam', 'fish-again': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_fishAGAIN.bam', 'cast': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_cast.bam', 'phoneBack': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_phoneBack.bam', 'phoneNeutral': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_phoneNeutral.bam', 'scientistJealous': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_scientistJealous.bam', 'battlecast': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_fish.bam', 'sit-start': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_intoSit.bam', 'toss': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_toss.bam', 'happy-dance': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_happy-dance.bam', 'running-jump-squat': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_leap_zstart.bam', 'teleport': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_teleport.bam', 'sit': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_sit.bam', 'sad-walk': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_losewalk.bam', 'give-props-start': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_give-props-start.bam', 'book': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_book.bam', 'running-jump-idle': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_leap_zhang.bam', 'scientistEmcee': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_scientistEmcee.bam', 'leverPull': 'phase_10/models/char/tt_a_chr_dgs_shorts_legs_leverPull.bam', 'tutorial-neutral': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_tutorial-neutral.bam', 'badloop-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_badloop-putt.bam', 'give-props': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_give-props.bam', 'hold-magnet': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_hold-magnet.bam', 'hypnotize': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_hypnotize.bam', 'left-point': 'phase_3.5/models/char/tt_a_chr_dgs_shorts_legs_left-point.bam', 'leverReach': 'phase_10/models/char/tt_a_chr_dgs_shorts_legs_leverReach.bam', 'feedPet': 'phase_5.5/models/char/tt_a_chr_dgs_shorts_legs_feedPet.bam', 'reel-H': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_reelH.bam', 'applause': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_applause.bam', 'smooch': 'phase_5/models/char/tt_a_chr_dgs_shorts_legs_smooch.bam', 'rotateR-putt': 'phase_6/models/char/tt_a_chr_dgs_shorts_legs_rotateR-putt.bam', 'fish-neutral': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_fishneutral.bam', 'push': 'phase_9/models/char/tt_a_chr_dgs_shorts_legs_push.bam', 'catch-neutral': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_gameneutral.bam', 'left': 'phase_4/models/char/tt_a_chr_dgs_shorts_legs_left.bam'} torsoAnimDict = {'right-hand-start': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_right-hand-start.bam', 'firehose': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_firehose.bam', 'rotateL-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_rotateL-putt.bam', 'slip-forward': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_slip-forward.bam', 'catch-eatnrun': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_eatnrun.bam', 'tickle': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_tickle.bam', 'water-gun': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_water-gun.bam', 'leverNeutral': 'phase_10/models/char/tt_a_chr_dgl_shorts_torso_leverNeutral.bam', 'swim': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_swim.bam', 'catch-run': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_gamerun.bam', 'sad-neutral': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_sad-neutral.bam', 'pet-loop': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_petloop.bam', 'jump-squat': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_jump-zstart.bam', 'wave': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_wave.bam', 'reel-neutral': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_reelneutral.bam', 'pole-neutral': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_poleneutral.bam', 'bank': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_jellybeanJar.bam', 'scientistGame': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_scientistGame.bam', 'right-hand': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_right-hand.bam', 'lookloop-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_lookloop-putt.bam', 'victory': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_victory-dance.bam', 'lose': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_lose.bam', 'cringe': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_cringe.bam', 'right': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_right.bam', 'headdown-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_headdown-putt.bam', 'conked': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_conked.bam', 'jump': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_jump.bam', 'into-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_into-putt.bam', 'fish-end': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_fishEND.bam', 'running-jump-land': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_leap_zend.bam', 'shrug': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_shrug.bam', 'sprinkle-dust': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_sprinkle-dust.bam', 'hold-bottle': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_hold-bottle.bam', 'takePhone': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_takePhone.bam', 'melt': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_melt.bam', 'pet-start': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_petin.bam', 'look-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_look-putt.bam', 'loop-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_loop-putt.bam', 'good-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_good-putt.bam', 'juggle': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_juggle.bam', 'run': 'phase_3/models/char/tt_a_chr_dgl_shorts_torso_run.bam', 'pushbutton': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_press-button.bam', 'sidestep-right': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_jump-back-right.bam', 'water': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_water.bam', 'right-point-start': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_right-point-start.bam', 'bad-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_bad-putt.bam', 'struggle': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_struggle.bam', 'running-jump': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_running-jump.bam', 'callPet': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_callPet.bam', 'throw': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_pie-throw.bam', 'catch-eatneutral': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_eat_neutral.bam', 'tug-o-war': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_tug-o-war.bam', 'bow': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_bow.bam', 'swing': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_swing.bam', 'climb': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_climb.bam', 'scientistWork': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_scientistWork.bam', 'think': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_think.bam', 'catch-intro-throw': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_gameThrow.bam', 'walk': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_walk.bam', 'down': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_down.bam', 'pole': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_pole.bam', 'periscope': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_periscope.bam', 'duck': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_duck.bam', 'curtsy': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_curtsy.bam', 'jump-land': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_jump-zend.bam', 'loop-dig': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_loop_dig.bam', 'angry': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_angry.bam', 'bored': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_bored.bam', 'swing-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_swing-putt.bam', 'pet-end': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_petend.bam', 'spit': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_spit.bam', 'right-point': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_right-point.bam', 'start-dig': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_into_dig.bam', 'castlong': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_castlong.bam', 'confused': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_confused.bam', 'neutral': 'phase_3/models/char/tt_a_chr_dgl_shorts_torso_neutral.bam', 'jump-idle': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_jump-zhang.bam', 'reel': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_reel.bam', 'slip-backward': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_slip-backward.bam', 'sound': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_shout.bam', 'sidestep-left': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_sidestep-left.bam', 'up': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_up.bam', 'fish-again': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_fishAGAIN.bam', 'cast': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_cast.bam', 'phoneBack': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_phoneBack.bam', 'phoneNeutral': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_phoneNeutral.bam', 'scientistJealous': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_scientistJealous.bam', 'battlecast': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_fish.bam', 'sit-start': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_intoSit.bam', 'toss': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_toss.bam', 'happy-dance': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_happy-dance.bam', 'running-jump-squat': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_leap_zstart.bam', 'teleport': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_teleport.bam', 'sit': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_sit.bam', 'sad-walk': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_losewalk.bam', 'give-props-start': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_give-props-start.bam', 'book': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_book.bam', 'running-jump-idle': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_leap_zhang.bam', 'scientistEmcee': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_scientistEmcee.bam', 'leverPull': 'phase_10/models/char/tt_a_chr_dgl_shorts_torso_leverPull.bam', 'tutorial-neutral': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_tutorial-neutral.bam', 'badloop-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_badloop-putt.bam', 'give-props': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_give-props.bam', 'hold-magnet': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_hold-magnet.bam', 'hypnotize': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_hypnotize.bam', 'left-point': 'phase_3.5/models/char/tt_a_chr_dgl_shorts_torso_left-point.bam', 'leverReach': 'phase_10/models/char/tt_a_chr_dgl_shorts_torso_leverReach.bam', 'feedPet': 'phase_5.5/models/char/tt_a_chr_dgl_shorts_torso_feedPet.bam', 'reel-H': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_reelH.bam', 'applause': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_applause.bam', 'smooch': 'phase_5/models/char/tt_a_chr_dgl_shorts_torso_smooch.bam', 'rotateR-putt': 'phase_6/models/char/tt_a_chr_dgl_shorts_torso_rotateR-putt.bam', 'fish-neutral': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_fishneutral.bam', 'push': 'phase_9/models/char/tt_a_chr_dgl_shorts_torso_push.bam', 'catch-neutral': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_gameneutral.bam', 'left': 'phase_4/models/char/tt_a_chr_dgl_shorts_torso_left.bam'} self.toonHead = loader.loadModel('phase_3/models/char/horse-heads-1000.bam') otherParts = self.toonHead.findAllMatches('**/*long*') for partNum in range(0, otherParts.getNumPaths()): if not 'muzzle' in str(otherParts.getPath(partNum)): otherParts.getPath(partNum).removeNode() ntrlMuzzle = self.toonHead.find('**/*muzzle*neutral') otherParts = self.toonHead.findAllMatches('**/*muzzle*') for partNum in range(0, otherParts.getNumPaths()): part = otherParts.getPath(partNum) if part != ntrlMuzzle: otherParts.getPath(partNum).removeNode() self.toonTorso = loader.loadModel('phase_3/models/char/tt_a_chr_dgl_shorts_torso_1000.bam') self.toonLegs = loader.loadModel('phase_3/models/char/tt_a_chr_dgs_shorts_legs_1000.bam') otherParts = self.toonLegs.findAllMatches('**/boots*')+self.toonLegs.findAllMatches('**/shoes') for partNum in range(0, otherParts.getNumPaths()): otherParts.getPath(partNum).removeNode() self.toonActor = Actor({'head':self.toonHead, 'torso':self.toonTorso, 'legs':self.toonLegs}, {'torso':torsoAnimDict, 'legs':legsAnimDict}) self.toonActor.setBlend(frameBlend = True) self.toonActor.attach('head', 'torso', 'def_head') self.toonActor.attach('torso', 'legs', 'joint_hips') gloves = self.toonActor.findAllMatches('**/hands') ears = self.toonActor.findAllMatches('**/*ears*') head = self.toonActor.findAllMatches('**/head-*') sleeves = self.toonActor.findAllMatches('**/sleeves') shirt = self.toonActor.findAllMatches('**/torso-top') shorts = self.toonActor.findAllMatches('**/torso-bot') neck = self.toonActor.findAllMatches('**/neck') arms = self.toonActor.findAllMatches('**/arms') legs = self.toonActor.findAllMatches('**/legs') feet = self.toonActor.findAllMatches('**/feet') self.bodyNodes = [] self.bodyNodes += [gloves] self.bodyNodes += [head, ears] self.bodyNodes += [sleeves, shirt, shorts] self.bodyNodes += [neck, arms, legs, feet] self.bodyNodes[0].setColor(1, 1, 1, 1) self.bodyNodes[1].setColor(0.18, 0.54, 0.34, 1) self.bodyNodes[2].setColor(0.18, 0.54, 0.34, 1) self.bodyNodes[3].setColor(1, 1, 1, 1) self.bodyNodes[4].setColor(1, 1, 1, 1) self.bodyNodes[5].setColor(1, 1, 1, 1) self.bodyNodes[6].setColor(0.18, 0.54, 0.34, 1) self.bodyNodes[7].setColor(0.18, 0.54, 0.34, 1) self.bodyNodes[8].setColor(0.18, 0.54, 0.34, 1) self.bodyNodes[9].setColor(0.18, 0.54, 0.34, 1) topTex = loader.loadTexture('phase_4/maps/ContestfishingVestShirt2.jpg') botTex = loader.loadTexture('phase_4/maps/CowboyShorts1.jpg') sleeveTex = loader.loadTexture('phase_4/maps/ContestfishingVestSleeve1.jpg') self.bodyNodes[3].setTexture(sleeveTex, 1) self.bodyNodes[4].setTexture(topTex, 1) self.bodyNodes[5].setTexture(botTex, 1) self.height = 3.2375 self.runNoise = loader.loadSfx('phase_3.5/audio/sfx/AV_footstep_runloop' + base.sfxExt2) self.runNoise.setLoop(True) self.walkNoise = loader.loadSfx('phase_3.5/audio/sfx/AV_footstep_walkloop' + base.sfxExt2) self.walkNoise.setLoop(True) self.loop('neutral') self.toonActor.reparentTo(render) def loop(self, anim): self.runNoise.stop() self.walkNoise.stop() self.toonActor.loop(anim) if anim == 'run': self.runNoise.play() elif anim == 'walk': self.walkNoise.play() def remove(self): self.toonActor.cleanup() self.toonActor.removeNode() del self
'**/shoes') for partNum in range(0, otherParts.getNumPaths()): otherParts.getPath(partNum).removeNode() duckBody = Actor({ 'head': duckHead, 'torso': duckTorso, 'legs': duckLegs }, { 'torso': torsoAnimDict, 'legs': legsAnimDict }) duckBody.attach('head', 'torso', 'def_head') duckBody.attach('torso', 'legs', 'joint_hips') gloves = duckBody.findAllMatches('**/hands') ears = duckBody.findAllMatches('**/*ears*') head = duckBody.findAllMatches('**/head*') sleeves = duckBody.findAllMatches('**/sleeves') shirt = duckBody.findAllMatches('**/torso-top') shorts = duckBody.findAllMatches('**/torso-bot') neck = duckBody.findAllMatches('**/neck') arms = duckBody.findAllMatches('**/arms') legs = duckBody.findAllMatches('**/legs') feet = duckBody.findAllMatches('**/feet') bodyNodes = [] bodyNodes += [gloves] bodyNodes += [head, ears] bodyNodes += [sleeves, shirt, shorts] bodyNodes += [neck, arms, legs, feet]