Modifying Breast Parameters Using a Script

Tech support and suggestions forum. If you only have a basic question on how to get started, please use the "newbies" forum in the community section.

Moderator: joepal

Modifying Breast Parameters Using a Script

Postby bd4 » Thu Sep 23, 2021 12:56 pm

Hello guys,

I'm trying to create a dataset made of diferent breast sizes and shapes. I created a python script that randomly modifies the Breast size (using setBreastSize) and the Breast Firmness (using setBreastFirmness), but I would like to be able to change some parameters that are included in the section Modelling/Gender/Breast, such as Vertical position, Horizontal position, Pointiness, Breast volume, Nipple Size and Nipple Point. Is there any way to do it by script? I think that it should be possible since I can do it on the MakeHuman interface.

Any help is welcomed,
Thank you!
bd4
 
Posts: 2
Joined: Thu Sep 23, 2021 10:48 am

Re: Modifying Breast Parameters Using a Script

Postby Elvaerwyn » Thu Sep 23, 2021 9:07 pm

Greetings,
And welcome! I believe what you would like to do is simply make some targets for makehuman? There are many available already i asset repo. However there is the add on for making own in the download section of site.
http://www.makehumancommunity.org/content/plugins.html
this link brings you to maketarget one and two for respective blender releases.

you will benefit from also reading some how tos in the wiki
http://www.makehumancommunity.org/wiki/ ... on:Targets
http://www.makehumancommunity.org/wiki/ ... :TargetsV2

Good luck with your work!
Elv
She who knows in repose with prose...
User avatar
Elvaerwyn
 
Posts: 373
Joined: Tue Aug 22, 2017 11:28 pm
Location: Canada

Re: Modifying Breast Parameters Using a Script

Postby punkduck » Sat Sep 25, 2021 8:19 pm

hmm, you want to write a plugin?

setBreastSize and firmness are from apps/human.py, These are macro targets. There are some other functions as well, but not all are directly added. It was not flexible enough to work the way, because the number of functions would be equal to the number of modifiers and nobody could work with custom ones, because there would be no code for these ...

https://github.com/makehumancommunity/makehuman/blob/master/makehuman/apps/human.py

For the other you can check here, which modifiers are used:

https://github.com/makehumancommunity/makehuman/blob/master/makehuman/data/modifiers/modeling_modifiers.json

As you can see, normally two targets form a slider (for custom targets it is only one). And the targets themselves are here:

https://github.com/makehumancommunity/makehuman/tree/master/makehuman/data/targets

I did not try, if it is possible to call the getModifier function from "outside", but it should work. If so, you should take the name from the json file or directory. The value is how much the target (or shape-key in Blender) is applied.

For breastsize it looks like this:

Code: Select all
modifier = self.getModifier('breast/BreastSize')
modifier.setValue(size)
self.applyAllTargets()


Maybe you can reach the other modifiers the same way. Just an idea ...
User avatar
punkduck
 
Posts: 1216
Joined: Mon Oct 17, 2016 7:24 pm
Location: Nuremberg, Germany

Re: Modifying Breast Parameters Using a Script

Postby bd4 » Mon Sep 27, 2021 10:10 am

Thanks, Elvaerwyn and punkduck,for your responses.

Punduck,I actually managed to solve my problem a while ago and I think we followed the same idea. I basically created the functions that I needed, inspired on the setBreastSize and setBreastFirmness located at the makehuman/apps/human.py file and using the information about the breast parameters' names presented in the makehuman/data/modifiers/modeling_modifiers.json file.

Here's an example of the Breast Volume functions I implemented at the makehuman/apps/human.py file:

Code: Select all
def setBreastVolume(self, size, updateModifier = True):
        if updateModifier:
            modifier = self.getModifier('breast/breast-volume-vert-down|up')
            modifier.setValue(size)
            self.applyAllTargets()
            return

        size = min(max(size, 0.0), 1.0)
        if self.breastVolume == size:
            return
        self.breastVolume = size
        self._setBreastVolumeVals()
        self.callEvent('onChanging', events3d.HumanEvent(self, 'breastVolume'))

    def getBreastVolume(self):
        return self.breastVolume

    def _setBreastVolumeVals(self):
        self.maxcupVal = max(0.0, self.breastVolume * 2 - 1)
        self.mincupVal = max(0.0, 1 - self.breastVolume * 2)
        if self.maxcupVal > self.mincupVal:
            self.averagecupVal = 1 - self.maxcupVal
        else:
            self.averagecupVal = 1 - self.mincupVal


where, self.breastVolume and self._setBreastVolumeVals() were initialized at setDefaultValues function also presented in that file and 'breast/breast-volume-vert-down|up' came from the json file.

I followed this method for each parameter that I needed (Vertical position, Horizontal position, Pointiness, Breast volume, Nipple Size and Nipple Point).
After this, I'm able to open the app with this new functions and change these parameters using a script.
Thankfully, this is a Open Source app. Hope this helps someone.
bd4
 
Posts: 2
Joined: Thu Sep 23, 2021 10:48 am


Return to Bugs, problems and feature requests

Who is online

Users browsing this forum: No registered users and 1 guest