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

How do signals work?

$
0
0

Hello :)

Could anyone explain how a signal works? I have made an attachment and I want its material to change if Genesis does. I have worked out how to apply "duplicate" the Gen material when the attachment first loads, but now I am stuck on updating it whenever Gens material changes. I just don't understand how to setup a signal. I know my code is a bit rough at the moment but will fix it up if I can figure this last step out. I have done hours of google searches and found only 2 posts that remotely help, but all the links from them are dead. I have got the SDK docs but they don't explain how to use things, just what is available.

 

I am assuming I am meant to use "settingsChanged(DzMaterial*)" but I just don't know what to do with it.

My Code atm:


// DAZ Studio version 4.9.0.63 filetype DAZ Script

var aNodes = Scene.getSelectedNodeList();
if (aNodes.Length > 1){
	return false;
}

var sScript = 'c2.dsa';	
var oSrcNode = aNodes[0];
var oTgtNode = oSrcNode.findNodeChild ("g3Lump");
var oSrcObject = oSrcNode.getObject();
var oTgtObject = oTgtNode.getObject();
var oSrcShape = oSrcObject.getCurrentShape();
var oTgtShape = oTgtObject.getCurrentShape();
var oSrcMaterial = oSrcShape.findMaterial( "Torso" );
var oTgtMaterial = oTgtShape.findMaterial( "Torso" );
var oContext = new DzElementDuplicateContext();
 
	// Duplicate the material
	var oDupeMaterial = oSrcMaterial.doDuplicateElement( oContext );
 
	// Set the name of the duplicate to the name of the target
	oDupeMaterial.name = oTgtMaterial.name;
 
	// Set the label of the duplicate to the label of the target
	oDupeMaterial.setLabel( oTgtMaterial.getLabel() );
 
	// If the duplicate material classname and the source material classname do not match
	if( oDupeMaterial.className() != oSrcMaterial.className() ){
		// If the duplicate material inherits types we know provide a setMaterialName function
		if( oDupeMaterial.inherits( "DzShaderMaterial" ) || oDupeMaterial.inherits( "DzBrickMaterial" ) ){
			// Copy the material name
			oDupeMaterial.setMaterialName( oSrcMaterial.getMaterialName() );
		}
	}
 
	// Re-create any aliases that exist
	oContext.createAlaises();
 
	// Re-create any ERC links that exist
	oContext.createERC();
 
	// Resolve references to the source material
	oContext.doResolve();
 
	// Finalize the duplication
	oContext.doFinalize();
 
	oTgtShape.replaceMaterial( oTgtMaterial, oDupeMaterial );
var cbm = App.getCallBackMgr();
var cb = cbm.createCallBack("chMat", sScript, true);
cb.setConnection(oSrcMaterial, 'settingsChanged(DzMaterial*)');

 

Thanks to anyone who can help me :) an example of any kind would be appreciated or just an explanation would also be awesome!


Viewing all articles
Browse latest Browse all 1036


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