Attaching an ERCFreeze to an Existing Morph [Solved]

MorgalothMorgaloth Posts: 23

I've been working on a script to automatically align the bones of Antenna to the head of whatever model they are attached to, then ERC freeze them, and Save the morph.

I've modified two of the Sample Scripts:

http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/erc_freeze/start

http://docs.daz3d.com/doku.php/artzone/wiki/user/rbtwhiz/technotes/daz_script/node_properties/start

I use the Node Properties script to find and isolate and FHM head morphs, then pass them onto the ERCFreeze function.

			for( var i = 0; i < aPROPERTIES.length; i++ ){				oProperty = aPROPERTIES[ i ];				oOwner = oProperty.getOwner();												if( oOwner.className() == "DzMorph" && (oProperty.getValue() != 0) ){					sMorphName = oOwner.getName();					sMorphName = sMorphName.toUpperCase();										if ( (sMorphName.slice(0, 3)) == "FHM") {					      oHeadMorph[nHeadMorphNum] = oProperty;==================================================================================================			// Define a controller; 			oControllerNode = (oTrgtNode);	 			// Create and setup a controller property			oControllerProperty = ( oHeadMorph[i] ); 			oControllerNode.addProperty( oControllerProperty );

While this technically works, it changes the NAME of the Controlling Property to VALUE, which is the actual name of the property. The real name is found by using oProperty.getOwner(). I don't want to create a NEW property, because then I'll have duplicate properties.

Using the oHeadMorph[i].getOwner() throws a null error, so I assume the FHM property is not compatible as an addProperty, while the child IS, but it's name is VALUE.

I still don't have an innate grasp of classes yet, so hard to wrap my head around. =/

Does anyone know how to attach an ERC Freeze to an Existing Controller? or how to REMOVE the current Morph controller, so I can just make a new one?

Post edited by Morgaloth on

Comments

  • Well, I've learned a little in the last week, first, that all of what I said above was also concluded in this post.

    https://www.daz3d.com/forums/discussion/386601/controlling-a-morph-slider-from-a-parameter-slider-what-object-type-is-it.

    But try as I might, I can't figure out how to ADD the ERCFreeze to the original morph without it's name being changed to Value.

    I did manage to ADD a second morph with the same Name, and it works, but it's tied to the original morph. If I remove the original morph the geometry gets throw off.

    Also, while looking at the two properies in the Property Hierarchy pane, i see the original morph has an M at the front, and the new created property has a P. Both are surronded by the little dashed boxes. I assume thats Morph or Modifier, and Parameter or Property. Does anyone know what those are for sure?

    If Richard or Rob are still around, could really use some help! =) (I don't know how to Tag someone, if you still can)

     

  • Doesn't the slider label belong to the property rather than the channel -
    sMorphName = oProperty.getLabel();

    or
    sMorphName = oProperty.getName();

  • Thanks for responding Richard. =)  I'm not sure what you mean by channel.

    oProperty.getName() will return "Value", but after just checking, .getLabel() will  return the Label of the modifier/morph but thats not helpful since the name and label can be different.

    The Antenna are a Geograft attached to a G8F. The antenna will always be oTrgtNode. Whatever G8F figure I attach it too will generate a Morph/Modifier on oTrgtNode, like FHMTika8, This Generated Morph contains the Deltas for the antenna to fit the new head, but of course it doesn't have the Bone Deltas.

    I have isolated that FHM morph, which becomes oProperty, by looking at .oProperty.getOwner(), which holds the true name of the property. But when I use that Property as oControllerProperty for the ERCFreeze, it changes the name of the modifier/morph from FHMTika8 to Value.

    I can make a completelty new Morph, with all the right names, and the ERCFreeze data, but it is missing the Deltas from the Generated Morph, so the geometry distorts.

     

  • ok, so after saving the original Generated Morph and looking at at the morph file, i know what you mean by channel.

    I've done a lot of experimenting with different ways to appoach this.

    1) Use the generated morph as the ControllerProperty for the ERCFreeze. This results in the morph owner being changed from FHMTika8 to Antenna, and the Class being changed from DzMorph to DzFigure. Also, it's no longer able to be saved as a Morph.

    2) Create a new DzFloatProperty to use as the ControllerProperty. This works somewhat. But it's class is still DzFigure, and it's owner is Antenna. but it's missing the Morph Deltas. Also, when looking at the morph.duff the parent is listed as .../AntennaStalks_2282.dsf#AntennaStalks_2282", while the generated morph is .../AntennaStalks_2282.dsf#AntennaStalks", and the Name in Channel is FHMTika8 instead of Value. I don't know if this makes any difference.

    So, basically the problem now is that anything done with the ErcFreeze creates a morph with the DzFigure class rather than the DzMorph class. Of course, when you chose a property through the Property Hierarchy pane, it adds the freeze to the Morph, without changing it to dzFigure. Hopefully someone can help me figure this out.

  • The links you give are not, I think, to the current samples. try http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/properties/node_properties/start for access to node proeprties.

    On a matter of presentation, oHeadMorph is an array (you are accessing members by index) so it ought to be aHeadMorph. It's also harder to follow your code snippet as you have mismatched braces.

    DzMorph inherits DzModifier, which inherits DzElement, and so it is therefore possible for any number of (uniquely named) properties to exist on it - although this typically does not occur for various reasons. Any number of (uniquely named) morphs (mesh modifiers) can exist on a DzObject. A DzMorph guarantees that it will provide a property to control the amplitude that its deltas are applied. The name of this property is always "Value" - while it is technically possible for something to change the name of the property, actually doing so will cause issues with the way the property is referenced in assets (scenes, presets, etc).

  • you are correct, the link i gave is a stripped down version of the official version that you linked. Sorry for the ugly code snippet that i presented, it's quite long. Thanks for the correction, I forgot about using a for arrays.

    In essence, I'm trying to duplicate the process of clicking on FHMTika8Head in the property Hierarchy pane, and ERC freezing on it. Doing it manually results in the ERC information being added to the DzMorph (FHMTika8Head). I've acquired the Property that is attached to FHMTika8Head with no problem, but using that as the ControllerProperty erases the morph Deltas, and converts the class from DzMorph to DzFigure, and the owner from FHMTika8Head to Antenna (which is the ControlNode)

    ideally, the ContollerNode should be the FHMTika8Head morph, but it seems like it has to be a Node (Antenna) that the morph is attached too. Might you have suggextions as to what I can be using for ContollerNode and ControllerProperty? Might using DzERCLink instead of ERCFreeze be a better solution?

     

  • I'm still not quite sure what you are doing - are you trying to link to the transitory projected morph from AutoFollow, rather than to a permanent morph you've created yourself (possibly by exporting the model with the Tika 8 morph projected in), then set up the ERC to control the custom bones as normal?

  • If it's possible, I'm trying to automate the process of linking the ERCFreeze to the autogenerated Transitory projected morph, just like if you were to have right clicked on it in the Property Hierarchy Pane and selected ERCFreeze. Then I'll figure out how to save that morph (making it permanent), so that it will load the next time the antennas are added to that figure. I've done this manually before, to make FHM's for the Antenna.

    With every method i've tried so far it changes the Morph Class from DzMorph to DzFigure.

     

  • MorgalothMorgaloth Posts: 23
    edited October 2020

    OK!! Finally got it!

    I think using ErcFreeze will always create a new property, or overwrite that precious "Value" property erasing the Morph Deltas if you use the Generated Morphs Property as the ControllerProperty.

    Turns out I was barking up the wrong tree. The solution was to use DzERCLink. I cycled through all the nodes (bones) of the Antenna, and created an ErcLink for each X,Y,Z Origin and End Point Delta, and BOOM!

    This link was a great help: https://www.daz3d.com/forums/discussion/342486/creating-a-simple-dzerclink-between-two-new-parameters

    Now to figure out how to Save Morph File. =)

    Post edited by Morgaloth on
  • ERC Freeze is creating the links. If you want to have chnages (in this case to joint centres) for a morph you need the morph (in this case you need to create a morph for Tika 8 Head with exactly the same name as the base figure's morph), then (with the rigging of the antennae memorised) you adjust their centres using either Adjust Rigging to Shape or manually, then with the morph set and the adjustments in place you do an ERC Freeze with the morph as the controller - ERC Freeze thens ets up the links so that when the morph is set the joints are adjusted.

    ERC Freeze is a process that adds links, it isn't a thing you add. In order for a morph on a fitted figure to follow a morph on the base figure it has to have exactly the same name. In order to use ERC Freeze you need to have the base rigging memorised as the freeze process is looking at the difference between the memorised state of the centres and their state when the command is run (so in order to have a script run the ERC Freeze it would already need to have all the offsets applied).

  • algovincianalgovincian Posts: 2,613

    ERC Freeze is creating the links. If you want to have chnages (in this case to joint centres) for a morph you need the morph (in this case you need to create a morph for Tika 8 Head with exactly the same name as the base figure's morph), then (with the rigging of the antennae memorised) you adjust their centres using either Adjust Rigging to Shape or manually, then with the morph set and the adjustments in place you do an ERC Freeze with the morph as the controller - ERC Freeze thens ets up the links so that when the morph is set the joints are adjusted.

    ERC Freeze is a process that adds links, it isn't a thing you add. In order for a morph on a fitted figure to follow a morph on the base figure it has to have exactly the same name. In order to use ERC Freeze you need to have the base rigging memorised as the freeze process is looking at the difference between the memorised state of the centres and their state when the command is run (so in order to have a script run the ERC Freeze it would already need to have all the offsets applied).

    This gives a nice conceptual picture - thanks for taking the time to post this. It's exactly the kind of thing that would be oh-so-helpful to have in a manual ;)

    Cheers!

    - Greg

  • ERC Freeze is creating the links. If you want to have chnages (in this case to joint centres) for a morph you need the morph (in this case you need to create a morph for Tika 8 Head with exactly the same name as the base figure's morph), then (with the rigging of the antennae memorised) you adjust their centres using either Adjust Rigging to Shape or manually, then with the morph set and the adjustments in place you do an ERC Freeze with the morph as the controller - ERC Freeze thens ets up the links so that when the morph is set the joints are adjusted.

    ERC Freeze is a process that adds links, it isn't a thing you add. In order for a morph on a fitted figure to follow a morph on the base figure it has to have exactly the same name. In order to use ERC Freeze you need to have the base rigging memorised as the freeze process is looking at the difference between the memorised state of the centres and their state when the command is run (so in order to have a script run the ERC Freeze it would already need to have all the offsets applied).

    Yes, the Offsets are done through Align Rigging to Shape. But, ERC Freeze will always create an extra property, not a morph. Skipping through and doing it's job for it performs exactly as I was wanting. Adding the Delta Links to the generated morph, just like would happen if you'd done it maually.

  • Morgaloth said:

    ERC Freeze is creating the links. If you want to have chnages (in this case to joint centres) for a morph you need the morph (in this case you need to create a morph for Tika 8 Head with exactly the same name as the base figure's morph), then (with the rigging of the antennae memorised) you adjust their centres using either Adjust Rigging to Shape or manually, then with the morph set and the adjustments in place you do an ERC Freeze with the morph as the controller - ERC Freeze thens ets up the links so that when the morph is set the joints are adjusted.

    ERC Freeze is a process that adds links, it isn't a thing you add. In order for a morph on a fitted figure to follow a morph on the base figure it has to have exactly the same name. In order to use ERC Freeze you need to have the base rigging memorised as the freeze process is looking at the difference between the memorised state of the centres and their state when the command is run (so in order to have a script run the ERC Freeze it would already need to have all the offsets applied).

    Yes, the Offsets are done through Align Rigging to Shape. But, ERC Freeze will always create an extra property, not a morph. Skipping through and doing it's job for it performs exactly as I was wanting. Adding the Delta Links to the generated morph, just like would happen if you'd done it maually.

    No, it won't - if you right-click on a property then that will be used as the controller, at least if it's a permanent property, it will not create a new property. There is a Create New option in the dialogue, for those occasions when you simply want to make a cotnroller slider for example, but that iss till in effect creating a proeprty before doing the ERC Freeze step rather than a part of the process itself.

  • Yes, Richard. Right-clicking does add the links directly to the morph, but I was talking about doing ERCFreeze through script, as I explained above. Through much experimentation, i was never able to replicate what the ERC Freeze Dialog does with any combination of ControllerProperties. So, I simply made my own loop of DzERCLink statements, adding them to the generated morph, which worked perfectly. My Script Generated Morph is exactly the same as one generated by manually using the ERC Freeze Dialog when you compare the saved Morph Files.

Sign In or Register to comment.