Source Filmmaker

Source Filmmaker

GolosoX Mar 25, 2020 @ 11:46am
Sharing flexes among bodygroups
I have compiled a custom clothing model in Blender to use on a base body model in SFM. I've separated the clothing model into bodygroups so that all the possible combinations can be matched, and some of the bodygroups have shapekeys with the same names. If you've tried something like this before you know what happens: The flex sliders inside SFM do not work.

I know I can either just rename the flexes so that no name repeats (undesirable, as it will clutter my model with flex sliders) or compile each bodygroup into its own separate model (even more clutter), but I've read a couple of times before that it is in fact possible to have the flexes of multiple bodygroups driven by a single slider, although I'm yet to find a concrete example of this.

Any ideas on how to do that?

I've reduced my QC to be pretty barebones. The "coat" and "shirt" DMX files below have flexes with the same names.


$modelname "test/clothing/testClothing"
$cdmaterials "models/test/clothing/testClothing/"

$texturegroup skinfamilies {
{ "cloth0_alt0" }
{ "cloth0_alt1" }
{ "cloth0_alt2" }
{ "cloth0_alt3" }
}

$bodygroup "Upper" {
studio "coat.dmx"
studio "shirt.dmx"
blank
}

$sequence idle "coat.dmx"
Originally posted by Zappy:
Originally posted by 3gos:
- If you've tried something like this before you know what happens: The flex sliders inside SFM do not work. -
That's not what happens. What happens is that there will be multiple entire sets of flex controllers (e.g. 2 separate "smile" flex controllers), one for each DMX defining them, while only the first (or last?) set will affect the model, with it affecting all different DMX meshes.


Originally posted by 3gos:
- $bodygroup "Upper" {
studio "coat.dmx"
studio "shirt.dmx"
blank
} -
In this example, "coat.dmx" should have shape keys and flex controller definitions, while "shirt.dmx" should have shape keys without flex definitions.

