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

Current: Month Day, Year

9.1.8 Code of core/target.py

core/target provides methods to deal with targets or morphs. The file contains 4 classes:

Class MacroTree

This class is used as a helper class for phenotype with 3 values.

Variables

These variables are all preset by __init__.
namedescription
names 3 names, preset to None.
values 3 values, preset to 0.0.

Methods:

nameparametersreturnsdescription
insert name
value
None If name is none, a certain value is inserted.

Class Modelling

All values and methods used for dealing with targets.

Variables

These variables are mostly preset by __init__.
namedescription
glob reference to global object.
obj set to baseClass object.
group current group of morph, set to empty string.
displayname displayed name.
default default value.
incr reference to increment morph, preset to None.
decr reference to decrement morph, preset to None.
macro reference to macro morph, preset to None.
macro_influence macro influences from json file.
m_influence list of influences, preset empty list.
barycentric reference to map slider, preset to None.
barycentric_diffuse sets values to diffuse color.
opposite dual slider, has an opposite.
slider reference to slider which gets the values.
sym name of symmmetric side (left or right).
isRSide morph is the right side (preset to false).
measure is measurement needed (preset to None).
virtual_val changed value by formula for virtual value (a text used with eval for e.g age.)
pattern a search pattern used for e.g opposite morphs.
tip target tip.

Methods:

nameparametersreturnsdescription
memInfo Nonelist of 5 elements this class creates the entries more the memory viewer. In case of barycentric it creates a special line with 3 entries, in case of a macro, the macro is returned, otherwise increment and decrement targets are returned (name and number of changed vertices)
setFromDict t
argetpath
bintargets
None fills all the initial values using t. for decr and incr it loads targetdata via Morphtarget class and set references. displayname, group, tip, sym, isRSide are set. In case of measurement, values are linked. If target influences text slot, it is also set. In case of a macro, macro and macro_influence are set, barycentric_diffuse is set, when available. Default value is multiplied by 100.
macro_influence arrayNone appends macro influences to m_influence
macro_barycentric valNone creates barycentric macro with 3 texts and values.
resetValue NoneNone resets a target to default and self.barycentric to 0.33, 0.33, 0.34
set_barycentricFromMapSlider NoneNone set the 3 barycentric values from slider.
printSlot Noneformatted text calculates the formula with eval and sets virtual value and returns formated text.
textSlot descrNone set the textslot via printSlot function.
search_pattern userpattern creates a pattern to be found in the target repo, for macros it is of a different type, dual targets will be referenced by dual patterns, the opposites are defined in base.json. Single targets will be referenced by just the name, user targets will get a "custom/" in front.
displayMeasurement new (boolean)None If it is new, the marker is set the first time, otherwise it is modified. Measurement were presented near slider.
initialize NoneNone Initialize a slider. Factor is calculated by dividing value by 100, marker is deleted, if it is a macro, mesh is resetted to all non-macro targets. Otherwise initial copy of slider is fetched and if needed measurement is displayed. In case of symmetry the copy of the symmetric slider is also fetched.
generateAllMacroWeights targetlist
macroname
factor
weights
None Recursive function to generate weights. Since for example 4 different components will change the character, one need to figure out how much each component will be used. Therefore one need to consider the components like a tree for the leaf the value itself is added, otherwise we do a further recursion.
macroCalculation m_influence listNone The complete macro calculation. The influences are used and a targetlist is created. Each component is considered, in case of barycentric macro and a value bigger than 0.001 it is inserted. Otherwise the steps are calculated and the the values are inserted according to the distance of two steps. In the end the weights are generated.

The last step is the optimization: Some weightfiles are not existing. So they would be a factor of 0. Sometimes targets are identical. All targets are in memory and there are no duplicates. The calculated target name will be mapped to the targets (using the value "t") So it either add them the new targetname to a list or add the second factor if allready exists. After that target will be add to macrobuffer and macro buffer itself will be added to basemesh (which only has all non-macro targets atm.)

macroCalculationLoad None listNone Creates all macro targets when loading.
changeMacroTarget bckproc
args
None Recalculates all Macros and updates assets.
setBaryCentricDiffuse NoneNone changes the diffuse color (mixcolor).
postChange NoneNone Handles all actions after change: change size, change skeleton, mark project as changed.
finished_bckproc NoneNone used in parallel mode, does last change and calls postChange.
callback NoneNone Target callback function, works different for macros (as a thread) when self.env.parslide is used otherwise it works normal to avoid pyInstaller problems. Handles Macro, barycentric and normal targets.

Class Morphtarget

Class to handle a single target.

Variables

These variables are all preset by __init__.
namedescription
name name of the target.
raw reference to raw data.
verts vertices changed by target.
data values for vertices.
env reference to global environment.

Methods:

nameparametersreturnsdescription
loadTargetData path
bintargets
None get Target data either from pre-loaded npz file or from single targets. Set raw, verts and data.
releaseNumpy NoneNone releases data explicitely.

Class Targets

Class used for Targets at all:

Variables

These variables are all preset by __init__.
namedescription
glob reference to global information.
env reference to environment information.
modelling_targets List of all targets.
collection Target collection connected with basename.
macrodef Macro defintion file.
target_sysindex Target index set to -1 (will be 0, 1, 2).
categories categories read from file.
baseClass reference to baseClass.
symmetry boolean set to false.
target_env Target environment, 3 classes of targets paths.
default_icon reference to empty target.

Methods:

nameparametersreturnsdescription
getSym NoneNone getter for symmetry
setSym valueNone setter for symmetry
makeSym RtoLNone creates symmetry for right to left or left to right.
loadModellingJSON NoneNone loads the macro.json and modelling.json file. So macro.json (if available) will be loaded first from contarget in user section, then from system path. Then load modelling.json from contarget in user section, then from system path, load additional flexible modelling.json from userpath. macrodefs are created and linked to glob.targetMacros. targetjson from system (+ userjson) are returned.
createTarget name
t
None create a target either from system/user-contarget path or user path. It is added to the glob.targetRepo by name or by name or list and appended to modelling_targets.
loadTargets None
t
None loads target categories, loads macros and modelling json files. Then it loads binary targets, if not possible it creates them. Inside the macro targets are loaded and all targets are created.
saveBinaryTargets bckproc
*args
t
None save targets as compressed binary (running as background command) also works for contargets. Argument [0][0] explains what to compress: 1 = system, 2 = user (3 is both).
setSkinDiffuseColor NoneNone searches for barycentric target and set diffuse color.
reset colorsNone reset all targets and does a setSkinDiffuseColor if colors is True.
isHeadPattern patternis head (boolean) returns True if a pattern is used for head.
isHeadTarget keyis head (boolean) returns True if a target is for head.
resetHead NoneNone sets all head values to default.
setTargetByName key
value
None set target name key to a certain value, also appends missing targets to glob.missingTargets.
modifierPresets presetsNone set presets mentioned in base.json to targets.
destroyTargets NoneNone destroys all targets and sets modelling_targets to an empty array.