Вы находитесь на странице: 1из 27

MakeHuman: A manual

Marc Flerackers

March 4, 2011
Contents

Preface iv

I General usage 1
1 The view 2
1.1 Mouse movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Keyboard movement . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 View options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Anaglyphs . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.3 Wireframe . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.4 Smooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Cameras . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Undo, redo and reset . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Modeling 4
2.1 Macro modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Detail modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.1 Face . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.2 Breasts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.3 Stomach, pelvis and buttocks . . . . . . . . . . . . . . . . . . 5
2.2.4 Genitals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Micro modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3 Files 6
3.1 Save and Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2 Export . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1 Wavefront (obj) . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1.1 Eyebrows . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1.2 Diamonds . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1.3 Skeleton . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1.4 Groups . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1.5 Subdivide . . . . . . . . . . . . . . . . . . . . . . 7

i
CONTENTS ii

3.2.1.6 Hair . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.2 Blender exchange (mhx) . . . . . . . . . . . . . . . . . . . . 7
3.2.2.1 Version . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.2.2 Expressions . . . . . . . . . . . . . . . . . . . . . 8
3.2.2.3 Rig . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.3 Collada (dae) . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.4 Quake (md5) . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.5 Stereolithography (stl) . . . . . . . . . . . . . . . . . . . . . 8
3.2.5.1 Format . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2.5.2 Subdivide . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Ethnics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4 Posing 9
4.1 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.2 Poses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5 Rendering 10
5.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2 Aqsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.2.1 Shading rate . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2.2 Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2.3 Skin oil . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.3 Povray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.3.1 Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.3.2 Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.4 LuxRender . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.5 Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.5.1 Dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.5.2 Hair . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.5.2.1 Clump radius . . . . . . . . . . . . . . . . . . . . 11
5.5.2.2 Clump children . . . . . . . . . . . . . . . . . . . 11
5.5.2.3 Multistrand children . . . . . . . . . . . . . . . . . 11
5.5.2.4 Randomness . . . . . . . . . . . . . . . . . . . . . 11

6 Advanced Modeling 12
6.1 Measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.2 Asymmetry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.3 Randomize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

7 Settings 13
7.1 Shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.2 Slider behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.3 Mouse behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.4 Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.5 Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
CONTENTS iii

II Development 15
8 Writing plugins 16
8.1 Plugins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
8.2 GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
8.3 Morph targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
8.4 Undo-redo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
8.5 Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
8.6 The camera . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
8.7 GUI controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8.8 Layout guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Preface

This manual, like the MakeHuman software, is under constant construction and will
change with the software. The latest edition can always be found on the makehuman
website. MakeHuman is a 3d modeling tool which is build for one single purpose:
creating a professional 3d human model. The base mesh has gone through many iter-
ations to perfect the topology and all the modifications which are available to the user
are morphs which are modeled by hand by skilled artists. While the software is build
with usability and simplicity in mind, there will always be questions, that’s what Part I
of this manual is for. It is modeled on the application and follows the menu system and
options closely. Part II focuses on developing with MakeHuman, to create your own
plugin and add functionality to the main application.
This manual is provided under an Attribution-NonCommercial-NoDerivs 3.0 Un-
ported (CC BY-NC-ND 3.0) license.

iv
Part I

General usage

1
Chapter 1

The view

1.1 Mouse movement


The model can be freely moved and rotated using the mouse. Keep the left button
pressed to rotate the model. Keep the right button pressed to translate the model. Zoom-
ing can be done by using the scroll wheel, or by keeping both the left and right button
pressed. If the manipulation speed is too slow, hold shift to speed up movement.

1.2 Keyboard movement


The following keyboard navigation is the standard navigation. It can be customized in
settings, shortcuts. Use the arrow keys to move the model around. Use the 2, 4, 6 and
8 keys to rotate the model. Use the + and - keys to zoom. There are 3 standard views
which have shortcut keys. For a side view press 7, for a front view press 1 and for a top
view press 3. The . key resets both position and zoom.

1.3 View options


There are 4 view options which might help during modeling: background, anaglyphs,
wireframe and smooth.