(You could also swap it around if you'd like; The important thing is that the flex controllers are only defined in one of the files, despite the shape keys being in both of them.)


To avoid having flex definitions in a DMX export, use the "Source Engine Exportables" panel (in Blender) to give the "shirt" object "advanced" flexes instead of "simple" ones, then use this as the flex definition block:
<!-- dmx encoding keyvalues2 1 format model 1 --> "DmElement" { "id" "elementid" "12345678-1234-1234-1234-012345678910" "name" "string" "root" "combinationOperator" "DmeCombinationOperator" { "id" "elementid" "01234567-8910-1112-1314-151617181920" "name" "string" "combinationOperator" "controls" "element_array" [ ] "controlValues" "vector3_array" [ ] "controlValuesLagged" "vector3_array" [ ] "usesLaggedValues" "bool" "0" "dominators" "element_array" [ ] "targets" "element_array" [ ] } }
(You can copy that into a text editor, save it as a TXT file, and then browse to that file as the "[Flex] Controller Source" near the simple/advanced flex type toggle.)

Admittedly, I haven't tested that specific flex definition block, but it should probably work, I hope.


After that, re-export the "shirt" object as a DMX file. If everything goes as planned, Blender should warn you that there are shape keys without flex controller definitions. Then you should just have to re-compile the model, and then it should work afterwards.
< >
Showing 1-8 of 8 comments
The author of this thread has indicated that this post answers the original topic.
Zappy Mar 25, 2020 @ 1:12pm 
Originally posted by 3gos:
- If you've tried something like this before you know what happens: The flex sliders inside SFM do not work. -
That's not what happens. What happens is that there will be multiple entire sets of flex controllers (e.g. 2 separate "smile" flex controllers), one for each DMX defining them, while only the first (or last?) set will affect the model, with it affecting all different DMX meshes.


Originally posted by 3gos:
- $bodygroup "Upper" {
studio "coat.dmx"
studio "shirt.dmx"
blank
} -
In this example, "coat.dmx" should have shape keys and flex controller definitions, while "shirt.dmx" should have shape keys without flex definitions.

(You could also swap it around if you'd like; The important thing is that the flex controllers are only defined in one of the files, despite the shape keys being in both of them.)


To avoid having flex definitions in a DMX export, use the "Source Engine Exportables" panel (in Blender) to give the "shirt" object "advanced" flexes instead of "simple" ones, then use this as the flex definition block:
<!-- dmx encoding keyvalues2 1 format model 1 --> "DmElement" { "id" "elementid" "12345678-1234-1234-1234-012345678910" "name" "string" "root" "combinationOperator" "DmeCombinationOperator" { "id" "elementid" "01234567-8910-1112-1314-151617181920" "name" "string" "combinationOperator" "controls" "element_array" [ ] "controlValues" "vector3_array" [ ] "controlValuesLagged" "vector3_array" [ ] "usesLaggedValues" "bool" "0" "dominators" "element_array" [ ] "targets" "element_array" [ ] } }
(You can copy that into a text editor, save it as a TXT file, and then browse to that file as the "[Flex] Controller Source" near the simple/advanced flex type toggle.)

Admittedly, I haven't tested that specific flex definition block, but it should probably work, I hope.


After that, re-export the "shirt" object as a DMX file. If everything goes as planned, Blender should warn you that there are shape keys without flex controller definitions. Then you should just have to re-compile the model, and then it should work afterwards.
Last edited by Zappy; Mar 25, 2020 @ 1:12pm
ZergSquad Mar 25, 2020 @ 2:09pm 
if u using smd, flex will looks like this

$model "asdf" "cookie_body.smd"
{
flexfile "cookie_body.vta"
{
defaultflex frame 0
flex "something" frame 1
}
flexcontroller something range 0 1 "something"
flexcontroller FlexWithCoat range 0 1 "FlexWithCoat"
flexcontroller OneControllerFor2FlexesFromCoatAndShirt range 0 1 "OneControllerFor2FlexesFromCoatAndShirt"

%something = something
}


$model "coat" "coat_body.smd"
{
flexfile "coat_body.vta"
{
defaultflex frame 0
flex "FlexWithCoat" frame 1
flex "OneControllerFor2FlexesFromCoatAndShirt" frame 2
}

%FlexWithCoat = FlexWithCoat
%OneControllerFor2FlexesFromCoatAndShirt = OneControllerFor2FlexesFromCoatAndShirt
}

$model "shirt" "shirt_body.smd"
{
flexfile "shirt_body.vta"
{
defaultflex frame 0
flex "OneControllerFor2FlexesFromCoatAndShirt" frame 1
}
%OneControllerFor2FlexesFromCoatAndShirt = OneControllerFor2FlexesFromCoatAndShirt
}


So when u load model u will have 2 flexes from body and coat. and ONE flex working on coat and shirt at once



If u want to share flexes among $bodygroup
u need to declare flex on body smd and make flexes on !!!!!!!!!!!.DMX!!!!!!!!!! models that u put in bodygroups as CORRECTIVE SHAPE KEY in blender or whatever you use

or the save if u use .dmx on main model, but flexNAMES on main model and corrective flexes on bodygrouped models must be the same


Last edited by ZergSquad; Mar 25, 2020 @ 2:12pm
GolosoX Mar 25, 2020 @ 2:58pm 
Originally posted by Zappy:
To avoid having flex definitions in a DMX export, use the "Source Engine Exportables" panel (in Blender) to give the "shirt" object "advanced" flexes instead of "simple" ones, then use this as the flex definition block:
<!-- dmx encoding keyvalues2 1 format model 1 --> "DmElement" { "id" "elementid" "12345678-1234-1234-1234-012345678910" "name" "string" "root" "combinationOperator" "DmeCombinationOperator" { "id" "elementid" "01234567-8910-1112-1314-151617181920" "name" "string" "combinationOperator" "controls" "element_array" [ ] "controlValues" "vector3_array" [ ] "controlValuesLagged" "vector3_array" [ ] "usesLaggedValues" "bool" "0" "dominators" "element_array" [ ] "targets" "element_array" [ ] } }
(You can copy that into a text editor, save it as a TXT file, and then browse to that file as the "[Flex] Controller Source" near the simple/advanced flex type toggle.)

Admittedly, I haven't tested that specific flex definition block, but it should probably work, I hope.

It works perfectly. Amazing, I never would have guessed to do this. This bodygroup-flexes problem has bothered me many times in the past, so thanks a lot.
76561198820688764 Apr 27, 2020 @ 3:04am 
Originally posted by Zappy:
To avoid having flex definitions in a DMX export, use the "Source Engine Exportables" panel (in Blender) to give the "shirt" object "advanced" flexes instead of "simple" ones, then use this as the flex definition block:
<!-- dmx encoding keyvalues2 1 format model 1 --> "DmElement" { "id" "elementid" "12345678-1234-1234-1234-012345678910" "name" "string" "root" "combinationOperator" "DmeCombinationOperator" { "id" "elementid" "01234567-8910-1112-1314-151617181920" "name" "string" "combinationOperator" "controls" "element_array" [ ] "controlValues" "vector3_array" [ ] "controlValuesLagged" "vector3_array" [ ] "usesLaggedValues" "bool" "0" "dominators" "element_array" [ ] "targets" "element_array" [ ] } }
do you know how to make this work with stereo? if I change stereo bool to 1, other dmx using above code will do nothing if I move the slider.
Last edited by ᠌ ᠌; Apr 27, 2020 @ 3:56am
Zappy Apr 27, 2020 @ 3:59am 
Originally posted by ᠌ ᠌:
do you know how to make this work with stereo? -
If it doesn't already just work, then I'm afraid not.
Muigio44 May 22, 2024 @ 8:50pm 
Originally posted by Zappy:
Originally posted by 3gos:
- If you've tried something like this before you know what happens: The flex sliders inside SFM do not work. -
That's not what happens. What happens is that there will be multiple entire sets of flex controllers (e.g. 2 separate "smile" flex controllers), one for each DMX defining them, while only the first (or last?) set will affect the model, with it affecting all different DMX meshes.


Originally posted by 3gos:
- $bodygroup "Upper" {
studio "coat.dmx"
studio "shirt.dmx"
blank
} -
In this example, "coat.dmx" should have shape keys and flex controller definitions, while "shirt.dmx" should have shape keys without flex definitions.

(You could also swap it around if you'd like; The important thing is that the flex controllers are only defined in one of the files, despite the shape keys being in both of them.)


To avoid having flex definitions in a DMX export, use the "Source Engine Exportables" panel (in Blender) to give the "shirt" object "advanced" flexes instead of "simple" ones, then use this as the flex definition block:
<!-- dmx encoding keyvalues2 1 format model 1 --> "DmElement" { "id" "elementid" "12345678-1234-1234-1234-012345678910" "name" "string" "root" "combinationOperator" "DmeCombinationOperator" { "id" "elementid" "01234567-8910-1112-1314-151617181920" "name" "string" "combinationOperator" "controls" "element_array" [ ] "controlValues" "vector3_array" [ ] "controlValuesLagged" "vector3_array" [ ] "usesLaggedValues" "bool" "0" "dominators" "element_array" [ ] "targets" "element_array" [ ] } }
(You can copy that into a text editor, save it as a TXT file, and then browse to that file as the "[Flex] Controller Source" near the simple/advanced flex type toggle.)

Admittedly, I haven't tested that specific flex definition block, but it should probably work, I hope.


After that, re-export the "shirt" object as a DMX file. If everything goes as planned, Blender should warn you that there are shape keys without flex controller definitions. Then you should just have to re-compile the model, and then it should work afterwards.

Hey, sorry to be reviving this old thread, but when you say “The important thing is that the flex controllers are only defined in one of the files, despite the shape keys being in both of them”, does this apply when there are more than two .dmx files in a bodygroup?

In my case, I’m making an updated smash bros sonic model port, and I made flexes for the mouth, so I have three different mouth .dmx models with the same flexes (one for the mouth on the left, right, and a “blank” mouth. Some of the flexes also control the shape of the muzzle). In this case, would defining the flex controllers for just one of them work, or would I need to define the flex controllers for the other two .dmx models so that the flexes work in SFM?

Also, just to make sure I understand what this would do, this would make it so that the one flex slider would affect all the models that have that same flex, or would this make an additional slider with the same flex name?

This isn’t important to the question, but if anyone is wondering, I’m trying to keep all the mouth models on one whole model rather than making a whole separate model for the left, right, and blank mouth like other sonic models on the workshop do because I already have separate whole models for each of his alts found in smash and I don't want to triple that if I can avoid it.
Zappy May 22, 2024 @ 11:51pm 
Originally posted by Muigio44:
- Hey, sorry to be reviving this old thread, but when you say “The important thing is that the flex controllers are only defined in one of the files, despite the shape keys being in both of them”, does this apply when there are more than two .dmx files in a bodygroup? -
Yes. Each flex controller should only be defined in one DMX file, regardless of how many files use that flex.

Originally posted by Muigio44:
- In my case, I’m making an updated smash bros sonic model port, and I made flexes for the mouth, so I have three different mouth .dmx models with the same flexes -
Let's pretend that the left and right mouth objects have flexes called "Smile", "Frown", and "Open Mouth", and that the blank-mouth object has flexes called "Smile" and "Gasp".
You should define "Smile", "Frown", and "Open Mouth" flex controllers in the left mouth DMX, and "Gasp" (but not "Smile"!) in the blank-mouth DMX, and no flex controllers in the right mouth DMX.

(If you'd like, you can probably(?) also define all of "Smile", "Frown", "Open Mouth", and "Gasp" in the left mouth DMX, even though "Gasp" isn't on the left mouth object, and not define any flex controllers in the right mouth nor blank-mouth DMXs.)
Muigio44 May 23, 2024 @ 6:58am 
Alright, thanks for clearing that up for me. I'll give this a try.
< >
Showing 1-8 of 8 comments
Per page: 1530 50

Date Posted: Mar 25, 2020 @ 11:46am
Posts: 8