Logo   Home Table of Contents    News  Dev Blogs  Gallery  Timeline  Legend  Tags  Sponsors 
Join us on... 
Banner

Current: Month Day, Year

9.1.2 Code of core/baseobj.py

core/baseobj provides all common global elements and functions to work with base object (the main mesh). These can be used everwhere in the program. The file contains 3 classes:

Class MakeHumanModel

This class is used to create mhm file. It is just a constructor to have variables in form of attributes.

Variables

These variables are all preset by __init__.
namedescription
name Name of the model, preset to None.
author author of the model, preset to "unknown".
uuid Generated UUID, preset to None.
version Makehuman version. Preset to None.
skinMaterial Name of skinMaterial, preset to None.
skeleton Name of the skeleton, preset to None.
modifiers List of modifiers, preset to empty list.
attached List of attached objects, preset to empty list.
materials List of materials, preset to empty list.
tags list of tags, preset to empty list.

Class loadEquipment

This class is used while loading mhm to calculate absolute pathes and materials

Variables

These variables are all preset by __init__.
namedescription
type the type of the asset.
name the name of the asset.
uuid the uuid of the asset.
path the absolute path of the asset.
material the absolute path of the material.
relmaterial a relative path of the material.

Class baseClass

This class should contain all functions and variables to handle the baseclass. The init also set env.basename to a new baseClass name, when it is changed. Methods are attach and detach functions and load, save functions

Variables

namedescription
glob reference to globalObjects
env reference to environment (class programInfo)
baseMesh reference to baseMesh object3d.
baseInfo dictionary created from base.json file.
attachedAssets list of attached assets.
pose_skeleton Pose skeleton used.
default_skeleton Default skeleton. Preset by baseInfo.
floorCalcMethod Method number to calculate floor. Preset to 0.
mhmfilename last loaded mhm file
skinMaterialName Name of the last loaded skin material
skinMaterial Reference to last loaded skin material
proxy Reference to proxy object.
tags Tags of the last loaded mhm file / new tags.
photo Icon created for character.
author Author of last mhm file. Default is "unknown".
uuid UUID of last mhm file.
skeleton Reference to skeleton.
in_posemode Boolean value if character is in pose mode.
pose_skelpath Pathname of the pose skeleton.
bvh Last loaded bvh object or None.
posemodifier indicates that posemodifiers are used (mhpose file).
expression indicates that expression are used (mhpose file).
faceunits reference to faceunits. Indicates that face-units are initalized.
faceposes List of faceposes used.
bodyunits reference to bodyunits. Indicates that body-units are initalized.
faceunitsinfo contains link to face-units dictionary .
bodyunitsinfo contains link to body-units dictionary.
posecorrections dictionary of values of pose corections for body and face.
positioncorrection root position correction, initialized with [0.0, 0.0, 0.0].
bodyposes List of bodyposes used.
hide_verts Marker to hide vertices.

Methods:

nameparametersreturnsdescription
reset NoneNone Reset a number of variables of the baseClass back to standard, also called by __init__. Also calls getFaceUnits() and getBodyUnits() to calculate which bones are allowed to be changed in face or body pose editor.
setPoseMode NoneNone Sets character to pose mode. Creates a mesh copy for basemesh, does a restPose, precalculates all assets in restpose, calculates new skeleton geometry and prepares the graphical presentation of the skeleton.
setStandardMode NoneNone Switches off pose mode. Reset mesh from copy, then calculates restPose and updates assets and prepares the graphical presentation of the skeleton.
loadMHMFile filename
verbose-function
bool-error
bool-errortext
Function resets character to default, then will load an mhm-file. After load all filenames are absolute paths. Objects are marked in use, if found in cache. Materials and assets are attached. All targets are applied and skeleton is added, pose skeleton is also considered.
loadMHMTargetsOnly filename
mode
bool-error
bool-errortext
Function loads only targets (mode = 1 all targets, mode =2 only head-targets mentioned in baseInfo["head-pattern"]. Before these targets are resetted. Pose skeleton is recalculated.
saveMHMFile filenamebool-error Save the MHM file and keep names in URL encoding (use /). Saves all assets, skin material, skeleton and targets.
calculateDeletedVerts NoneNone In case hide_verts is False all objects are drawn without deleted vertices. Otherwise all attached meshes will be calculated in reverse order starting with first layer (no deleted vertices at all). Then each layer is tested and may also have deleted vertices. In the end the baseMesh itself is tested. Process works with a boolean mask.
setNoPose NoneNone resets baseMesh and all attached objects to no pose (object3d method).
recalcLowestPosePos NoneNone calculates lowest vertex of baseMesh and assets.
getLowestPos posed: booleanvalue (float) Calculates lowest position of whole character for exports and grid.
setSkinMaterial asset: dictionary from ImageSelectorNone Sets skin material. Also handles proxy and marks used asset.
isLinkedByFilename filenameasset Tests all assets if the a given filename will match. (attached clothes .. bvh, posemodifier, expression, skeleton, skin) and return the asset. If it is not attached None is returned.
getAttachedByFilename filenameasset Tests only meshes attached by filename and returns the asset if found.
getAttachedOrBase filenameasset Tests only meshes attached by filename and returns the asset if found. Also may return the basemesh. Function is used to find materials.
countAttachedByType itypecnt Function used to enable buttons. Checks if assets of a certain type are attached. Number of attached assets is returned.
markAllAttachedAssets NoneNone Marks all assets by testing filenames. Used for ImageSelector display.
delAsset filenameNone Deletes mesh. The used asset is removed. Deleted vertices are corrected. If proxy is deleted, proxy is set to None.
addAsset path
eqtype
materialpath
materialsource
attached asset. Adds mesh. In case makehuman2 starts with a character name, the program will terminate, if sth. cannot be found. Otherwise errors will only appear if a certain level is given and never in parallel mode. The loaded asset is marked. If the mesh is a proxy, skin material is added from body and proxy is set. Mesh is sorted according to z-depth. Deleted vertices are calculated.
addAndDisplayAsset path
eqtype
multi
None Adds and displays and asset. In case of multi is False, the asset of same type will be deleted (e.g. hair). Otherwise it is created in openGL and approximated to baseMesh.
addSkeleton name
path
verbose
None Adds a new skeleton from a json file. If it is the same pose-skeleton it is simply reused. When loaded with verbose option the skeleton name is displayed in requester. Used skeleton is marked.
modSkeleton name
path
None Old skeleton is deleted and new one add. Skeletons are marked accordingly and skeleton is prepared for scene.
delSkeleton pathNone Deletes a skeleton (set skeleton to None). It is unmarked and the internal pose-skeleton is prepared.
getVirtualBonePosition nameposition vector
bone
returns world position of the tail of a virtual bone (a bone using an alias name). For further calculation bone is also returned. If bone is not fould or other problems will occur, bone and position are None.
hasPoses Nonebool has pose
cnt int
returns if poses are available (either bvh or posemodifiers) and returns the number of frames for bvh.
restPose NoneNone Calls skeleton function restPose
showPose frameNone Shows pose of a certain frame. If frame is none, bvh.currentFrame is used.
showExpression NoneNone The expression.blends were presenting by using skeleton posebyBlends function with faceunits.bonemask.
showPoseModifiers NoneNone The posemodifier.blends were presenting by using skeleton posebyBlends function with bodyunits.bonemask.
showPoseAndExpression NoneNone A function to show bvh or pose-modifiers for body and expression.
addPose name
path
bool: loaded Adds a pose from a filename. Existing bvh or posemodifier are unmarked and restPose is called. The file is loaded depending to suffix (bvh, mhpose). Pose and expression are shown. File is marked. For a pose-ḿodifier a one time bvh animation is calculated.
delPose pathNone set bvh and posemodifier to none, unmarkes pose. Set character to restPose and shows Pose and expression. Set all to no pose.
detachAssetByName pathNone detach a an asset by a given name. The path is compared with the filename attribute of mesh-assets, skeleton, bvh, expression and posemodfier, If the name is found it is detached from the character.
getFaceUnits NoneNone In case faceunits are not yet loaded, they are loaded from face-poses.json.
getBodyUnits NoneNone In case bodyunits are not yet loaded, they are loaded from body-poses.json.
addExpression name
path
None For this function a pose-skeleton and faceunits must be available. If an expression is already there it is deleted. Otherwise the pose is loaded, converted (old MakeHuman has different poses for increase, decrease, here it is summarized). The Expression is shown and marked.
delExpression pathNone The expression is set to None and unmarked. Character is set to restPose and shown.
prepareClass modelfilebool success This is the big command to change the baseClass. The program tests for an existing class of the env.basename. It creates missing subfolders, test for base.json, inits the new filecache. Then it either loads an mhbin or obj file.

Then old targets are destroyed and new loaded. Assets are re-scanned. New pose-skeleton is added. The the modifier-presets create the default character and the modelfile standard base.mhm is loaded.

getInitialCopyForSlider factor
decr
incr
None calls identical function for baseMesh
updateNormals NoneNone Updates all normals on baseMesh and all assets.
updateAttachedAssets NoneNone All attached assets are approximated to baseMesh.
precalculateAssetsInRestPose NoneNone All attached assets are approximated to baseMesh in restPose.
poseAttachedAssets NoneNone All attached assets are skinned to skeleton. If they have no weights, an approxToBasemesh is done (should not be the case).
updateByTarget factor
decr
incr
None The basenesh is updated to a certain target. All attached assets are also changed.
applyAllTargets bckproc
args
None Applies all targets and corrects attached assets. It is done by resetting mesh to non-macro targets, then doing the macroCalculation and updating the assets.
finishApply NoneNone Finish function for parallel updater. Simply recalculates skeleton.
parApplyTargets NoneNone Using a worker thread to apply all targets and adding finish function.
nonParApplyTargets NoneNone Non-parallel function to apply all targets.