def makeLight(self, levelObj): light = EditorGlobals.LightModular(levelObj, self.areaGeometry, drawIcon = False) if levelObj.get('VisZone'): if light: light.setTag('SubLight', levelObj.get('VisZone')) OTPRender.renderReflection(False, light, 'p_light', None) return light
def __init__(self, other=None): self._name = '' try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=0) ShadowCaster.__init__(self) self.__font = OTPGlobals.getInterfaceFont() self.__speechFont = OTPGlobals.getInterfaceFont() self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None self.commonChatFlags = 0 self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__currentDialogue = None self.whitelistChatFlags = 0 self.setBlend( frameBlend=config.GetBool('interpolate-animations', True)) return
def __init__(self, other=None): try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=1) self.setBlend(frameBlend=base.wantSmoothAnims) self.setLODAnimation(base.lodMaxRange, base.lodMinRange, base.lodDelayFactor) ShadowCaster.__init__(self) self.name = '' self.npcType = None self.__font = OTPGlobals.getInterfaceFont() self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) interfaceFont = OTPGlobals.getInterfaceFont() self.nametag.setFont(interfaceFont) self.nametag.setChatFont(interfaceFont) self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None self.commonChatFlags = 0 self.understandable = 1 self.setPlayerType(NametagGlobals.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__chatQuitButton = False self.__currentDialogue = None self.whitelistChatFlags = 0
def __init__(self, name, shadow_model, parent, use_water_bin=True, bin_number=7): self.name = name self.use_water_bin = use_water_bin self.bin_number = bin_number self.shadow_model = shadow_model if self.shadow_model: self.shadow_model.hide(OTPRender.MainCameraBitmask) self.shadow_model.showThrough(OTPRender.EnviroCameraBitmask) if hasattr(base, 'pe'): shadow_spn = SeaPatchNode('water_shadow_spn', base.pe.seaPatch.patch) else: shadow_spn = SeaPatchNode('water_shadow_spn', base.cr.activeWorld.getWater().patch) shadow_spn.setWantColor(0) shadow_spn.setWantUv(0) shadow_spn.setWantNormal(0) shadow_spn.setWantReflect(0) NodePath.__init__(self, shadow_spn) self.shadow_model.reparentTo(self) shadow_spn.collectGeometry() if self.use_water_bin: self.setBin('water', self.bin_number) self.setDepthWrite(0) else: self.setBin('ground', -2) self.setDepthTest(0) self.setLightOff() self.reparentTo(parent) OTPRender.renderReflection(False, self, 'p_water_shadow', None) if hasattr(base, 'pe'): shadow_spn.setEffect( CompassEffect.make(base.pe.seaPatch.patchNP, CompassEffect.PZ)) else: shadow_spn.setEffect( CompassEffect.make(base.cr.activeWorld.getWater().patchNP, CompassEffect.PZ)) if self.use_water_bin: mask = 4294967295L stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask) self.setAttrib(stencil) if not base.useStencils: self.hide()
def __init__(self, other = None): self.name = '' try: self.Avatar_initialized return except: self.Avatar_initialized = 1 Actor.__init__(self, None, None, other, flattenable=0, setFinal=0) ShadowCaster.__init__(self) self.__font = OTPGlobals.getInterfaceFont() self.__speechFont = OTPGlobals.getInterfaceFont() self.soundChatBubble = None self.avatarType = '' self.nametagNodePath = None self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None) self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None self.commonChatFlags = 0 self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 self.__currentDialogue = None self.whitelistChatFlags = 0 self.wantAdminTag = True return
def __init__(self, animationMixer=None): Avatar.Avatar.__init__(self) UsesEffectNode.__init__(self) self.setPickable(0) self.shadowFileName = 'models/misc/drop_shadow' self.nameText = None self.avatarType = None if not SeaMonster.sfx: for name in SeaMonster.SfxNames: SeaMonster.sfx[name] = loadSfx(SeaMonster.SfxNames[name]) OTPRender.renderReflection(False, self, 'p_creature', None) animationMixer = self.AnimationMixer UsesAnimationMixer.__init__(self, animationMixer)
def __init__(self, animationMixer = None): Avatar.Avatar.__init__(self) UsesEffectNode.__init__(self) self.setPickable(0) self.shadowFileName = 'models/misc/drop_shadow' self.nameText = None self.avatarType = None if not SeaMonster.sfx: for name in SeaMonster.SfxNames: SeaMonster.sfx[name] = loadSfx(SeaMonster.SfxNames[name]) OTPRender.renderReflection(False, self, 'p_creature', None) animationMixer = self.AnimationMixer UsesAnimationMixer.__init__(self, animationMixer)
def __init__(self, name, parent_node_path): DirectObject.__init__(self) NodePath.__init__(self, name) self.active = True self.enable = True self.pause = False self.pause_time = 0.0 self.fade = False self.fade_end = False self.fade_start_time = 0.0 self.fade_color_scale = 1.0 self.total_vertices = 0 self.last_update_time = 0.0 self.texture = None self.vertex_list = [] self.frame_list = [] self.parent_node_path = parent_node_path self.previous_matrix = None self.calculate_relative_matrix = False self.playing = False self.continuous_motion_trail = True self.color_scale = 1.0 self.time_window = 1.0 self.sampling_time = 0.0 self.square_t = True self.root_node_path = None self.reparentTo(parent_node_path) self.geom_node = GeomNode('motion_trail') self.geom_node_path = self.attachNewNode(self.geom_node) node_path = self.geom_node_path node_path.setTwoSided(True) OTPRender.setAdditiveEffect(node_path, 'motion_trail') if MotionTrail.task_added == False: taskMgr.add(self.motion_trail_task, MotionTrail.motion_trail_task_name) self.acceptOnce('clientLogout', remove_task) MotionTrail.task_added = True self.relative_to_render = False self.use_nurbs = False self.resolution_distance = 0.5 self.cmotion_trail = CMotionTrail() self.cmotion_trail.setGeomNode(self.geom_node) self.modified_vertices = True if base.config.GetBool('want-python-motion-trails', 0): self.use_python_version = True else: self.use_python_version = False return
def __init__(self, area, zoneId): self.gridNode = NodePath('Grid-' + str(zoneId) + 'Node') OTPRender.renderReflection(False, self.gridNode, 'p_grid', None) lod = LODNode.makeDefaultLod('LodNode') self.lodNode = self.gridNode.attachNewNode(lod) gridDetail = base.gridDetail if gridDetail == 'high': lod.addSwitch(500, 0) lod.addSwitch(1000, 500) lod.addSwitch(1500, 1000) lod.addSwitch(3000, 1500) high = self.lodNode.attachNewNode('High') med = self.lodNode.attachNewNode('Med') low = self.lodNode.attachNewNode('Low') superLow = self.lodNode.attachNewNode('superLow') self.highLodNode = high else: if gridDetail == 'med': lod.addSwitch(750, 0) lod.addSwitch(1500, 750) lod.addSwitch(3000, 1500) high = None med = self.lodNode.attachNewNode('Med') low = self.lodNode.attachNewNode('Low') superLow = self.lodNode.attachNewNode('superLow') self.highLodNode = med else: if gridDetail == 'low': lod.addSwitch(1500, 0) lod.addSwitch(3000, 1500) high = None med = None low = self.lodNode.attachNewNode('Low') superLow = self.lodNode.attachNewNode('Low') self.highLodNode = low else: raise StandardError, 'Invalid grid-detail: %s' % gridDetail low.setLightOff(base.cr.timeOfDayManager.sunLight) low.setLightOff(base.cr.timeOfDayManager.shadowLight) self.children = [high, med, low] if zoneId == PiratesGlobals.FakeZoneId: pos = area.master.getPos() else: pos = area.master.getZoneCellOriginCenter(zoneId) self.gridNode.setPos(pos[0], pos[1], pos[2]) self.gridNode.reparentTo(area.staticGridRoot) return
def __init__(self, area, zoneId): self.gridNode = NodePath('Grid-' + str(zoneId) + 'Node') OTPRender.renderReflection(False, self.gridNode, 'p_grid', None) lod = LODNode.makeDefaultLod('LodNode') self.lodNode = self.gridNode.attachNewNode(lod) gridDetail = base.gridDetail if gridDetail == 'high': lod.addSwitch(500, 0) lod.addSwitch(1000, 500) lod.addSwitch(1500, 1000) lod.addSwitch(3000, 1500) high = self.lodNode.attachNewNode('High') med = self.lodNode.attachNewNode('Med') low = self.lodNode.attachNewNode('Low') superLow = self.lodNode.attachNewNode('superLow') self.highLodNode = high elif gridDetail == 'med': lod.addSwitch(750, 0) lod.addSwitch(1500, 750) lod.addSwitch(3000, 1500) high = None med = self.lodNode.attachNewNode('Med') low = self.lodNode.attachNewNode('Low') superLow = self.lodNode.attachNewNode('superLow') self.highLodNode = med elif gridDetail == 'low': lod.addSwitch(1500, 0) lod.addSwitch(3000, 1500) high = None med = None low = self.lodNode.attachNewNode('Low') superLow = self.lodNode.attachNewNode('Low') self.highLodNode = low else: raise StandardError, 'Invalid grid-detail: %s' % gridDetail low.setLightOff(base.cr.timeOfDayManager.sunLight) low.setLightOff(base.cr.timeOfDayManager.shadowLight) self.children = [ high, med, low] if zoneId == PiratesGlobals.FakeZoneId: pos = area.master.getPos() else: pos = area.master.getZoneCellOriginCenter(zoneId) self.gridNode.setPos(pos[0], pos[1], pos[2]) self.gridNode.reparentTo(area.staticGridRoot)
def __init__(self, cr): DistributedWeapon.DistributedWeapon.__init__(self, cr) self.ship = None self.tutorial = 0 self.prop = None self.baseVel = Vec3(0) self.mouseX = 0 self.mouseY = 0 self.setPos(0, 0, 0) self.moveCannon = 0 self.av = None self.ball = None self.ship = None self.shipId = None self.tubeNP = None self.cgui = None self.numShots = 0 self.grapplingHook = None self.cannonDressingNode = NodePath(ModelNode('dressingNode')) self._cameraState = 'Cannon' self.collisionLists = {} self.listening = False self.skillId = InventoryType.CannonShoot self.reloadTime = 0 self.rechargeTime = 0 self.volley = WeaponGlobals.getAttackVolley(self.skillId, self.getAmmoSkillId()) self.modeFSM = ClassicFSM.ClassicFSM('modeFSM', [ State.State('off', self.enterOff, self.exitOff), State.State('fireCannon', self.enterFireCannon, self.exitFireCannon), State.State('tutorialCutscene', self.enterTutorialCutscene, self.exitTutorialCutscene) ], 'off', 'off') self.modeFSM.enterInitialState() self.aimAITrack = None self.headingNode = NodePath('dummy') OTPRender.renderReflection(False, self, 'p_cannon', None) if not self.emptySound: DistributedPCCannon.emptySound = loadSfx( SoundGlobals.SFX_WEAPON_CANNON_EMPTY) self.fireSubframeCall = None self.__invRequest = None self.shotNum = -1 return
def createNametagIcon(self): if self.nametagIcon or not (self.icon): return None self.nametagIcon = self.getIconParent().attachNewNode('formation-nametagIcon') self.icon.instanceTo(self.nametagIcon) self.nametagIcon.setTag('cam', 'formation-nametag') self.nametagIcon.setFogOff() self.nametagIcon.setLightOff() self.nametagIcon.setPos(0, 0, 650) self.nametagIcon.setBillboardPointEye() self.nametagIcon.setScale(150.0) OTPRender.renderReflection(False, self.nametagIcon, 'p_ship_nametag', None) if base.hideShipNametags: self.hideNametagIcon() self.accept('hide-ship-nametags', self.hideNametagIcon) self.accept('show-ship-nametags', self.showNametagIcon)
def createNametagIcon(self): if self.nametagIcon or not self.icon: return self.nametagIcon = self.getIconParent().attachNewNode( 'formation-nametagIcon') self.icon.instanceTo(self.nametagIcon) self.nametagIcon.setTag('cam', 'formation-nametag') self.nametagIcon.setFogOff() self.nametagIcon.setLightOff() self.nametagIcon.setPos(0, 0, 650) self.nametagIcon.setBillboardPointEye() self.nametagIcon.setScale(150.0) OTPRender.renderReflection(False, self.nametagIcon, 'p_ship_nametag', None) if base.hideShipNametags: self.hideNametagIcon() self.accept('hide-ship-nametags', self.hideNametagIcon) self.accept('show-ship-nametags', self.showNametagIcon) return
def load(self): """ load the hood models and dna storage """ assert (self.notify.debug("load()")) # Load the neighborhood specific models and textures if self.storageDNAFile: loader.loadDNAFile(self.dnaStore, self.storageDNAFile) # Overwrite dna storage with holiday specific models # We might not have a newsManager if we are running in the dev # environment without an AI server. newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() for holiday in holidayIds: for storageFile in self.holidayStorageDNADict.get(holiday, []): loader.loadDNAFile(self.dnaStore, storageFile) if (ToontownGlobals.HALLOWEEN_COSTUMES not in holidayIds) or (not self.spookySkyFile): # Load the sky model so we will have it in memory for the entire hood self.sky = loader.loadModel(self.skyFile) #self.sky.setColorScale(Vec4(Vec3(self.skyLightScale), 1.0)) self.sky.setTag("sky", "Regular") self.sky.setScale(1.0) self.sky.setFogOff() else: self.sky = loader.loadModel(self.spookySkyFile) #self.sky.setColorScale(Vec4(Vec3(self.skyLightScale), 1.0)) self.sky.setTag("sky", "Halloween") if not newsManager: # Load the sky model so we will have it in memory for the entire hood self.sky = loader.loadModel(self.skyFile) self.sky.setTag("sky", "Regular") self.sky.setScale(1.0) #self.sky.setColorScale(Vec4(Vec3(self.skyLightScale), 1.0)) # Normally, fog is turned off for the sky. This will prevent # the sky from being contaminated by the trolley tunnel shadow # if we jump on the trolley. Hoods like DD that require fog # will specifically turn fog on for the sky. self.sky.setFogOff() self.sky.setLightOff() OTPRender.renderShadow(False, self.sky)
def genTextNode(self, parent, satellite=False): if satellite == False and self.hpText: self.hpText.removeNode() self.textNode = self.textGenerator.generate() hpText = parent.attachNewNode(self.textNode) if satellite == False: self.hpText = hpText if satellite: hpText.setScale(self.scale * 0.7) else: hpText.setScale(self.scale) hpText.setBillboardPointEye(3.0) hpText.setBin('fixed', 100) hpText.setDepthWrite(0) hpText.setFogOff() hpText.setLightOff() hpText.setPos(0, 0, 2.0) OTPRender.renderReflection(False, hpText, 'p_text_effect', None) return hpText
def __init__(self, cr): DistributedCreature.DistributedCreature.__init__(self, cr) self.battleCollisionBitmask = PiratesGlobals.WallBitmask | PiratesGlobals.TargetBitmask OTPRender.renderReflection(False, self, 'p_animal', None) self.isFlying = 0 self.flyIval = None self.maxSwingX = 35.0 self.swingCycles = 7 self.stepSwingX = 7.0 self.maxHeight = 50.0 self.heightCycles = 5 self.stepHeight = 10.0 self.stepVelocity = 0.0 self.stepVelStep = 1.0 self.flightCount = 0 self.minFlightCount = 7 self.flightData = (6.0, 20.0) self.flightForward = 20.0 self.flapLoopIval = None self.cawLoopIval = None
def genTextNode(self, parent, satellite = False): if satellite == False and self.hpText: self.hpText.removeNode() self.textNode = self.textGenerator.generate() hpText = parent.attachNewNode(self.textNode) if satellite == False: self.hpText = hpText if satellite: hpText.setScale(self.scale * 0.69999999999999996) else: hpText.setScale(self.scale) hpText.setBillboardPointEye(3.0) hpText.setBin('fixed', 100) hpText.setDepthWrite(0) hpText.setFogOff() hpText.setLightOff() hpText.setPos(0, 0, 2.0) OTPRender.renderReflection(False, hpText, 'p_text_effect', None) return hpText
def __init__(self, cr): DistributedWeapon.DistributedWeapon.__init__(self, cr) self.ship = None self.tutorial = 0 self.prop = None self.baseVel = Vec3(0) self.mouseX = 0 self.mouseY = 0 self.setPos(0, 0, 0) self.moveCannon = 0 self.av = None self.ball = None self.ship = None self.shipId = None self.tubeNP = None self.cgui = None self.numShots = 0 self.grapplingHook = None self.cannonDressingNode = NodePath(ModelNode('dressingNode')) self._cameraState = 'Cannon' self.collisionLists = { } self.listening = False self.skillId = InventoryType.CannonShoot self.reloadTime = 0 self.rechargeTime = 0 self.volley = WeaponGlobals.getAttackVolley(self.skillId, self.getAmmoSkillId()) self.modeFSM = ClassicFSM.ClassicFSM('modeFSM', [ State.State('off', self.enterOff, self.exitOff), State.State('fireCannon', self.enterFireCannon, self.exitFireCannon), State.State('tutorialCutscene', self.enterTutorialCutscene, self.exitTutorialCutscene)], 'off', 'off') self.modeFSM.enterInitialState() self.aimAITrack = None self.headingNode = NodePath('dummy') OTPRender.renderReflection(False, self, 'p_cannon', None) if not self.emptySound: DistributedPCCannon.emptySound = loadSfx(SoundGlobals.SFX_WEAPON_CANNON_EMPTY) self.fireSubframeCall = None self._DistributedPCCannon__invRequest = None self.shotNum = -1
def __init__(self, name, shadow_model, parent, use_water_bin = True, bin_number = 7): self.name = name self.use_water_bin = use_water_bin self.bin_number = bin_number self.shadow_model = shadow_model if self.shadow_model: self.shadow_model.hide(OTPRender.MainCameraBitmask) self.shadow_model.showThrough(OTPRender.EnviroCameraBitmask) if hasattr(base, 'pe'): shadow_spn = SeaPatchNode('water_shadow_spn', base.pe.seaPatch.patch) else: shadow_spn = SeaPatchNode('water_shadow_spn', base.cr.activeWorld.getWater().patch) shadow_spn.setWantColor(0) shadow_spn.setWantUv(0) shadow_spn.setWantNormal(0) shadow_spn.setWantReflect(0) NodePath.__init__(self, shadow_spn) self.shadow_model.reparentTo(self) shadow_spn.collectGeometry() if self.use_water_bin: self.setBin('water', self.bin_number) self.setDepthWrite(0) else: self.setBin('ground', -2) self.setDepthTest(0) self.setLightOff() self.reparentTo(parent) OTPRender.renderReflection(False, self, 'p_water_shadow', None) if hasattr(base, 'pe'): shadow_spn.setEffect(CompassEffect.make(base.pe.seaPatch.patchNP, CompassEffect.PZ)) else: shadow_spn.setEffect(CompassEffect.make(base.cr.activeWorld.getWater().patchNP, CompassEffect.PZ)) if self.use_water_bin: mask = 0xFFFFFFFFL stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask) self.setAttrib(stencil) if not base.useStencils: self.hide()
def loadParticleFile(name): global particleSearchPath if particleSearchPath == None: particleSearchPath = DSearchPath() if AppRunnerGlobal.appRunner: # In the web-publish runtime, it will always be here: particleSearchPath.appendDirectory( Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/etc')) else: # In other environments, including the dev environment, look here: basePath = os.path.expandvars('$TOONTOWN') or './toontown' particleSearchPath.appendDirectory( Filename.fromOsSpecific(basePath + '/src/battle')) particleSearchPath.appendDirectory( Filename.fromOsSpecific(basePath + '/src/safezone')) particleSearchPath.appendDirectory(Filename('phase_3.5/etc')) particleSearchPath.appendDirectory(Filename('phase_4/etc')) particleSearchPath.appendDirectory(Filename('phase_5/etc')) particleSearchPath.appendDirectory(Filename('phase_8/etc')) particleSearchPath.appendDirectory(Filename('phase_9/etc')) particleSearchPath.appendDirectory(Filename('.')) pfile = Filename(name) found = vfs.resolveFilename(pfile, particleSearchPath) if not found: notify.warning('loadParticleFile() - no path: %s' % name) return notify.debug('Loading particle file: %s' % pfile) effect = ParticleEffect() # print("particle filename = ", pfile.getFullpath()) effect.loadConfig(pfile) # Don't render shadows on any particles. There are some particles that are # non-triangles (like points or lines). The shadow render shader does not # currently handle non-triangle geometry. OTPRender.renderShadow(False, effect) return effect
def __init__(self, parentNP=render, reflection=None, todMgr=None): Water.__init__(self, 'Sea') if base.win.getFbProperties().getStencilBits() == 0: self.use_water_bin = False self.p3 = Point3() self.parentNP = parentNP self.followWater = base.config.GetBool('ships-follow-water', 1) self.damper = 0.2 * 180.0 / math.pi self.floats = {} self.floatmasses = {} self.patch = SeaPatchRoot() self.patch.setSeaLevel(0) self.hidden = False self.usingFlatWater = False if base.camera: self.setCenter(base.camera) self.setAnchor(render) patchNode = SeaPatchNode('seapatch', self.patch) patchNode.setWantReflect(0) self.patchNP = NodePath(patchNode) self.patchNP.setColorScale(0.15, 0.4, 0.5, 1.0) self.patchNP.setTwoSided(True) self.patchNP.hide() shader_file_path = None if base.config.GetBool('want-shaders', 1): if base.win: if base.win.getGsg(): if base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20: patchNode.setWantColor(0) shader_directory = 'models/sea/' shader_file_name_array = [ '', 'water008_11.cg', 'water008_20.cg', 'water008_2X.cg'] shader_model = base.win.getGsg().getShaderModel() maximum_shader_model = len(shader_file_name_array) - 1 if shader_model > maximum_shader_model: shader_model = maximum_shader_model file_name = shader_file_name_array[shader_model] shader_file_path = shader_directory + file_name self.shader = loader.loadShader(shader_file_path) if self.shader: pass if self.shader: if base.win.getGsg().getShaderModel() == GraphicsStateGuardian.SM20: self.seamodel = loader.loadModel('models/sea/SeaPatch34') else: self.seamodel = loader.loadModel('models/sea/SeaPatch31') else: if base.options.getTerrainDetailSetting() == 0: self.seamodel = loader.loadModel('models/sea/pir_m_are_wld_seaPatch_low') else: self.seamodel = loader.loadModel('models/sea/SeaPatch31') self.seamodel.setScale(2, 1, 1) self.seamodel.flattenMedium() mask = 4294967295L if self.use_water_bin: self.seamodel.setBin('water', 0) stencil = StencilAttrib.makeWithClear(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask, 1, 0) self.seamodel.setAttrib(stencil) else: self.seamodel.setBin('background', 200) self.seamodel.hide(OTPRender.MainCameraBitmask) self.seamodel.showThrough(OTPRender.EnviroCameraBitmask) self.reflectStage = None if False: self.model = loader.loadModel('models/misc/smiley') self.model.reparentTo(render) self.model.setPos(0.0, 50.0, 10.0) self.model.setHpr(0.0, 180.0, 0.0) self.model.setBin('water', 100) self.model2 = loader.loadModel('models/misc/smiley') self.model2.reparentTo(render) self.model2.setPos(10.0, 50.0, 15.0) self.model2.setHpr(180.0, 0.0, 0.0) self.model2.setBin('water', 50) self.model3 = loader.loadModel('models/misc/smiley') self.model3.reparentTo(render) self.model3.setPos(-10.0, 50.0, 15.0) self.model3.setHpr(0.0, 0.0, 0.0) self.model3.setBin('water', 50) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask) self.model.setAttrib(stencil) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 0, mask, mask) self.model3.setAttrib(stencil) self.flatSea = self.seamodel.find('**/flatsea') flat2 = self.flatSea.copyTo(self.flatSea) flat2.setScale(2, 2, 1) flat2.setZ(-4) flat4 = self.flatSea.copyTo(self.flatSea) flat4.setScale(4, 4, 1) flat4.setZ(-8) if not self.flatSea.isEmpty(): self.flatSea.setTag('flat_sea', 'true') self.flatSea.setPos(0, 0, -1) if False: self.flatSea.setScale(1.3) if self.use_water_bin: self.flatSea.setDepthWrite(0) self.flatSea.flattenStrong() if self.use_water_bin: self.patchNP.setBin('water', 10) else: self.patchNP.setBin('ground', -10) self.todMgr = todMgr if self.getTodMgr(): self.patchNP.setLightOff() self.patchNP.setLight(self.getTodMgr().alight) seaMin, seaMax = self.seamodel.getTightBounds() seaDelta = seaMax - seaMin cp = CollisionPolygon(Point3(-1.0, -1.0, 0), Point3(1.0, -1.0, 0), Point3(1.0, 1.0, 0), Point3(-1.0, 1.0, 0)) cNode = CollisionNode('seaCollision') cNode.setCollideMask(PiratesGlobals.TargetBitmask) cNode.addSolid(cp) cNodePath = NodePath(cNode) cNodePath.reparentTo(self.seamodel) cNodePath.setScale(Vec3(seaDelta).length()) cNodePath.setZ(-3) cNodePath.setTag('objType', str(PiratesGlobals.COLL_SEA)) cNodePath.reparentTo(self.parentNP) self.cNodePath = cNodePath ccPlane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) ccNode = CollisionNode('seaCamCollision') ccNode.setCollideMask(PiratesGlobals.CameraBitmask) ccNode.addSolid(ccPlane) ccNodePath = NodePath(ccNode) ccNodePath.reparentTo(self.seamodel) self.ccNodePath = ccNodePath self.seamodel.reparentTo(self.patchNP) self.patchNP.flattenLight() patchNode.collectGeometry() self.enabled = False self.enable() if self.use_alpha_map: if self.enable_alpha_map: self.patchNP.setTransparency(1) alpha_test_attrib = AlphaTestAttrib.make(RenderAttrib.MAlways, 0) self.patchNP.setAttrib(alpha_test_attrib, 100) if self.water_panel != None: self.water_panel.setSeaPatch(self) if self.enable_parameter_keys: def showSeaPatchPanel(): from pirates.seapatch import SeaPatchPanel self.spp = SeaPatchPanel.SeaPatchPanel() self.spp.setPatch(self) self.accept('shift-5', showSeaPatchPanel) self.setting_0() self.patchNP.setTransparency(0) buffer_width = 512 buffer_height = 512 self.texture_extension = '.jpg' if self.shader: self.seamodel.setShader(self.shader) self.seamodel.setFogOff() if self.use_alpha_map: self.patchNP.setTransparency(1) self.base_texture = loader.loadTexture('maps/oceanWater2' + self.texture_extension) self.texture_d = self.base_texture.loadRelated(InternalName.make('-d')) self.texture_n = self.base_texture.loadRelated(InternalName.make('-n')) self.texture_bb = self.base_texture.loadRelated(InternalName.make('-bb')) self.setting_0() self.water_r = 77 self.water_g = 128 self.water_b = 179 self.water_a = 255 self.set_water_color() default_water_color_texture_filename = 'maps/ocean_color_1' + self.texture_extension default_water_alpha_texture_filename = 'maps/default_inv_alpha' + self.texture_extension self.set_water_color_texture(default_water_color_texture_filename) self.set_water_alpha_texture(default_water_alpha_texture_filename) if self.enable_water_panel: self.water_panel.set_texture(default_water_color_texture_filename) self.water_panel.set_shader(shader_file_path) self.reflection = True and reflection and reflection else: self.reflection = Reflection('seapatch', buffer_width, buffer_height, render, Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) self.reflection_enabled() and self.reflection_on() else: self.reflection_off() self.reflection.reflectShowThroughOnly(self.reflect_show_through_only) self.seamodel.setShaderInput(self.reflectiontexture_name, self.reflection.reflection_texture) OTPRender.renderReflection(False, self.patchNP, 'p_ocean_water', None) else: self.reflection_factor = 0.0 self.set_reflection_parameters_np() if not self.shader: self.accept('timeOfDayChange', self._timeChange) if self.reflection: self.reflection.createCard('water', 6) self.setting_0() self.reflection_factor = 0.2 self.set_reflection_parameters_np() if False: default_water_color_texture_filename = 'maps/ocean_color_1' + self.texture_extension self.set_water_color_texture(default_water_color_texture_filename) self.setup_color_map() self.create_interface() self.patchNP.reparentTo(self.parentNP) self.accept('grid-detail-changed', self.updateWater) return
def __init__(self, cr): DistributedCreature.DistributedCreature.__init__(self, cr) self.battleCollisionBitmask = PiratesGlobals.WallBitmask | PiratesGlobals.TargetBitmask OTPRender.renderReflection(False, self, "p_animal", None)
def __init__(self, cr): DistributedCreature.DistributedCreature.__init__(self, cr) self.battleCollisionBitmask = PiratesGlobals.WallBitmask | PiratesGlobals.TargetBitmask OTPRender.renderReflection(False, self, 'p_animal', None)
def setupReflection(self): OTPRender.renderReflection(False, self, 'p_creature', None)
def __init__(self, swamp_model_file_path, parentNP=render, reflection=None, input_swamp_model=None, input_shader_file_path=None, input_water_color=None): if input_swamp_model: swamp_name = 'Swamp I' else: swamp_name = 'Swamp' Water.__init__(self, swamp_name) self.parentNP = parentNP self.swamp_model = input_swamp_model if input_swamp_model: self.seamodel = input_swamp_model self.parentNP = input_swamp_model.getParent() self.patchNP = NodePath(self.seamodel) elif swamp_model_file_path: self.seamodel = loader.loadModel(swamp_model_file_path) else: self.swampmodel = loader.loadModel('models/swamp/SwampA') self.swampmodel.reparentTo(self.parentNP) self.swampmodel.setPos(0.0, 0.0, -1.0) self.seamodel = loader.loadModel('models/swamp/swampA_water') self.patchNP = NodePath(self.seamodel) self.patchNP.reparentTo(self.parentNP) self.hidden = False mask = 0xFFFFFFFFL if self.use_water_bin: self.seamodel.setBin('water', 1) stencil = StencilAttrib.make(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask) self.seamodel.setAttrib(stencil) else: self.seamodel.setBin('background', 200) self.reflectStage = None if False: self.model = loader.loadModel('models/misc/smiley') self.model.reparentTo(render) self.model.setPos(0.0, 50.0, 10.0) self.model.setHpr(0.0, 180.0, 0.0) self.model.setBin('water', 100) self.model2 = loader.loadModel('models/misc/smiley') self.model2.reparentTo(render) self.model2.setPos(10.0, 50.0, 15.0) self.model2.setHpr(180.0, 0.0, 0.0) self.model2.setBin('water', 50) self.model3 = loader.loadModel('models/misc/smiley') self.model3.reparentTo(render) self.model3.setPos(-10.0, 50.0, 15.0) self.model3.setHpr(0.0, 0.0, 0.0) self.model3.setBin('water', 50) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask) self.model.setAttrib(stencil) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 0, mask, mask) self.model3.setAttrib(stencil) if self.use_water_bin: self.patchNP.setBin('water', 10) else: self.patchNP.setBin('ground', -10) try: self.todMgr = base.cr.timeOfDayManager except: self.todMgr = None if self.todMgr: self.patchNP.setLightOff() self.patchNP.setLight(self.todMgr.alight) (seaMin, seaMax) = self.seamodel.getTightBounds() seaDelta = seaMax - seaMin cp = CollisionPolygon(Point3(-1.0, -1.0, 0), Point3(1.0, -1.0, 0), Point3(1.0, 1.0, 0), Point3(-1.0, 1.0, 0)) cNode = CollisionNode('seaCollision') cNode.setCollideMask(PiratesGlobals.TargetBitmask) cNode.addSolid(cp) cNodePath = self.parentNP.attachNewNode(cNode) cNodePath.reparentTo(self.seamodel) cNodePath.setScale(Vec3(seaDelta).length()) cNodePath.setZ(3) cNodePath.setTag('objType', str(PiratesGlobals.COLL_SEA)) self.cNodePath = cNodePath ccPlane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) ccNode = CollisionNode('seaCamCollision') ccNode.setCollideMask(PiratesGlobals.CameraBitmask) ccNode.addSolid(ccPlane) ccNodePath = self.parentNP.attachNewNode(ccNode) ccNodePath.reparentTo(self.seamodel) self.ccNodePath = ccNodePath self.enabled = False self.enable() self.setting_0() if input_water_color: self.water_r = input_water_color[0] self.water_g = input_water_color[1] self.water_b = input_water_color[2] self.water_a = input_water_color[3] else: self.water_r = 33 self.water_g = 43 self.water_b = 38 self.water_a = 255 self.set_water_color() self.reflection_factor = 0.34000000000000002 self.set_reflection_parameters_np() if self.use_alpha_map: if self.enable_alpha_map: self.patchNP.setTransparency(1) if self.water_panel != None: self.water_panel.setSeaPatch(self) if input_shader_file_path == None: shader_file_path = 'models/swamps/swamp002_2X.cg' else: shader_file_path = input_shader_file_path if base.config.GetBool( 'want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg( ).getShaderModel() >= GraphicsStateGuardian.SM20: self.shader = loader.loadShader(shader_file_path) if self.shader != None: self.seamodel.setShader(self.shader) self.seamodel.setFogOff() self.setting_0() if input_water_color: self.water_r = input_water_color[0] self.water_g = input_water_color[1] self.water_b = input_water_color[2] self.water_a = input_water_color[3] else: self.water_r = 33 self.water_g = 43 self.water_b = 38 self.water_a = 255 self.set_water_color() self.reflection_factor = 0.34000000000000002 self.set_reflection_parameters_np() if self.use_alpha_map: self.patchNP.setTransparency(1) self.texture_extension = '.jpg' default_water_color_texture_filename = 'maps/ocean_color_1' + self.texture_extension default_water_alpha_texture_filename = 'maps/default_inv_alpha' + self.texture_extension if swamp_model_file_path: if False: self.base_texture = loader.loadTexture( 'maps/oceanWater2' + self.texture_extension) self.texture_d = self.base_texture.loadRelated( InternalName.make('-d')) self.texture_n = self.base_texture.loadRelated( InternalName.make('-n')) self.texture_bb = self.base_texture.loadRelated( InternalName.make('-bb')) else: swamp_texture = self.seamodel.findTexture('*') self.set_water_color_texture( default_water_color_texture_filename, True, swamp_texture) if False: card_x_size = 0.5 card_y_size = 0.5 card = CardMaker('test_texture_card') card.setFrame(-card_x_size, card_x_size, -card_y_size, card_y_size) card_node_path = NodePath(card.generate()) card_node_path.setTexture(swamp_texture, 1) card_node_path.node().setBounds( OmniBoundingVolume()) card_node_path.node().setFinal(1) card_node_path.reparentTo(render2d) self.texture_d = loader.loadTexture( 'maps/oceanWater2-d' + self.texture_extension) self.texture_n = loader.loadTexture( 'maps/oceanWater2-n' + self.texture_extension) self.texture_bb = loader.loadTexture( 'maps/oceanWater2-bb' + self.texture_extension) self.texture_low2 = loader.loadTexture( 'maps/oceanWater2-low2' + self.texture_extension) self.seamodel.setShaderInput('d', self.texture_d) self.seamodel.setShaderInput('n', self.texture_n) self.seamodel.setShaderInput('bb', self.texture_bb) self.seamodel.setShaderInput('low2', self.texture_low2) self.set_water_alpha_texture( default_water_alpha_texture_filename) else: self.texture_d = loader.loadTexture('maps/oceanWater2-d' + self.texture_extension) self.texture_n = loader.loadTexture('maps/oceanWater2-n' + self.texture_extension) self.texture_bb = loader.loadTexture( 'maps/oceanWater2-bb' + self.texture_extension) self.texture_low2 = loader.loadTexture( 'maps/oceanWater2-low2' + self.texture_extension) self.seamodel.setShaderInput('d', self.texture_d) self.seamodel.setShaderInput('n', self.texture_n) self.seamodel.setShaderInput('bb', self.texture_bb) self.seamodel.setShaderInput('low2', self.texture_low2) self.set_water_color_texture( default_water_color_texture_filename) self.set_water_alpha_texture( default_water_alpha_texture_filename) if self.enable_water_panel: self.water_panel.set_texture( default_water_color_texture_filename) self.water_panel.set_shader(shader_file_path) buffer_width = 512 buffer_height = 512 if True: if reflection: self.reflection = reflection else: self.reflection = Reflection( 'swamp', buffer_width, buffer_height, render, Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) if self.reflection_enabled(): self.reflection_on() else: self.reflection_off() self.seamodel.setShaderInput('reflectiontexture', self.reflection.reflection_texture) OTPRender.renderReflection(False, self.patchNP, 'p_swamp_water', None) else: self.reflection_factor = 0.0 self.set_reflection_parameters() if not self.shader: if True: self.reflection.createCard('water', 6) self.setting_0() self.reflection_factor = 0.34000000000000002 self.set_reflection_parameters_np() self.create_interface()
def setupReflection(self): OTPRender.renderReflection(False, self, 'p_creature', None) return
def setupReflection(self): OTPRender.renderReflection(True, self, 'grabber', None)
def __init__(self, swamp_model_file_path, parentNP = render, reflection = None, input_swamp_model = None, input_shader_file_path = None, input_water_color = None): if input_swamp_model: swamp_name = 'Swamp I' else: swamp_name = 'Swamp' Water.__init__(self, swamp_name) self.parentNP = parentNP self.swamp_model = input_swamp_model if input_swamp_model: self.seamodel = input_swamp_model self.parentNP = input_swamp_model.getParent() self.patchNP = NodePath(self.seamodel) elif swamp_model_file_path: self.seamodel = loader.loadModel(swamp_model_file_path) else: self.swampmodel = loader.loadModel('models/swamp/SwampA') self.swampmodel.reparentTo(self.parentNP) self.swampmodel.setPos(0.0, 0.0, -1.0) self.seamodel = loader.loadModel('models/swamp/swampA_water') self.patchNP = NodePath(self.seamodel) self.patchNP.reparentTo(self.parentNP) self.hidden = False mask = 0xFFFFFFFFL if self.use_water_bin: self.seamodel.setBin('water', 1) stencil = StencilAttrib.make(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask) self.seamodel.setAttrib(stencil) else: self.seamodel.setBin('background', 200) self.reflectStage = None if False: self.model = loader.loadModel('models/misc/smiley') self.model.reparentTo(render) self.model.setPos(0.0, 50.0, 10.0) self.model.setHpr(0.0, 180.0, 0.0) self.model.setBin('water', 100) self.model2 = loader.loadModel('models/misc/smiley') self.model2.reparentTo(render) self.model2.setPos(10.0, 50.0, 15.0) self.model2.setHpr(180.0, 0.0, 0.0) self.model2.setBin('water', 50) self.model3 = loader.loadModel('models/misc/smiley') self.model3.reparentTo(render) self.model3.setPos(-10.0, 50.0, 15.0) self.model3.setHpr(0.0, 0.0, 0.0) self.model3.setBin('water', 50) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask) self.model.setAttrib(stencil) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 0, mask, mask) self.model3.setAttrib(stencil) if self.use_water_bin: self.patchNP.setBin('water', 10) else: self.patchNP.setBin('ground', -10) try: self.todMgr = base.cr.timeOfDayManager except: self.todMgr = None if self.todMgr: self.patchNP.setLightOff() self.patchNP.setLight(self.todMgr.alight) (seaMin, seaMax) = self.seamodel.getTightBounds() seaDelta = seaMax - seaMin cp = CollisionPolygon(Point3(-1.0, -1.0, 0), Point3(1.0, -1.0, 0), Point3(1.0, 1.0, 0), Point3(-1.0, 1.0, 0)) cNode = CollisionNode('seaCollision') cNode.setCollideMask(PiratesGlobals.TargetBitmask) cNode.addSolid(cp) cNodePath = self.parentNP.attachNewNode(cNode) cNodePath.reparentTo(self.seamodel) cNodePath.setScale(Vec3(seaDelta).length()) cNodePath.setZ(3) cNodePath.setTag('objType', str(PiratesGlobals.COLL_SEA)) self.cNodePath = cNodePath ccPlane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) ccNode = CollisionNode('seaCamCollision') ccNode.setCollideMask(PiratesGlobals.CameraBitmask) ccNode.addSolid(ccPlane) ccNodePath = self.parentNP.attachNewNode(ccNode) ccNodePath.reparentTo(self.seamodel) self.ccNodePath = ccNodePath self.enabled = False self.enable() self.setting_0() if input_water_color: self.water_r = input_water_color[0] self.water_g = input_water_color[1] self.water_b = input_water_color[2] self.water_a = input_water_color[3] else: self.water_r = 33 self.water_g = 43 self.water_b = 38 self.water_a = 255 self.set_water_color() self.reflection_factor = 0.34000000000000002 self.set_reflection_parameters_np() if self.use_alpha_map: if self.enable_alpha_map: self.patchNP.setTransparency(1) if self.water_panel != None: self.water_panel.setSeaPatch(self) if input_shader_file_path == None: shader_file_path = 'models/swamps/swamp002_2X.cg' else: shader_file_path = input_shader_file_path if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20: self.shader = loader.loadShader(shader_file_path) if self.shader != None: self.seamodel.setShader(self.shader) self.seamodel.setFogOff() self.setting_0() if input_water_color: self.water_r = input_water_color[0] self.water_g = input_water_color[1] self.water_b = input_water_color[2] self.water_a = input_water_color[3] else: self.water_r = 33 self.water_g = 43 self.water_b = 38 self.water_a = 255 self.set_water_color() self.reflection_factor = 0.34000000000000002 self.set_reflection_parameters_np() if self.use_alpha_map: self.patchNP.setTransparency(1) self.texture_extension = '.jpg' default_water_color_texture_filename = 'maps/ocean_color_1' + self.texture_extension default_water_alpha_texture_filename = 'maps/default_inv_alpha' + self.texture_extension if swamp_model_file_path: if False: self.base_texture = loader.loadTexture('maps/oceanWater2' + self.texture_extension) self.texture_d = self.base_texture.loadRelated(InternalName.make('-d')) self.texture_n = self.base_texture.loadRelated(InternalName.make('-n')) self.texture_bb = self.base_texture.loadRelated(InternalName.make('-bb')) else: swamp_texture = self.seamodel.findTexture('*') self.set_water_color_texture(default_water_color_texture_filename, True, swamp_texture) if False: card_x_size = 0.5 card_y_size = 0.5 card = CardMaker('test_texture_card') card.setFrame(-card_x_size, card_x_size, -card_y_size, card_y_size) card_node_path = NodePath(card.generate()) card_node_path.setTexture(swamp_texture, 1) card_node_path.node().setBounds(OmniBoundingVolume()) card_node_path.node().setFinal(1) card_node_path.reparentTo(render2d) self.texture_d = loader.loadTexture('maps/oceanWater2-d' + self.texture_extension) self.texture_n = loader.loadTexture('maps/oceanWater2-n' + self.texture_extension) self.texture_bb = loader.loadTexture('maps/oceanWater2-bb' + self.texture_extension) self.texture_low2 = loader.loadTexture('maps/oceanWater2-low2' + self.texture_extension) self.seamodel.setShaderInput('d', self.texture_d) self.seamodel.setShaderInput('n', self.texture_n) self.seamodel.setShaderInput('bb', self.texture_bb) self.seamodel.setShaderInput('low2', self.texture_low2) self.set_water_alpha_texture(default_water_alpha_texture_filename) else: self.texture_d = loader.loadTexture('maps/oceanWater2-d' + self.texture_extension) self.texture_n = loader.loadTexture('maps/oceanWater2-n' + self.texture_extension) self.texture_bb = loader.loadTexture('maps/oceanWater2-bb' + self.texture_extension) self.texture_low2 = loader.loadTexture('maps/oceanWater2-low2' + self.texture_extension) self.seamodel.setShaderInput('d', self.texture_d) self.seamodel.setShaderInput('n', self.texture_n) self.seamodel.setShaderInput('bb', self.texture_bb) self.seamodel.setShaderInput('low2', self.texture_low2) self.set_water_color_texture(default_water_color_texture_filename) self.set_water_alpha_texture(default_water_alpha_texture_filename) if self.enable_water_panel: self.water_panel.set_texture(default_water_color_texture_filename) self.water_panel.set_shader(shader_file_path) buffer_width = 512 buffer_height = 512 if True: if reflection: self.reflection = reflection else: self.reflection = Reflection('swamp', buffer_width, buffer_height, render, Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) if self.reflection_enabled(): self.reflection_on() else: self.reflection_off() self.seamodel.setShaderInput('reflectiontexture', self.reflection.reflection_texture) OTPRender.renderReflection(False, self.patchNP, 'p_swamp_water', None) else: self.reflection_factor = 0.0 self.set_reflection_parameters() if not self.shader: if True: self.reflection.createCard('water', 6) self.setting_0() self.reflection_factor = 0.34000000000000002 self.set_reflection_parameters_np() self.create_interface()
def setupReflection(self): OTPRender.renderReflection(True, self, 'grabber', None) return
def __init__(self, other=None): """ Create the toon, suit, or char specified by the dna array """ self.name = "" # name is used in debugPrint. assert self.debugPrint("Avatar()") try: self.Avatar_initialized return except: self.Avatar_initialized = 1 # create an empty actor to add parts to Actor.__init__(self, None, None, other, flattenable = 0, setFinal = 1) ShadowCaster.__init__(self) # The default font. self.__font = OTPGlobals.getInterfaceFont() self.soundChatBubble = None # Holds Type of Avatar self.avatarType = "" self.nametagNodePath = None # Set up a nametag (actually, a group of nametags, # including a Nametag2d and a Nametag3d) for the avatar. # The nametag won't be visible until it is managed, which # will happen during addActive(). self.__nameVisible = 1 self.nametag = NametagGroup() self.nametag.setAvatar(self) self.nametag.setFont(OTPGlobals.getInterfaceFont()) self.nametag2dContents = Nametag.CName | Nametag.CSpeech # nametag2dDist is changed only by DistributedAvatar. self.nametag2dDist = Nametag.CName | Nametag.CSpeech self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech self.nametag3d = self.attachNewNode('nametag3d') self.nametag3d.setTag('cam', 'nametag') self.nametag3d.setLightOff() #Accept ambient lighting changes if self.ManagesNametagAmbientLightChanged: self.acceptNametagAmbientLightChange() # do not display in reflections OTPRender.renderReflection (False, self.nametag3d, 'otp_avatar_nametag', None) # But do show in shadows, except for the nametag. self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask) self.nametag3d.hide(OTPRender.ShadowCameraBitmask) self.collTube = None self.battleTube = None # set some initial values self.scale = 1.0 self.nametagScale = 1.0 self.height = 0.0 self.battleTubeHeight = 0.0 self.battleTubeRadius = 0.0 self.style = None # commonChatFlags is a bitmask that may include the CommonChat # and SuperChat bits. self.commonChatFlags = 0 # This is either CCNonPlayer, CCSuit, or CCNormal, # according to whether there's a human behind the avatar # or not. This determines the color nametag that is # assigned, as well as whether chat messages from this # avatar will be garbled. self.understandable = 1 self.setPlayerType(NametagGroup.CCNormal) self.ghostMode = 0 # Page chat private vars self.__chatParagraph = None self.__chatMessage = None self.__chatFlags = 0 self.__chatPageNumber = None self.__chatAddressee = None self.__chatDialogueList = [] self.__chatSet = 0 self.__chatLocal = 0 # Record current dialogue so it can be interrupted the # next time the avatar talks self.__currentDialogue = None # since whiteListChatFlags is not a required field, init it just in case self.whitelistChatFlags = 0
def setRenderReflection(self): OTPRender.renderReflection(self.renderReflection, self, 'p_biped', None)
def createObject(self, object, parent, parentUid, objKey, dynamic, fileName = None, actualParentObj = None): objType = WorldCreatorBase.WorldCreatorBase.createObject(self, object, parent, parentUid, objKey, dynamic, fileName = fileName) if not objType: return (None, None) newObj = None objParent = None parentDoId = base.cr.uidMgr.getDoId(parentUid) if parentDoId: objParent = base.cr.getDo(parentDoId) if not objParent: pass if dynamic: objectCat = self.findObjectCategory(objType) if objType == 'Jack Sparrow Standin' and base.config.GetBool('want-npcs', 1) is 1: newObj = self.createJackSparrowStandin(object, objKey, objParent) elif objectCat == 'PROP_OBJ' or objectCat == 'BUILDING_OBJ': if objType == 'Light - Dynamic': light = objParent.builder.createDynamicLight(object, objParent) if light: base.cr.uidMgr.uid2obj[objKey] = light objParent.builder.addLight(light) OTPRender.renderReflection(False, light, 'p_light', None) elif objParent: if object.has_key('Color'): if not object.has_key('Visual'): object['Visual'] = { } if not object['Visual'].has_key('Color'): object['Visual']['Color'] = object['Color'] self.propNum += 1 newObj = objParent.builder.addChildObj(object, objKey, altParent = actualParentObj, actualParentObj = actualParentObj) if newObj: base.cr.uidMgr.uid2obj[objKey] = newObj if objType in ('Pier', 'Dinghy'): OTPRender.renderReflection(True, newObj, 'p_pier', None) elif objType == 'Cell Portal Area': newObj = objParent.builder.addChildObj(object, objKey) elif objType == 'Event Sphere': newObj = self.addEventSphere(object, objParent) elif objType == 'Port Collision Sphere': pos = object.get('Pos', Point3(0, 0, 0)) radius = object.get('Scale', VBase3(500))[0] elif objType == 'Location Sphere': if objParent: newObj = self.addLocationSphere(objKey, object, objParent, parentUid) if objType == 'Cutscene Origin Node': if objParent: pos = object['Pos'] hpr = object['Hpr'] name = object['CutsceneId'] node = objParent.attachNewNode(ModelNode(name)) node.node().setPreserveTransform(ModelNode.PTLocal) node.setPosHpr(pos, hpr) self.cr.activeWorld.addCutsceneOriginNode(node, name) newObj = node elif objType == 'Effect Node': if objParent: pos = object['Pos'] hpr = object['Hpr'] if object.has_key('Scale'): scale = object['Scale'] else: scale = Point3(1.0, 1.0, 1.0) name = object['EffectName'] node = objParent.attachNewNode(ModelNode(name)) node.node().setPreserveTransform(ModelNode.PTLocal) node.setPosHprScale(pos, hpr, scale) newObj = node elif objType == 'Dinghy': newObj = objParent.builder.addChildObj(object, objKey) return (newObj, None)
def createObject(self, object, parent, parentUid, objKey, dynamic, fileName=None, actualParentObj=None): objType = WorldCreatorBase.WorldCreatorBase.createObject( self, object, parent, parentUid, objKey, dynamic, fileName=fileName) if not objType: return (None, None) newObj = None objParent = None parentDoId = base.cr.uidMgr.getDoId(parentUid) if parentDoId: objParent = base.cr.getDo(parentDoId) if not objParent: pass if dynamic: objectCat = self.findObjectCategory(objType) if objType == 'Jack Sparrow Standin': if base.config.GetBool('want-npcs', 1) is 1: newObj = self.createJackSparrowStandin( object, objKey, objParent) elif objectCat == 'PROP_OBJ' or objectCat == 'BUILDING_OBJ': if objType == 'Light - Dynamic': light = objParent.builder.createDynamicLight( object, objParent) if light: base.cr.uidMgr.uid2obj[objKey] = light objParent.builder.addLight(light) OTPRender.renderReflection(False, light, 'p_light', None) elif objParent: if object.has_key('Color'): if not object.has_key('Visual'): object['Visual'] = {} if not object['Visual'].has_key('Color'): object['Visual']['Color'] = object['Color'] self.propNum += 1 newObj = objParent.builder.addChildObj( object, objKey, altParent=actualParentObj, actualParentObj=actualParentObj) if newObj: base.cr.uidMgr.uid2obj[objKey] = newObj if objType in ('Pier', 'Dinghy'): OTPRender.renderReflection( True, newObj, 'p_pier', None) elif objType == 'Cell Portal Area': newObj = objParent.builder.addChildObj(object, objKey) elif objType == 'Event Sphere': newObj = self.addEventSphere(object, objParent) elif objType == 'Port Collision Sphere': pos = object.get('Pos', Point3(0, 0, 0)) radius = object.get('Scale', VBase3(500))[0] elif objType == 'Location Sphere': if objParent: newObj = self.addLocationSphere( objKey, object, objParent, parentUid) if objType == 'Cutscene Origin Node': pos = objParent and object['Pos'] hpr = object['Hpr'] name = object['CutsceneId'] node = objParent.attachNewNode(ModelNode(name)) node.node().setPreserveTransform(ModelNode.PTLocal) node.setPosHpr(pos, hpr) self.cr.activeWorld.addCutsceneOriginNode(node, name) newObj = node else: if objType == 'Effect Node': if objParent: pos = object['Pos'] hpr = object['Hpr'] if object.has_key('Scale'): scale = object['Scale'] else: scale = Point3(1.0, 1.0, 1.0) name = object['EffectName'] node = objParent.attachNewNode(ModelNode(name)) node.node().setPreserveTransform(ModelNode.PTLocal) node.setPosHprScale(pos, hpr, scale) newObj = node else: if objType == 'Dinghy': newObj = objParent.builder.addChildObj(object, objKey) return (newObj, None)
def __init__(self, parentNP = render, reflection = None, todMgr = None): Water.__init__(self, 'Sea') if base.win.getFbProperties().getStencilBits() == 0: self.use_water_bin = False self.p3 = Point3() self.parentNP = parentNP self.followWater = base.config.GetBool('ships-follow-water', 1) self.damper = 0.20000000000000001 * 180.0 / math.pi self.floats = { } self.floatmasses = { } self.patch = SeaPatchRoot() self.patch.setSeaLevel(0) self.hidden = False self.usingFlatWater = False if base.camera: self.setCenter(base.camera) self.setAnchor(render) patchNode = SeaPatchNode('seapatch', self.patch) patchNode.setWantReflect(0) self.patchNP = NodePath(patchNode) self.patchNP.setColorScale(0.14999999999999999, 0.40000000000000002, 0.5, 1.0) self.patchNP.setTwoSided(True) self.patchNP.hide() shader_file_path = None if base.config.GetBool('want-shaders', 1) and base.win and base.win.getGsg() and base.win.getGsg().getShaderModel() >= GraphicsStateGuardian.SM20: patchNode.setWantColor(0) shader_directory = 'models/sea/' shader_file_name_array = [ '', 'water008_11.cg', 'water008_20.cg', 'water008_2X.cg'] shader_model = base.win.getGsg().getShaderModel() maximum_shader_model = len(shader_file_name_array) - 1 if shader_model > maximum_shader_model: shader_model = maximum_shader_model file_name = shader_file_name_array[shader_model] shader_file_path = shader_directory + file_name self.shader = loader.loadShader(shader_file_path) if self.shader: pass if self.shader: if base.win.getGsg().getShaderModel() == GraphicsStateGuardian.SM20: seamodel = loader.loadModel('models/sea/SeaPatch34') else: seamodel = loader.loadModel('models/sea/SeaPatch31') self.patch.seamodel = seamodel self.seamodel = self.patch.seamodel elif base.options.getTerrainDetailSetting() == 0: self.seamodel = loader.loadModel('models/sea/pir_m_are_wld_seaPatch_low') else: self.seamodel = loader.loadModel('models/sea/SeaPatch31') self.seamodel.setScale(2, 1, 1) self.seamodel.flattenMedium() mask = 0xFFFFFFFFL if self.use_water_bin: self.seamodel.setBin('water', 0) stencil = StencilAttrib.makeWithClear(1, StencilAttrib.SCFAlways, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOReplace, 1, mask, mask, 1, 0) self.seamodel.setAttrib(stencil) else: self.seamodel.setBin('background', 200) self.seamodel.hide(OTPRender.MainCameraBitmask) self.seamodel.showThrough(OTPRender.EnviroCameraBitmask) self.reflectStage = None if False: self.model = loader.loadModel('models/misc/smiley') self.model.reparentTo(render) self.model.setPos(0.0, 50.0, 10.0) self.model.setHpr(0.0, 180.0, 0.0) self.model.setBin('water', 100) self.model2 = loader.loadModel('models/misc/smiley') self.model2.reparentTo(render) self.model2.setPos(10.0, 50.0, 15.0) self.model2.setHpr(180.0, 0.0, 0.0) self.model2.setBin('water', 50) self.model3 = loader.loadModel('models/misc/smiley') self.model3.reparentTo(render) self.model3.setPos(-10.0, 50.0, 15.0) self.model3.setHpr(0.0, 0.0, 0.0) self.model3.setBin('water', 50) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 1, mask, mask) self.model.setAttrib(stencil) stencil = StencilAttrib.make(1, StencilAttrib.SCFEqual, StencilAttrib.SOKeep, StencilAttrib.SOKeep, StencilAttrib.SOKeep, 0, mask, mask) self.model3.setAttrib(stencil) self.flatSea = self.seamodel.find('**/flatsea') flat2 = self.flatSea.copyTo(self.flatSea) flat2.setScale(2, 2, 1) flat2.setZ(-4) flat4 = self.flatSea.copyTo(self.flatSea) flat4.setScale(4, 4, 1) flat4.setZ(-8) if not self.flatSea.isEmpty(): self.flatSea.setTag('flat_sea', 'true') self.flatSea.setPos(0, 0, -1) if False: self.flatSea.setScale(1.3) if self.use_water_bin: self.flatSea.setDepthWrite(0) self.flatSea.flattenStrong() if self.use_water_bin: self.patchNP.setBin('water', 10) else: self.patchNP.setBin('ground', -10) self.todMgr = todMgr if self.getTodMgr(): self.patchNP.setLightOff() self.patchNP.setLight(self.getTodMgr().alight) (seaMin, seaMax) = self.seamodel.getTightBounds() seaDelta = seaMax - seaMin cp = CollisionPolygon(Point3(-1.0, -1.0, 0), Point3(1.0, -1.0, 0), Point3(1.0, 1.0, 0), Point3(-1.0, 1.0, 0)) cNode = CollisionNode('seaCollision') cNode.setCollideMask(PiratesGlobals.TargetBitmask) cNode.addSolid(cp) cNodePath = NodePath(cNode) cNodePath.reparentTo(self.seamodel) cNodePath.setScale(Vec3(seaDelta).length()) cNodePath.setZ(-3) cNodePath.setTag('objType', str(PiratesGlobals.COLL_SEA)) cNodePath.reparentTo(self.parentNP) self.cNodePath = cNodePath ccPlane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) ccNode = CollisionNode('seaCamCollision') ccNode.setCollideMask(PiratesGlobals.CameraBitmask) ccNode.addSolid(ccPlane) ccNodePath = NodePath(ccNode) ccNodePath.reparentTo(self.seamodel) self.ccNodePath = ccNodePath self.seamodel.reparentTo(self.patchNP) self.patchNP.flattenLight() patchNode.collectGeometry() self.enabled = False self.enable() if self.use_alpha_map: if self.enable_alpha_map: self.patchNP.setTransparency(1) alpha_test_attrib = AlphaTestAttrib.make(RenderAttrib.MAlways, 0) self.patchNP.setAttrib(alpha_test_attrib, 100) if self.water_panel != None: self.water_panel.setSeaPatch(self) if self.enable_parameter_keys: def showSeaPatchPanel(): SeaPatchPanel = SeaPatchPanel import pirates.seapatch self.spp = SeaPatchPanel.SeaPatchPanel() self.spp.setPatch(self) self.accept('shift-5', showSeaPatchPanel) self.setting_0() self.patchNP.setTransparency(0) buffer_width = 512 buffer_height = 512 self.texture_extension = '.jpg' if self.shader: self.seamodel.setShader(self.shader) self.seamodel.setFogOff() if self.use_alpha_map: self.patchNP.setTransparency(1) self.base_texture = loader.loadTexture('maps/oceanWater2' + self.texture_extension) self.texture_d = self.base_texture.loadRelated(InternalName.make('-d')) self.texture_n = self.base_texture.loadRelated(InternalName.make('-n')) self.texture_bb = self.base_texture.loadRelated(InternalName.make('-bb')) self.setting_0() self.water_r = 77 self.water_g = 128 self.water_b = 179 self.water_a = 255 self.set_water_color() default_water_color_texture_filename = 'maps/ocean_color_1' + self.texture_extension default_water_alpha_texture_filename = 'maps/default_inv_alpha' + self.texture_extension self.set_water_color_texture(default_water_color_texture_filename) self.set_water_alpha_texture(default_water_alpha_texture_filename) if self.enable_water_panel: self.water_panel.set_texture(default_water_color_texture_filename) self.water_panel.set_shader(shader_file_path) if True: if reflection: self.reflection = reflection else: self.reflection = Reflection('seapatch', buffer_width, buffer_height, render, Plane(Vec3(0, 0, 1), Point3(0, 0, 0))) if self.reflection_enabled(): self.reflection_on() else: self.reflection_off() self.reflection.reflectShowThroughOnly(self.reflect_show_through_only) self.seamodel.setShaderInput(self.reflectiontexture_name, self.reflection.reflection_texture) OTPRender.renderReflection(False, self.patchNP, 'p_ocean_water', None) else: self.reflection_factor = 0.0 self.set_reflection_parameters_np() if not self.shader: self.accept('timeOfDayChange', self._timeChange) if self.reflection: self.reflection.createCard('water', 6) self.setting_0() self.reflection_factor = 0.20000000000000001 self.set_reflection_parameters_np() if False: default_water_color_texture_filename = 'maps/ocean_color_1' + self.texture_extension self.set_water_color_texture(default_water_color_texture_filename) self.setup_color_map() self.create_interface() self.patchNP.reparentTo(self.parentNP) self.accept('grid-detail-changed', self.updateWater)