def loadFrets(self): super(Drum, self).loadFrets() engine = self.engine themename = self.engine.data.themeLabel get = lambda file: self.checkPath("frets", file) if self.twoDkeys == True: #death_au if engine.loadImgDrawing(self, "fretButtons", os.path.join("themes",themename, "frets", "drum", "fretbuttons.png")): self.drumFretButtons = True elif engine.loadImgDrawing(self, "fretButtons", os.path.join("themes",themename, "frets", "fretbuttons.png")): self.drumFretButtons = None else: defaultOpenKey = False if self.engine.fileExists(get("key_open.dae")): #look in the frets folder for files engine.resource.load(self, "keyMeshOpen", lambda: Mesh(engine.resource.fileName(get("key_open.dae")))) else: #default to files in data folder engine.resource.load(self, "keyMeshOpen", lambda: Mesh(engine.resource.fileName("key_open.dae"))) defaultOpenKey = True if defaultOpenKey: self.keytexopen = False else: engine.loadImgDrawing(self, "keytexopen", get("keytex_open.png"))
def test_unflatten(self): """ Test the _unflatten method """ mesh = Mesh(self.filename) vertices = range(6) stride = 2 unflat = mesh._unflatten(vertices, stride) self.assertEqual(unflat, [(0, 1), (2, 3), (4, 5)])
def loadNotes(self): super(Drum, self).loadNotes() engine = self.engine get = lambda file: self.checkPath("tails", file) if self.twoDnote == True: if self.noteSpin: engine.loadImgDrawing(self, "noteOpenAnimatedPowerActive", get("animated_open_power_active.png")) engine.loadImgDrawing(self, "noteOpenAnimatedPower", get("animated_open_power.png")) engine.loadImgDrawing(self, "noteOpenAnimated", get("animated_open.png")) size = (self.boardWidth/1.9, (self.boardWidth/self.strings)/3.0) self.openVtx = np.array([[-size[0], 0.0, size[1]], [size[0], 0.0, size[1]], [-size[0], 0.0, -size[1]], [size[0], 0.0, -size[1]]], dtype=np.float32) self.noteTexCoord = [[np.array([[i/float(self.strings), s/6.0], [(i+1)/float(self.strings), s/6.0], [i/float(self.strings), (s+1)/6.0], [(i+1)/float(self.strings), (s+1)/6.0]], dtype=np.float32) for i in range(self.strings)] for s in range(0,5,2)] self.openTexCoord = [np.array([[0.0, s/6.0], [1.0, s/6.0], [0.0, (s+1)/6.0], [1.0, (s+1)/6.0]], dtype=np.float32) for s in range(1,6,2)] self.animatedOpenTexCoord = [[np.array([[0.0, s/float(self.noteSpinFrames)], [1.0, s/float(self.noteSpinFrames)], [0.0, (s+1)/float(self.noteSpinFrames)], [1.0, (s+1)/float(self.noteSpinFrames)]], dtype=np.float32) for i in range(self.strings)] for s in range(self.noteSpinFrames)] else: defaultOpenNote = False if self.engine.fileExists(get("open.dae")): #load from notes folder self.engine.resource.load(self, "openMesh", lambda: Mesh(self.engine.resource.fileName(get("open.dae")))) else: #fallback to the default in the data folder self.engine.resource.load(self, "openMesh", lambda: Mesh(self.engine.resource.fileName("open.dae"))) defaultOpenNote = True engine.loadImgDrawing(self, "spActTex", get("spacttex.png")) if defaultOpenNote: self.opentexture = False self.opentexture_star = False self.opentexture_stara = False else: self.engine.loadImgDrawing(self, "opentexture", get("opentex.png")) self.engine.loadImgDrawing(self, "opentexture_star", get("opentex_star.png")) self.engine.loadImgDrawing(self, "opentexture_stara", get("opentex_stara.png"))
def loadImages(self): self.loadIcons() #mesh... if os.path.exists(os.path.join(Version.dataPath(),"themes",self.themename,"setlist","item.dae")): self.engine.resource.load(self, "itemMesh", lambda: Mesh(self.engine.resource.fileName("themes",self.themename,"setlist","item.dae")), synch = True) else: self.itemMesh = None if os.path.exists(os.path.join(Version.dataPath(),"themes",self.themename,"setlist","library.dae")): self.engine.resource.load(self, "libraryMesh", lambda: Mesh(self.engine.resource.fileName("themes",self.themename,"setlist","library.dae")), synch = True) else: self.libraryMesh = None if os.path.exists(os.path.join(Version.dataPath(),"themes",self.themename,"setlist","label.dae")): self.engine.resource.load(self, "label", lambda: Mesh(self.engine.resource.fileName("themes",self.themename,"setlist","label.dae")), synch = True) else: self.label = None if os.path.exists(os.path.join(Version.dataPath(),"themes",self.themename,"setlist","library_label.dae")): self.engine.resource.load(self, "libraryLabel", lambda: Mesh(self.engine.resource.fileName("themes",self.themename,"setlist","library_label.dae")), synch = True) else: self.libraryLabel = None if os.path.exists(os.path.join(Version.dataPath(),"themes",self.themename,"setlist","tier.dae")): self.engine.resource.load(self, "tierMesh", lambda: Mesh(self.engine.resource.fileName("themes",self.themename,"setlist","tier.dae")), synch = True) else: self.tierMesh = self.libraryMesh if os.path.exists(os.path.join(Version.dataPath(),"themes",self.themename,"setlist","list.dae")): self.engine.resource.load(self, "listMesh", lambda: Mesh(self.engine.resource.fileName("themes",self.themename,"setlist","list.dae")), synch = True) else: self.listMesh = self.libraryMesh
def test_find(self): mesh = Mesh(self.filename) mesh.render() self.assertTrue(mesh.find('Mesh_001')) self.assertTrue(mesh.find('Mesh_002')) self.assertFalse(mesh.find('Mesh_003'))
def loadNotes(self): engine = self.engine get = lambda file: self.checkPath(os.path.join("notes", "pro"), file) self.noteSpin = self.engine.config.get("performance", "animated_notes") self.spActTex = None self.noteTex = None self.noteButtons = None if self.twoDnote == True: if self.noteSpin: self.starSpinFrames = 16 engine.loadImgDrawing(self, "noteAnimatedNormal", get("animated_normal.png")) engine.loadImgDrawing(self, "noteAnimatedHOPO", get("animated_hopo.png")) engine.loadImgDrawing(self, "noteAnimatedPower", get("animated_power.png")) engine.loadImgDrawing(self, "noteAnimatedPowerHOPO", get("animated_power_hopo.png")) engine.loadImgDrawing(self, "noteAnimatedPowerActive", get("animated_power_active.png")) engine.loadImgDrawing(self, "noteAnimatedPowerActiveHOPO", get("animated_power_active_hopo.png")) if self.gameMode2p == 6: #battle multiplayer if engine.loadImgDrawing(self, "noteButtons", get("spinnotesbattle.png")): self.starSpinFrames = 8 if self.gameMode2p == 6: #battle multiplayer if not self.engine.loadImgDrawing(self, "noteButtons", get("notesbattle.png")): engine.loadImgDrawing(self, "noteButtons", get("notes.png")) else: engine.loadImgDrawing(self, "noteButtons", get("notes.png")) #if special notes for pro aren't found then it will need to #draw using font the number of the fret over the note self.proNum = engine.loadImgDrawing(self, "fretNumbers", get("fretNumbers.png")) else: #Pro instruments must have a specially made note file if it's going to use #3d just so it can display the fret number, if it does not then it needs to #fall back to 2d if self.engine.fileExists(get("note.dae")): #look in the notes folder for files self.engine.resource.load(self, "noteMesh", lambda: Mesh(engine.resource.fileName(get("note.dae")))) else: #default to files in data folder self.twoDnote = True self.loadNotes() return if self.engine.fileExists(get("star.dae")): #look in the notes folder for files self.engine.resource.load(self, "starMesh", lambda: Mesh(self.engine.resource.fileName(get("star.dae")))) else: #No mesh for star notes self.twoDnote = True self.loadNotes() return if defaultNote: self.notetex = False else: self.notetex = True self.startex = True self.staratex = True for i in range(5): if not engine.loadImgDrawing(self, "notetex"+chr(97+i), get("notetex_"+chr(97+i)+".png")): self.notetex = False break for i in range(5): if not self.engine.loadImgDrawing(self, "startex"+chr(97+i), get("startex_"+chr(97+i)+".png")): self.startex = False break for i in range(5): if not self.engine.loadImgDrawing(self, "staratex"+chr(97+i), get("staratex_"+chr(97+i)+".png")): self.staratex = False break #these are necessary, if they don't exist then you can't use 3d notes for i in range(13): if not self.engine.loadImgDrawing(self, "fretnumtex" + str(i), get("fretnumtex_"+str(i)+".png")): self.twoDnote = True self.loadNotes() return