Esempio n. 1
0
 def update(self, task):
     dt = globalClock.getDt()
     self.timeActive += dt
     self.textureYOffset += self.textureYDelta * dt
     trans = TransformState.makePos((0, self.textureYOffset, 0))
     self.waterStream.setTexTransform(self.textureStage, trans)
     done = False
     if self.getCurrentOrNextState() == 'Active' and self.textureYOffsetAlpha < _activePosition:
         self.textureYOffsetAlpha += self.textureYDeltaAlpha * dt
         if self.textureYOffsetAlpha > _activePosition:
             self.textureYOffsetAlpha = _activePosition
         
         trans2 = TransformState.makePos((0, self.textureYOffsetAlpha, 0))
         self.waterStream.setTexTransform(self.textureStage3, trans2)
     
     if self.getCurrentOrNextState() == 'Patched':
         if self.textureYOffsetAlpha < _activePosition:
             self.textureYOffsetAlpha = 0.75 - self.textureYOffsetAlpha / 2.0
             trans2 = TransformState.makePos((0, self.textureYOffsetAlpha, 0))
             self.waterStream.setTexTransform(self.textureStage3, trans2)
         elif self.textureYOffsetAlpha < 1.0:
             self.textureYOffsetAlpha += self.textureYDeltaAlpha * dt
             trans2 = TransformState.makePos((0, self.textureYOffsetAlpha, 0))
             self.waterStream.setTexTransform(self.textureStage3, trans2)
         
     
     self.textureYOffset2 += self.textureYDelta2 * dt
     trans = TransformState.makePos((0, self.textureYOffset2, 0))
     self.waterStream2.setTexTransform(self.textureStage2, trans)
     if self.getCurrentOrNextState() == 'Active' and self.textureYOffsetAlpha2 < _activePosition:
         self.textureYOffsetAlpha2 += self.textureYDeltaAlpha2 * dt
         if self.textureYOffsetAlpha2 > _activePosition:
             self.textureYOffsetAlpha2 = _activePosition
         
         trans2 = TransformState.makePos((0, self.textureYOffsetAlpha2, 0))
         self.waterStream2.setTexTransform(self.textureStage5, trans2)
     
     if self.getCurrentOrNextState() == 'Patched':
         if self.textureYOffsetAlpha2 < _activePosition:
             self.textureYOffsetAlpha2 = 0.75 - self.textureYOffsetAlpha2 / 2.0
             trans2 = TransformState.makePos((0, self.textureYOffsetAlpha2, 0))
             self.waterStream2.setTexTransform(self.textureStage5, trans2)
         
         if self.textureYOffsetAlpha2 < 1.0:
             self.textureYOffsetAlpha2 += self.textureYDeltaAlpha2 * dt
             trans2 = TransformState.makePos((0, self.textureYOffsetAlpha2, 0))
             self.waterStream2.setTexTransform(self.textureStage5, trans2)
         else:
             done = True
     
     if done:
         self.waterStream.stash()
         self.waterStream2.stash()
         self.fadeSequence = Sequence(LerpColorScaleInterval(self, duration = 2.0, colorScale = (1.0, 1.0, 1.0, 0.0)), Func(self.destroy))
         self.fadeSequence.start()
         return Task.done
     else:
         return Task.cont
    def update(self, task):
        dt = globalClock.getDt()
        self.timeActive += dt
        self.textureYOffset += self.textureYDelta * dt
        trans = TransformState.makePos((0, self.textureYOffset, 0))
        self.waterStream.setTexTransform(self.textureStage, trans)
        done = False
        if self.getCurrentOrNextState() == 'Active' and self.textureYOffsetAlpha < _activePosition:
            self.textureYOffsetAlpha += self.textureYDeltaAlpha * dt
            if self.textureYOffsetAlpha > _activePosition:
                self.textureYOffsetAlpha = _activePosition

            trans2 = TransformState.makePos((0, self.textureYOffsetAlpha, 0))
            self.waterStream.setTexTransform(self.textureStage3, trans2)

        if self.getCurrentOrNextState() == 'Patched':
            if self.textureYOffsetAlpha < _activePosition:
                self.textureYOffsetAlpha = 0.75 - self.textureYOffsetAlpha / 2.0
                trans2 = TransformState.makePos((0, self.textureYOffsetAlpha, 0))
                self.waterStream.setTexTransform(self.textureStage3, trans2)
            elif self.textureYOffsetAlpha < 1.0:
                self.textureYOffsetAlpha += self.textureYDeltaAlpha * dt
                trans2 = TransformState.makePos((0, self.textureYOffsetAlpha, 0))
                self.waterStream.setTexTransform(self.textureStage3, trans2)


        self.textureYOffset2 += self.textureYDelta2 * dt
        trans = TransformState.makePos((0, self.textureYOffset2, 0))
        self.waterStream2.setTexTransform(self.textureStage2, trans)
        if self.getCurrentOrNextState() == 'Active' and self.textureYOffsetAlpha2 < _activePosition:
            self.textureYOffsetAlpha2 += self.textureYDeltaAlpha2 * dt
            if self.textureYOffsetAlpha2 > _activePosition:
                self.textureYOffsetAlpha2 = _activePosition

            trans2 = TransformState.makePos((0, self.textureYOffsetAlpha2, 0))
            self.waterStream2.setTexTransform(self.textureStage5, trans2)

        if self.getCurrentOrNextState() == 'Patched':
            if self.textureYOffsetAlpha2 < _activePosition:
                self.textureYOffsetAlpha2 = 0.75 - self.textureYOffsetAlpha2 / 2.0
                trans2 = TransformState.makePos((0, self.textureYOffsetAlpha2, 0))
                self.waterStream2.setTexTransform(self.textureStage5, trans2)

            if self.textureYOffsetAlpha2 < 1.0:
                self.textureYOffsetAlpha2 += self.textureYDeltaAlpha2 * dt
                trans2 = TransformState.makePos((0, self.textureYOffsetAlpha2, 0))
                self.waterStream2.setTexTransform(self.textureStage5, trans2)
            else:
                done = True

        if done:
            self.waterStream.stash()
            self.waterStream2.stash()
            self.fadeSequence = Sequence(LerpColorScaleInterval(self, duration = 2.0, colorScale = (1.0, 1.0, 1.0, 0.0)), Func(self.destroy))
            self.fadeSequence.start()
            return Task.done
        else:
            return Task.cont