1.3.1 Background
The background mode shows an image file on top of the model. This is useful when
the model should resemble an existing sketch, photograph or render. The first time it is
activated, it shows a list of files from the ~/makehuman/backgrounds folder to choose
from. Afterward the background button toggles the background on and off. To choose
another image go to library, background.

2
CHAPTER 1. THE VIEW 3

1.3.2 Anaglyphs
Anaglyphs mode renders the view from two viewpoints in red and cyan. When view-
ing this using red-cyan 3d glasses you can see the model in real 3d. There are two
anaglyphs modes which use a slightly different method to render both views, so it
takes two presses of the button to turn it back off.

1.3.3 Wireframe
Wireframe mode is good to see the topology and how vertices and faces are changed
by certain modifications.

1.3.4 Smooth
Smooth view might be too slow to work with on some systems. It subdivides the
mesh with Catmull-Clark subdivision and keeps this subdivided mesh updated when
modifying the model.

1.4 Cameras
There are two camera viewpoints between which can be quickly toggled, global camera
and face camera.

1.5 Undo, redo and reset


These are not view options, but they appear throughout the application. Undo and
redo are quite straightforward, they undo the last modification or redo the last undone
modification. Reset removes all modifications, be careful as it is impossible to undo
this action.
Chapter 2

Modeling

2.1 Macro modeling


Macro modeling is the roughest step in modeling a human, but it also has the biggest
impact on the resulting mesh. Macro modeling has 5 sliders. The first 4 sliders modify
the 4 main dimensions of the human: gender, age, muscle and weight. The last slider,
height, modifies the proportions. The functionality of the gender and age sliders are
straightforward. Gender goes from female to male, initially it is at 50% of each, which
gives a neutral gender. Age goes from 12 years old to 70 years old, initially it is at 25
years old. The muscle and weight sliders influence each other. Only increasing muscle
you doesn’t create a bodybuilder, that also requires weight. Similarly only increasing
weight doesn’t create a really fat model, that also requires less muscle. Finally as
said before the height slider doesn’t just scale the model vertically, but it changes the

4
CHAPTER 2. MODELING 5

proportions too. It goes from dwarf to giant.

2.2 Detail modeling


Detail modeling lets you move and scale large body parts. The moving and scaling
is not just geometrical, but preserves body shapes. Manipulation is done on the mesh
itself. Click and drag to transform the bodypart which lights up. Besides these trans-
formations, detail modeling also lets you change some other details of the model.

2.2.1 Face
Many facial features like eyes, nose, ears, mouth, jaw, head shape can be modified
using the sliders in the corresponding categories. Face age varies from young to old
and face angle from slanted up to slated down.

2.2.2 Breasts
Breasts have two sliders, size and firmness. Since this is only sufficient for a subset of
shapes, more sliders are planned.

2.2.3 Stomach, pelvis and buttocks


The stomach goes from bulging to firm. For female models this can be used to simulate
mid to late pregnancy. The pelvis goes from wide to thin and the buttocks from round
to firm.

2.2.4 Genitals
The genital slider goes from female to male genitals, initially it is in the center, which
means no genitals.

2.3 Micro modeling


Micro modeling, like detail modeling lets you move and scale body parts, but on a
much finer level.
Chapter 3

Files

3.1 Save and Load


Saving and loading happens in a custom and optimized format for MakeHuman with
the mhm extension. It is advised to always save in this format also when you export
models, since you can’t load any other format back into MakeHuman. This is important
when you want to make changes at a later stage of production.

6
CHAPTER 3. FILES 7

3.2 Export
3.2.1 Wavefront (obj)
Wavefront obj is a good format when you need a simple mesh for an external renderer.
It comes with an mtl file defining the material.

3.2.1.1 Eyebrows
For some uses, like raytracing, the eyebrow geometry causes problems. If this is the
case, uncheck it to avoid it from being exported.

3.2.1.2 Diamonds
The diamond geometry is used to keep track of the skeleton. However in most cases
this is not needed. In case the diamond geometry is desired, check it to export it.

3.2.1.3 Skeleton
This option exports the skeleton in Biovision hierarchical data (bvh) format which is
generally used for motion capture. Note however that the model is not rigged to this
skeleton.

