Skip to content

Instantly share code, notes, and snippets.

@aobond2
aobond2 / BlenderThumbnail.py
Last active April 12, 2024 09:29
Iterate on objects, create camera+lights, then make nice thumbnail render
import bpy
from mathutils import Vector
import math
import os
folderPath = "C:/Users/BondhanKimbalazani/Documents/ModularCharacter/GLB_Test/BodyA"
#folderPath = 'C:/Users/BondhanKimbalazani/Documents/ModularCharacter/GLB_Test/BodyA/TorsoUpper'
thumbnailFolder = 'C:/Users/BondhanKimbalazani/Pictures/Thumbnails/'
def importGLBs():
import json
import os
import csv
bucketURL = "https://storage.googleapis.com/glb-content-bucket/GLB/"
thumbnailLocalPath =""
thumbnailLocalFolder = "C:/Users/BondhanKimbalazani/Documents/ModularCharacter/GLB_Test/Thumbnails"
GLBfolder = "C:/Users/BondhanKimbalazani/Documents/ModularCharacter/GLB_Test/"
csvData = []
csvPath = "C:/Users/BondhanKimbalazani/Documents/parts.csv"
import subprocess
import os
import sys
# TODO: Not sure if this is default folder for everyone
userFolder = os.path.expanduser('~')
avatarToolsFolder = userFolder + '\\avatar-tools'
recursiveArg = '--r'
def getArguments():
@aobond2
aobond2 / MakeMMLFromCSV.py
Last active February 21, 2024 17:29
Read csv for all categories and available GLBs, then write out MML avatar based on some rule
import csv
import random
import os
# Source CSV
CSVfilepath = "C:/Users/BondhanKimbalazani/Documents/ModularCharacter/ClothingTest-Sheet3.csv"
TextOutputFolder = "C:/Users/BondhanKimbalazani/Documents/ModularCharacter/MMLOutput"
BodyArray = []
HairArray = []
LegBaseArray = []
@aobond2
aobond2 / MakeBodyPartsCSV.py
Last active February 21, 2024 16:29
Get all available GLBs, then make a csv to categorized them
import csv
import os
import glob
# Define the CSV file path
characterGLBFolder = "C:/Users/BondhanKimbalazani/Documents/ModularCharacter/GLB_Test"
targetFile = "C:/Users/BondhanKimbalazani/Documents/ModularCharacter/ClothingTest-Sheet3.csv"
BodyArray = []
HairArray = []
LegBaseArray = []
import unreal
# Change this with desired LOD level
targetLOD = 0
# Change this with target folder for GLB output
targetFolder = "C:\\GLBExportTest\\"
targetFileFormat = ".glb"
selectedAssets = unreal.EditorUtilityLibrary.get_selected_assets()
numAssets = len(selectedAssets)
@aobond2
aobond2 / FaceAttachmentAutoBlendshape.py
Last active November 15, 2023 14:13
Transfer blendshape between mesh with different topology. In this case from head to additional meshes (eyebrows, moustache, etc)
import maya.cmds as cmds
blendshapeList = []
# TODO: Change this, hard code for now
objectAffected = "eyebrow"
mainHead = None
blendshapeCopies = []
meshDeformer = None
renamedBlendshapesArray = []
@aobond2
aobond2 / BlendshapeOrg.py
Last active November 8, 2023 11:46
Auto create blendshape from separate maya file
import os
import maya.cmds as cmds
import pymel.core as pm
currentFilePath = cmds.file(query=True, location=True)
subFolderName = "Blendshapes"
subFolderPath = os.path.join(os.path.dirname(currentFilePath), subFolderName)
blendshapeNamespace = 'Blendshape'
mainHead = None
targetShapes = []
@aobond2
aobond2 / OptimizeVCBased.py
Last active September 12, 2023 08:33
Vertex colour aware mesh optimizing
import bpy
BUpperLimit = 0.7
BLowerLimit = 0.3
GLimit = 0.3
vertexGroupName = "vcolorVG"
decimateRatio = 0.8
def objectSelection():
# TODO: Change this based on needs. Get all meshes in hierarchy
@aobond2
aobond2 / BakeToVC.py
Last active September 12, 2023 08:32
Baking AO and curvature to vertex colour
import bpy
import sys
import os
aoVC = None
aovcName = "AOVC"
pointinessMatName = "NewMat"
cVC = None
cvcName = "CVC"
finalVCName = "FinalVC"