Esempio n. 3
0
 def __init__(self, uniqueId, data):
     self.uniqueId = uniqueId
     self.data = data
     pos = data.get('Pos', Vec3(0, 0, 0))
     hpr = data.get('Hpr', Vec3(0, 0, 0))
     scale = data.get('Scale', Vec3(1, 1, 1))
     self.transform = TransformState.makePosHprScale(pos, hpr, scale)
Esempio n. 4
0
 def __init__(self, uniqueId, data):
     self.uniqueId = uniqueId
     self.data = data
     pos = data.get("Pos", Vec3(0, 0, 0))
     hpr = data.get("Hpr", Vec3(0, 0, 0))
     scale = data.get("Scale", Vec3(1, 1, 1))
     self.transform = TransformState.makePosHprScale(pos, hpr, scale)
    def getSwapVisibleIval(self, wait = 5.0, tFadeOut = 3.0, tFadeIn = 3.0):
        loader = base.cr.playGame.hood.loader
        npl = render.findAllMatches('**/=DNARoot=holiday_prop;+s')
        p = Parallel()
        for i in range(npl.getNumPaths()):
            np = npl.getPath(i)
            np.setTransparency(TransparencyAttrib.MDual, 1)
            if not np.hasTag('DNACode'):
                continue
            dnaCode = np.getTag('DNACode')
            dnaNode = self.dnaStore.findNode(dnaCode)
            if dnaNode.isEmpty():
                continue
            newNP = dnaNode.copyTo(np.getParent())
            newNP.setTag('DNARoot', 'holiday_prop')
            newNP.setTag('DNACode', dnaCode)
            newNP.setColorScale(1, 1, 1, 0)
            newNP.setTransparency(TransparencyAttrib.MDual, 1)
            if np.hasTag('transformIndex'):
                index = int(np.getTag('transformIndex'))
                transform = loader.holidayPropTransforms.get(index, TransformState.makeIdentity())
                newNP.setTransform(NodePath(), transform)
                newNP.setTag('transformIndex', `index`)
            s = Sequence(Wait(wait), np.colorScaleInterval(tFadeOut, Vec4(1, 1, 1, 0), startColorScale=Vec4(1, 1, 1, 1), blendType='easeInOut'), Func(np.detachNode), Func(np.clearTransparency), newNP.colorScaleInterval(tFadeOut, Vec4(1, 1, 1, 1), startColorScale=Vec4(1, 1, 1, 0), blendType='easeInOut'), Func(newNP.clearTransparency), Func(newNP.clearColorScale))
            p.append(s)

        return p
    def getSwapVisibleIval(self, wait = 5.0, tFadeOut = 3.0, tFadeIn = 3.0):
        loader = base.cr.playGame.hood.loader
        npl = render.findAllMatches('**/=DNARoot=holiday_prop;+s')
        p = Parallel()
        for i in range(npl.getNumPaths()):
            np = npl.getPath(i)
            np.setTransparency(TransparencyAttrib.MDual, 1)
            if not np.hasTag('DNACode'):
                continue
            dnaCode = np.getTag('DNACode')
            dnaNode = self.dnaStore.findNode(dnaCode)
            if dnaNode.isEmpty():
                continue
            newNP = dnaNode.copyTo(np.getParent())
            newNP.setTag('DNARoot', 'holiday_prop')
            newNP.setTag('DNACode', dnaCode)
            newNP.setColorScale(1, 1, 1, 0)
            newNP.setTransparency(TransparencyAttrib.MDual, 1)
            if np.hasTag('transformIndex'):
                index = int(np.getTag('transformIndex'))
                transform = loader.holidayPropTransforms.get(index, TransformState.makeIdentity())
                newNP.setTransform(NodePath(), transform)
                newNP.setTag('transformIndex', `index`)
            s = Sequence(Wait(wait), np.colorScaleInterval(tFadeOut, Vec4(1, 1, 1, 0), startColorScale=Vec4(1, 1, 1, 1), blendType='easeInOut'), Func(np.detachNode), Func(np.clearTransparency), newNP.colorScaleInterval(tFadeOut, Vec4(1, 1, 1, 1), startColorScale=Vec4(1, 1, 1, 0), blendType='easeInOut'), Func(newNP.clearTransparency), Func(newNP.clearColorScale))
            p.append(s)

        return p