3.2.1.4 Groups
Whether groups are useful depends on the software used. Many importers also give the
option to import the groups or not. Groups can be used to select specific body parts for
modification or deletion. If groups are not desired, uncheck it.

3.2.1.5 Subdivide
If a high poly mesh is needed, and the modeler or renderer used does not have a good
subdivision algorithm, you can check the subdivide option to export a mesh with 4
times the amount of faces, generated with Catmull-Clark subdivision.

3.2.1.6 Hair
If hair is present, it can be exported as a polygon mesh or as curves. Again it depends
on the software which is going to import the file whether mesh or curves is the best
option.

3.2.2 Blender exchange (mhx)


The Blender exchange format is a custom format designed to bring a rigged model into
Blender. It comes with a skeleton, forward and inverse kinematics with limits, render
materials, lip-sync and more.
CHAPTER 3. FILES 8

3.2.2.1 Version
Currently it is still possible to export for Blender 2.4, however this may change once
Blender 2.5 is stable.

3.2.2.2 Expressions
If checked, all expressions available within MakeHuman are exported to the mhx, this
makes the export considerably bigger in size.

3.2.2.3 Rig
Two rigs are available, mhx rig or game rig. For posing and animating the mhx rig is
preferred.

3.2.3 Collada (dae)


3.2.4 Quake (md5)
The md5 exporter is not yet fully functional, the skin is not correctly attached to the
skeleton.

3.2.5 Stereolithography (stl)


Stereolithography is a format used for 3d printing.

3.2.5.1 Format
The binary format is a lot more compact than the ASCII format. However the latter is
provided for compatibility reasons.

3.2.5.2 Subdivide
If a high poly mesh is needed, and the exernal modeler or renderer does not have a
good subdivision algorithm, you can check the subdivide option to export a mesh with
4 times the amount of faces, generated with Catmull-Clark subdivision.

3.3 Ethnics
Ethnics are models which try to closely resemble people from a specific region in the
world. They are model files with a special finishing morph for features which cannot
be created with the tools in MakeHuman. To load an ethnic, the main ethnic is selected,
then one of the sub ethnics of that ethnic. The gender and age are also chosen before
loading. While the these can, theoretically, be modified afterward, it is advised to
choose the gender and age as close as to what you need.
Chapter 4

Posing

4.1 Expressions
To make an expression on the model’s face, choose the expression category on the
right, then drag the slider from the desired expression on the left as much to the right
as needed.

4.2 Poses

9
Chapter 5

Rendering

5.1 General
For rendering, MakeHuman uses one of the installed external renderers. You only need
to install the renderer of your choice.

5.2 Aqsis
Aqsis, a renderman compliant renderer, can be downloaded from http://www.aqsis.org/.

10
CHAPTER 5. RENDERING 11

5.2.1 Shading rate


5.2.2 Samples
5.2.3 Skin oil

5.3 Povray
Povray, or the Persistence of Vision Raytracer, can be downloaded from http://www.povray.org/.

5.3.1 Format
There is both support for the older array format and the newer mesh2 format.

5.3.2 Action
Determines whether only the pov files are written or whether Povray is also launched
to render the file.

5.4 LuxRender
LuxRender, a physically based and unbiased rendering engine, can be downloaded
from http://www.luxrender.net.

5.5 Settings
Some of the rendering settings are valid for all renderers. These include the dimensions
of the rendered image and the hair settings.

5.5.1 Dimensions
The width and height of the rendered image

5.5.2 Hair
5.5.2.1 Clump radius
5.5.2.2 Clump children
5.5.2.3 Multistrand children
5.5.2.4 Randomness
Chapter 6

Advanced Modeling

6.1 Measure
Measure has sliders which modify the length and/or circumference of specific body
parts and shows the length and/or circumference of many body parts in centimeters.
You can change the units to inches in Settings. Note that modifying one parameter
might have impact on other measurements too.

6.2 Asymmetry
Sometimes a perfect symmetric model is not what is desired. Asymmetry can make
some features of the model’s face or body asymmetric.

6.3 Randomize
When a lot of different models are needed, or some inspiration is needed, it is some-
times better to let the pseudorandom generator decide how the macro modeling is done.
An existing model can also be modified by randomization of its macro features.

