Jump to content

[WIP] BodyMorph


Expired6978

Recommended Posts

So I figured I'd play around with my NetImmerse Override mod and see what I could do with body sliding in-game. Turns out it's really not that difficult and it's essentially just vertex diffs. Very similar to how FaceGen's TRI files work. 

 

To test I used an existing hook and come up with some code to read a test diff file.

 

Here's what happens:

Game loads the mesh into memory

Runs into my hooked code passing the Actor, the root NiObject, the Armor, and the ArmorAddon

Checks the Actor's gender, check acquire the Addon's mesh path passes it to the vertex diff loading function

Strips replaces the "nif" with "tri" and builds a path "meshes\\ADDONPATH.tri"

Loads the binary file into memory

Reads the vertex count

Loops all verts in the file (index, X, Y, Z)

Adds the vert diff to the specific TriShapeData

Destroys file and frees mem

 

The way weight works is it essentially just re-applies the new armor again so this same hook is called and it reapplies the vertex changes.

 

I borrowed one of the BodySlide files from a UNP setting "PregnancyBelly.bsd" for this proof of concept. I intend to change the formatting such that you could essentially create a morph file for the body much like the face.

 

Here's proof of concept, this belly was made in-game without pregeneration by BodySlide.

http://i.imgur.com/uHnfIC7.jpg

 

I intend to have a special format so that you can outline all vertex deltas for all TriShapes on the mesh.

 

The BodySlide vertex delta files (.bsd) are like this:

<int vertex count> 
[
<int vertex index 1><float diff x, diff y, diffz> 
<int vertex index 2><float diff x, diff y, diffz>
...
]
 
If I create a framework I'll have it very similar to the TRI files:
<int Morph Count>
[
<char size>
<char Morph Name>
<int TriShape Count>
---- [
---- <char size>
---- <char TriShape Name>
---- <int Vertex Count>
--------- [
--------- <int Vertex Index><float diff x, diff y, diff z>
--------- ]
---- ]
]
 
This way you can outline what morphs do what in one single file. This would be equivalent to having a whole bunch of BSD files for each slider type for BodySlide.
 
I will probably add an NiExtraData to the root of the body mesh so that you can more strictly enforce the loading of this vertex diff file. I.E. so you can't install a Body mesh that supports it, then install a body mesh that doesn't support it as you would otherwise end up loading the diff file onto a body that shouldn't have it.
 
So, what you would do to get this to work is:
Add an NiStringExtraData to the root NiNode of the body/armor named "TRI" with String Data pointing to the vertex diff file like "meshes\actors\character\character assets\femalebody_1.tri" (I may force this to be relative to "meshes\")
Make your BSD vertex delta files as you would normally
Run a tool that will merge your BSD files into a morph file.
 
I haven't designed the tool yet, but you would have the option to create morphs, these morphs would hold an independent BSD for each NiTriShape of the model. Ideally you would just create a bunch of morphs like
 
Breasts
Butt
Pregnancy Belly
 
Then you'd specify the NiTriShape to Act on, then locate the BSD file then add it.
 
I haven't figured out how I'd transfer the 'master list' of morphs to the RaceMenu since the morphs are specific to the Body/Armor in this case. Perhaps I'll just add Papyrus functions to script the changes (Yes that means you could get pregnant in stages by script, but only if the armor/body you're wearing supports it). Then have RaceMenu Slider plugins to add the options. So if a modder creates a new morph, they can add their slider to the RaceMenu.
 
 
While I can provide the framework for making this possible, I cannot create all the vertex delta files for every armor and body. I worked off the vertex delta files from the current version of BodySlide (Plus some presets and morphs I found). So essentially if your armor has ShapeData for BodySlide there's a very good chance you could make it work with this.
Link to comment

