[ Coding ] Appearance and skin lock, how to ?

hazmhox

Moderator
Featured Contributor
Messages
1,523
Reactions
7,340
Points
173
Hey guys and fellow coders,

I'm trying to achieve something and I cannot find a way to do it.
The new feature of locking in VAM is frikkin' great. And I want to use it to allow swapping appearance in a scene. These two checkboxes :

lock-panel.png


The fact is : these parameters do not save inside the json file. I wish it did but well... maybe @meshedvr can do something about that at some point ? :]

So I tried to checkout the code, but I can't find a way to access the UI or the atom settings that would allow me to create a plugin that can check or uncheck automatically these checkboxes when the scene loads ( or with specific triggers ).

If some of you coders had an idea... it would be frikkin' great :]
 
Hazmhox,

Great work on the 2069 story ?, must have taken some time to put together.

I finally found that the presetManager is linked to the atom. Here is some code to set the presets.
C#:
        public override void Init()
        {
            try
            {
                PresetLock(containingAtom, "Appearance", true);
                PresetLock(containingAtom, "Skin", true);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }

        /// <summary>
        /// Function to set the lock state of the presets.
        /// </summary>
        /// <param name="atom">A valid person atom</param>
        /// <param name="presetName"> Names returned from preset manager controls
        /// rescale2
        /// geometry
        /// AppearancePresets
        /// PosePresets
        /// FemaleGlutePhysicsPresets
        /// FemaleBreastPhysicsPresets
        /// PluginPresets
        /// SkinPresets
        /// MorphPresets
        /// HairPresets
        /// ClothingPresets
        /// <param name="locked">Whether locked or not. true/false</param>
        public void PresetLock(Atom atom, string presetName, bool locked = false)
        {
            //Make sure we have some valid data
            if (atom == null || atom.presetManagerControls == null || presetName == "") return;

            //Go through each PresetManagerControl
            foreach (MeshVR.PresetManagerControl ctrl in atom.presetManagerControls)
            {
                //If we find the name then set it
                if (ctrl.name.Contains(presetName))
                {
                    ctrl.lockParams = locked;
                }
            }
        }
 
@VRStudy ! This is frikkin' great mate ! Thank you so much for that.

I would be curious to understand how you managed to find out with the solution. I'm not a big visual studio guy and some of my knowledge when it comes to finding out how some functions works from a C# source is kinda limited. Even tho I could have coded that if I knew.

Do you mind if make a plugin based on your source code and share it with the idea I have in mind ? ( full credits to you of course ! )

Also ! Thank you very much about 2069. ( If someday you have the time to drop a review, I would be very glad ! )

Thanks again for the code snippet, I'm trying that asap !

EDIT : Quickly made a test, it works perfectly !
 
Last edited:
@hazmhox Usual process used by most is to reverse engineer VaM by using tools like ILSpy to look at VaM_Data\Managed\Assembly-CSharp.dll. You can look at the decompiled source code, seeing exactly what is happening. Since its C# it can be decompiled to almost the same as Meshed wrote it, except that comments and local variable names are missing. (in comparison a C++ compiler would do far more optimizations and result would be far more unreadable)
 
Glad it works, feel free to use the code :). I used ILSpy to look through code, sometimes you have to find workarounds since a lot of the class method/properties are protected or private.
 
Great ! The plugin is already ready haha. I was waiting for your signal ;]
 
Back
Top Bottom