12
Chapter 7

Settings

7.1 Shader
MakeHuman can make use of GLSL shaders to give a better preview of how the model
will look when rendered.

7.2 Slider behavior


MakeHuman does not require a very fast computer, though some operations might be
too heavy for some systems. Turning off normal recalculation or turning off real-time
updates completely might help in making MakeHuman usable on low-end systems.

13
CHAPTER 7. SETTINGS 14

7.3 Mouse behavior


This allows you to fine-tune the speed of moving the model using the mouse. Both the
normal speed and the speed when holding down shift can be modified.

7.4 Units
Metric or imperial units can be chosen. Note that imperial units will use inches through-
out the program, also for longer lengths.

7.5 Shortcuts
All shortcuts can be customized.
Part II

Development

15
Chapter 8

Writing plugins

8.1 Plugins
Makehuman has a simple plugin framework which makes it easy to add and remove
features. At startup, MakeHuman now looks for .py files in the plugins folder which are
not starting with an underscore (which makes it easier to disable unwanted plugins).
It loads them one by one and calls the load entry point passing a reference to the
application. The plugin can use this reference to add the necessary GUI widgets or
code to the application.
The rules for plugins are very simple:

• A plugin is a .py file in the plugins folder with a load entry point.
• A plugin only imports core files.
The reason a plugin cannot import other plugins is that it would make it difficult to
know which files belong to which plugin. We still need to define a convention for
shared files beyond the core MakeHuman files. To get started look at example.py or
any of the other plugins to see how you can create your own feature in MakeHuman.

8.2 GUI
The GUI in MakeHuman is still far from finished. Since the first alpha there have been
many changes already and many other will come. This is because when features are
added or modified, we can run out of space, or start to see things differently. Some-
times we experiment to see how a modifier can be manipulated in a different way. For
example in the details and microdetails we chose to have tools manipulating the model
directly instead of using sliders. Another idea for the macrodetails was a multidimen-
sional slider, like a radar chart which would replace all five sliders. It is impossible to
pour the GUI into into its final form while we are still adding functionality and getting
new ideas. However don’t let the lack of guidelines stop you from adding a GUI to
your own plugins. The current GUI API is very usable, and gets more mature every

16
CHAPTER 8. WRITING PLUGINS 17

day. The layout at the moment is a two level tab control. The tabs at the top repre-
sent categories, like modeling, files, rendering. The ones at the bottom are the tasks
in the current category and refine the more broad category in macrodetail, detail and
microdetail modeling, or saving, loading and exporting. So when creating your plugin,
the first thought should be "In which category does it belong?". From experience we
know that it can be a though question to answer. Sometimes the only answer is adding
a new category. This is what we initially did for measurement for example.
1 def load(app):
2 category = gui3d.Category(app, "Measurement")

Next you probably want your own task to implement your feature. While it’s pos-
sible to attach functionality to an instance of gui3d.Task, it’s often easier to derive your
own class. When you create an instance of your class, you pass the parent of your task,
which can either be an existing category
1 def load(app):
2 taskview = HairPropertiesTaskView(app.categories["Modelling"])

or the new one which you added.


1 def load(app):
2 category = gui3d.Category(app, "Measurement")
3 taskview = MeasurementTaskView(category)

In your derived task you will then add the necessary controls to let the user interact.
A good place to see how to use the different controls is the example plugin. You will
see that even if you don’t add any controls, the model is already visible. This is because
the model is attached to the root of the GUI tree. In the onShow event of your task you
might want to reset the camera position, like we do in the save task, or hide the model,
like we do in the load task. Just don’t forget to reset the state when your task gets
hidden in onHide.

8.3 Morph targets


