Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1036

Creating new morph channels with script

$
0
0

Hi,

I've been playing around on an idea of creating new morph channels on the fly, much like Poser's PMD files do. Sadly the PMD plugin AFAIK died off as of DS 4. I think I'll give it a shot using a script.

As a test, I setup/modify Victoria 4 cr2 file to add a channel to accept one of NGM morph, and compare it to a plain Victoria 4 with the same channel created by script.

As far as my test go, it seems that when loaded to DS4.9, only the root object (DzSkeleton) has a DzObject. All other bodyparts doesn't have DzObject. All the morphs/magnets loaded (like Morph++) has a corresponding DzModifier contained in the root's DzObject. All of them has the name/label with "MorphChannelName_BodyPartName" format, i.e. "FBMVoluptuous_chest". In closer inspection, the DzModifiers will have 1 DzFloatProperty with the same name of the DzMorph, and path with "/Morphs/Imported/[BodyPartName]" format, i.e. "/Morphs/Imported/chest". Setting several of the default morphs property hidden flag to false will cause those morphs listed in V4's BODY part in the "Morphs/Imported" group. With the editor's parameters tab in edit mode, such morphs will have an "M" icon in front of it.

image

All those familiar morphs in the "Morphs | Shapes" group have a corresponding DzFloatProperty in their respected DzNode. However, with the parameters tab in edit mode those morphs will have a "P" icon in front of it.

image

Curiously, if I select a bodypart other than root, the icon in front of the morphs is "A" instead of "P".

image

Upon opening the parameter settings, I found that the "P" and "A" will refer to the "M" in the root. With that info, I wrote this script

// DAZ Studio version 4.9.1.30 filetype DAZ Script

var oRootNode  = Scene.getSelectedNode( 0 ).getSkeleton();
var oObject    = oRootNode.getObject();

// Create new morph
var oMorph = new DzMorph;
oMorph.setName( "NGM_0_chest" );
oMorph.setLabel( "NGM_0_chest" );

// Create new property to replace the one already exist
var oMorphProp = new DzFloatProperty( "NGM_0_chest", true, false);
oMorphProp.setLabel( "NGM_0_chest" );
oMorphProp.setPath( "/Morphs/Imported/chest" );

oMorph.insertProperty( 0, oMorphProp);

// Add modifier to root
oObject.addModifier( oMorph );

// Create new property for the root node
var oNewProp = new DzFloatProperty( "NGM_0", true, false);
oNewProp.setPath( "/Morphs | Shapes/NGM_V4" );

oObject.addProperty( oNewProp );

Running the script to a plain V4 will a new "M" parameter in "/Morphs/Imported/chest" as well as a "P" parameter in "Morphs | Shapes/NGM_V4". However, after injecting the morph data from the PZ2 file, the sliders of those 2 new parameters / morphs don't have effect. In contrast, if I use the cr2 where the corresponding channel already edited in, sliding "M" parameter do have effect / the morph works.

How can I fix this problem?

THX


Viewing all articles
Browse latest Browse all 1036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>