FaceGen 3 SDKs Reference
Loading...
Searching...
No Matches
FgApply.hpp
1//
2// Copyright (c) 2023 Singular Inversions Inc. (facegen.com)
3//
4// Apply a face to Daz Genesis or Metahuman DNA
5//
6
7#ifndef FG_APPLY_HPP
8#define FG_APPLY_HPP
9
10#include "Fg3dMesh.hpp"
11#include "FgTransform.hpp"
12#include "FgGuiApi.hpp"
13#include "Fg3Face.hpp"
14#include "Fg3Sam.hpp"
15#include "FgImageIo.hpp"
16#include "FgAnthropometry.hpp"
17
18namespace Fg {
19
20Arr<ScaleTrans3F,2> cEyesTransform(FaceLmPos3Fs const & lmBases,Vec3Fs const & allTargs);
21
22// returns mean RGB of 'img' over pixels where 'region' is 255:
23Arr3D sampleColor(
24 ImgRgba8 const & img,
25 ImgUC const & region); // [0,255] aspect ratio must be same as 'img'
26
27// additive color shift modulated over given region:
28void shiftColor_(
29 Arr3D delta,
30 ImgUC const & region, // [0,255] aspect ration must be same as 'img'
31 ImgRgba8 & img); // MODIFIED
32
33enum struct DazGenesisVer { G1, G2, G3, G8, G81, G9 };
34
36{
37 DazGenesisVer ver;
38 String str; // just the number part of the above symbols
39
40 bool operator==(DazGenesisVer v) const {return (v==ver); }
41 bool operator==(String const & s) const {return (s==str); }
42};
43
44Svec<DazGenesis> cDazGenesisInfo();
45std::ostream & operator<<(std::ostream &,DazGenesisVer);
46// Returns exported map names for given Genesis version other than face and eyes:
47Strings dazGenesisBodyMapNames(DazGenesisVer ver);
48String dazRelMorphDir(DazGenesisVer ver,bool female);
49// returns a de-duped list of DS content dirs stored by DS in Windows registry (if exists) followed by a
50// de-duped list of DS public beta content dirs stored by DSPB in Windows registry, in their given order,
51// filtering out any that do not exist:
52String8s getDazContentDirs();
53// return the first daz content library containing the given relative path within it (file or directory).
54// Returns empty if none do:
55String8 getDazContentDirContaining(String const & relPath);
56// there are only 2 possible Daz Connect dirs (DS and DSPB) but within each of these are the versioned data directories
57// which contain the compressed content; this searches DS first, and from most recent to find the first instance of 'relPath':
58String8 getDazConnectDirContaining(String const & relPath);
59
60typedef Sfun<void(const Img2F &,Mesh &)> EmbossMesh;
61typedef Sfun<void(const Img2F &,ImgRgba8 &)> TattooImage;
62
63// Applies the given face coordinate to the given Daz Genesis mesh and stores in the given content library.
64// If provided, applies the given detail texture to the color maps and also stores in the given content library.
65// Returns true for success or user cancellation, false if unable to write to the given content library,
66// and throws for unexpected conditions such as not being able to locate data files:
67void dazExport(
68 DazGenesisVer ver,
69 bool female, // true = female, false = male
70 String8 const & contentDir, // Daz content library for writing (don't use Daz Connect library).
71 Sam3Coord const & coord, // given face
72 Bytes const & detail, // given detail texture
73 bool sphericalEyes, // Apply spherical eye correction
74 String8 const & group, // Daz grouping path for morph
75 String8 const & name, // Export name
76 // Filenames of original color maps. First must be face, then in order of 'dazGenesisBodyMapNames'.
77 // These are used in the creation of the customized maps. If not supplied, no maps will be exported:
78 String8s const & baseMapNames,
79 // Optional. If non-empty, this callback will be invoked 3 times with 'true' as the argument
80 // (indicating each of the 3 milestones). The callback should return immediately (blocking call)
81 // and if it returns true this function will terminate without completion:
82 WorkerCallback const & callback,
83 EmbossMesh const & embossMesh={}, // Ignore
84 TattooImage const & tattooImage={}); // Ignore
85
86// Genesis 9 CS is X - subject's left, Y - subject's up, Z - subect's forward, in inches, with origin at base of feet
87// on saggital plane:
88void dazExportShapeG9(
89 Sam3Coord const & coord,
90 String8 const & contentDir, // valid DS4 content library absolute path
91 // parameter group specifies path withing Head shape in DS. It can contain delimiters for sub-paths.
92 // it is not used for the output file location:
93 String8 const & group,
94 String8 const & name, // non-empty, no delimiters. Used for both control and output file name.
95 IdxVec3Fs const & deltas={}); // Ignore
96
97// extract the relative (to DCL) paths of the color maps for the given parts from the material DUF as long as it uses
98// the same naming as the G9 starter essentials base maps:
99Strings dazGetMapPathsG9(String8 const & materialDuf,Strings const & parts);
100
101void dazExportColorG9(
102 Sam3Coord const & coord,
103 Bytes const & detail,
104 String8 const & contentDir, // valid DS4 content library absolute path to save in
105 String8s const & baseMapPaths, // absolute paths of Head, Arms, Body, Legs, Eyes base map images in that order
106 // parameter group specifies path withing Head shape in DS. It can contain delimiters for sub-paths.
107 // it is not used for the output file location:
108 String8 const & group,
109 String8 const & name, // output name; non-empty, no delimiters
110 bool adjustIray, // apply the color adjustment for the iRay renderer.
111 WorkerCallback const & updateFn, // As above. Albedo map export takes most of the time.
112 TattooImage const & tattooImage={}); // Ignore
113
114// each mesh has the name given to it in the DNA file (modified for improvement):
115Meshes dnaImport(Bytes const & dnaFile);
116// inject the given vertex positions into the dna file overwriting the existing:
117void dnaInject_(
118 Vec3Fss const & shapes, // must be 1-1 with the meshes and vertex counts in the file below
119 Bytes & dnaFile); // modified
120
121}
122
123#endif
FaceGen face space coordinate.
Definition Fg3Face.hpp:49