Did I miss something?

Here are some codes I used to make morphs,It' work's fine,but if I save scene and reopen it,the morphs added by code are not same as before,Did I miss something?

 

//tshape is a obj read from file (using DzImporter)
DzVertexMesh *vvmesh = tshape->getModifiableAssemblyGeom(false);
int vlength =vvmesh->getNumVertices();

//node is the node you want add morphs;
DzObject *obj = node->getObject();
DzVertexMesh *gemo = obj->getCachedGeom();

DzQuat rotSubject = node->getWSRot();
DzQuat inversedRotSubject = rotSubject.inverse();

//adding deltas
DzMorphDeltas *morphDeltas =new DzMorphDeltas();
for(int i=0;i<vlength;i++)
{
    float dx= vvmesh->getVertex(i).m_x-gemo->getVertex(i).m_x;
    float dy= vvmesh->getVertex(i).m_y-gemo->getVertex(i).m_y;
    float dz= vvmesh->getVertex(i).m_z-gemo->getVertex(i).m_z;

    if(  abs(dx) >= 0.01 || abs(dy) >= 0.01 || abs(dz) >= 0.01 )
    {
        DzVec3 pt = DzVec3(dx,dy,dz);
        pt =  inversedRotSubject.multVec( pt );
        morphDeltas->addDelta( i,pt);
        
    }
}


int findex = dzScene->getFrame();
QString morphName="f"+QString::number(findex);


DzMorph * morpher = (DzMorph *)obj->findModifier(morphName);

    if(!morpher)
    {
        morpher = new  DzMorph( morphDeltas );
        morpher->setLabel( morphName );
        morpher->setName( morphName );
        morpher->setStorablePaths("Morphs/Morph Loader/"+morphName);
        obj->addModifier( morpher );
    }
    else
    {
        morpher->setDeltas( morphDeltas );
        morpher->getValueChannel()->setHidden( false );
    }

Sign In or Register to comment.