Conversion from metric measurements to modifier [0,1]

MakeHuman python API, python plugins, etc

Moderator: joepal

Conversion from metric measurements to modifier [0,1]

Postby cjacobs » Mon Apr 17, 2017 10:51 pm

I've been reading through the MakeHuman source but can't find the file where the each modifier slider's value on the interval [0.0, 1.0] is converted to an actual measurement and written to the measurement boxes. I'd like to find the code governing those conversions. Perhaps someone more experienced with the MakeHuman source could point me in the right direction?

Many thanks!
cjacobs
 
Posts: 3
Joined: Mon Apr 17, 2017 10:48 pm

Re: Conversion from metric measurements to modifier [0,1]

Postby RobBaer » Tue Apr 18, 2017 5:05 am

MH doesn't really do "real measurement" in the sense you probably want, but perhaps what you are looking for is 0_modeling_a_measurement.py in the plugins folder.
User avatar
RobBaer
 
Posts: 1209
Joined: Sat Jul 13, 2013 3:30 pm
Location: Kirksville, MO USA

Re: Conversion from metric measurements to modifier [0,1]

Postby cjacobs » Tue Apr 18, 2017 3:03 pm

@RobBauer Thanks! I've been looking at that file, and I wonder if what I'm looking for is the displayToData function:

Code: Select all

    def displayToData(self, value):
        goal = float(value)
        measure = self.task.getMeasure(self.measure)
        minValue = -1.0
        maxValue = 1.0
        if math.fabs(measure - goal) < 0.01:
            return self.value
        else:
            tries = 10
            while tries:
                if math.fabs(measure - goal) < 0.01:
                    break;
                if goal < measure:
                    maxValue = self.value
                    if value == minValue:
                        break
                    self.value = minValue + (self.value - minValue) / 2.0
                    self.modifier.updateValue(self.value, 0)
                    measure = self.task.getMeasure(self.measure)
                else:
                    minValue = self.value
                    if value == maxValue:
                        break
                    self.value = self.value + (maxValue - self.value) / 2.0
                    self.modifier.updateValue(self.value, 0)
                    measure = self.task.getMeasure(self.measure)
                tries -= 1
        return self.value



But I'm not entirely sure what it's doing. I think what it's doing is taking a goal measurement, and, given the model's current measurements, constructing the slider
value within (-1, 1) required to reach the goal. I think this because it updates the modifiers during the code.

Am I correct?

Thanks again for your help!
cjacobs
 
Posts: 3
Joined: Mon Apr 17, 2017 10:48 pm


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron