MakeHuman  0.95beta
 All Data Structures Files Functions Variables Typedefs Macros Pages
Functions | Variables
core.c File Reference

Integration layer between the C core and Python functions. More...

Go to the source code of this file.

Functions

void RegisterObject3D (PyObject *module)
 Registers the Object3D object in the Python environment. More...
 
void Object3D_dealloc (Object3D *self)
 Takes care of the deallocation of the vertices, faces and text the Object3D object. More...
 
PyObject * Object3D_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 Takes care of the initialization of the Object3D object members. More...
 
int Object3D_init (Object3D *self, PyObject *args, PyObject *kwds)
 The constructor of the Object3D object. More...
 
PyObject * Object3D_setVertCoo (Object3D *self, PyObject *args)
 Sets a single coordinate value (x, y or z) for a vertex in G.world. More...
 
PyObject * Object3D_setNormCoo (Object3D *self, PyObject *args)
 Sets a single normal component value (x, y or z) for a vertex in G.world. More...
 
PyObject * Object3D_setUVCoo (Object3D *self, PyObject *args)
 Sets a single UV component value (U or V) for a vertex in G.world. More...
 
PyObject * Object3D_setColorIDComponent (Object3D *self, PyObject *args)
 Sets a single color component value (R, G or B) for a vertex in G.world. More...
 
PyObject * Object3D_setColorComponent (Object3D *self, PyObject *args)
 Sets a single color component value (R, G, B or A) for a vertex in G.world. More...
 
PyObject * Object3D_getShaderParameters (Object3D *self, void *closure)
 Gets the shader parameter dictionary for this Object3D object. More...
 
PyObject * Object3D_getTranslation (Object3D *self, void *closure)
 Gets the translation for this Object3D object as a list. More...
 
int Object3D_setTranslation (Object3D *self, PyObject *value)
 Sets the translation for this Object3D object as a list. More...
 
PyObject * Object3D_getRotation (Object3D *self, void *closure)
 Gets the rotation for this Object3D object as a list. More...
 
int Object3D_setRotation (Object3D *self, PyObject *value)
 Sets the rotation for this Object3D object as a list. More...
 
PyObject * Object3D_getScale (Object3D *self, void *closure)
 Gets the scale for this Object3D object as a list. More...
 
int Object3D_setScale (Object3D *self, PyObject *value)
 Sets the scale for this Object3D object as a list. More...
 
void callMouseButtonDown (int b, int x, int y)
 Invokes the Python mouseButtonDown function. More...
 
void callMouseButtonUp (int b, int x, int y)
 Invokes the Python mouseButtonUp function. More...
 
void callMouseMotion (int s, int x, int y, int xrel, int yrel)
 Invokes the Python mouseMotion function. More...
 
void callKeyDown (int key, unsigned short character, int modifiers)
 Invokes the Python keyDown function. More...
 
void callKeyUp (int key, unsigned short character, int modifiers)
 
void callResize (int w, int h, int fullscreen)
 
void setClearColor (float r, float g, float b, float a)
 
float * makeFloatArray (int n)
 Creates an array of n floats and returns a pointer to that array. More...
 
unsigned char * makeUCharArray (int n)
 Creates an array of n characters and returns a pointer to that array. More...
 
int * makeIntArray (int n)
 Creates an array of n integers and returns a pointer to that array. More...
 

Variables

static PyMemberDef Object3D_members []
 
static PyMethodDef Object3D_methods []
 
static PyGetSetDef Object3D_getset []
 
PyTypeObject Object3DType
 

Detailed Description

Integration layer between the C core and Python functions.

Project Name: MakeHuman
Product Home Page: http://www.makehuman.org/
SourceForge Home Page: http://sourceforge.net/projects/makehuman/
Authors: Manuel Bastioni, Paolo Colombo, Simone Re, Hans-Peter Dusel
Copyright(c): MakeHuman Team 2001-2010
Licensing: GPL3 (see also http://makehuman.wiki.sourceforge.net/Licensing)
Coding Standards: See http://makehuman.wiki.sourceforge.net/DG_Coding_Standards

This module contains functions that pass events up from the SDL core to Python and functions that process calls from Python back to C. There are also a small number of utility functions for allocating memory for lists of Integers, Strings, Floats and Objects.

Definition in file core.c.

Function Documentation

void callKeyDown ( int  key,
unsigned short  character,
int  modifiers 
)

Invokes the Python keyDown function.

Parameters
keyan int containing the key code of the key pressed.
characteran unsigned short character containing the Unicode character corresponding to the key pressed.

This function invokes the Python keyDown function when the SDL module detects a standard keyboard event, ie. when a standard character key is pressed.

Definition at line 621 of file core.c.

void callKeyUp ( int  key,
unsigned short  character,
int  modifiers 
)

Definition at line 632 of file core.c.

void callMouseButtonDown ( int  b,
int  x,
int  y 
)

Invokes the Python mouseButtonDown function.

Parameters
ban int indicating which button this event relates to.
xan int specifying the horizontal mouse pointer position in the GUI window (in pixels).
yan int specifying the vertical mouse pointer position in the GUI window (in pixels).

This function invokes the Python mouseButtonDown function when the SDL module detects a mouse button down event.

Definition at line 576 of file core.c.

void callMouseButtonUp ( int  b,
int  x,
int  y 
)

Invokes the Python mouseButtonUp function.

Parameters
ban int indicating which button this event relates to.
xan int specifying the horizontal mouse pointer position in the GUI window (in pixels).
yan int specifying the vertical mouse pointer position in the GUI window (in pixels).

This function invokes the Python mouseButtonUp function when the SDL module detects a mouse button up event.

Definition at line 590 of file core.c.

void callMouseMotion ( int  s,
int  x,
int  y,
int  xrel,
int  yrel 
)

Invokes the Python mouseMotion function.

Parameters
san int indicating the mouse.motion.state of the event (1=Mouse moved, 0=Mouse click)..
xan int specifying the horizontal mouse pointer position in the GUI window (in pixels).
yan int specifying the vertical mouse pointer position in the GUI window (in pixels).
xrelan int specifying the difference between the previously recorded horizontal mouse pointer position in the GUI window and the current position (in pixels).
yrelan int specifying the difference between the previously recorded vertical mouse pointer position in the GUI window and the current position (in pixels).

This function invokes the Python mouseMotion function when the SDL module detects movement of the mouse.

Definition at line 608 of file core.c.

void callResize ( int  w,
int  h,
int  fullscreen 
)

Definition at line 643 of file core.c.

float* makeFloatArray ( int  n)

Creates an array of n floats and returns a pointer to that array.

Parameters
nan int indicating the number of floats to add into the array.

This function creates an array of n floats each containing a value of 1.0 and returns a pointer to that array.

Definition at line 662 of file core.c.

int* makeIntArray ( int  n)

Creates an array of n integers and returns a pointer to that array.

Parameters
nan int indicating the number of integers to add into the array.

This function creates an array of n integers set to '-1' and returns a pointer to that array.

Definition at line 713 of file core.c.

unsigned char* makeUCharArray ( int  n)

Creates an array of n characters and returns a pointer to that array.

Parameters
nan int indicating the number of characters to add into the array.

This function creates an array of n characters set to high values and returns a pointer to that array.

Definition at line 687 of file core.c.

void Object3D_dealloc ( Object3D *  self)

Takes care of the deallocation of the vertices, faces and text the Object3D object.

Parameters
selfThe Object3D object which is being deallocated.

This function takes care of the deallocation of the vertices, faces and text the Object3D object.

Definition at line 162 of file core.c.

PyObject* Object3D_getRotation ( Object3D *  self,
void *  closure 
)

Gets the rotation for this Object3D object as a list.

Parameters
selfThe 3D object.

This function gets the rotation for this Object3D object as a list.

Definition at line 505 of file core.c.

PyObject* Object3D_getScale ( Object3D *  self,
void *  closure 
)

Gets the scale for this Object3D object as a list.

Parameters
selfThe 3D object.

This function gets the scale for this Object3D object as a list.

Definition at line 539 of file core.c.

PyObject* Object3D_getShaderParameters ( Object3D *  self,
void *  closure 
)

Gets the shader parameter dictionary for this Object3D object.

Parameters
selfAn 3D object.

This function gets the shader parameter dictionary for this Object3D object.

Definition at line 457 of file core.c.

PyObject* Object3D_getTranslation ( Object3D *  self,
void *  closure 
)

Gets the translation for this Object3D object as a list.

Parameters
selfThe 3D object.

This function gets the translation for this Object3D object as a list.

Definition at line 471 of file core.c.

int Object3D_init ( Object3D *  self,
PyObject *  args,
PyObject *  kwds 
)

The constructor of the Object3D object.

Parameters
selfThe Object3D object which is being constructed.
argsThe arguments.

The constructor of the Object3D object. It allocates the vertex and face arrays.

Definition at line 231 of file core.c.

PyObject* Object3D_new ( PyTypeObject *  type,
PyObject *  args,
PyObject *  kwds 
)

Takes care of the initialization of the Object3D object members.

Parameters
selfThe Object3D object which is being initialized.

This function takes care of the initialization of the Object3D object members.

Definition at line 181 of file core.c.

PyObject* Object3D_setColorComponent ( Object3D *  self,
PyObject *  args 
)

Sets a single color component value (R, G, B or A) for a vertex in G.world.

Parameters
objIndexan int containing the index of the 3D object that contains this vertex.
nIdxan int indexing the vertex color component to update.
ran unsigned char (an integer value from 0-255) specifying the Red channel component to be assigned to this color component in the G.world array.
gan unsigned char (an integer value from 0-255) specifying the Green channel component to be assigned to this color component in the G.world array.
ban unsigned char (an integer value from 0-255) specifying the Blue channel component to be assigned to this color component in the G.world array.
aan unsigned char (an integer value from 0-255) specifying the Alpha channel component to be assigned to this color component in the G.world array.

This function sets the value of a G.world color component (R, G, B or A).

Definition at line 430 of file core.c.

PyObject* Object3D_setColorIDComponent ( Object3D *  self,
PyObject *  args 
)

Sets a single color component value (R, G or B) for a vertex in G.world.

Parameters
objIndexan int containing the index of the 3D object that contains this vertex.
nIdxan int indexing the vertex color component to update.
ran unsigned char (an integer value from 0-255) specifying the Red channel component to be assigned to this color component.
gan unsigned char (an integer value from 0-255) specifying the Green channel component to be assigned to this color component.
ban unsigned char (an integer value from 0-255) specifying the Blue channel component to be assigned to this color component.

This function sets the value of a G.world color component (R, G or B). This function is called by the mh_setColorCoord function in main.c which splits a list of the three color components into 3 separate calls to this function.

Definition at line 395 of file core.c.

PyObject* Object3D_setNormCoo ( Object3D *  self,
PyObject *  args 
)

Sets a single normal component value (x, y or z) for a vertex in G.world.

Parameters
objIndexan int containing the index of the 3D object that contains this vertex.
nIdxan int indexing the vertex normal component to update.
xa float specifying the X component of the value to be assigned to this normal in the G.world array.
ya float specifying the Y component of the value to be assigned to this normal in the G.world array.
za float specifying the Z component of the value to be assigned to this normal in the G.world array.

This function sets the value of a G.world normal component (x, y or z). This function is called indirectly by the setNormCoord Python wrapper. The Python wrapper specifies a list of the three components, but this list is split up into 3 separate calls to this function by the mh_setNormCoord function in main.c.

Definition at line 326 of file core.c.

int Object3D_setRotation ( Object3D *  self,
PyObject *  value 
)

Sets the rotation for this Object3D object as a list.

Parameters
selfThe 3D object.
selfThe new rotation as a python list.

This function sets the rotation for this Object3D object as a list.

Definition at line 516 of file core.c.

int Object3D_setScale ( Object3D *  self,
PyObject *  value 
)

Sets the scale for this Object3D object as a list.

Parameters
selfThe 3D object.
selfThe new scale as a python list.

This function sets the scale for this Object3D object as a list.

Definition at line 550 of file core.c.

int Object3D_setTranslation ( Object3D *  self,
PyObject *  value 
)

Sets the translation for this Object3D object as a list.

Parameters
selfThe 3D object.
selfThe new translation as a python list.

This function sets the translation for this Object3D object as a list.

Definition at line 482 of file core.c.

PyObject* Object3D_setUVCoo ( Object3D *  self,
PyObject *  args 
)

Sets a single UV component value (U or V) for a vertex in G.world.

Parameters
objIndexan int containing the index of the 3D object that contains this vertex.
nIdxan int indexing the vertex UV component to update.
ua float specifying the value to be assigned to the U component of the UV mapping data associated with the specified vertex in the G.world array.
va float specifying the value to be assigned to the V component of the UV mapping data associated with the specified vertex in the G.world array.

This function sets the value of a G.world UV component (U or V). This function is called indirectly by the setUVCoord Python wrapper. The Python wrapper specifies a list of the two components, but this list is split up into 2 separate calls to this function by the mh_setUVCoord function in main.c.

Definition at line 360 of file core.c.

PyObject* Object3D_setVertCoo ( Object3D *  self,
PyObject *  args 
)

Sets a single coordinate value (x, y or z) for a vertex in G.world.

Parameters
objIndexan int containing the index of the 3D object that contains this vertex.
vIdxan int indexing the vertex coordinate component to update.
xa float specifying the X component of the value to be assigned to this vertex coordinate in the G.world array.
ya float specifying the Y component of the value to be assigned to this vertex coordinate in the G.world array.
za float specifying the Z component of the value to be assigned to this vertex coordinate in the G.world array.

This function sets the value of a G.world coordinate component (x, y or z). This function is called indirectly by the setVertCoord Python wrapper. The Python wrapper specifies a list of the three coordinates, but this list is split up into 3 separate calls to this function by the mh_setVertCoord function in main.c.

Definition at line 290 of file core.c.

void RegisterObject3D ( PyObject *  module)

Registers the Object3D object in the Python environment.

Parameters
moduleThe module to register the Object3D object in.

This function registers the Object3D object in the Python environment.

Definition at line 148 of file core.c.

void setClearColor ( float  r,
float  g,
float  b,
float  a 
)

Definition at line 649 of file core.c.

Variable Documentation

PyGetSetDef Object3D_getset[]
static
Initial value:
=
{
{"shaderParameters", (getter)Object3D_getShaderParameters, (setter)NULL, "The dictionary containing the shader parameters, read only.", NULL},
{"translation", (getter)Object3D_getTranslation, (setter)Object3D_setTranslation, "The translation of the object as a 3 component vector.", NULL},
{"rotation", (getter)Object3D_getRotation, (setter)Object3D_setRotation, "The rotation of the object as a 3 component vector.", NULL},
{"scale", (getter)Object3D_getScale, (setter)Object3D_setScale, "The scale of the object as a 3 component vector.", NULL},
{NULL}
}
int Object3D_setRotation(Object3D *self, PyObject *value)
Sets the rotation for this Object3D object as a list.
Definition: core.c:516
int Object3D_setTranslation(Object3D *self, PyObject *value)
Sets the translation for this Object3D object as a list.
Definition: core.c:482
PyObject * Object3D_getRotation(Object3D *self, void *closure)
Gets the rotation for this Object3D object as a list.
Definition: core.c:505
PyObject * Object3D_getShaderParameters(Object3D *self, void *closure)
Gets the shader parameter dictionary for this Object3D object.
Definition: core.c:457
PyObject * Object3D_getTranslation(Object3D *self, void *closure)
Gets the translation for this Object3D object as a list.
Definition: core.c:471
PyObject * Object3D_getScale(Object3D *self, void *closure)
Gets the scale for this Object3D object as a list.
Definition: core.c:539
int Object3D_setScale(Object3D *self, PyObject *value)
Sets the scale for this Object3D object as a list.
Definition: core.c:550

Definition at line 90 of file core.c.

PyMemberDef Object3D_members[]
static
Initial value:
=
{
{"x", T_FLOAT, offsetof(Object3D, x), 0, "X translation"},
{"y", T_FLOAT, offsetof(Object3D, y), 0, "Y translation"},
{"z", T_FLOAT, offsetof(Object3D, z), 0, "Z translation"},
{"rx", T_FLOAT, offsetof(Object3D, rx), 0, "X rotation"},
{"ry", T_FLOAT, offsetof(Object3D, ry), 0, "Y rotation"},
{"rz", T_FLOAT, offsetof(Object3D, rz), 0, "Z rotation"},
{"sx", T_FLOAT, offsetof(Object3D, sx), 0, "X scale"},
{"sy", T_FLOAT, offsetof(Object3D, sy), 0, "Y scale"},
{"sz", T_FLOAT, offsetof(Object3D, sz), 0, "Z scale"},
{"shadeless", T_UINT, offsetof(Object3D, shadeless), 0, "Whether this object is affected by scene lights or not."},
{"texture", T_UINT, offsetof(Object3D, texture), 0, "A texture id or 0 if this object doesn't have a texture."},
{"shader", T_UINT, offsetof(Object3D, shader), 0, "A shader id or 0 if this object doesn't have a shader."},
{"visibility", T_INT, offsetof(Object3D, isVisible), 0, "Whether this object is currently visible or not."},
{"cameraMode", T_INT, offsetof(Object3D, inMovableCamera), 0, "Whether this object uses the Movable or Fixed camera mode."},
{"pickable", T_INT, offsetof(Object3D, isPickable), 0, "Whether this object can be picked."},
{"solid", T_INT, offsetof(Object3D, isSolid), 0, "Whether this object is solid or wireframe."},
{NULL}
}

Definition at line 47 of file core.c.

PyMethodDef Object3D_methods[]
static
Initial value:
=
{
{"setVertCoord", (PyCFunction)Object3D_setVertCoo, METH_VARARGS,
""
},
{"setNormCoord", (PyCFunction)Object3D_setNormCoo, METH_VARARGS,
""
},
{"setUVCoord", (PyCFunction)Object3D_setUVCoo, METH_VARARGS,
""
},
{"setColorIDComponent", (PyCFunction)Object3D_setColorIDComponent, METH_VARARGS,
""
},
{"setColorComponent", (PyCFunction)Object3D_setColorComponent, METH_VARARGS,
""
},
{NULL}
}
PyObject * Object3D_setNormCoo(Object3D *self, PyObject *args)
Sets a single normal component value (x, y or z) for a vertex in G.world.
Definition: core.c:326
PyObject * Object3D_setUVCoo(Object3D *self, PyObject *args)
Sets a single UV component value (U or V) for a vertex in G.world.
Definition: core.c:360
PyObject * Object3D_setVertCoo(Object3D *self, PyObject *args)
Sets a single coordinate value (x, y or z) for a vertex in G.world.
Definition: core.c:290
PyObject * Object3D_setColorComponent(Object3D *self, PyObject *args)
Sets a single color component value (R, G, B or A) for a vertex in G.world.
Definition: core.c:430
PyObject * Object3D_setColorIDComponent(Object3D *self, PyObject *args)
Sets a single color component value (R, G or B) for a vertex in G.world.
Definition: core.c:395

Definition at line 69 of file core.c.

PyTypeObject Object3DType

Definition at line 100 of file core.c.