I like where this is going. And the data would be retain-able for save files? (Well, assuming it's integrated into the RaceMenu, I suppose that it would be.)

 

Best of luck on this and keep up the great work!

Much like CharGen I'd save it to the co-save.

Link to comment

Mockup UI for the merging tool:

http://i.imgur.com/rfV6S6v.png

 

Right click on the Morphs to Add/Remove a TriShape.

Right click anywhere else to Add/Remove a Morph.

Right click TriShape to browse for vertex delta file or Drag & Drop BSD vertex delta file onto the TriShape.

Double click to edit names.

 

Morph data will be saved to co-save via the NiOverride plugin.

Morph data will be editable via script, E.G. NiOverride.SetBodyMorph(actor, "Blessed Breast", delta)

Link to comment

Finished the vertex merging program, implemented processing it in the plugin. All that's left is serialize the morph % offsets, restore them when loading a game and then provide functions to edit the morph values.

 

Right now I've just merged a whole bunch of UNP morph vertex data into a single morph file: http://i.imgur.com/9nvmO5J.png

The plugin will read the first NiStringExtraData named TRI on the target body (I put it on the TriShape of both the female_0 and female_1) you need it on both the _0 and _1 body.

Then it'll load the merged file, read the morph count, read the morph names, then read each TriShape for each morph. Right now it'll just apply 100% to all the morphs but it won't be difficult to scale them based on the stored values for the actor.

 

I've only tested for UNP, but theoretically if you have the vertex delta files you can make it work with any body since the morph file is dependent on the armor's target morph via the ExtraData.

Link to comment

Finished the vertex merging program, implemented processing it in the plugin. All that's left is serialize the morph % offsets, restore them when loading a game and then provide functions to edit the morph values.

 

Right now I've just merged a whole bunch of UNP morph vertex data into a single morph file: http://i.imgur.com/9nvmO5J.png

The plugin will read the first NiStringExtraData named TRI on the target body (I put it on the TriShape of both the female_0 and female_1) you need it on both the _0 and _1 body.

Then it'll load the merged file, read the morph count, read the morph names, then read each TriShape for each morph. Right now it'll just apply 100% to all the morphs but it won't be difficult to scale them based on the stored values for the actor.

 

I've only tested for UNP, but theoretically if you have the vertex delta files you can make it work with any body since the morph file is dependent on the armor's target morph via the ExtraData.

 

This is amazing work Expired! 

 

I was wondering if this also meant that the facial morphs for phonemes (and beyond) could also be made to work through your in-game bodyslide even on patch 1.9? 

Link to comment

This is amazing work Expired! 

 

 

 

I was wondering if this also meant that the facial morphs for phonemes (and beyond) could also be made to work through your in-game bodyslide even on patch 1.9? 

 

I wouldn't want to do that low level of stuff to the face as I am to the body. You could probably force FaceGen to morph the phonemes without this, you can morph pretty much any of the named morphs within a TRI. I restricted the ones in CharGen to the ones you create yourself, but yeah I guess you could morph the phonemes if you really wanted. Facial animations probably do some interpolation from 0.0 to 1.0, you could probably force it straight to the full value immediately, I wouldn't want to mess around with interpolating it myself though. The values are also all relative, so subsequent calls would probably result in major clipping if you didn't know what you were doing.

 

I'm essentially making my own form of FaceGen, but for the body. It appears to be turning out fine, though, much like weight, you cannot call the update function while mounted.

 

I've got it so you can call script driven changes:

NiOverride.SetMorphValue(player, "PregnancyBelly", 1.0)

player.UpdateWeight(0.0) ; Using this update function for now

Link to comment

Here's the first test version: http://www.mediafire.com/download/uu58rdb44x2mmdg/BodyMorph.7z

 

Package includes:

Data/Scripts/NiOverride.pex

Data/Scripts/RaceMenu.pex

Data/Scripts/RaceMenuBase.pex

Data/Scripts/RaceMenuLoad.pex

Data/Scripts/RaceMenuOverlays.pex

Data/Scripts/RaceMenuPlugin.pex

Data/Scripts/Source/NiOverride.psc

Data/Scripts/Source/RaceMenu.psc

Data/Scripts/Source/RaceMenuBase.psc

Data/Scripts/Source/RaceMenuLoad.psc

Data/Scripts/Source/RaceMenuOverlays.psc

Data/Scripts/Source/RaceMenuPlugin.psc

Data/RaceMenu.bsa

Data/RaceMenu.esp

Data/RaceMenuPlugin.esp (Contains the test morphs)

Data/SKSE/Plugins/nioverride.dll

Data/SKSE/Plugins/nioverride.ini

Data/meshes/actors/character/character assets/femalebody_0.nif (Note that this is UNP TBBP)

Data/meshes/actors/character/character assets/femalebody_1.nif (Note that this is UNP TBBP)

Data/meshes/actors/character/character assets/femalebody.tri (Should work with any UNP)

MorphMerge/BodyMorph.exe (Merges bsd vertex delta files into mapped morph and trishape files, or TRI files for the body)

MorphMerge/msvcr100.dll

MorphMerge/QtCore4.dll

MorphMerge/QtGui4.dll

 

Please note that I've only included the bodies because they have NiStringExtraData on their TriShapes for NiOverride plugin to locate the appropriate morph file. If you place those on a regular UNP body the premade morphs should also work.

 

BodyMorph is used for merging vertex delta files you would create for BodySlide into a mapped file for morph lookup. It should be able to load femalebody.tri as an example. I included the latest RaceMenu version because I was too lazy to create a plugin, so I stuck the new sliders in the existing plugin.

 

Known issues:

-Slider values don't save (This is intentional, just a test)

-Reloading game results in loss of morphs visibly (This isn't finished yet, I have to somehow apply the changes without invoking UpdateWeight)

-Deformation (This is probably just a result of using UNP to UNPB morphs on an already morphed body, the morphs are actually meant for the base body)

Link to comment

I was amazed, after I saw this project and the PoC pictures, but sadly, it crashes my game every time :/

 

I have the XPMS Skeleton, used RaceMenu before to alter my character and use UNP Blessed Body - UNPB Redux Project.

 

I first thought, that maybe another mod, which I also installed at the same time, caused it, but then i restored everything back till the point, before I installed BodyMorph and it worked again. Installed BodyMorph and crashed again, both on New Game on loading my current save.

 

EDIT:

 

I don't know, if I have to do any additional steps, besides putting the esp, esm, bsa, scripts, skse plugin and mesh files in there. Maybe I forgot an additional step?

Link to comment

Well, narrowing down the problem would help the most. First try installing it without the included meshes, if it still crashes, try using the previous RaceMenu but replace the newer version of NiOverride.dll. If that still crashes try with only the meshes. There are 3 possible sources of error: The meshes, the plugin, or RaceMenu, I'm strongly convinced it would be the first but the second and last are certainly still possible.

Link to comment

I tried it with copying all files, except the meshes. Still crashes. I will try the other methods as well.

 

EDIT: Updating post while testing.

 

---

 

First try:

 

Copy all files: Crashes

 

---

 

Second try:

 

Copy meshes\actors\character\character assets\femalebody.tri, all Scripts & SKSE Plugin: Crashes

 

---

 

Third try:

 

Copy Plugins, + tri + Scripts: Works

 

---

 

Conclusion: Seems like the NiOverride.dll is causing issues.

 

I have the newest SKSE (I re-installed and modded Skyrim 2 days ago) and Dragon Script (for some other stuff). I would not know, what the NiOverride.dll has problems with, since the original one from the latest RaceMenu Mod works.

 

 

 

Link to comment

Edited: Sorry Maxunit for the nonsense I've written here before. Simply red too fast.

 

 

Expired6978, I can see the sliders ingame.

But while changing em won't do anything. The whole body stays the same.

Tried it on a CustomRace, don't think that I've done anything wrong and gonna test it again tomorrow.

Link to comment

Nipple length and nipple height? Downloading now!

 

On more serious note, does it mean that as long as armors are compatible (ie have "TRI") then it can be morphed by scripts as much as I want? That smells like some kind of revolution...

Link to comment

Edited: Sorry Maxunit for the nonsense I've written here before. Simply red too fast.

 

 

Expired6978, I can see the sliders ingame.

But while changing em won't do anything. The whole body stays the same.

Tried it on a CustomRace, don't think that I've done anything wrong and gonna test it again tomorrow.

It'll only work if the body/armor you have supports it, custom races are unlikely to have this if they have custom bodies. This is why I included a UNP variant that actually has the morph attached.

 

Nipple length and nipple height? Downloading now!

 

On more serious note, does it mean that as long as armors are compatible (ie have "TRI") then it can be morphed by scripts as much as I want? That smells like some kind of revolution...

Yes, this is exactly what it means, as long as the armor supports it will work. Currently the only armor that supports it is the naked UNPB-TBBP body that I shipped with it.

 

I did a bit more testing...I can copy everything from BodyMorph, except the Nioverride.dll and no crashes.

 

Whenever I copy Nioverride.dll, it crashes.

 

Just as a headsup, that I tested (pretty much) everything, to figure out, what is causing the crashes on my end.

Okay, well that's a problem since most of it is handled via the plugin, the NiOverride from the current RaceMenu (includes body tattoos) works though? This means that you're crashing because of something recent that I've changed. Also a problem since I don't crash so it's very difficult to determine why you crash.

 

Try this: http://www.mediafire.com/download/ph191fxr5z262hf/nioverride.7z

I added a few more safeties in places where null pointers could potentially occur and also threaded the morph update.

Link to comment

one question, can this be applied to body parts aswell simultaneously along with the body? like hands, feet, etc? lets say I want to add a morph target that changes the vertex loop edge on the wrists/ankles/neck. Is it possible to have it seamless, or will it create a mesh gap?

 

EDIT:

To make it a little bit more clear: I do understand that each nif has to have the ExtraData linking to its own TRI, what I'm asking is really if the same slider is able to control the morph targets in all body parts.

Link to comment

Thank you for the edited file, I will try it right away. I also enabled Papyrus logging, since I forgot to do that before.

 

And yes, the original nioverride.dll from RaceMenu works flawlessly on my end.

 

EDIT:

 

Interesting...now it loads, but the new sliders have no effect on the mesh. BlessedBreasts, for example, does nothing. Or the nipple lenght etc. Meshes and scripts are in place tho, same for plugins.

Link to comment

one question, can this be applied to body parts aswell simultaneously along with the body? like hands, feet, etc? lets say I want to add a morph target that changes the vertex loop edge on the wrists/ankles/neck. Is it possible to have it seamless, or will it create a mesh gap?

 

EDIT:

To make it a little bit more clear: I do understand that each nif has to have the ExtraData linking to its own TRI, what I'm asking is really if the same slider is able to control the morph targets in all body parts.

Yes, it can work on any mesh as long as the NiStringExtraData links to a valid TRI. Penis length? Sure. Pauldron length? Sure. You can create your own morphs and activate them via script.

 

I can only guarantee it for Armor type nodes though, I cannot say the same for weapons or hair (If you were thinking of growing hair). This is due to the nature of the hook that's modifying the armors as they are loaded.

 

Hair length could actually be done using CharGen, only problem is that I'm fairly certain that all of the Apachii hairs actually use dummy TRI files (Or at least don't really do much), to make new morphs of this nature you'd need to add the morphs to the face but make no change to the face, then also add it to the hair and it would propagate when changed.

 

 

Thank you for the edited file, I will try it right away. I also enabled Papyrus logging, since I forgot to do that before.

 

And yes, the original nioverride.dll from RaceMenu works flawlessly on my end.

 

EDIT:

 

Interesting...now it loads, but the new sliders have no effect on the mesh. BlessedBreasts, for example, does nothing. Or the nipple lenght etc.

Are you naked are using the included mesh? It will only take effect for that specific mesh.

Link to comment

Thank you for the edited file, I will try it right away. I also enabled Papyrus logging, since I forgot to do that before.

 

And yes, the original nioverride.dll from RaceMenu works flawlessly on my end.

 

EDIT:

 

Interesting...now it loads, but the new sliders have no effect on the mesh. BlessedBreasts, for example, does nothing. Or the nipple lenght etc.

Are you naked are using the included mesh? It will only take effect for that specific mesh.

 

 

Yep, I copied the mesh files, tri, scripts, esp's and bsa.

Link to comment

I checked the last papyrus log and I found this:

 

 

stack:
[ (000C6963)].FXSetBlendVariableScript.SetAnimationVariableFloat() - "<native>" Line ?
[ (000C6963)].FXSetBlendVariableScript.OnLoad() - "FXSetBlendVariableScript.psc" Line 38
[07/10/2013 - 02:55:10AM] error: Native static function ClearMorphValue does not match existing signature on linked type NiOverride. Function will not be bound.
[07/10/2013 - 02:55:57AM] Error:  (000C6984): cannot find variable named fToggleBlend.
Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use