Whatever your plugin does, there’s a big chance that it will modify the model. As
many of you probably know, MakeHuman doesn’t work mathematically or procedu-
ral, but artistically. This means that you don’t just drag vertices when moving a part
of the body, but you actually apply a morph made by an artist. There are different
kind of morphs targets which are applied in different ways. Macro targets, which
are the most complex internally, are ironically the easiest to use: human.setGender,
human.setAge, human.setWeight and human.setMuscle can be used to change the cor-
responding macro features. Height was originally not there, so you had to make the
modifier yourself. We will look at that in a moment. Detail and micro detail targets
both come in pairs. For example one target to move a body part to the left, and another
target to move the same body part to the right. Therefore you should never apply both
targets at the same time. This means that when you apply one, and later you want to
apply the other, you need to remove the first. While you could use human.setDetail to
this, it is easier to use the Modifier class which does all of the needed logic behind the
the method modifier.setValue, it has an accompanying modifier.getValue which has the
reverse logic. To use it, you create a modifier passing the two opposite targets:
CHAPTER 8. WRITING PLUGINS 18

1 modifier = humanmodifier.Modifier(
2 "data/targets/macrodetails/universal-stature-dwarf.target",
3 "data/targets/macrodetails/universal-stature-giant.target")
4 modifier.setValue(human, 0.0)

A value between -1.0 and 0.0 will use the dwarf target, while a value between 0.0
and 1.0 will use the giant target. Using 0.0 will remove both targets. While using a
modifier also applies the target, to keep changes interactive other targets are not reap-
plied and normals are not recalculated. Once you have made the necessary changes,
you commit them using human.applyAllTargets. Which does exactly what it says. It
applies all the targets one by one and additionally recalculates the normals. Reapplying
all targets minimizes the size of mathematical error in the final model.

8.4 Undo-redo
One of the first features written was undo-redo. Having this from the start saves us
a lot of time later as we add this functionality to each kind of model modification
immediately. It is important that every modification is undo-able, since just one undo-
able modification would leave the user without the possibility to undo anything. So it’s
crucial that if you write a plugin which modifies the model, you also make undo work.
The Application class has several methods to work with actions. An action is a class
with two methods, do and undo. If the action itself does the modification you can use
app.do to add it to the undo stack. If you did the modification yourself already during
user interaction, you can add the action using app.did. The application won’t call the
do method of the action in that case. If you want to make your own undo-redo buttons,
you can use app.undo and app.redo. To illustrate, here is the action we use to change
the hair color:
1 class Action:
2 def __init__(self, human, before, after, postAction = None):
3 self.name = "Change hair color"
4 self.human = human
5 self.before = before
6 self.after = after
7 self.postAction = postAction
8
9 def do(self):
10 self.human.hairColor = self.after
11 if self.postAction:
12 self.postAction()
13 return True
14
15 def undo(self):
16 self.human.hairColor = self.before
17 if self.postAction:
18 self.postAction()
19 return True

The postAction is a handy way to specify a method to keep your GUI in sync with
the changes. In this case we update the color control to show the correct color when
the user chooses to undo or redo the hair color change.
CHAPTER 8. WRITING PLUGINS 19

8.5 Meshes
When writing exporters, subdivision or polygon reducing algorithms it can be useful
to know how the mesh is stored in Python (the C side has a different compact but
less convenient representation). An Object3D has three important lists: object.verts,
object.faces and object.faceGroups. The first two lists contain instances of Vertex and
Face. The facesGroups contain FaceGroup objects. A FaceGroup specifies the name
of the group and the faces that make up the group. A Face references 3 vertices in
face.verts. A Vert or vertex holds its coordinates in vert.co and normal in vert.no. If we
put all this together, we can write a simple Wavefront object exporter now:
1 f = open(filename, ’w’)
2
3 for v in obj.verts:
4 f.write("v %f %f %f\n" %tuple(v.co))
5
6 for uv in obj.uvValues:
7 f.write("vt %f %f\n" %tuple(uv))
8
9 for v in obj.verts:
10 f.write("vn %f %f %f\n" %tuple(v.no))
11
12 for g in obj.faceGroups:
13 f.write("g %s\n" %(g.name))
14 for fc in g.faces:
15 f.write("f")
16 for v in fc.verts:
17 f.write(" %i/%i/%i " %(v.idx + 1, fc.uv[i] + 1, v.idx + 1))
18
19 f.close()

As you can see, we take the uv values from obj.uvValues. The uv values are ref-
erenced in two places, obj.uvValues holds all the uv values of each vertex by index.
Face.uv is a list with the uv values of each vertex of the face. The reason is that while
normals are per vertex, uv values are per face-vertex, because a vertex can have a dif-
ferent uv depending on which face is drawn.