Esempio n. 7
0
  def draw_leaf(self, position, vector_list, scale = 0.125):
    # use the vectors that describe the direction the branch grows
    # to make the right rotation matrix
    new_cs = Mat4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
    new_cs.setRow(0, vector_list[2]) # right
    new_cs.setRow(1, vector_list[1]) # up
    new_cs.setRow(2, vector_list[0]) # forward
    new_cs.setRow(3, Vec3(0, 0, 0))
    new_cs.setCol(3, Vec4(0, 0, 0, 1))

    axis_adjustment = Mat4.scaleMat(scale) * new_cs * Mat4.translateMat(position)

    leaf_model = base.loader.loadModelCopy(APP_PATH + 'media/models/shrubbery')
    leaf_texture = base.loader.loadTexture(APP_PATH + 'media/models/material-10-cl.png')

    leaf_model.reparentTo(self.get_model())
    leaf_model.setTexture(leaf_texture, 1)
    leaf_model.setTransform(TransformState.makeMat(axis_adjustment))
def drawLeaf(nodePath,vdata,pos=Vec3(0,0,0),vecList=[Vec3(0,0,1), Vec3(1,0,0),Vec3(0,-1,0)], scale=0.125):
	
	#use the vectors that describe the direction the branch grows to make the right 
		#rotation matrix
	newCs=Mat4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
	newCs.setRow(0, vecList[2]) #right
	newCs.setRow(1, vecList[1]) #up
	newCs.setRow(2, vecList[0]) #forward
	newCs.setRow(3, Vec3(0,0,0))
	newCs.setCol(3,Vec4(0,0,0,1))

	axisAdj=Mat4.scaleMat(scale)*newCs*Mat4.translateMat(pos)	
	
	#orginlly made the leaf out of geometry but that didnt look good
	#I also think there should be a better way to handle the leaf texture other than
	#hardcoding the filename
	leafModel=loader.loadModelCopy('models/shrubbery')
	leafTexture=loader.loadTexture('models/material-10-cl.png')


	leafModel.reparentTo(nodePath)
	leafModel.setTexture(leafTexture,1)
	leafModel.setTransform(TransformState.makeMat(axisAdj))
