MorphBlend

Plugins MorphBlend v1.1

demo.jpg


v1 plugin release


HOW TO USE

- add the plugin to a person
- add a morph uid (internal name) like "Head Scale"
- set the start value (what the morph should be at 0% of the blend)
- set the end value (what the morph should be at 100% of the blend)
- now when triggering the blend, the morph value will be calculated and adjusted accordingly
- add up to 10 morphs to a blend. you can add the plugin multiple times and do different separate stuff with each instance. check the demo scene for examples

IDEAS
With this plugin it should be a bit easier to create in vam the folllowing:
- generate completely random models without any code (with aetool3 dynamic text for random morphs)
- handle expressions easier based on scene triggers
- handle state morphs through triggers easier (eyes open/closed, mouth, erection, etc.)
- add randomness to posing to make unique stuff


Initial release

for an answer on the forum https://hub.virtamate.com/threads/perfect-blend-between-2-morphs.19461. quick person plugin to blend morphs based on a slider.
writes a txt list of all morphnames in Saves\PluginData\BlendDebug


using System;
using UnityEngine;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using SimpleJSON;
using MVR.FileManagementSecure;
namespace SPQR
{
public class Template : MVRScript {
Dictionary<string, float> morphsList1;
Dictionary<string, float> morphsList2;
public override void Init() {
PopulateMorphs();
WriteDebugList(); // writes a list of all morphs in Saves\PluginData\BlendDebug

JSONStorableFloat jfloat = new JSONStorableFloat("Blend", 0.33f, BlendCallback, 0f, 1f, true);
RegisterFloat(jfloat);
UIDynamicSlider dslider = CreateSlider(jfloat);
}
void Start() {

}
void Update() {

}
void FixedUpdate() {

}
void OnDestroy() {
}

//--------------------------------------//
void PopulateMorphs(){ // Add or read custom morphs here
morphsList1 = new Dictionary<string, float>(){
{ "Aiko 6 Body", 1f },
{ "Destiny Head", 0.7f }
};
morphsList2 = new Dictionary<string, float>(){
{ "Aiko 6 Body", 0.2f },
{ "Destiny Head", 0f }
};
}
void BlendCallback(JSONStorableFloat jf){
GenerateDAZMorphsControlUI morphControl = returnMorphs();
morphControl.GetMorphDisplayNames().ForEach((name) =>{
if(morphsList1.ContainsKey(name) && morphsList2.ContainsKey(name)){
DAZMorph morph = morphControl.GetMorphByDisplayName(name);
morph.morphValue = Mathf.Lerp(morphsList1[name], morphsList2[name],jf.val);
}
});
}
GenerateDAZMorphsControlUI returnMorphs() {
JSONStorable geometry = containingAtom.GetStorableByID("geometry");
DAZCharacterSelector character = geometry as DAZCharacterSelector;
return character.morphsControlUI;
}
void WriteDebugList(){
GenerateDAZMorphsControlUI morphControl = returnMorphs();
string debugList ="";
morphControl.GetMorphDisplayNames().ForEach((name) =>{
debugList+= ""+name+"\r\n";
});
FileManagerSecure.CreateDirectory(@"Saves\PluginData\BlendDebug");
FileManagerSecure.WriteAllText(@"Saves\PluginData\BlendDebug\morphs.txt",debugList);
}
}
}
Author
SPQR
Downloads
534
Views
2,724
First release
Last update
Rating
5.00 star(s) 1 ratings

More resources from SPQR

Share this resource

Latest updates

  1. v1.1 update

    - made it an actual plugin package - added support to change morph names directly from the...

Latest reviews

I figured out the easy stuff, like naming and changing morphs, the question I have if there's an easy way to add more sliders?
SPQR
SPQR
yes, it's very easy. jump to the discussion tab, i'll add the code there
Top Bottom