8.6 The camera


When your plugin allows editing a certain part of the model, it’s often good to focus
the camera on that region. There are two camera’s used in MakeHuman, accessible
from the application class as modelCamera and guiCamera. The camera which we are
interested in is the modelCamera. The application class itself is accessible in every
GUI control as app. A camera has the following properties:

• fovAngle: The field of view angle.


• nearPlane: The near clipping plane.
• farPlane: The far clipping plane.

• projection: The projection type, 0 for orthogonal, 1 for perspective.


• stereoMode: The stereo mode, 0 for no stereo, 1 for toe-in, 2 for off-axis.
CHAPTER 8. WRITING PLUGINS 20

• eyeSeparation: The eye separation.


• eyeX, eyeY, eyeZ: The position of the eye.
• focusX, focusY, focusZ: The position of the focus.
• upX, upY, upZ: The up vector.

The properties you’ll use to position the camera are the eye and focus position. The
Application class has a few methods for camera presets, like setFaceCamera to focus
on the face. We’ll look at what this method does to better understand how to position
the camera:
First we get the currently selected human (yes, we do anticipate having more than
one human in the scene).
1 human = self.scene3d.selectedHuman

Next we get the vertices which belong to the head by facegroup names.
2 headNames = [group.name for group in human.meshData.facesGroups if ("head" in
group.name or "jaw" in group.name)]
3 self.headVertices, self.headFaces = human.meshData.getVerticesAndFacesForGroups(
headNames)

We calculate the center of these vertices as this will become our focus point at
which we will look at.
4 center = centroid([v.co for v in self.headVertices])

Now we are ready to set the eye and focus positions. We set the focus to the center
position, and the eye a bit to the back.
5 self.modelCamera.eyeX = center[0]
6 self.modelCamera.eyeY = center[1]
7 self.modelCamera.eyeZ = 10
8 self.modelCamera.focusX = center[0]
9 self.modelCamera.focusY = center[1]
10 self.modelCamera.focusZ = 0

Finally we reset the human’s position and rotation so that our calculations are as
simple as the ones above.
11 human.setPosition([0.0, 0.0, 0.0])
12 human.setRotation([0.0, 0.0, 0.0])

If we would allow the human to be translated and rotated, we would need to take
this transformation into account, as above we calculated the center of the untrans-
formed mesh.

8.7 GUI controls


Whether you are writing an exporter, modeling feature or mesh algorithm, sooner or
later you will need to add some controls in order to interact with the user. MakeHuman
has a lot of the usual controls which you find in in other GUI toolkits:

• Button: A regular push button.


CHAPTER 8. WRITING PLUGINS 21

• ToggleButton: A button which has two states, selected and deselected, clicking
the button toggles between the states. Used for making an on/off choice.
• CheckBox: A togglebutton, but with a check box look.
• RadioButton: A button which is part of a group, clicking one of the buttons
selects it and deselects the others. Used for a multiple choice.
• Slider: Used to select a value from a discrete or continous range.
• TextEdit: A one line text field.
• TextView: A label.

• GroupBox: Used to group a few controls together under a title.

8.8 Layout guidelines


To have a consistent look, it is important that all tasks use the same layout practices.
GroupBoxes on the left side have x=10. The first GroupBox starts at y=80. Con-
trols start 25 pixels lower, and after the last control there are 6 extra pixels (besides the
4 pixels spacing from the last control). So the total height of a GroupBox is 25+con-
tent+6. Sliders start at x=10 and are 128 pixels wide, so there is no border left or right.
Buttons start at x=18 and are 112 wide, so there are 8 pixels of border on each side. Be-
tween controls there are 4 pixels. Sliders are 32 pixels high and Buttons are 20 pixels
high. This means that the space to the next control for a Slider is 36, and for a Button
24. So the height of a GroupBox can be calculated as 25+36*sliders+24*buttons+6.
Between GroupBoxes there are 10 pixels.
Labels only have the first letter capitalized, unless there is an acronym that needs
to be in uppercase.
CHAPTER 8. WRITING PLUGINS 22

Figure 8.1: Padding in yellow, spacing in fuschia, size in green

Вам также может понравиться