FaceGen 3 SDKs Reference
Loading...
Searching...
No Matches
Fg3Face.hpp
1//
2// Copyright (c) Singular Inversions Inc. 2012
3//
4// Authors: Andrew Beatty
5// Created: Feb 16, 2012
6//
7
8#ifndef FG3FACE_HPP
9#define FG3FACE_HPP
10
11#include "FgSerial.hpp"
12#include "FgImage.hpp"
13
14namespace Fg {
15
24typedef enum
25{
30 FANTYPE_SIZE
31} FanTypeE;
32
33extern Strings fg3ModeTypeStrs;
34
36typedef enum
37{
42 FANSYMM_SIZE
43} FanSymmE;
44
45extern Strings fg3ModeSymmStrs;
46
49{
51 Mat<Floats,2,2> crd {Floats(50,0),Floats(30,0),Floats(50,0),Floats(),};
52 FG_SER1(crd)
53
54 Sam3Coord() {};
56 explicit Sam3Coord(Floats const & coord);
57 explicit Sam3Coord(Doubles const & coord);
58 // Components can be of arbitrary dimensions:
59 explicit Sam3Coord(Mat<Floats,2,2> const & m) : crd{m} {}
60
61 static Mat22UI dims;
62
63 bool valid() const; // Ensure dimensions are a valid FG coord
64 Floats const & ts(uint type,uint symm) const {return crd.rc(type,symm); }
65 Floats & ts(uint type,uint symm) {return crd.rc(type,symm); }
66 Sam3Coord operator*(float f) const {return Sam3Coord{{crd[0]*f,crd[1]*f,crd[2]*f,crd[3]*f,}}; }
67 inline Sam3Coord operator+(const Sam3Coord & rhs) const {return Sam3Coord{crd+rhs.crd}; }
68 inline Sam3Coord operator-(const Sam3Coord & rhs) const {return Sam3Coord{crd-rhs.crd}; }
70 inline size_t getVectorDim() const {return crd[0].size()+crd[1].size()+crd[2].size()+crd[3].size(); }
72 inline Floats getVector() const {return cat(crd[0],crd[1],crd[2],crd[3]); }
74 void setVector(Floats const & coord);
75 inline bool operator==(const Sam3Coord & rhs) const {return (crd == rhs.crd); }
76};
77
78std::ostream & operator<<(std::ostream &,Sam3Coord const &);
79inline double cMagD(Sam3Coord const & sc) {return cMagD(sc.crd); }
80
81// Linear inpolation (aka 'tween') between 2 face coordinates:
82Sam3Coord interpolate(
83 Sam3Coord const & coord0,
84 Sam3Coord const & coord1,
85 float param); // 0: 'coord0', 1: 'coord1'
86
87struct Face3
88{
92 Bytes detail;
93 FG_SER2(coord,detail)
94
95 Face3() {}
96 explicit Face3(Sam3Coord const & c) : coord(c) {}
97 Face3(Sam3Coord const & c,Bytes const & d) : coord(c), detail(d) {}
98 explicit Face3(String8 const & filename_fg);
99
101 void load(String8 const & filename_fg);
103 void save(String8 const & filename_fg) const;
105 void getDetail(ImgRgba8 & img) const;
106 bool operator==(const Face3 & rhs) const
107 {return ((coord == rhs.coord) && (detail == rhs.detail)); }
108};
109
110typedef Svec<Face3> Face3s;
111
112std::ostream & operator<<(std::ostream &,Face3 const &);
113
114inline Face3 loadFg(String8 const & filename)
115{
116 Face3 ret;
117 ret.load(filename);
118 return ret;
119}
120
121inline void saveFg(Face3 const & face,String8 const & fname) {face.save(fname); }
122
123}
124
125#endif
Mat< Floats, 2, 2 > crd
Column vectors for position in face space. column: symm/asym, row: shape/color.
Definition Fg3Face.hpp:51
Floats getVector() const
Get the face coordinate as a single vector:
Definition Fg3Face.hpp:72
void setVector(Floats const &coord)
Set the face coordinate. Will accept sizes of 50, 80 or 130:
Bytes detail
JPEG-encoded detail modulation in internal UV layout.
Definition Fg3Face.hpp:92
Sam3Coord coord
Coordinate of this face in 'face space'.
Definition Fg3Face.hpp:90
FanTypeE
Enumerate the statistical model types.
Definition Fg3Face.hpp:25
void getDetail(ImgRgba8 &img) const
Decode the JPEG detail texture into FG image format:
FanSymmE
Enumerate symmetry types.
Definition Fg3Face.hpp:37
Sam3Coord(Floats const &coord)
Will accept 'coord' sizes of 50, 80 or 130:
void load(String8 const &filename_fg)
Load face from .FG file:
size_t getVectorDim() const
Get the combined dimensionality of the face coordinate:
Definition Fg3Face.hpp:70
void save(String8 const &filename_fg) const
Save face to .FG file:
@ FANTYPE_TEX
Texture (color)
Definition Fg3Face.hpp:29
@ FANTYPE_GEO
Geometry (shape)
Definition Fg3Face.hpp:27
@ FANSYMM_SYMM
Symmetric.
Definition Fg3Face.hpp:39
@ FANSYMM_ASYM
Asymmetric.
Definition Fg3Face.hpp:41
FaceGen face space coordinate.
Definition Fg3Face.hpp:49