Esempio n. 1
0
	def deployAsset( self, node, context ):
		super( PrebuiltAtlasAssetManager, self ).deployAsset( node, context )
		for key, value in node.objectFiles.items():
			if not key.startswith( 'pixmap' ): continue
			pixmapPath = value
			mappedPath = context.getAbsFile( pixmapPath )
			if context.isNewFile( mappedPath ):
				# print( node.getNodePath(), mappedPath )
				ImageHelpers.convertToWebP( mappedPath )
Esempio n. 2
0
 def deployAsset(self, node, context):
     super(PrebuiltAtlasAssetManager, self).deployAsset(node, context)
     for key, value in node.objectFiles.items():
         if not key.startswith('pixmap'): continue
         pixmapPath = value
         mappedPath = context.getAbsFile(pixmapPath)
         if context.isNewFile(mappedPath):
             # print( node.getNodePath(), mappedPath )
             ImageHelpers.convertToWebP(mappedPath)
Esempio n. 3
0
 def _processTexture(self, src, dst, texture):
     #convert single image
     result = ImageHelpers.convertToPNG(src, dst)
     #apply processor on dst file
     group = texture.parent
     if group:
         groupProcessor = group.processor
         if groupProcessor:
             applyTextureProcessor(groupProcessor, dst)
         nodeProcessor = texture.processor
         if nodeProcessor:
             applyTextureProcessor(nodeProcessor, dst)
Esempio n. 4
0
	def _processTexture( self, src, dst, texture ):
		#convert single image
		result = ImageHelpers.convertToPNG( src, dst )		
		#apply processor on dst file
		group = texture.parent
		if group:
			groupProcessor = group.processor
			if groupProcessor:
				applyTextureProcessor( groupProcessor, dst )
			nodeProcessor = texture.processor
			if nodeProcessor:
				applyTextureProcessor( nodeProcessor, dst )				
Esempio n. 5
0
    def _convertTextureFormat(self, fullPath, format, outputPath=None):
        if format == 'auto':
            format = 'webp'
        else:
            format = 'png'

        print 'converting texture', fullPath, format

        if format == 'webp':
            ImageHelpers.convertToWebP(fullPath)
        elif format == 'png':
            pass
        elif format == 'PVR-2':
            ImageHelpers.convertToPVR(fullPath, outputPath, bbp=2)
        elif format == 'PVR-4':
            ImageHelpers.convertToPVR(fullPath, outputPath, bbp=4)
Esempio n. 6
0
	def _convertTextureFormat( self, fullPath, format, outputPath = None ):
		if format == 'auto':
			format = 'webp'
		else:
			format = 'png'
		
		print 'converting texture', fullPath, format

		if format == 'webp':
			ImageHelpers.convertToWebP( fullPath )
		elif format == 'png':
			pass
		elif format == 'PVR-2':
			ImageHelpers.convertToPVR( fullPath, outputPath, bbp = 2 )
		elif format == 'PVR-4':
			ImageHelpers.convertToPVR( fullPath, outputPath, bbp = 4 )
Esempio n. 7
0
    def processTextureNode(self, texture, assetNode):
        logging.info('processing texture: %s' % assetNode.getNodePath())

        if assetNode.isType('texture'):
            assetNode.clearCacheFiles()
            if assetNode.isVirtual():
                src = assetNode.getMetaData('source', None)
                if not src:
                    raise Exception(
                        'virtual texture node has no source metadata given')
                src = AssetLibrary.get().getAbsProjectPath(src)
            else:
                src = assetNode.getAbsFilePath()
            dst = assetNode.getAbsCacheFile('pixmap')
            self._processTexture(src, dst, texture)

        elif assetNode.isType('prebuilt_atlas'):
            atlasSourcePath = assetNode.getCacheFile('atlas_source')
            atlas = self.delegate.call('loadPrebuiltAtlas', atlasSourcePath)
            pageId = 0
            for page in atlas.pages.values():
                pageId += 1
                src = self.getAssetLibrary().getAbsProjectPath(page.source)
                dst = assetNode.getCacheFile('pixmap_%d' % pageId)
                assetNode.setObjectFile('pixmap_%d' % pageId, dst)
                self._processTexture(src, dst, texture)
                if page.w < 0:
                    w, h = ImageHelpers.getImageSize(dst)
                    page.w = w
                    page.h = h
            assetNode.setMetaData('page_count', pageId)
            atlasOutputPath = assetNode.getCacheFile('atlas')
            assetNode.setObjectFile('atlas', atlasOutputPath)
            texture.prebuiltAtlasPath = atlasOutputPath
            atlas.save(atlas, atlasOutputPath)

        else:
            raise Exception('unknown texture node type!!')
Esempio n. 8
0
	def processTextureNode( self, texture, assetNode ):
		logging.info( 'processing texture: %s' % assetNode.getNodePath() )

		if assetNode.isType( 'texture' ):
			assetNode.clearCacheFiles()
			if assetNode.isVirtual():
				src = assetNode.getMetaData( 'source', None )
				if not src:
					raise Exception( 'virtual texture node has no source metadata given' )
				src = AssetLibrary.get().getAbsProjectPath( src )
			else:
				src = assetNode.getAbsFilePath()
			dst = assetNode.getAbsCacheFile( 'pixmap' ) 
			self._processTexture( src, dst, texture )

		elif assetNode.isType( 'prebuilt_atlas' ):
			atlasSourcePath = assetNode.getCacheFile( 'atlas_source' )
			atlas = self.delegate.call( 'loadPrebuiltAtlas', atlasSourcePath )
			pageId = 0
			for page in atlas.pages.values():
				pageId += 1
				src = self.getAssetLibrary().getAbsProjectPath( page.source )
				dst = assetNode.getCacheFile( 'pixmap_%d' % pageId )
				assetNode.setObjectFile( 'pixmap_%d' % pageId, dst )
				self._processTexture( src, dst, texture )
				if page.w < 0:
					w, h = ImageHelpers.getImageSize( dst )
					page.w = w
					page.h = h
			assetNode.setMetaData( 'page_count', pageId )			
			atlasOutputPath = assetNode.getCacheFile( 'atlas' )
			assetNode.setObjectFile( 'atlas', atlasOutputPath )
			texture.prebuiltAtlasPath = atlasOutputPath
			atlas.save( atlas, atlasOutputPath )

		else:
			raise Exception( 'unknown texture node type!!' )
Esempio n. 9
0
 def onBuildAssetThumbnail(self, assetNode, targetPath, size):
     srcPath = assetNode.getAbsFilePath()
     if not ImageHelpers.buildThumbnail(srcPath, targetPath, size):
         return False
     return True
Esempio n. 10
0
	def onBuildAssetThumbnail( self, assetNode, targetPath, size ):
		srcPath = assetNode.getAbsFilePath()
		ImageHelpers.buildThumbnail( srcPath, targetPath, size )
		return True