Final fixes for implementing animations

Refactored Config.py
Added in  animatoinFileFormat variable to specify file export type for animations
Changed path creation method in Exporter.py to os.makedirs
Added animation to Exporter.py
Changed file path export method for 3D models in Exporter.py
Deleted old code in metaData.py file
pull/32/head
Torrin Leonard 2021-12-03 17:05:55 -05:00
rodzic 0584beee19
commit cf193361dc
3 zmienionych plików z 48 dodań i 32 usunięć

Wyświetl plik

@ -106,8 +106,15 @@ def render_and_save_NFTs():
time_start_2 = time.time()
batchFolder = os.path.join(config.images_save_path, "Batch" + str(config.renderBatch))
imagePath = os.path.join(batchFolder, "Images", "Image_" + name)
modelPath = os.path.join(batchFolder, "Models")
animationPath = os.path.join(batchFolder, "Animations", "Animation_" + name)
modelPath = os.path.join(batchFolder, "Models", "Model_" + name)
imageFolder = os.path.join(batchFolder, "Images")
animationFolder = os.path.join(batchFolder, "Animations")
modelFolder = os.path.join(batchFolder, "Models")
metaDataFolder = os.path.join(batchFolder, "NFT_metaData")
if config.enableGeneration:
@ -134,14 +141,24 @@ def render_and_save_NFTs():
print("Generating")
if config.enableImages:
if not os.path.exists(imageFolder):
os.makedirs(imageFolder)
bpy.context.scene.render.filepath = imagePath
bpy.context.scene.render.image_settings.file_format = config.imageFileFormat
bpy.ops.render.render(write_still=True)
if config.enableModelsBlender:
if config.enableAnimations:
if not os.path.exists(animationFolder):
os.makedirs(animationFolder)
if not os.path.exists(modelPath):
os.mkdir(modelPath)
bpy.context.scene.render.filepath = animationPath
bpy.context.scene.render.image_settings.file_format = config.animationFileFormat
bpy.ops.render.render(animation=True)
if config.enableModelsBlender:
if not os.path.exists(modelFolder):
os.makedirs(modelFolder)
for i in dnaDictionary:
coll = dnaDictionary[i]
@ -153,33 +170,30 @@ def render_and_save_NFTs():
obj.select_set(True)
if config.objectFormatExport == 'glb':
bpy.ops.export_scene.gltf(filepath=os.path.join(modelPath, "Model_" + name),
bpy.ops.export_scene.gltf(filepath=modelPath,
check_existing=True,
export_format='GLB',
use_selection=True)
elif config.objectFormatExport == 'fbx':
bpy.ops.export_scene.fbx(filepath=os.path.join(modelPath, "Model_" + name),
bpy.ops.export_scene.fbx(filepath=modelPath,
check_existing=True,
use_selection=True)
elif config.objectFormatExport == 'obj':
bpy.ops.export_scene.obj(filepath=os.path.join(modelPath, "Model_" + name),
bpy.ops.export_scene.obj(filepath=modelPath,
check_existing=True,
use_selection=True)
elif config.objectFormatExport == 'x3d':
bpy.ops.export_scene.x3d(filepath=os.path.join(modelPath, "Model_" + name),
bpy.ops.export_scene.x3d(filepath=modelPath,
check_existing=True,
use_selection=True)
if config.enableAnimations:
if config.enableMetaData:
metaData.returnMetaData(config.metaDataType, metaDataDict, name, a, dnaDictionary)
if not os.path.exists(metaDataFolder):
os.mkdir(metaDataFolder)
os.makedirs(metaDataFolder)
metaData.returnMetaData(config.metaDataType, metaDataDict, name, a, dnaDictionary)
jsonMetaData = json.dumps(metaDataDict, indent=1, ensure_ascii=True)
with open(os.path.join(metaDataFolder, name + "_Data.json"), 'w') as outfile:
outfile.write(jsonMetaData + '\n')

Wyświetl plik

@ -60,11 +60,6 @@ def returnMetaData(metaDataType, metaDataDict, name, a, dnaDictionary):
"category": "",
"creators": [{"address": "", "share": None}]
}
metaDataDict["category"] = ""
metaDataDict["creators"] = [{
"address": "",
"share": None
}]
elif metaDataType == "ADA":
metaDataDict["721"] = {

Wyświetl plik

@ -9,19 +9,28 @@ imageFileFormat = '' # Dictate the image extension when Blender renders the ima
# JPEG - Exports the .jpeg format
# PNG - Exports the .png format
# Visit https://docs.blender.org/api/current/bpy.types.Image.html#bpy.types.Image.file_format
# for a complete list of file formats supported by Blender. Enter the file extension exactly as specified in
# the Blender API documentation.
# for a complete list of file formats supported by Blender. (Only use Image file extensions with imageFileFormat, 3D
# object, or animation file extensions will cause the program to fail)
animationFileFormat = '' # Dictate the animations extension when Blender renders and compiles the images
# Type the exact name provided below in the '' above:
# AVI_JPEG - Exports the .avi jpeg format
# AVI_RAW - Exports the .avi raw format
# FFMPEG - Exports the .ffmpeg format
# Visit https://docs.blender.org/api/current/bpy.types.Image.html#bpy.types.Image.file_format
# for a complete list of file formats supported by Blender. (These are the Blender only supported animation formats)
objectFormatExport = '' # The file format of the objects you would like to export
# The following are file formats Blender accepts for exporting object files.
# Please type the exact name provided below in the '' above:
# Type the exact name provided below in the '' above:
# fbx - The .FBX file format
# glb - The .glb file format
# obj - The .obj file format *Exports both a .obj and a .mtl files for the same generated object
# x3d - The .x3d file format
# Visit https://docs.blender.org/api/current/bpy.ops.export_scene.html?highlight=export_scene#module-bpy.ops.export_scene
# for a complete list of object formats supported by Blender.
# The path to Blend_My_NFTs folder:
save_path_mac = '/Users/Path/To/Blend_My_NFTs'
save_path_mac = ''
save_path_windows = r''
# Place the path in the '', e.g: save_path_mac = '/Users/Path/to/Blend_My_NFTs'
# Example mac: /Users/Path/to/Blend_My_NFTs
@ -36,6 +45,7 @@ renderBatch = 0 # The batch number to render in Exporter.py
enableExporter = False
enableImages = False # Renders and exports Images when main.py is run in Blender if enableExporter = True
enableAnimations = False # Renders and exports Animations when main.py is run in Blender if enableExporter = True
enableModelsBlender = False # Generates 3D models when main.py is run in Blender if enableExporter = True
# ^^ Generates models with .blend file NOT external object library.
@ -44,6 +54,8 @@ enableRarity = False
# generateColors must be turned off and enableMaxNFTs must be turned on.
# True = include weighted rarity percentages in NFTRecord.json calculations,
# False = Pure random selection of variants
# Note: The more attributes and variants you have, and by nature the more possible NFT combinations you have, the more
# accurate your percentages will be.
### Select colour or material.###
# Object generation options:
@ -80,7 +92,7 @@ if generationType == 'material': # Do not change this line.
# Meta Data generation
enableMetaData = False # Set to True to turn on meta data, set to False to turn off meta data generation.
metaDataType = 'DEFAULT' # Select the format of the generated Meta Data for your NFTs blockchain.
metaDataType = '' # Select the format of the generated Meta Data for your NFTs blockchain.
# DEFAULT - The default setting; exports variants, dna, number, name, and rarity of each NFT to a dictionary (Not a blockchain standard)
# ADA - Cardano - Format Source: https://cips.cardano.org/cips/cip25/
# SOL - Solana - Format Source: https://docs.metaplex.com/nft-standard
@ -90,7 +102,7 @@ metaDataType = 'DEFAULT' # Select the format of the generated Meta Data for you
# yourself when you upload and mint your NFT collection.
# DISCLAIMER: These are only templates based on the common standards for the given blockchain, you will have to modify
# and fill them in with a script of your own when you mint your NFT collection. These metadata templates are only provided
# for your convenience.
# for your convenience and are as accurate to the standards above that I could make them.
metaDataDescription = '' # The description of your NFT that will be inserted into its meta data
@ -138,9 +150,4 @@ maxNFTsTest = 5 # Increase to get a more accurate reading of the render time. T
# Turn this on when you run main.py to generate NFTRecord.json and appropriate batches to confirm there are no duplicate
# NFT DNA.
checkDups = True
# EXPERIMENTAL FEATURES:
enableAnimations = True # enableExporter must be set to True, and enableImages and enableModelsBlender must be set to False
checkDups = False