1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- def generateHuman(cloth_list, person_id, sex):
- haveAcc = 0
- # load acc
- hair = open('modeleTxt/hair.txt', 'r').readlines()
- shoe = open('modeleTxt/shoe.txt', 'r').readlines()
- pifu = open('modeleTxt/skin.txt', 'r').readlines()
- if not os.path.exists(person_save_Folder):
- os.makedirs(person_save_Folder)
- if sex > 0:
- Gender1 = 1000000
- else:
- Gender1 = 0
- # setting
- Gender = '%.6f' % (Gender1 / 1000000)
- Muscle = '%.6f' % (random.randint(0, 1000000) / 1000000)
- African_1 = random.randint(0, 1000000)
- African = '%.6f' % (African_1 / 1000000)
- Asian_1 = random.randint(0, 1000000 - African_1)
- Asian = '%.6f' % (Asian_1 / 1000000)
- Caucasian = '%.6f' % ((1000000 - Asian_1 - African_1) / 1000000)
- if Gender1 > 1000000 / 2:
- m_height = random.gauss(170, 5.7) / 200
- while m_height > 1:
- m_height = random.gauss(170, 5.7) / 200
- Height = '%.6f' % (m_height)
- else:
- m_height = random.gauss(160, 5.2) / 200
- while m_height > 1:
- m_height = random.gauss(160, 5.2) / 200
- Height = '%.6f' % (m_height)
- BreastSize = '%.6f' % (random.randint(0, 70) / 100)
- Age = '%.6f' % (random.randint(20, 90) / 100)
- BreastFirmness = '%.6f' % (random.randint(30, 100) / 100)
- Weight = '%.6f' % (random.randint(0, 1000000) / 1000000)
- file_name = 'B' + str(person_id)
- # creating person file
- f = open(person_save_Folder + file_name + ".mhm", 'a')
- f.write('# Written by MakeHuman 1.1.1\n')
- f.write('version v1.1.1\n')
- f.write('tags ' + file_name + '\n')
- f.write('camera 0.0 0.0 0.0 0.0 0.0 1.0\n')
- f.write('modifier macrodetails-universal/Muscle ' + Muscle + '\n')
- f.write('modifier macrodetails/African ' + African + '\n')
- f.write('modifier macrodetails-proportions/BodyProportions 0.500000\n')
- f.write('modifier macrodetails/Gender ' + Gender + '\n')
- f.write('modifier macrodetails-height/Height ' + Height + '\n')
- f.write('modifier breast/BreastSize ' + BreastSize + '\n')
- f.write('modifier macrodetails/Age ' + Age + '\n')
- f.write('modifier breast/BreastFirmness ' + BreastFirmness + '\n')
- f.write('modifier macrodetails/Asian ' + Asian + '\n')
- f.write('modifier macrodetails/Caucasian ' + Caucasian + '\n')
- f.write('modifier macrodetails-universal/Weight ' + Weight + '\n')
- f.write('skeleton cmu_mb.mhskel\n')
- f.write('eyes HighPolyEyes 2c12f43b-1303-432c-b7ce-d78346baf2e6\n')
- # adding clothes
- if Gender1 > 1000000 / 2:
- f.write(hair[random.randint(0, len(hair) - 1)])
- else:
- f.write(hair[random.randint(0, len(hair) - 1)])
- f.write(shoe[random.randint(0, len(shoe) - 1)])
- for i in range(0, len(cloth_list)):
- f.write(cloth_list[i] + '\n')
- f.write('clothesHideFaces True\n')
- f.write(pifu[random.randint(0, len(pifu) - 1)])
- f.write('material Braid01 eead6f99-d6c6-4f6b-b6c2-210459d7a62e braid01.mhmat\n')
- f.write('material HighPolyEyes 2c12f43b-1303-432c-b7ce-d78346baf2e6 eyes/materials/brown.mhmat\n')
- f.write('subdivide False\n')
|