def CreateTiledMovieObjectFromLayout(layoutFile, screenRect, pos, absRect, fullRect, loadAllMovieTiles=False, scale=None, allowFrameSkip=None): print "CreateTiledMovieObjectFromLayout" objectsToGroup = [] if None == pos: pos = (0, 0) layoutEntries = ReadLayout(layoutFile) for entry in layoutEntries: moviePos = Vec2(pos[0] + entry.pos[0], pos[1] + entry.pos[1]) movieRenderRect = Rect(moviePos[0], moviePos[1], entry.getWidth(), entry.getHeight()) tileObject = None # same code as below func if loadAllMovieTiles or movieRenderRect.colliderect(absRect): movieTileFilename = entry.path fullMovieTilePath = movieTileFilename # for now has absolute paths # same code as below function print "movieTileFilename:", movieTileFilename, len(movieTileFilename) if len(movieTileFilename.strip()) > 0: print "movieTileFilename:", movieTileFilename, len(movieTileFilename) print "TiledMovie: loading tile: ", fullMovieTilePath # obj.pos and obj.size will be used to group movie tiles. fps = fps=entry.getProperty("fps") tileObject = CreateMovieObject(fullMovieTilePath, screenRect, moviePos, absRect, fullRect, fps=fps, scale=scale, allowFrameSkip=allowFrameSkip) else: print "Warning movieTile not found for:", xIndex, yIndex if not tileObject: tileObject = NullTileDisplayObject(pos=moviePos,size=(movieRenderRect.width,movieRenderRect.height) ) # Empty object to represent # objects on other nodes # and keep object list synced. objectsToGroup.append(tileObject) shortName = os.path.basename(layoutFile.strip(os.path.sep)) duration = layoutEntries[0].getProperty("duration") fps = fps=layoutEntries[0].getProperty("fps") groupObject = TiledMovieGroupObject(shortName, objectsToGroup, duration=duration, fps=fps) groupObject.doChildUpdates=True returnObj = groupObject return returnObj
def CreateTiledMovieObjectFromLayout(layoutFile, screenRect, pos, absRect, fullRect, loadAllMovieTiles=False, scale=None, allowFrameSkip=None): print "CreateTiledMovieObjectFromLayout" objectsToGroup = [] if None == pos: pos = (0, 0) layoutEntries = ReadLayout(layoutFile) for entry in layoutEntries: moviePos = Vec2(pos[0] + entry.pos[0], pos[1] + entry.pos[1]) movieRenderRect = Rect(moviePos[0], moviePos[1], entry.getWidth(), entry.getHeight()) tileObject = None # same code as below func if loadAllMovieTiles or movieRenderRect.colliderect(absRect): movieTileFilename = entry.path fullMovieTilePath = movieTileFilename # for now has absolute paths # same code as below function print "movieTileFilename:", movieTileFilename, len( movieTileFilename) if len(movieTileFilename.strip()) > 0: print "movieTileFilename:", movieTileFilename, len( movieTileFilename) print "TiledMovie: loading tile: ", fullMovieTilePath # obj.pos and obj.size will be used to group movie tiles. fps = fps = entry.getProperty("fps") tileObject = CreateMovieObject(fullMovieTilePath, screenRect, moviePos, absRect, fullRect, fps=fps, scale=scale, allowFrameSkip=allowFrameSkip) else: print "Warning movieTile not found for:", xIndex, yIndex if not tileObject: tileObject = NullTileDisplayObject( pos=moviePos, size=(movieRenderRect.width, movieRenderRect.height)) # Empty object to represent # objects on other nodes # and keep object list synced. objectsToGroup.append(tileObject) shortName = os.path.basename(layoutFile.strip(os.path.sep)) duration = layoutEntries[0].getProperty("duration") fps = fps = layoutEntries[0].getProperty("fps") groupObject = TiledMovieGroupObject(shortName, objectsToGroup, duration=duration, fps=fps) groupObject.doChildUpdates = True returnObj = groupObject return returnObj
def CreateTiledMovieObject(filename, screenRect, pos, absRect, fullRect, loadAllMovieTiles=False, scale=None, allowFrameSkip=None): # A tiled movie object has a mostly frozen position on the display (for now) # Each tile only loads the movie tiles that it will display at the # movie's current position. # Find the tiles that are located on the current display, load them, and # position them. print "CreateTiledMovieObject" objectsToGroup = [] # Load info from description des = ReadTiledMovieDescription(filename) tileFilenames = os.listdir(filename) print "tileFilenames:", tileFilenames # calculate adjustment in case full movie width and height are not # evenly divisible by tile width and height. adjustment = (des["tileColsRows"][0] * des["tileRes"][0]-des["fullRes"][0], des["tileColsRows"][1] * des["tileRes"][1]-des["fullRes"][1]) imageBased = False if IsTiledMovieChunkImageBased(os.path.join(filename, tileFilenames[0])): imageBased = True for xIndex in range(des["tileColsRows"][0]): for yIndex in range(des["tileColsRows"][1]): # TZ==TopZero yIndexBZ = des["tileColsRows"][1] - 1 - yIndex # BZ==BottomZero movieTileFilename = "" for f in tileFilenames: tileYIndex = yIndexBZ if imageBased: # The 0th row for our movie and image loaders is different. tileYIndex = yIndex if f.startswith("%s_%s." % (xIndex,tileYIndex)) or f == "%s_%s" % (xIndex,tileYIndex): movieTileFilename = f fullMovieTilePath = os.path.join(filename, movieTileFilename) tileObject = None # full movie width and height are not evenly divisible by # tile width and tile height, so adjust offset xSrcOffset = xIndex * des["tileRes"][0] - adjustment[0] ySrcOffset = yIndex * des["tileRes"][1] - adjustment[1] srcWidth,srcHeight = (des["tileRes"][0], des["tileRes"][1]) # adjust a possibly small row or column's offset and size # might only be necessary for y, since y is flipped (x untested). #if xIndex == 0: # xOffset -= adjustment[0] # width -= adjustment[0] if scale != None: xRenderOffset = xIndex * des["tileRes"][0] * scale[0] - adjustment[0] yRenderOffset = yIndex * des["tileRes"][1] * scale[1] - adjustment[1] * scale[1] # remove the adjustment when yIndex == 0 if yIndex == 0: yRenderOffset = yIndex * des["tileRes"][1] * scale[1] srcHeight -= adjustment[1] renderWidth, renderHeight = srcWidth * scale[0], srcHeight * scale[1] else: # remove the adjustment when yIndex == 0 if yIndex == 0: # FIXME, if we ever use imagebased (slow, movies # from image files, this may have to be adjusted # to use tileYIndex and maybe flip signs below. ySrcOffset += adjustment[1] srcHeight -= adjustment[1] xRenderOffset, yRenderOffset = xSrcOffset, ySrcOffset renderWidth, renderHeight = srcWidth, srcHeight #xSrcOffset = xIndex * des["tileRes"][0] #ySrcOffset = yIndex * des["tileRes"][1] #moviePos = Vec2(pos[0] + xSrcOffset, pos[1] + ySrcOffset) moviePos = Vec2(pos[0] + xRenderOffset, pos[1] + yRenderOffset) #movieRect = Rect(pos[0] + xSrcOffset, pos[1] + ySrcOffset, srcWidth, srcHeight) movieRenderRect = Rect(pos[0] + xRenderOffset, pos[1] + yRenderOffset, renderWidth, renderHeight) # print "Checking colliderects to see if movie tile is on this display tile:", movieRenderRect.colliderect(absRect), movieRenderRect, absRect, movieRenderRect.colliderect(absRect), "indexes:", xIndex, yIndex, "flipped indexes:", xIndex,yIndexBZ if loadAllMovieTiles or movieRenderRect.colliderect(absRect): movieTileFilename = "" for f in tileFilenames: if f.startswith("%s_%s." % (xIndex,yIndexBZ)) or f == "%s_%s" % (xIndex,yIndexBZ): movieTileFilename = f print "movieTileFilename:", movieTileFilename, len(movieTileFilename) if len(movieTileFilename.strip()) > 0: print "movieTileFilename:", movieTileFilename, len(movieTileFilename) print "TiledMovie: loading tile: ", fullMovieTilePath # obj.pos and obj.size will be used to group movie tiles. tileObject = CreateMovieObject(fullMovieTilePath, screenRect, moviePos, absRect, fullRect, fps=des["FPS"], scale=scale, allowFrameSkip=allowFrameSkip) else: print "Warning movieTile not found for:", xIndex, yIndex if not tileObject: tileObject = NullTileDisplayObject(pos=moviePos,size=(movieRenderRect.width,movieRenderRect.height) ) # Empty object to represent # objects on other nodes # and keep object list synced. objectsToGroup.append(tileObject) shortName = os.path.basename(filename.strip(os.path.sep)) groupObject = TiledMovieGroupObject(shortName, objectsToGroup, duration=des["duration"], fps=des["FPS"]) groupObject.doChildUpdates=True returnObj = groupObject return returnObj
def CreateTiledMovieObject(filename, screenRect, pos, absRect, fullRect, loadAllMovieTiles=False, scale=None, allowFrameSkip=None): # A tiled movie object has a mostly frozen position on the display (for now) # Each tile only loads the movie tiles that it will display at the # movie's current position. # Find the tiles that are located on the current display, load them, and # position them. print "CreateTiledMovieObject" objectsToGroup = [] # Load info from description des = ReadTiledMovieDescription(filename) tileFilenames = os.listdir(filename) print "tileFilenames:", tileFilenames # calculate adjustment in case full movie width and height are not # evenly divisible by tile width and height. adjustment = (des["tileColsRows"][0] * des["tileRes"][0] - des["fullRes"][0], des["tileColsRows"][1] * des["tileRes"][1] - des["fullRes"][1]) imageBased = False if IsTiledMovieChunkImageBased(os.path.join(filename, tileFilenames[0])): imageBased = True for xIndex in range(des["tileColsRows"][0]): for yIndex in range(des["tileColsRows"][1]): # TZ==TopZero yIndexBZ = des["tileColsRows"][1] - 1 - yIndex # BZ==BottomZero movieTileFilename = "" for f in tileFilenames: tileYIndex = yIndexBZ if imageBased: # The 0th row for our movie and image loaders is different. tileYIndex = yIndex if f.startswith("%s_%s." % (xIndex, tileYIndex) ) or f == "%s_%s" % (xIndex, tileYIndex): movieTileFilename = f fullMovieTilePath = os.path.join(filename, movieTileFilename) tileObject = None # full movie width and height are not evenly divisible by # tile width and tile height, so adjust offset xSrcOffset = xIndex * des["tileRes"][0] - adjustment[0] ySrcOffset = yIndex * des["tileRes"][1] - adjustment[1] srcWidth, srcHeight = (des["tileRes"][0], des["tileRes"][1]) # adjust a possibly small row or column's offset and size # might only be necessary for y, since y is flipped (x untested). #if xIndex == 0: # xOffset -= adjustment[0] # width -= adjustment[0] if scale != None: xRenderOffset = xIndex * des["tileRes"][0] * scale[ 0] - adjustment[0] yRenderOffset = yIndex * des["tileRes"][1] * scale[ 1] - adjustment[1] * scale[1] # remove the adjustment when yIndex == 0 if yIndex == 0: yRenderOffset = yIndex * des["tileRes"][1] * scale[1] srcHeight -= adjustment[1] renderWidth, renderHeight = srcWidth * scale[ 0], srcHeight * scale[1] else: # remove the adjustment when yIndex == 0 if yIndex == 0: # FIXME, if we ever use imagebased (slow, movies # from image files, this may have to be adjusted # to use tileYIndex and maybe flip signs below. ySrcOffset += adjustment[1] srcHeight -= adjustment[1] xRenderOffset, yRenderOffset = xSrcOffset, ySrcOffset renderWidth, renderHeight = srcWidth, srcHeight #xSrcOffset = xIndex * des["tileRes"][0] #ySrcOffset = yIndex * des["tileRes"][1] #moviePos = Vec2(pos[0] + xSrcOffset, pos[1] + ySrcOffset) moviePos = Vec2(pos[0] + xRenderOffset, pos[1] + yRenderOffset) #movieRect = Rect(pos[0] + xSrcOffset, pos[1] + ySrcOffset, srcWidth, srcHeight) movieRenderRect = Rect(pos[0] + xRenderOffset, pos[1] + yRenderOffset, renderWidth, renderHeight) # print "Checking colliderects to see if movie tile is on this display tile:", movieRenderRect.colliderect(absRect), movieRenderRect, absRect, movieRenderRect.colliderect(absRect), "indexes:", xIndex, yIndex, "flipped indexes:", xIndex,yIndexBZ if loadAllMovieTiles or movieRenderRect.colliderect(absRect): movieTileFilename = "" for f in tileFilenames: if f.startswith("%s_%s." % (xIndex, yIndexBZ) ) or f == "%s_%s" % (xIndex, yIndexBZ): movieTileFilename = f print "movieTileFilename:", movieTileFilename, len( movieTileFilename) if len(movieTileFilename.strip()) > 0: print "movieTileFilename:", movieTileFilename, len( movieTileFilename) print "TiledMovie: loading tile: ", fullMovieTilePath # obj.pos and obj.size will be used to group movie tiles. tileObject = CreateMovieObject( fullMovieTilePath, screenRect, moviePos, absRect, fullRect, fps=des["FPS"], scale=scale, allowFrameSkip=allowFrameSkip) else: print "Warning movieTile not found for:", xIndex, yIndex if not tileObject: tileObject = NullTileDisplayObject( pos=moviePos, size=(movieRenderRect.width, movieRenderRect.height)) # Empty object to represent # objects on other nodes # and keep object list synced. objectsToGroup.append(tileObject) shortName = os.path.basename(filename.strip(os.path.sep)) groupObject = TiledMovieGroupObject(shortName, objectsToGroup, duration=des["duration"], fps=des["FPS"]) groupObject.doChildUpdates = True returnObj = groupObject return returnObj