Esempio n. 9
0
 def restoreRigging(self, index):
     if index in self.riggingControls:
         self.riggingControls[index].applyFreeze(
             TransformState.makeMat(
                 self.riggingControls[index].getDefaultValue()))
         self.char.node().forceUpdate()
Esempio n. 10
0
 def dropRigging(self, index):
     if index in self.riggingControls:
         self.riggingControls[index].applyFreeze(
             TransformState.makeScale((0, 0, 0)))
         self.char.node().forceUpdate()
Esempio n. 11
0
 def _initVisuals(self):
     textureCard = loader.loadModel('models/minigames/pir_m_gam_srp_water')
     self.waterStream = textureCard.find('**/waterPlane')
     tex = textureCard.findTexture('pir_t_gui_srp_waterDrops')
     textureCard2 = loader.loadModel('models/minigames/pir_m_gam_srp_water')
     self.waterStream2 = textureCard2.find('**/waterPlane')
     tex2 = textureCard2.findTexture('pir_t_gui_srp_waterDrops')
     alphaCard = loader.loadModel(
         'models/minigames/pir_m_gui_srp_waterDropsAlpha')
     self.alphaWaterStream = textureCard.find(
         '**/pir_t_gui_srp_waterDropsAlpha')
     alphatex = alphaCard.find(
         '**/pir_t_gui_srp_waterDropsAlpha').findTexture('*')
     self.alphaWaterStream2 = textureCard.find(
         '**/pir_t_gui_srp_waterDropsAlpha2')
     alphatex2 = alphaCard.find(
         '**/pir_t_gui_srp_waterDropsAlpha2').findTexture('*')
     alphaCard2 = loader.loadModel(
         'models/minigames/pir_m_gui_srp_waterDropsAlpha')
     self.alphaWaterStream3 = textureCard.find(
         '**/pir_t_gui_srp_waterDropsAlpha')
     alphatex3 = alphaCard2.findTexture('*')
     self.alphaWaterStream4 = textureCard.find(
         '**/pir_t_gui_srp_waterDropsAlpha2')
     alphatex4 = alphaCard2.findTexture('*')
     tex.setWrapU(Texture.WMRepeat)
     tex.setWrapV(Texture.WMRepeat)
     alphatex.setWrapU(Texture.WMRepeat)
     alphatex.setWrapV(Texture.WMRepeat)
     tex2.setWrapU(Texture.WMRepeat)
     tex2.setWrapV(Texture.WMRepeat)
     alphatex3.setWrapU(Texture.WMRepeat)
     alphatex3.setWrapV(Texture.WMRepeat)
     self.setScale(2.5 * self.leakScale)
     self.waterStream.setScale(self.leakScale)
     self.waterStream.setPos(self.getX(), 0.0,
                             -0.5 * self.leakScale + self.getZ())
     self.waterStream2.setScale(self.leakScale * 0.8, self.leakScale,
                                self.leakScale * 1.2)
     self.waterStream2.setPos(self.getX(), 0.0,
                              -0.6 * self.leakScale + self.getZ())
     self.waterStream.setColor(0.7, 0.85, 1.0, 1.0)
     self.waterStream2.setColor(0.5, 0.6, 0.9, 1.0)
     self.waterStream2.reparentTo(self.pitchingGame)
     self.waterStream.reparentTo(self.pitchingGame)
     self.waterStream2.setBin('fixed', 42)
     self.waterStream.setBin('fixed', 40)
     self.textureYOffset = random.random()
     self.textureYDelta = 0.25 + 0.025 / self.leakScale
     self.textureYOffset2 = random.random()
     self.textureYDelta2 = 0.25412354 + 0.058754645634 / self.leakScale
     self.textureYOffsetAlpha = 0.0
     self.textureYDeltaAlpha = 0.25 + 0.025 / self.leakScale
     self.textureYOffsetAlpha2 = 0.0
     self.textureYDeltaAlpha2 = 0.25412354 + 0.058754645634 / self.leakScale
     self.textureStage = self.waterStream.findTextureStage('*')
     self.textureStage2 = self.waterStream2.findTextureStage('*')
     self.textureStage3 = TextureStage('alphaLayer')
     self.textureStage3.setMode(TextureStage.MModulate)
     self.textureStage3.setSort(1)
     self.waterStream.setTexture(self.textureStage3, alphatex)
     self.textureStage4 = TextureStage('alphaLayer2')
     self.textureStage4.setMode(TextureStage.MModulate)
     self.textureStage4.setSort(2)
     self.waterStream.setTexture(self.textureStage4, alphatex2)
     trans = TransformState.makePos((0, 0.48, 0))
     self.waterStream.setTexTransform(self.textureStage4, trans)
     self.textureStage5 = TextureStage('alphaLayer3')
     self.textureStage5.setMode(TextureStage.MModulate)
     self.textureStage5.setSort(1)
     self.waterStream2.setTexture(self.textureStage5, alphatex3)
     self.textureStage6 = TextureStage('alphaLayer4')
     self.textureStage6.setMode(TextureStage.MModulate)
     self.textureStage6.setSort(2)
     self.waterStream2.setTexture(self.textureStage6, alphatex4)
     trans = TransformState.makePos((0, 0.48, 0))
     self.waterStream2.setTexTransform(self.textureStage6, trans)
 def _initVisuals(self):
     textureCard = loader.loadModel('models/minigames/pir_m_gam_srp_water')
     self.waterStream = textureCard.find('**/waterPlane')
     tex = textureCard.findTexture('pir_t_gui_srp_waterDrops')
     textureCard2 = loader.loadModel('models/minigames/pir_m_gam_srp_water')
     self.waterStream2 = textureCard2.find('**/waterPlane')
     tex2 = textureCard2.findTexture('pir_t_gui_srp_waterDrops')
     alphaCard = loader.loadModel('models/minigames/pir_m_gui_srp_waterDropsAlpha')
     self.alphaWaterStream = textureCard.find('**/pir_t_gui_srp_waterDropsAlpha')
     alphatex = alphaCard.find('**/pir_t_gui_srp_waterDropsAlpha').findTexture('*')
     self.alphaWaterStream2 = textureCard.find('**/pir_t_gui_srp_waterDropsAlpha2')
     alphatex2 = alphaCard.find('**/pir_t_gui_srp_waterDropsAlpha2').findTexture('*')
     alphaCard2 = loader.loadModel('models/minigames/pir_m_gui_srp_waterDropsAlpha')
     self.alphaWaterStream3 = textureCard.find('**/pir_t_gui_srp_waterDropsAlpha')
     alphatex3 = alphaCard2.findTexture('*')
     self.alphaWaterStream4 = textureCard.find('**/pir_t_gui_srp_waterDropsAlpha2')
     alphatex4 = alphaCard2.findTexture('*')
     tex.setWrapU(Texture.WMRepeat)
     tex.setWrapV(Texture.WMRepeat)
     alphatex.setWrapU(Texture.WMRepeat)
     alphatex.setWrapV(Texture.WMRepeat)
     tex2.setWrapU(Texture.WMRepeat)
     tex2.setWrapV(Texture.WMRepeat)
     alphatex3.setWrapU(Texture.WMRepeat)
     alphatex3.setWrapV(Texture.WMRepeat)
     self.setScale(2.5 * self.leakScale)
     self.waterStream.setScale(self.leakScale)
     self.waterStream.setPos(self.getX(), 0.0, -0.5 * self.leakScale + self.getZ())
     self.waterStream2.setScale(self.leakScale * 0.80000000000000004, self.leakScale, self.leakScale * 1.2)
     self.waterStream2.setPos(self.getX(), 0.0, -0.59999999999999998 * self.leakScale + self.getZ())
     self.waterStream.setColor(0.69999999999999996, 0.84999999999999998, 1.0, 1.0)
     self.waterStream2.setColor(0.5, 0.59999999999999998, 0.90000000000000002, 1.0)
     self.waterStream2.reparentTo(self.pitchingGame)
     self.waterStream.reparentTo(self.pitchingGame)
     self.waterStream2.setBin('fixed', 42)
     self.waterStream.setBin('fixed', 40)
     self.textureYOffset = random.random()
     self.textureYDelta = 0.25 + 0.025000000000000001 / self.leakScale
     self.textureYOffset2 = random.random()
     self.textureYDelta2 = 0.25412353999999998 + 0.058754645634 / self.leakScale
     self.textureYOffsetAlpha = 0.0
     self.textureYDeltaAlpha = 0.25 + 0.025000000000000001 / self.leakScale
     self.textureYOffsetAlpha2 = 0.0
     self.textureYDeltaAlpha2 = 0.25412353999999998 + 0.058754645634 / self.leakScale
     self.textureStage = self.waterStream.findTextureStage('*')
     self.textureStage2 = self.waterStream2.findTextureStage('*')
     self.textureStage3 = TextureStage('alphaLayer')
     self.textureStage3.setMode(TextureStage.MModulate)
     self.textureStage3.setSort(1)
     self.waterStream.setTexture(self.textureStage3, alphatex)
     self.textureStage4 = TextureStage('alphaLayer2')
     self.textureStage4.setMode(TextureStage.MModulate)
     self.textureStage4.setSort(2)
     self.waterStream.setTexture(self.textureStage4, alphatex2)
     trans = TransformState.makePos((0, 0.47999999999999998, 0))
     self.waterStream.setTexTransform(self.textureStage4, trans)
     self.textureStage5 = TextureStage('alphaLayer3')
     self.textureStage5.setMode(TextureStage.MModulate)
     self.textureStage5.setSort(1)
     self.waterStream2.setTexture(self.textureStage5, alphatex3)
     self.textureStage6 = TextureStage('alphaLayer4')
     self.textureStage6.setMode(TextureStage.MModulate)
     self.textureStage6.setSort(2)
     self.waterStream2.setTexture(self.textureStage6, alphatex4)
     trans = TransformState.makePos((0, 0.47999999999999998, 0))
     self.waterStream2.setTexTransform(self.textureStage6, trans)
 def restoreRigging(self, index):
     if index in self.riggingControls:
         self.riggingControls[index].applyFreeze(TransformState.makeMat(self.riggingControls[index].getDefaultValue()))
         self.char.node().forceUpdate()
 def dropRigging(self, index):
     if index in self.riggingControls:
         self.riggingControls[index].applyFreeze(TransformState.makeScale((0, 0, 0)))
         self.char.node().forceUpdate()
