Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Space Pony
Original Poster
#1 Old 21st Jun 2021 at 8:24 PM Last edited by Battery : 21st Jun 2021 at 8:38 PM.
Default Problem with FacialBlendData/Blendunit creation via C# Script
Hey everyone,

while working on a side project which includes work on sliders with my Script Utility, i noticed that i am only able to obtain 62 out of 75 Facial sliders. (From Fullbuild0 and Deltabuild0)
I am obtaining sliders by creating a Blendunit form a resourcekey and use that to create the FacialBlendData, for some reason this does not work for all sliders but for the majority it does.

For example EyeRotation reskey = 0xB52F5055-0x00000000-0x74A950DCB9CAFCB2 does not work and the created FacialBlendData seems to be hollow as if its a wrong reskey.

So any ideas why something like EyeHeight reskey = 0xB52F5055-0x00000000-0x5EC0D68857B02929 works but EyeRotation and a few others dont ?

Also if anyone knows are these 75 sliders all the vanilla sliders(FacialBlends) or am i missing some ?

My Slider List (including Failures)


Thanks in advance
Advertisement
Forum Resident
#2 Old 24th Jun 2021 at 7:36 PM
I'm getting 74 slightly different ones. This is a slider dump from landslide mod. Are you getting the same reskeys on the ones that don't work for you?


Find my Mods: Here at MTS, over at Simlogical
Space Pony
Original Poster
#3 Old 24th Jun 2021 at 8:17 PM Last edited by Battery : 24th Jun 2021 at 8:40 PM.
Quote: Originally posted by Consort
I'm getting 74 slightly different ones. This is a slider dump from landslide mod. Are you getting the same reskeys on the ones that don't work for you?




Yes im getting the same Reskeys but they dont work for me (that is the ones stated in my first post)


Do these work for you then if you used them in your mod ?

I found that i am able to use the FacialBlend class directly even for those failed FacialBlendData. I would have prefered just FacialBlendData, but it seems to get all the customization options you need either only the FacialBlend or a mix of FacialBlendData and FacialBlends.

Thanks for taking the time and extracting the FacialBlendData entries from your mod for comparison.
Forum Resident
#4 Old 24th Jun 2021 at 8:54 PM
I'm using this to set the blend, nicked from CmarNYC

Code:
   public static bool SetMorph(SimDescription simdesc, FacialBlendData blend, float value)
            {
           
                foreach (OutfitCategories categories in simdesc.GetCurrentOutfits().Keys)
                {
                    SetMorph(simdesc, blend, value, categories);
                }
                return true;
            }

public static bool SetMorph(SimDescription simdesc, FacialBlendData blend, float value, OutfitCategories cat)
            {

                int outfitCount = simdesc.GetOutfitCount(cat);
                for (int i = 0; i < outfitCount; i++)
                {

                    using (SimBuilder builder = new SimBuilder())
                    {
                        SimOutfit outfit = simdesc.GetOutfit(cat, i);
                        OutfitUtils.SetOutfit(builder, outfit, simdesc);

                        if (blend.mBlend2 == null)
                        {
                            builder.SetFacialBlend(blend.mBlend1.GetKey(), value);
                        }
                        else if (value >= 0)
                        {
                            builder.SetFacialBlend(blend.mBlend1.GetKey(), value);
                            builder.SetFacialBlend(blend.mBlend2.GetKey(), 0f);
                        }
                        else
                        {
                            builder.SetFacialBlend(blend.mBlend1.GetKey(), 0f);
                            builder.SetFacialBlend(blend.mBlend2.GetKey(), -value);
                        }




                        string instanceName = string.Concat(new object[] { simdesc.FirstName, simdesc.LastName, cat.ToString(), i });
                        SimOutfit outfit2 = new SimOutfit(builder.CacheOutfit(instanceName));
                        simdesc.RemoveOutfit(cat, i, true);
                        simdesc.AddOutfit(outfit2, cat, i);
                    }
                }
                return true;
            }

And I generate the facialblenddata like this

FacialBlendData someslider = new FacialBlendData(new BlendUnit(new ResourceKey(0x8A977878AF6EEB92L, 0xb52f5055, 0)));

this really should work on all sliders. I tried a few of the ones that don't work for you in Landslide and they work with pretty much the above code.


How do you use the FacialBlend class directly?

Find my Mods: Here at MTS, over at Simlogical
Space Pony
Original Poster
#5 Old 25th Jun 2021 at 2:55 PM Last edited by Battery : 29th Jun 2021 at 8:25 PM.
I use something that is almost the same.



But i tested your version and it wroked !

It seems that checking SliderType.mBidirectional does not work the way i hoped it would so fortunately i just remove it then with the null check and im set thank you so much Consort !

About the FacialBlend well as i see it the FacialblendData consists of FacialBlends so you can do the same with the FacialBlend Directly (via Simbuilder) this way you have some more options like eyesAsain etc which maybe are somewhere in the EyeShape slider.

Code:
simBuilder.SetFacialBlend(facialBlend.GetKey(), 3f);


thanks again i will update the utility with that fix, wouldnt have thought that the Bidirectional method was the problem !

Oh now to give something back to you(small thing though). You can pull the Simbuilder out of the loop resulting in a performance boost. ( See my borked code bit)
Forum Resident
#6 Old 25th Jun 2021 at 10:17 PM
I believe there are two different concepts. There is bidirectional sliders which default in the middle and go left and right in the UI as opposed to default to the left. And there are asymmetrical sliders which do different things depending on wether they are positive or negative. I believe it's possible to make one slider that makes the ears go smaller when you pull it to the left and the nose go bigger when you pull to the right.

Yes, I used to experiment with the simbuilder instance outside the main loop but ran into some problems. Unfortunately I cant remember what those were...

If you discover something cool with the FacialBlend class pls let me know

Find my Mods: Here at MTS, over at Simlogical
Back to top