static GUIStyle miniLabelAlignLeft ;
static GUIStyle miniLabelAlignRight ;
static bool framesFoldout = tru e;
static bool framesFoldout = fals e;
var iarr = SkinDeformationFittingImpl . GetBlendShapeIndices ( clip . importSettings . transferTarget ) ;
var iarr = SkinDeformationFitting . GetBlendShapeIndices ( clip . importSettings . transferTarget ) ;
clip . importSettings . fittedIndices = String . Join ( "," , iarr . Select ( i = > i . ToString ( ) ) . ToArray ( ) ) ;
}
var clip = userData as SkinDeformationClip ;
var iarr = new int [ ] {
// all indices from snappers head
// 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317
// subtract linearly dependent indices
// 23,106,107,108,109,176,177,178,179,296,297,298,299
// =>
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 0 , 1 1 , 1 2 , 1 3 , 1 4 ,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 3 0 5 , 3 0 6 , 3 0 7 , 3 0 8 , 3 0 9 , 3 1 0 , 3 1 1 , 3 1 2 , 3 1 3 , 3 1 4 , 3 1 5 , 3 1 6 , 3 1 7
} ;
var iarr = new int [ ]
{
// all indices from snappers head
// 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317
// subtract linearly dependent indices
// 23,106,107,108,109,176,177,178,179,296,297,298,299
// =>
0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 0 , 1 1 , 1 2 , 1 3 , 1 4 , 1 5 , 1 6 , 1 7 , 1 8 , 1 9 , 2 0 , 2 1 , 2 2 , 2 4 , 2 5 , 2 6 , 2 7 , 2 8 , 2 9 , 3 0 , 3 1 , 3 2 , 3 3 , 3 4 , 3 5 , 3 6 , 3 7 , 3 8 , 3 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> i . ToString ( ) ) . ToArray ( ) ) ;
}
var clip = userData as SkinDeformationClip ;
var iarr = new int [ ] {
// all indices from snappers head that contribute to wrinkle maps
// =>
1 , 1 4 , 1 5 , 4 4 , 4 8 , 5 1 , 5 4 , 5 9 , 6 2 , 6 7 , 7 2 , 8 0 , 8 5 , 8 7 , 8 9 , 9 1 , 9 3 , 9 5 , 9 7 , 1 1 0 , 1 1 3 , 1 1 6 , 1 1 8 , 1 1 9 , 1 2 1 , 1 2 3 , 1 2 6 , 1 2 9 , 1 3 2 , 1 3 5 , 1 3 8 , 1 4 1 , 1 4 4 , 1 4 7 , 1 5 0 , 1 5 8 , 1 6 3 , 1 8 1 , 1 8 3 , 1 8 4 , 1 8 7 , 1 9 1 , 1 9 4 , 1 9 7 , 2 0 0 , 2 0 7 , 2 0 9 , 2 1 9 , 2 2 1 , 2 2 7 , 2 2 9 , 2 3 0 , 2 3 1 , 2 3 2 , 2 3 3 , 2 3 5 , 2 3 7 , 2 4 0 , 2 4 1 , 2 5 0 , 2 5 1 , 2 5 2 , 2 5 3 , 2 5 4 , 2 5 5 , 2 5 6 , 2 5 7 , 2 5 8 , 2 5 9 , 2 6 4 , 2 6 5 , 2 9 0 , 2 9 1 , 2 9 2 , 2 9 3 , 2 9 4 , 2 9 5
} ;
var iarr = new int [ ]
{
// all indices from snappers head that contribute to wrinkle maps
// =>
1 , 1 4 , 1 5 , 4 4 , 4 8 , 5 1 , 5 4 , 5 9 , 6 2 , 6 7 , 7 2 , 8 0 , 8 5 , 8 7 , 8 9 , 9 1 , 9 3 , 9 5 , 9 7 , 1 1 0 , 1 1 3 , 1 1 6 , 1 1 8 , 1 1 9 , 1 2 1 , 1 2 3 , 1 2 6 , 1 2 9 , 1 3 2 , 1 3 5 , 1 3 8 , 1 4 1 , 1 4 4 , 1 4 7 , 1 5 0 , 1 5 8 , 1 6 3 , 1 8 1 , 1 8 3 , 1 8 4 , 1 8 7 , 1 9 1 , 1 9 4 , 1 9 7 , 2 0 0 , 2 0 7 , 2 0 9 , 2 1 9 , 2 2 1 , 2 2 7 , 2 2 9 , 2 3 0 , 2 3 1 , 2 3 2 , 2 3 3 , 2 3 5 , 2 3 7 , 2 4 0 , 2 4 1 , 2 5 0 , 2 5 1 , 2 5 2 , 2 5 3 , 2 5 4 , 2 5 5 , 2 5 6 , 2 5 7 , 2 5 8 , 2 5 9 , 2 6 4 , 2 6 5 , 2 9 0 , 2 9 1 , 2 9 2 , 2 9 3 , 2 9 4 , 2 9 5
} ;
clip . importSettings . fittedIndices = String . Join ( "," , iarr . Select ( i = > i . ToString ( ) ) . ToArray ( ) ) ;
}
var iarr = Array . ConvertAll < string , int > ( istr . Split ( ',' ) , int . Parse ) ;
Array . Sort < int > ( iarr ) ;
iarr = SkinDeformationFittingImpl . ComputeLinearlyIndependentBlendShapeIndices ( clip . importSettings . transferTarget , iarr ) ;
iarr = SkinDeformationFitting . ComputeLinearlyIndependentBlendShapeIndices ( clip . importSettings . transferTarget , iarr ) ;
if ( iarr = = null )
{
void OnDisable ( )
{
SkinDeformationClipPreview . Disable ( ) ;
SkinDeformationClipRegions . Disable ( ) ;
}
public override void OnInspectorGUI ( )
SkinDeformationClip clip = ( SkinDeformationClip ) target ;
if ( clip . importSettings . solveRegionPreview )
SkinDeformationClipPreview . Enable ( clip ) ;
SkinDeformationClipRegions . Enable ( clip ) ;
SkinDeformationClipPreview . Disable ( ) ;
SkinDeformationClipRegions . Disable ( ) ;
EditorGUILayout . HelpBox ( GetInfoString ( clip ) , MessageType . Info , true ) ;
if ( GUILayout . Button ( "Import" ) )
}
else
{
SkinDeformationClipPreview . Disable ( ) ;
SkinDeformationClipRegions . Disable ( ) ;
EditorGUILayout . HelpBox ( "Skin Deformation Clip (multiple)" , MessageType . Info , true ) ;
if ( GUILayout . Button ( "Import" ) )
s + = "\n -- contains albedo: " + GetInfoString ( clip . framesContainAlbedo ) ;
s + = "\n -- contains fitted weights: " + GetInfoString ( clip . framesContainFittedWeights ) ;
s + = "\n -- (rev " + clip . version + ")" ;
//s += "\n" + clip.frameDataFilename;
return s ;
}
EditorUtility . DisplayProgressBar ( progressTitle , "Loading assets" , progressIndex + + / progressCount ) ;
var sourceObjs = null as string [ ] ;
var sourceMeshes = null as Mesh [ ] ;
var sourceAlbedos = null as Texture2D [ ] ;
var sourceObjPath s = null as string [ ] ;
var sourceMeshAss et s = null as Mesh [ ] ;
var sourceAlbedoAsset s = null as Texture2D [ ] ;
var useExternalLoader = clip . importSettings . externalLoader ;
var useExternalLoader = ( clip . importSettings . readFrom = = SkinDeformationClip . InputType . ExternalObj ) ;
sourceObjs = GetFilesAtPath ( clip . importSettings . externalObjPath , clip . importSettings . externalObjPattern ) ;
Debug . Assert ( sourceObjs . Length > 0 , ".obj count == 0 (check import settings)" ) ;
sourceObjPath s = GetFilesAtPath ( clip . importSettings . externalObjPath , clip . importSettings . externalObjPattern ) ;
Debug . Assert ( sourceObjPath s . Length > 0 , "source .obj count == 0 (check import settings)" ) ;
using ( var nativeMesh = NativeMeshObjLoader . Parse ( sourceObjs [ 0 ] ) )
using ( var nativeMesh = NativeMeshObjLoader . Parse ( sourceObjPath s [ 0 ] ) )
frameCount = sourceObjs . Length ;
frameCount = sourceObjPath s . Length ;
sourceMeshes = GetAssetsAtPath < Mesh > ( clip . importSettings . meshFolder , clip . importSettings . meshPrefix ) ;
Debug . Assert ( sourceMeshes . Length > 0 , "mesh count == 0 (check import settings)" ) ;
sourceMeshAss et s = GetAssetsAtPath < Mesh > ( clip . importSettings . meshAssetPath , clip . importSettings . meshAsset Prefix ) ;
Debug . Assert ( sourceMeshAss et s . Length > 0 , "mesh count == 0 (check import settings)" ) ;
sourceAlbedos = GetAssetsAtPath < Texture2D > ( clip . importSettings . albedoFolder , clip . importSettings . albedoPrefix ) ;
if ( sourceAlbedos . Length ! = sourceMeshes . Length )
sourceAlbedoAsset s = GetAssetsAtPath < Texture2D > ( clip . importSettings . albedoAssetPath , clip . importSettings . albedoAsset Prefix ) ;
if ( sourceAlbedoAsset s . Length ! = sourceMeshAss et s . Length )
sourceAlbedos = null ;
Debug . LogWarning ( "mesh count != albedo count: skipping albedos" ) ;
sourceAlbedoAsset s = null ;
Debug . LogWarning ( "mesh asset count != albedo asset count: skipping albedos" ) ;
frameCount = sourceMeshes . Length ;
frameVertexCount = sourceMeshes [ 0 ] . vertexCount ;
frameCount = sourceMeshAss et s . Length ;
frameVertexCount = sourceMeshAss et s [ 0 ] . vertexCount ;
}
int frameFittedWeightsCount = 0 ; // modified later
if ( useExternalLoader )
{
using ( var nativeMesh = NativeMeshObjLoader . Parse ( sourceObjs [ 0 ] ) )
using ( var nativeMesh = NativeMeshObjLoader . Parse ( sourceObjPath s [ 0 ] ) )
{
buffersFrame0 . LoadFrom ( nativeMesh ) ;
buffersFrame0 . ApplyRotation ( sourceRotation ) ;
else
{
buffersFrame0 . LoadFrom ( sourceMeshes [ 0 ] ) ;
buffersFrame0 . LoadFrom ( sourceMeshAssets [ 0 ] ) ;
var denoiseFactor = clip . importSettings . denoiseFactor ;
var denoiseIndices = ResolveIndexArrayFromVertexSelectionArray ( clip . importSettings . denoiseRegion , weldedAdjacency ) ;
var denoiseIndices = ResolveIndexArrayFromVertexSelectionArray ( clip . importSettings . denoiseRegions , weldedAdjacency ) ;
var denoiseFactor = clip . importSettings . denoiseStrength ;
var transplantFactor = clip . importSettings . transplantFactor ;
var transplantIndices = ResolveIndexArrayFromVertexSelectionArray ( clip . importSettings . transplantRegion , weldedAdjacency ) ;
var transplantIndices = ResolveIndexArrayFromVertexSelectionArray ( clip . importSettings . transplantRegions , weldedAdjacency ) ;
var transplantFactor = clip . importSettings . transplantStrength ;
var transplantSource = clip . importSettings . transferTarget ;
if ( transplantFactor < float . Epsilon | | clip . importSettings . transferTarget = = null )
if ( transplantFactor < float . Epsilon | | transplantSource = = null )
//TODO cleanup
var transferIndices = ResolveIndexArrayFromVertexSelection ( clip . importSettings . transferRegion , weldedAdjacency ) ;
var laplacianConstraintCount = frameVertexCount ;
var laplacianConstraintIndices = null as int [ ] ;
var laplacianConstraintCount = frameVertexCount ;
var laplacianConstraintIndices = null as int [ ] ;
unsafe
{
using ( var laplacianFreeVertexMap = new UnsafeArrayBool ( frameVertexCount ) )
{
laplacianFreeVertexMap . Clear ( false ) ;
unsafe
{
for ( int k = 0 ; k ! = denoiseIndices . Length ; k + + )
{
if ( laplacianFreeVertexMap . val [ denoiseIndices [ k ] ] = = false )
{
laplacianFreeVertexMap . val [ denoiseIndices [ k ] ] = true ;
laplacianConstraintCount - - ;
}
}
using ( var laplacianFreeVertexMap = new UnsafeArrayBool ( frameVertexCount ) )
{
laplacianFreeVertexMap . Clear ( false ) ;
for ( int k = 0 ; k ! = transplantIndices . Length ; k + + )
{
if ( laplacianFreeVertexMap . val [ transplantIndices [ k ] ] = = false )
{
laplacianFreeVertexMap . val [ transplantIndices [ k ] ] = true ;
laplacianConstraintCount - - ;
}
}
for ( int k = 0 ; k ! = denoiseIndices . Length ; k + + )
{
if ( laplacianFreeVertexMap . val [ denoiseIndices [ k ] ] = = false )
{
laplacianFreeVertexMap . val [ denoiseIndices [ k ] ] = true ;
laplacianConstraintCount - - ;
}
}
for ( int k = 0 ; k ! = transplantIndices . Length ; k + + )
{
if ( laplacianFreeVertexMap . val [ transplantIndices [ k ] ] = = false )
{
laplacianFreeVertexMap . val [ transplantIndices [ k ] ] = true ;
laplacianConstraintCount - - ;
}
}
laplacianConstraintIndices = new int [ laplacianConstraintCount ] ;
laplacianConstraintIndices = new int [ laplacianConstraintCount ] ;
for ( int i = 0 , k = 0 ; i ! = frameVertexCount ; i + + )
{
if ( laplacianFreeVertexMap . val [ i ] = = false )
laplacianConstraintIndices [ k + + ] = i ;
}
}
}
for ( int i = 0 , k = 0 ; i ! = frameVertexCount ; i + + )
{
if ( laplacianFreeVertexMap . val [ i ] = = false )
laplacianConstraintIndices [ k + + ] = i ;
}
}
}
#else
var laplacianROIIndices = denoiseIndices . Union ( transplantIndices ) . ToArray ( ) ;
var laplacianConstraintCount = frameVertexCount - laplacianROIIndices . Length ;
var meshLaplacianTransform = null as MeshLaplacianTransform ;
var meshLaplacianTransform = null as MeshLaplacianTransform ;
#else
var meshLaplacianTransform = null as MeshLaplacianTransformROI ;
#endif
if ( laplacianResolve )
{
#if SOLVE_FULL_LAPLACIAN
meshLaplacianTransform = new MeshLaplacianTransform ( weldedAdjacency , laplacianConstraintIndices ) ;
meshLaplacianTransform = new MeshLaplacianTransform ( weldedAdjacency , laplacianConstraintIndices ) ;
#else
meshLaplacianTransform = new MeshLaplacianTransformROI ( weldedAdjacency , laplacianROIIndices , 0 ) ;
{
#endif
meshLaplacianTransform . ComputeMeshLaplacian ( meshLaplacianDenoised , buffersFrame0 ) ;
if ( transplantIndices . Length > 0 & & clip . importSettings . transferTarget ! = null )
if ( transplantIndices . Length > 0 & & transplantSource ! = null )
transplantBuffers . LoadFrom ( clip . importSettings . transferTarget ) ;
transplantBuffers . LoadFrom ( transplantSource ) ;
//TODO cleanup
var transferTemp = new MeshBuffers ( frameVertexCount ) ;
var transferLaplacianTransform = null as MeshLaplacianTransformROI ;
var transferLaplacian = new MeshLaplacian ( ) ;
var laplacianTransfer = ( transferIndices . Length > 0 ) & & ( clip . importSettings . transferTarget ! = null ) ;
if ( laplacianTransfer )
{
transferLaplacianTransform = new MeshLaplacianTransformROI ( weldedAdjacency , transferIndices , 0 ) ;
}
for ( int i = 0 ; i ! = frameCount ; i + + )
{
EditorUtility . DisplayProgressBar ( progressTitle , "Importing frames" , ( progressIndex - 1 + ( ( float ) i / frameCount ) ) / progressCount ) ;
using ( var nativeMesh = NativeMeshObjLoader . Parse ( sourceObjs [ i ] ) )
using ( var nativeMesh = NativeMeshObjLoader . Parse ( sourceObjPaths [ i ] ) )
{
buffersFrameX . LoadFrom ( nativeMesh ) ;
buffersFrameX . ApplyRotation ( sourceRotation ) ;
else
{
buffersFrameX . LoadFrom ( sourceMeshes [ i ] ) ;
buffersFrameX . LoadFrom ( sourceMeshAss et s [ i ] ) ;
buffersFrameX . ApplyRotation ( sourceRotation ) ;
buffersFrameX . ApplyScale ( sourceScale ) ;
}
buffersFrameX . ApplyWeldedChanges ( weldedAdjacency ) ;
}
//TODO cleanup
if ( laplacianTransfer )
{
buffersTarget . CopyTo ( transferTemp ) ;
transferLaplacianTransform . ComputeMeshLaplacian ( transferLaplacian , buffersFrameX ) ;
transferLaplacianTransform . ResolveMeshBuffers ( transferTemp , transferLaplacian ) ;
transferTemp . CopyTo ( buffersFrameX ) ;
buffersFrameX . RecalculateNormals ( weldedAdjacency ) ;
buffersFrameX . ApplyWeldedChanges ( weldedAdjacency ) ;
}
frames [ i ] . SetAlbedo ( ( sourceAlbedos ! = null ) ? sourceAlbedos [ i ] : null ) ;
//frames[i].SetDeltas(buffersFrame0, buffersFrameX);
//TODO cleanup
if ( laplacianTransfer )
frames [ i ] . SetDeltas ( buffersTarget , buffersFrameX ) ;
else
frames [ i ] . SetDeltas ( buffersFrame0 , buffersFrameX ) ;
frames [ i ] . SetAlbedo ( ( sourceAlbedoAssets ! = null ) ? sourceAlbedoAssets [ i ] : null ) ;
frames [ i ] . SetDeltas ( buffersFrame0 , buffersFrameX ) ;
var targetVertexCount = laplacianTransfer ? buffersTarget . vertexCount : buffersFrame0 . vertexCount ;
var targetVertexCount = buffersFrame0 . vertexCount ;
Debug . LogWarning ( "frame " + i + " has different vertexCount (" + buffersFrameX . vertexCount + " vs. " + targetVertexCount + " in frame 0)" ) ;
{
Debug . LogWarning ( "frame " + i + " has different vertexCount (" + buffersFrameX . vertexCount + " vs " + targetVertexCount + " in frame 0)" ) ;
}
}
for ( int i = 0 ; i ! = subframeCount ; i + + )
subframes [ i ] . fractionHi = 1.0f ;
}
ImportFrameIntervalsFromCSV ( clip . importSettings . keyframesCSV , frameCount - 1 , ref subframeCount , ref subframes ) ;
if ( clip . importSettings . keyframes )
{
ImportFrameIntervalsFromCSV ( clip . importSettings . keyframesCSV , frameCount - 1 , ref subframeCount , ref subframes ) ;
}
}
EditorUtility . DisplayProgressBar ( progressTitle , "Retargeting frames" , progressIndex + + / progressCount ) ;
for ( int j = 0 ; j ! = frameVertexCount ; j + + )
{
frames [ i ] . deltaPositions [ j ] + = firstFrameDelta . deltaPositions [ j ] ;
frames [ i ] . deltaTangents [ j ] + = firstFrameDelta . deltaTangents [ j ] ;
frames [ i ] . deltaNormals [ j ] + = firstFrameDelta . deltaNormals [ j ] ;
}
}
var blendShapeIndicesCommaSep = clip . importSettings . fittedIndices ;
var blendShapeIndices = Array . ConvertAll < string , int > ( blendShapeIndicesCommaSep . Split ( ',' ) , int . Parse ) ;
SkinDeformationFittingImpl . FitFramesToBlendShapes ( frames , clip . importSettings . transferTarget , blendShapeIndices , clip . importSettings . fittingMethod , clip . importSettings . fittingParam ) ;
SkinDeformationFitting . FitFramesToBlendShapes ( frames , clip . importSettings . transferTarget , blendShapeIndices , clip . importSettings . fittingMethod , clip . importSettings . fittingParam ) ;
clip . lastBuild = clip . importSettings . Clone ( ) ;
clip . lastImport = clip . importSettings . Clone ( ) ;
clip . frameCount = frameCount ;
clip . frameVertexCount = frameVertexCount ;
clip . frameFittedWeightsCount = frameFittedWeightsCount ;
}
}
static void ImportFrameIntervalsFromCSV ( string filename , int maxFrameIndex , ref int subframeCount , ref SkinDeformationClip . Subframe [ ] subframes )
static void ImportFrameIntervalsFromCSV ( TextAsset textAsset , int maxFrameIndex , ref int subframeCount , ref SkinDeformationClip . Subframe [ ] subframes )
if ( ! File . Exists ( filename ) )
if ( textAsset = = null )
return ;
// skip 1st column of every row
var vals = new int [ NUM_ROWS ] [ ] ;
var valCount = NO_VALUE ;
using ( StreamReader reader = new StreamReader ( filename ) )
using ( StringReader reader = new StringReader ( textAsset . text ) )
if ( reader . EndOfStream )
return ; // bad input, missing rows
var line = reader . ReadLine ( ) ;
if ( line = = null )
return ; // bad input, missing rows