Esempio n. 15
0
    def _getQuestPath(self, questDestUid, isPrivate, alreadyVisited, needToVisit, pathDict, avId):
        questDest = None
        questPath = []
        needToStore = False
        if not isPrivate:
            if not questPath:
                questIds = self.world.queryGoal(questDestUid, self, avId)
                for (questDoId, questUid) in questIds:
                    questGoalObj = self.air.doId2do.get(questDoId)
                    if questGoalObj:
                        if questGoalObj.getParentObj() is self or questGoalObj is self:
                            if questDoId != self.doId:
                                pathDict.setdefault(questDoId, self.doId)
                                newIds = [
                                    self.doId,
                                    questDoId]
                            else:
                                newIds = [
                                    self.doId]
                            questPath = alreadyVisited + [
                                self.doId,
                                questDoId]
                            questDest = QuestStep(self.doId, questDoId, questGoalObj._getQuestStepType(), questGoalObj._getQuestStepPosH())
                            needToStore = True
                            avObj = self.air.doId2do.get(avId)
                            if avObj:
                                avObj.setQuestGoalDoId(questGoalObj)
                            
                            break
                        
                    elif questDoId != None:
                        pass
                    
                    if questDestUid.getType() != QuestGoal.Type_Custom and questUid:
                        
                        try:
                            objInfo = self.air.worldCreator.getObjectDataFromFileByUid(questUid, self.getFileName())
                            if objInfo:
                                if objInfo.get('Type') == 'Dinghy':
                                    pos = objInfo['Pos']
                                    hpr = objInfo['Hpr']
                                    questPath = alreadyVisited + [
                                        self.doId]
                                    questDest = QuestStep(self.doId, 0, QuestStep.STQuestNode, (pos[0], pos[1], pos[2], hpr[0]))
                                    needToStore = True
                                    break
                                elif objInfo.get('Type') == 'Quest Node':
                                    pos = objInfo['Pos']
                                    nodePos = None
                                    parentUid = self.air.worldCreator.getObjectDataFromFileByUid(questUid, self.getFileName(), getParentUid = True)
                                    if parentUid:
                                        parentObj = self.world.uidMgr.justGetMeMeObject(parentUid)
                                        if parentObj:
                                            tform = TransformState.makePosHpr(parentObj.getPos(self), parentObj.getHpr(self))
                                            nodePos = tform.getMat().xformPoint(pos)
                                        
                                    
                                    if nodePos == None:
                                        nodePos = pos
                                    
                                    hpr = objInfo['Hpr']
                                    at = int(float(objInfo['At']))
                                    near = int(float(objInfo['Near']))
                                    nearOffset = (int(objInfo['NearOffsetX']), int(objInfo['NearOffsetY']), int(objInfo['NearOffsetZ']))
                                    nearVis = (int(objInfo['NearVisX']), int(objInfo['NearVisY']), int(objInfo['NearVisZ']))
                                    questPath = alreadyVisited + [
                                        self.doId]
                                    questDest = QuestStep(self.doId, 0, QuestStep.STQuestNode, (nodePos[0], nodePos[1], nodePos[2], hpr[0]), nodeSizes = [
                                        at,
                                        near], nearOffset = nearOffset, nearVis = nearVis)
                                    needToStore = True
                                    break
                                elif objInfo.get('Type') == 'Object Spawn Node':
                                    pos = objInfo['Pos']
                                    hpr = objInfo['Hpr']
                                    questPath = alreadyVisited + [
                                        self.doId]
                                    questDest = QuestStep(self.doId, 0, QuestStep.STArea, (pos[0], pos[1], pos[2], hpr[0]))
                                    needToStore = True
                                    break
                                
                        except AttributeError:
                            pass
                        

                
            
        elif not questPath:
            if self.air.worldCreator.isObjectDefined(questDestUid.getGoalIds(all = False), self.world.getFileName() + '.py'):
                questPath = alreadyVisited + [
                    self.doId]
                needToStore = False
            
        
        if questPath:
            finalPath = [
                questPath[-1]]
            next = pathDict.get(finalPath[-1])
            while next:
                finalPath.append(next)
                next = pathDict.get(finalPath[-1])
            finalPath.reverse()
        
        exitLinks = questPath
        for link in exitLinks:
            pathDict[link] = self.doId
        
        needToVisit += exitLinks
        if needToVisit:
            nextDoId = needToVisit.pop(0)
            nextStep = self.air.doId2do[nextDoId]
            finalPath = nextStep._getQuestPath(questDestUid, isPrivate, alreadyVisited + [
                self.doId], needToVisit, pathDict, avId)
            if questDestUid.getType() == QuestGoal.Type_Custom:
                nextStep.questSteps.pop(questDestUid, None)
            
            needToStore = True
        else:
            finalPath = []
            needToStore = True
        if needToStore and self.doId in finalPath:
            self._storeQuestStep(finalPath, questDestUid, questDest)
        
        if not finalPath:
            self._storeQuestStep(finalPath, questDestUid, questStep = QuestStep.getNullStep())
        
        return finalPath
