Perfect blend between 2 morphs

Vamateur

New member
Messages
5
Reactions
1
Points
3
Hi everyone,

I search a solution for blending two morphs. I finded two plugins but it's not perfect.

I want to blend with a slider "model 1" to "model 2". For exemple if the slider is on value 0 the morph is the exact morph 1, on value 1 exact morph 2 and 0.5 a blend of the two morph.
Being able to choose the part of the body as in the plugins mentioned above would be perfect but at first it is not my priority.

I experiment that with a slider like that : https://hub.virtamate.com/threads/h...h-sliders-using-a-uislider-atom-trigger.2486/

For exemple :
All active morph 1 (added one by one in the slider) I selected StartValue to : "actual value", EndValue : "0"
All active morph 2 I selected StartValue to : "0", EndValue : "actual value"

It works good but manualy it's too long.

Maybe I can create this in visual basic, the goal would be to put the parameters of morph 1 in one table and morph 2 in another and to retrieve the values automatically to make a preset file for my slider but if it's possible I would prefer to have a plugin directly in VAM :p

Someone knows a plugin or have an idea to do that easily ? Maybe one of the plugins already mentioned is able to do that, but I haven't found how it works 😅

Thanks to the community ;)
 
You could use the timeline plugin, it can animate morphs, its probably the easiest way to achieve what you need
Animation 1: morph1 - 0%, morph2 - 100%
Animation 2: morph1 - 100%, morph2 - 0%
:unsure:
 
i don't know of any existing plugins but if you're willing to make one you can change morphs through vam plugins. you can take a look at my spqarlive code for a quick & dirty example. There I'm updating some morphs by their name. There's a foreach somewhere that goes through all the model's morphs and checks their names that would be helpful to you.

you could do quickly something like:
- declare 2 dictionaries <string, float> where you keep your mapping, e.g. morphsList1["morphA"] = 0.5f; morphsList2["morphA"] = 0.75f;
- add a slider 0 to 1 ( you can find an example in the example scripts that come with vam), it's very quick, and when it gets updated there's a function like callback(newSliderVal) where you'll do your stuff
- on that callback you do a foreach morphs like in my plugin (goes through all the morphs of the model; containingAtom = the atom that has the plugin,) and if morphsList1.ContainsKey(morphName) && morphsList2.ContainsKey(morphName) you set the value of it to something like Mathf.Lerp(morphsList1[morphName], morphsList2[morphName], newSliderVal ) (gets the value between two other values at a given percent 0-1, if newSliderVal is 0.5 for example it will return the middle between the two, if it's 0 it will return the value from list1, 1 will return the value from list2)
- if it's your first plugin, don't do stuff on Update() or FixedUpdate(), those are called multiple times per second. You only need to add the slider in an Init() function and the callback function for your slider, you can find that in the example plugins made by meshedvr in the scripts folder. you can just copy-paste one of those plugins and use the demo slider and then later remove the stuff you don't need
 
here you go https://hub.virtamate.com/resources/blend-plugin-demo.16943/ went and made that real quick

notes:
- the morphs are hardcoded, you can create multiple scripts and just change their names there.
like head1.blendScript.cs , body1.blendScript.cs
or you can copy-paste it and add more sliders directly in the plugin ,head1 slider, body1 slider etc.
- if it's for personal use using any morphs is fine, if you want to share it you should either use only default morphs or also add dependencies for the morphs packages. you might use a morph there that works for you, others might not have
- for more dynamic stuff I'd recommend loading & reading the morphs from looks or presets instead of hardcoding them but that's more advanced stuff

you can comment WriteDebugList(); if you don't need that, it writes a txt in Saves\PluginData\BlendDebug with all the morphs names found
 
Last edited by a moderator:
Hello,

Thank you for your answers. After doing a lots of testing I realized that the problem came from a morph that had the "Use man moph on femal" option active. Finally the moph merge and slip plugin works great if the option is not checked. I will propose to the creator of this plugin to make a small update.


Otherwise concerning the creation of plugin that interests me, you know where I could find a fairly complete tutorial?

Thanks again !
 
Otherwise concerning the creation of plugin that interests me, you know where I could find a fairly complete tutorial?

There are a few if you go through these pages in guides https://hub.virtamate.com/resources/categories/guides.13

There are also a few very useful examples from MeshedVR himself included with vam, namely Custom\Scripts\MeshedVR\TemplateWithSample.cs

it's probably covered in some of those but just in case, the basics from my experience:
- you can add either a .cs file or a .cslist (list of multiple .cs files) as a plugin. You can copy a template file, edit some code there and done. no compilation needed
- Init() is the main function that gets called when the plugin gets loaded, there stuff like the plugin settings page gets initialized
- Update() gets called every frame, UpdateFixed() gets called every physics frame. In them you can check for stuff, e.g. if atom1 is close to atom2, if a key is pressed, etc.
- you can do async calls (have something dynamic happen like an object to move from point A to point B in 1s) using coroutines https://docs.unity3d.com/Manual/Coroutines.html , they're sort of like functions that repeat themselves so that you don't have to do stuff frame by frame
- there's a very important SuperController class that holds a lot of VAM functions and variables, you'll see that a lot and find stuff there. SuperController.LogMessage("a") writes stuff to the vam notice log (in-game). LogError() to the error log.
- https://www.reddit.com/r/VirtAMate/wiki/scripting_examples

the tricky part is figuring out all the custom functions that you can use, what's available and how to do stuff:
- there's no documentation on available functions but you can use this https://hub.virtamate.com/threads/is-there-a-plugin-developer-guide.725/post-39445 to see info about available functions & how they're used, what parameters they take, what stuff is public and what you can call. Without it you'll be in the dark
- https://docs.unity3d.com/Manual/ has lots of useful example too and usually if you google how to do x in unity you'll find a solution unless it's something superspecific to vam
- myself I checked a lot other plugins to see how they're doing stuff, MacGrubber's in particular, he has a MacGruber_Utils.cs in his Logicbricks plugin with lots of useful functions.


for help I think on discord you'll get quick responses, here on the forum there's less activity. Hope you make awesome stuff!
 
Thank you for all those informations. I'll try to do something simple to start but it's more complicated than I thought.

Thanks again !
 
Back
Top Bottom