MakeHuman  0.95beta
 All Data Structures Files Functions Variables Typedefs Macros Pages
MakeHuman - 'C' Documentation

Introduction

MakeHuman© is a free interactive modelling tool for creating custom 3D human characters. These characters can be modelled very quickly and can then be exported and used with many other modelling and rendering programs to incorporate realistic human figures into computer generated images and animations. Features that make this software unique include the tetra-parametric GUI© and the Natural Pose System©, for advanced muscular simulation.

The home page for MakeHuman© is at http://www.makehuman.org/ . The MakeHuman project is an open source project hosted on sourceforge at http://sourceforge.net/projects/makehuman/ and documented on a Wiki at http://makehuman.wiki.sourceforge.net/.

The program uses a small (but crucial) C core to support MakeHuman application functionality written in Python. These pages document the C source code that forms the core of the MakeHuman application. The Python API is documented at http://makehuman.sourceforge.net/API/ .

The C code uses OpenGL to manage the 3D graphics environment and SDL to control user interaction with the main GUI window. The C code passes events up to the Python code and provides functions to the Python code to enable it to interact with the 3D environment. The C source is contained in 4 key files and their header files (see the 'Files' tab for the full list):

src/main.c [code] The main C application file
src/glmodule.c [code] This module integrates with OpenGL functionality
src/core.c [code] Integration layer between the C core and Python functions

Application Startup

When MakeHuman is launched, the C code from the 'main' function in main.c is run which dynamically creates the Python module 'mh'. This module contains a series of embedded integration functions that map through to the other C functions in main.c, connecting the C application with the Python front-end by providing Python functions that call C functions.

For example, the "getCameraRotations" function is created as an embedded Python function on the 'mh' module that calls the C function "mh_getCameraRotations" (defined in the file main.c). This returns camera rotation angles as Python values based upon settings stored in C global variables.

Having created the 'mh' module in memory the 'main' C function loads the 'main.py' module. This displays a splash screen and a progress bar as it loads the initial 3D humanoid model (the neutral base object) and adds the various GUI sections into the scene. It creates the main toolbar that enables the user to switch between different GUI modes and defines functions to perform that switch for all active buttons. Active buttons are connected to these functions by being registered to receive events.

At the end of the initiation process the splash screen is hidden and Modelling mode is activated. The 'startEventLoop' method on the main Scene3D object is invoked to call the OpenGL/SDL C functions that manage the low-level event loop.

This Python module responds to high-level GUI toolbar events to switch between different GUI modes, but otherwise events are handled by GUI mode specific Python modules.

GUI Events

SDL manages all low-level events and mhEventLoop calls C functions to handle these events. The C functions mostly pass through the events to the corresponding Python functions that have been registered against the Scene3D object. This is handled by core.c which contains a series of C functions that call Python functions using the PyRun_SimpleString function. Some Python functions need to make calls back to the OpenGL C code to perform processing such as redraws before returning control to the C code.

Whether implemented within the C handler or bubbled up to Python, the handler performs an action and ends, returning control to mhEventLoop.

Application Close

Keyboard and mouse events that are configured to end the application bubble up to the Python handlers in main.py which call mh_shutDown in main.c which in turn calls mhShutDown in glmodule.c. This issues a system exit(0) to end the SDL application loop. The exit is intercepted to enable cleanup to be performed and control to be passed back through the main function in the main.c file which issues a 'goodbye' message and exits.