Esempio n. 16
0
 def update(self, dt):
     self.t += dt
     trans = TransformState.makePos((self.t, -self.t, 0))
     self.model.setTexTransform(self._texStage, trans)
     trans = TransformState.makePos((self.t * 2.0, -self.t * 2.0, 0))
 def update(self, dt):
     self.t += dt
     trans = TransformState.makePos((self.t, -self.t, 0))
     self.model.setTexTransform(self._texStage, trans)
     trans = TransformState.makePos((self.t * 2.0, -self.t * 2.0, 0))
    def _getQuestPath(self, questDestUid, isPrivate, alreadyVisited, needToVisit, pathDict, avId):
        questDest = None
        questPath = []
        needToStore = False
        if not isPrivate:
            if not questPath:
                questIds = self.world.queryGoal(questDestUid, self, avId)
                for (questDoId, questUid) in questIds:
                    questGoalObj = self.air.doId2do.get(questDoId)
                    if questGoalObj:
                        if questGoalObj.getParentObj() is self or questGoalObj is self:
                            if questDoId != self.doId:
                                pathDict.setdefault(questDoId, self.doId)
                                newIds = [
                                    self.doId,
                                    questDoId]
                            else:
                                newIds = [
                                    self.doId]
                            questPath = alreadyVisited + [
                                self.doId,
                                questDoId]
                            questDest = QuestStep(self.doId, questDoId, questGoalObj._getQuestStepType(), questGoalObj._getQuestStepPosH())
                            needToStore = True
                            avObj = self.air.doId2do.get(avId)
                            if avObj:
                                avObj.setQuestGoalDoId(questGoalObj)
                            
                            break
                        
                    elif questDoId != None:
                        pass
                    
                    if questDestUid.getType() != QuestGoal.Type_Custom and questUid:
                        
                        try:
                            objInfo = self.air.worldCreator.getObjectDataFromFileByUid(questUid, self.getFileName())
                            if objInfo:
                                if objInfo.get('Type') == 'Dinghy':
                                    pos = objInfo['Pos']
                                    hpr = objInfo['Hpr']
                                    questPath = alreadyVisited + [
                                        self.doId]
                                    questDest = QuestStep(self.doId, 0, QuestStep.STQuestNode, (pos[0], pos[1], pos[2], hpr[0]))
                                    needToStore = True
                                    break
                                elif objInfo.get('Type') == 'Quest Node':
                                    pos = objInfo['Pos']
                                    nodePos = None
                                    parentUid = self.air.worldCreator.getObjectDataFromFileByUid(questUid, self.getFileName(), getParentUid = True)
                                    if parentUid:
                                        parentObj = self.world.uidMgr.justGetMeMeObject(parentUid)
                                        if parentObj:
                                            tform = TransformState.makePosHpr(parentObj.getPos(self), parentObj.getHpr(self))
                                            nodePos = tform.getMat().xformPoint(pos)
                                        
                                    
                                    if nodePos == None:
                                        nodePos = pos
                                    
                                    hpr = objInfo['Hpr']
                                    at = int(float(objInfo['At']))
                                    near = int(float(objInfo['Near']))
                                    nearOffset = (int(objInfo['NearOffsetX']), int(objInfo['NearOffsetY']), int(objInfo['NearOffsetZ']))
                                    nearVis = (int(objInfo['NearVisX']), int(objInfo['NearVisY']), int(objInfo['NearVisZ']))
                                    questPath = alreadyVisited + [
                                        self.doId]
                                    questDest = QuestStep(self.doId, 0, QuestStep.STQuestNode, (nodePos[0], nodePos[1], nodePos[2], hpr[0]), nodeSizes = [
                                        at,
                                        near], nearOffset = nearOffset, nearVis = nearVis)
                                    needToStore = True
                                    break
                                elif objInfo.get('Type') == 'Object Spawn Node':
                                    pos = objInfo['Pos']
                                    hpr = objInfo['Hpr']
                                    questPath = alreadyVisited + [
                                        self.doId]
                                    questDest = QuestStep(self.doId, 0, QuestStep.STArea, (pos[0], pos[1], pos[2], hpr[0]))
                                    needToStore = True
                                    break
                                
                        except AttributeError:
                            pass
                        

                
            
        elif not questPath:
            if self.air.worldCreator.isObjectDefined(questDestUid.getGoalIds(all = False), self.world.getFileName() + '.py'):
                questPath = alreadyVisited + [
                    self.doId]
                needToStore = False
            
        
        if questPath:
            finalPath = [
                questPath[-1]]
            next = pathDict.get(finalPath[-1])
            while next:
                finalPath.append(next)
                next = pathDict.get(finalPath[-1])
            finalPath.reverse()
        
        exitLinks = questPath
        for link in exitLinks:
            pathDict[link] = self.doId
        
        needToVisit += exitLinks
        if needToVisit:
            nextDoId = needToVisit.pop(0)
            nextStep = self.air.doId2do[nextDoId]
            finalPath = nextStep._getQuestPath(questDestUid, isPrivate, alreadyVisited + [
                self.doId], needToVisit, pathDict, avId)
            if questDestUid.getType() == QuestGoal.Type_Custom:
                nextStep.questSteps.pop(questDestUid, None)
            
            needToStore = True
        else:
            finalPath = []
            needToStore = True
        if needToStore and self.doId in finalPath:
            self._storeQuestStep(finalPath, questDestUid, questDest)
        
        if not finalPath:
            self._storeQuestStep(finalPath, questDestUid, questStep = QuestStep.getNullStep())
        
        return finalPath