kopia lustrzana https://github.com/torrinworx/Blend_My_NFTs
Merge pull request #26 from torrinworx/Meta-Data-Implementation
Meta data implementationpull/27/head
commit
a52ae604ad
|
@ -1,3 +1,7 @@
|
|||
# Some code in this file was generously sponsored by the amazing team over at SolSweepers!
|
||||
# Feel free to check out their amazing project and see how they are using Blend_My_NFTs:
|
||||
# https://discord.gg/QTT7dzcuVs
|
||||
|
||||
import bpy
|
||||
import os
|
||||
import sys
|
||||
|
@ -47,6 +51,8 @@ def render_and_save_NFTs():
|
|||
|
||||
x = 1
|
||||
for a in BatchDNAList:
|
||||
metaData = {}
|
||||
|
||||
for i in hierarchy:
|
||||
for j in hierarchy[i]:
|
||||
if config.enableGeneration:
|
||||
|
@ -63,22 +69,56 @@ def render_and_save_NFTs():
|
|||
'''
|
||||
|
||||
listAttributes = list(hierarchy.keys())
|
||||
listDnaDecunstructed = a.split('-')
|
||||
listDnaDecunstructed = a.split('-')
|
||||
dnaDictionary = {}
|
||||
|
||||
for i,j in zip(listAttributes,listDnaDecunstructed):
|
||||
for i, j in zip(listAttributes, listDnaDecunstructed):
|
||||
dnaDictionary[i] = j
|
||||
|
||||
for x in dnaDictionary:
|
||||
for k in hierarchy[x]:
|
||||
kNum = hierarchy[x][k]["number"]
|
||||
if kNum == dnaDictionary[x]:
|
||||
dnaDictionary.update({x:k})
|
||||
dnaDictionary.update({x: k})
|
||||
return dnaDictionary
|
||||
|
||||
dnaDictionary = match_DNA_to_Variant(a)
|
||||
name = config.nftName + str(x)
|
||||
|
||||
|
||||
def returnMetaData(metaDataType):
|
||||
'''
|
||||
This function exports formatted meta data based on the metaDataType variable in config.py
|
||||
'''
|
||||
|
||||
if metaDataType == "DEFAULT":
|
||||
metaData["name"] = name
|
||||
metaData["description"] = config.metaDataDescription
|
||||
metaData["NFT_DNA"] = a
|
||||
metaData["NFT_Variants"] = dnaDictionary
|
||||
|
||||
elif metaDataType == "SOL":
|
||||
metaData["name"] = name
|
||||
metaData["symbol"] = ""
|
||||
metaData["description"] = config.metaDataDescription
|
||||
metaData["seller_fee_basis_points"] = None
|
||||
metaData["image"] = ""
|
||||
metaData["animation_url"] = ""
|
||||
metaData["external_url"] = ""
|
||||
metaData["attributes"] = {"NFT_DNA": a, "NFT_Variants": dnaDictionary}
|
||||
metaData["collection"] = {"name": "", "family": ""}
|
||||
metaData["properties"] = {"files": [{"uri": "", "type": ""}],
|
||||
"category": "",
|
||||
"creators": [{"address": "", "share": None}]
|
||||
}
|
||||
elif metaDataType == "ADA":
|
||||
print("Cardano meta data template not yet supported.")
|
||||
return
|
||||
|
||||
elif metaDataType == "ETH":
|
||||
print("Ethereum meta data template not yet supported.")
|
||||
return
|
||||
|
||||
print("")
|
||||
print("----------Rendering New NFT----------")
|
||||
print("DNA attribute list:")
|
||||
|
@ -95,15 +135,15 @@ def render_and_save_NFTs():
|
|||
|
||||
time_start_2 = time.time()
|
||||
|
||||
imageOutputBatchSubFolder = "Batch" + str(config.renderBatch)
|
||||
|
||||
fullImagePath = config.images_save_path + config.slash + imageOutputBatchSubFolder + config.slash + "{}.jpeg".format(name)
|
||||
batchFolder = os.path.join(config.images_save_path, "Batch" + str(config.renderBatch))
|
||||
imagePath = os.path.join(batchFolder, "Images", name)
|
||||
metaDataFolder = os.path.join(batchFolder, "Image_Data")
|
||||
|
||||
if config.enableGeneration:
|
||||
for c in dnaDictionary:
|
||||
collection = dnaDictionary[c]
|
||||
if stripColorFromName(collection) in config.colorList:
|
||||
colorVal = int(collection.rsplit("_",1)[1])-1
|
||||
colorVal = int(collection.rsplit("_", 1)[1])-1
|
||||
collection = stripColorFromName(collection)
|
||||
bpy.data.collections[collection].hide_render = False
|
||||
bpy.data.collections[collection].hide_viewport = False
|
||||
|
@ -120,10 +160,20 @@ def render_and_save_NFTs():
|
|||
bpy.data.collections[collection].hide_render = False
|
||||
bpy.data.collections[collection].hide_viewport = False
|
||||
print("Rendering")
|
||||
bpy.context.scene.render.filepath = fullImagePath
|
||||
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.enableMeteData:
|
||||
returnMetaData(config.metaDataType)
|
||||
|
||||
if not os.path.exists(metaDataFolder):
|
||||
os.mkdir(metaDataFolder)
|
||||
|
||||
jsonMetaData = json.dumps(metaData, indent=1, ensure_ascii=True)
|
||||
with open(os.path.join(metaDataFolder, name + "_Data"), 'w') as outfile:
|
||||
outfile.write(jsonMetaData + '\n')
|
||||
|
||||
print("Completed {} render in ".format(name) + "%.4f seconds" % (time.time() - time_start_2))
|
||||
x += 1
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# The code in this file was generous sponsored by the amazing team over at Rumble Worlds!
|
||||
# Feel free to check out their amazing project and see how they are using Blend_My_NFTs
|
||||
# The code in this file was generously sponsored by the amazing team over at Rumble Worlds!
|
||||
# Feel free to check out their amazing project and see how they are using Blend_My_NFTs:
|
||||
# https://www.rumbleworlds.io/
|
||||
|
||||
import bpy
|
||||
|
|
|
@ -36,11 +36,6 @@ objectFormatExport = '' # The file format of the objects you would like to expo
|
|||
# obj - The .obj file format *Exports both a .obj and a .mtl files for the same generated object
|
||||
# x3d - The .x3d file format
|
||||
|
||||
# error handling #
|
||||
|
||||
if objectFormatExport not in ['fbx', 'glb', 'obj', 'x3d'] and enable3DModels:
|
||||
raise ValueError("Output format in `objectFormatExport` can only be 'fbx', 'glb', 'obj', 'x3d'.")
|
||||
|
||||
### Select colour or material.###
|
||||
# Object generation options:
|
||||
enableGeneration = False # When set to true this applies the sets of colors listed below to the objects in the collections named below
|
||||
|
@ -73,6 +68,23 @@ materialList2 = ['Material2', 'Material2.001', 'Material2.002', 'Material2.003',
|
|||
if generationType == 'material': # Do not change this line.
|
||||
colorList = {"Cube_1_33": materialList1, "Sphere_2_0": materialList2}
|
||||
|
||||
# Meta Data generation
|
||||
enableMeteData = True # 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.
|
||||
# DEFAULT - The default setting; exports variants, dna, number, name, and rarity of each NFT to a dictionary
|
||||
# ADA - Cardano - Format: Not supported yet.
|
||||
# SOL - Solana - Format: https://docs.metaplex.com/nft-standard
|
||||
# ETH - Ethereum - Format: Not supported yet.
|
||||
|
||||
# NOTE: This is just the information Blend_My_NFTs can provide, you will have to add policy ID, URI information, etc
|
||||
# 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.
|
||||
|
||||
metaDataDescription = '' # The description of your NFT that will be inserted into its meta data
|
||||
|
||||
# Utilities - DO NOT TOUCH:
|
||||
mac = 'Darwin' # Mac OS
|
||||
windows = 'Windows' # Windows
|
||||
|
@ -94,6 +106,11 @@ modelAssetPath = save_path + slash + "3D_Model_Input" # The input path for 3D m
|
|||
model_save_path = save_path + slash + "3D_Model_Output" # The output path for 3D models generated by Model_Generator.py
|
||||
model_Script_Ignore_Path = modelAssetPath + slash + "Script_Ignore_Folder" # The path to the Script_Ignore_Folder for 3D models
|
||||
|
||||
# error handling #
|
||||
|
||||
if objectFormatExport not in ['fbx', 'glb', 'obj', 'x3d'] and enable3DModels:
|
||||
raise ValueError("Output format in `objectFormatExport` can only be 'fbx', 'glb', 'obj', 'x3d'.")
|
||||
|
||||
# EXPERIMENTAL FEATURES:
|
||||
|
||||
# Enables Rarity_Sorter to weigh NFT DNA attributes and variants:
|
||||
|
|
Ładowanie…
Reference in New Issue