Unity3d BlendShapes, too many!

Identifying blendShape IDs in FBX objects that have more than you can count

I've been working with Daz3D and Unity3D FBX objects and their blendShapes.  Sometimes, for testing I export EVERYTHING, and it can be 100s of blends.

I've written the following C# code that will allow you to add target meshes and skinnedMeshes to the Inspector and will enumerate each mesh's blends and put them in a CSV file.  From there, you can target the integer based representation that is matched up with the string name of the blend shape.

You could also loop through all blend shape in object, and use name matching to apply blends as well.  A for each blend, if name contains or name equals blink, do xyz. etc... but here is the code that will dump it out to CSV.

This will try and create the directory as well, so be careful to put in a good path.  Also, if an Mesh contains no blends, then  EndOfList - If this is the only entry... will be written to the file.

change the logPath below to your own directory, or just update it in the inspector.

Unity3d C# Code

using System.IO;
using UnityEngine;

public class SharedBodyFunctions : MonoBehaviour {


    public string charName;
    public Mesh[] primaryObjectBlendMeshes;
    public SkinnedMeshRenderer[] skinnedMeshRenderer;
    public string logPath = "S:\\Unity\\Projects7\\Lighting\\Assets\\Logs\\";

 

 void Start () {
 }
 
 void Update ()
    {
        if(Input.GetKeyDown(KeyCode.F12))
        {writeBlendShapesToLog();}

 }

    void writeBlendShapesToLog()
    {
        string flogPath=logPath + charName;

        try
        { System.IO.Directory.CreateDirectory(flogPath); }
        catch
        { print(flogPath + " exists");
        }

        foreach (Mesh primaryObjectBlendMesh in primaryObjectBlendMeshes)
        {
            string logname = primaryObjectBlendMesh.name;
            string uid = primaryObjectBlendMesh.GetHashCode().ToString();
            StreamWriter outputFile = new StreamWriter(flogPath +"\\" + logname + "_" + charName + ".csv", false);
            int f = 0;
            do
            {
                string output = "Unfound";

                try { output = (f + "," + primaryObjectBlendMesh.GetBlendShapeName(f)); }
                catch {output = (f + ", EndOfList - If this is the only entry, then there are no blend shapes for the select SkinnedMesh" ); }
                
                outputFile.WriteLine(output);
                f++;
            } while (f < primaryObjectBlendMesh.blendShapeCount);
            outputFile.Close();
        }
    }

}
//as always use at your own risk, even though i have tested it over and over.

Comments

  1. Top Soccer Tipsters - vntopbet.com
    Top Soccer Tipsters: Expert soccer tipsters bk8 with best profits and highest ROI. Get a m88 free Bet & share matchpoint your success today.

    ReplyDelete
  2. Casino at Bryson City Hotel and Casino - Mapyro
    Find all information and reviews for Casino at Bryson 당진 출장안마 City Hotel and 구리 출장안마 Casino in 창원 출장마사지 Bryson City, including real guest 부천 출장마사지 reviews, photos, directions,  Rating: 4.4 양산 출장마사지 · ‎19 reviews

    ReplyDelete
  3. JOHNN'S CASINO IN SEAH OLYMPUS CITY - Air Jordan
    JOHNN'S find air jordan 18 stockx CASINO IN SEAH OLYMPUS air jordan 18 retro yellow sale CITY JOHNN'S CASINO IN SEAH OLYMPUS CITY JOHNN'S CASINO IN SEAH OLYMPUS CITY website to buy air jordan 18 retro red suede JOHNN'S CASINO IN SEAH OLYMPUS CITY how can i find air jordan 18 retro yellow | where to get air jordan 18 retro varsity red JOHNN'S

    ReplyDelete
  4. The King Casino: A Review of A Good Casino
    An overview of the The King Casino, the https://deccasino.com/review/merit-casino/ best jancasino online goyangfc.com casino of the https://septcasino.com/review/merit-casino/ 2020, casino game list. Learn about bonuses and games 스포츠 토토 사이트 and more

    ReplyDelete
  5. Luckily, yow will discover lots of roulette variations at the most effective Arabic casinos online. 카지노 French Roulette options an interesting insurance wager referred to as En Partage. You will receive half your even-money stake again if the zero seems.

    ReplyDelete

Post a Comment

Popular posts from this blog

SAPI Interface and Unity3d