Importing morphs

SMokeyDemonSMokeyDemon Posts: 0


Just wondering if anyone has had any luck with importing morphs using the sdk...

Ive managed to create a blank morph so far by creating a DzMorph and adding it to the DzObject, Im assuming adding the deltas is the next step. But its not clear how the deltas are generated, is there a way to load in obj's maybe through importing them to some geometry, Or do we need to write code to generate the deltas.

If anyones got any ideas, would be great. Otherwise ill report back if I work it out...


So after a bit of searching around it looks like its necessary to write custom code to load morphs (and objs), the process thats working so far:

- loading the obj: there doesnt seem to be a way of loading a obj using the sdk without it being imported into the scene. So writing custom code here seems to be the only way.

- get a reference to the DzVertexMesh using DzObject->getCachedGeom()

- create a DzMorph set the name and add it to the modifiers to your DzObject

- get the reference to the deltas DzMorph->getDeltas();

- compare your imported obj and the DzVertexMesh and if the point is different, add a delta to the deltas for the difference between each vertex.

After all that it seems to work fine... (well not fully tested yet but a morph shows up and looks like its working)

But.. problem lies when you want to import a morph as a auto follow, i.e a morph with the name "FBMBasicMale".
You follow normal procedure and add the deltas to your morph, but then when its all done and your process ends, Daz seems to overwrite your morph with its own default morph...

I've tried calling various functions after adding the morph... invalidateCache, finalize, forceCacheUpdate, invalidateAllCachedGeom
to try maybe get the Daz default morph applied before I apply my deltas but no success yet.

A simple test was to try remove the default morph of a t-shirt after setting the base morph on genesis...

DzSkeleton * skelly = (DzSkeleton *)dzScene->findNode("TShirt for Genesis");
DzObject * obj = skelly->getObject();
DzMorph * morph = (DzMorph *)obj->findModifier("FBMBasicMale");
if (morph)
        print "morph found before morph set"
        print "morph not found before morph set"

SetMorph(QString("FBMBasicMale"), 1); //this function has stuff in it to set that morph on genesis...

morph = (DzMorph *)obj->findModifier("FBMBasicMale");
if (morph)
        print "morph found after morph set"
        print "morph not found after morph set"


morph = (DzMorph *)obj->findModifier("FBMBasicMale");
if (morph)
        print "morph found after removing"
        print "morph not found after removing"

The first time its run output is:

morph not found before morph set
morph not found after morph set
morph not found after removing

in the viewport you get the default morph on the shirt for FBMBasicMale, the process does not find a morph applied to the object after the morph is set on genesis.

The second time this is run the output is:

morph found before morph set
morph found after set
morph not found after removing

so it seems by some voodoo magic a DzMorph is added to the t-shirt after the entire block of code was run the first time. Im assuming that this added morph might be whats over-writing my imported morph. Ill keep poking around see if i can find out the cause...

but if anyone has any hints they would be very helpful :)


Post edited by SMokeyDemon on
Sign In or Register to comment.