|
Active Member
Total Posts: 416
Joined 2003-10-09
|
Well, I should have known it was too good to be true. This script is causing a new set of problems.
I had been testing the script with a basic door (in Room Creator), which is the slimmed-down version of the main door. Today I tried applying it to the main door, which has numerous other items parented to it - crossbars, dividers, etc - and discovered that when I apply the script, all items parented to the door move a considerable distance away. (That distance appears to be the exact reverse of the distance from the center of the scene - Ztrans -595).
So what I want to know now is, is there a way to ensure all parented items behave properly? I see various oChild references, but I don’t know what they mean. In this script, the final line reads
this.setProperties( oSkeleton, oChild, false );
whereas in my old 1.5 script, it reads
this.setProperties( oSkeleton, oChild, bRecurse );
I tried changing it to bRecurse, but with no luck. I’m almost ready to forget this and use the old v1.5 script which works perfectly.
Anyway, here’s the latter part of the script as it stands now. (Note - I made it a Char preset so I could include the material switch as well, but that shouldn’t make any difference).
TIA
mac
DsActions.prototype.begin = function()
{
var bSelected = false;
var bRecurse = false;
var bRoot = false;
if( g_oGui.getNodes() == g_sSELECTED )
{
bSelected = true;
}
if( g_oGui.getPropagation() == g_sRECURSIVE )
{
bRecurse = true;
}
if( g_oGui.getNodes() == g_sROOT )
{
bRoot = true;
bSelected = true;
}
g_oPresetHelper.setDoMorphs( g_oGui.morphsChecked() );
g_oPresetHelper.setLimits( g_oGui.limitsChecked() );
g_oPresetHelper.setTransforms( g_oGui.transformsChecked() );
g_oPresetHelper.setXRot( g_oGui.xRotChecked() );
g_oPresetHelper.setYRot( g_oGui.yRotChecked() );
g_oPresetHelper.setZRot( g_oGui.zRotChecked() );
g_oPresetHelper.setXPos( g_oGui.xTranChecked() );
g_oPresetHelper.setYPos( g_oGui.yTranChecked() );
g_oPresetHelper.setZPos( g_oGui.zTranChecked() );
g_oPresetHelper.setGScl( g_oGui.gScaleChecked() );
g_oPresetHelper.setXScl( g_oGui.xScaleChecked() );
g_oPresetHelper.setYScl( g_oGui.yScaleChecked() );
g_oPresetHelper.setZScl( g_oGui.zScaleChecked() );
setBusyCursor();
this.m_aNodes = g_oSceneHelper.collectNodes( bSelected, bRecurse, bRoot );
beginUndo();
for( var i = 0; i < this.m_aNodes.length; i++ ){
this.setProperties( this.m_aNodes[ i ].getSkeleton(), this.m_aNodes[ i ], bRecurse );
}
bSelected = false;
bRoot = false;
if( g_oGui.getSurfaces() == g_sSELECTED )
{
bSelected = true;
bRoot = true;
}
if( g_oGui.getSurfaces() == g_sALL )
{
bRoot = true;
}
if( g_oGui.getMapSettings() == g_sIGNORE_MAPS )
g_oPresetHelper.setMapSetting( DzPresetHelper.Ignore );
else
g_oPresetHelper.setMapSetting( DzPresetHelper.Replace );
this.m_aNodes = g_oSceneHelper.collectNodes( true, true, true );
for( var i = 0; i < this.m_aNodes.length; i++ )
{
this.m_oNode = this.m_aNodes[ i ];
this.m_aNewMaterials = new Array;
g_oPresetHelper.collectMaterials( this.m_oNode, false, bSelected, bRoot );
this.m_aMaterials = g_oPresetHelper.getCollectedMaterials();
this.m_aMaterialShapes = g_oPresetHelper.getCollectedMaterialShapes();
for( var j = 0; j < this.m_aMaterials.length; j++ )
this.setMaterialProperties( this.m_aMaterials[ j ] );
}
acceptUndo( String( “\”%1\”” ).arg( g_sSCRIPT_NAME ) );
clearBusyCursor();
}
/*********************************************************************/
DsActions.prototype.setMaterialProperties = function( oMaterial, oShape ){
this.m_oElement = oMaterial;
var sID = this.m_oElement.name;
switch( sID ){
case “hinge”:
this.m_sMaterialType = “DzDefaultMaterial”;
this.m_sMaterialName = “DAZ Studio Default”;
this.prepareMaterial();
g_oPresetHelper.setTargetElement( this.m_oElement );
g_oPresetHelper.setColorProperty( “Diffuse Color”, [ 255, 255, 255 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Diffuse Strength”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Glossiness”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setColorProperty( “Specular Color”, [ 0, 0, 0 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Specular Strength”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setNumericProperty( “Multiply Specular Through Opacity”, [ 0 ] );
g_oPresetHelper.setColorProperty( “Ambient Color”, [ 0, 0, 0 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Ambient Strength”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Opacity Strength”, true, 0, 1, [ 0 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Bump Strength”, true, 0, 2, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Negative Bump”, [ -0.01 ] );
g_oPresetHelper.setNumericProperty( “Positive Bump”, [ 0.01 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Displacement Strength”, true, 0, 2, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Minimum Displacement”, [ -0.1 ] );
g_oPresetHelper.setNumericProperty( “Maximum Displacement”, [ 0.1 ] );
g_oPresetHelper.setPropertyWithString( “Normal Map”, “” );
g_oPresetHelper.setColorProperty( “Reflection Color”, [ 255, 255, 255 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Reflection Strength”, true, 0, 1, [ 0 ] );
g_oPresetHelper.setColorProperty( “Refraction Color”, [ 255, 255, 255 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Refraction Strength”, true, 0, 1, [ 0 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Index of Refraction”, true, 0, 10, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Horizontal Tiles”, [ 1 ] );
g_oPresetHelper.setNumericProperty( “Horizontal Offset”, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Vertical Tiles”, [ 1 ] );
g_oPresetHelper.setNumericProperty( “Vertical Offset”, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Lighting Model”, [ 3 ] );
g_oPresetHelper.setNumericProperty( “UV Set”, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Smooth On”, [ 1 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Smooth Angle”, true, 0, 180, [ 89.9 ] );
break;
case “hinge_back”:
this.m_sMaterialType = “DzDefaultMaterial”;
this.m_sMaterialName = “DAZ Studio Default”;
this.prepareMaterial();
g_oPresetHelper.setTargetElement( this.m_oElement );
g_oPresetHelper.setColorProperty( “Diffuse Color”, [ 0, 0, 0 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Diffuse Strength”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Glossiness”, true, 0, 1, [ 0.6 ] );
g_oPresetHelper.setColorProperty( “Specular Color”, [ 255, 237, 178 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Specular Strength”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setNumericProperty( “Multiply Specular Through Opacity”, [ 1 ] );
g_oPresetHelper.setColorProperty( “Ambient Color”, [ 0, 0, 0 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Ambient Strength”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Opacity Strength”, true, 0, 1, [ 1 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Bump Strength”, true, 0, 2, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Negative Bump”, [ -0.01 ] );
g_oPresetHelper.setNumericProperty( “Positive Bump”, [ 0.01 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Displacement Strength”, true, 0, 2, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Minimum Displacement”, [ -0.1 ] );
g_oPresetHelper.setNumericProperty( “Maximum Displacement”, [ 0.1 ] );
g_oPresetHelper.setPropertyWithString( “Normal Map”, “” );
g_oPresetHelper.setColorProperty( “Reflection Color”, [ 244, 216, 130 ],
“/Runtime/textures/maclean/room creator/rc0chrome.jpg” );
g_oPresetHelper.setNumericPropertyWithAttributes( “Reflection Strength”, true, 0, 1, [ 0.6 ] );
g_oPresetHelper.setColorProperty( “Refraction Color”, [ 255, 255, 255 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Refraction Strength”, true, 0, 1, [ 0 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Index of Refraction”, true, 0, 10, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Horizontal Tiles”, [ 1 ] );
g_oPresetHelper.setNumericProperty( “Horizontal Offset”, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Vertical Tiles”, [ 1 ] );
g_oPresetHelper.setNumericProperty( “Vertical Offset”, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Lighting Model”, [ 3 ] );
g_oPresetHelper.setNumericProperty( “UV Set”, [ 0 ] );
g_oPresetHelper.setNumericProperty( “Smooth On”, [ 1 ] );
g_oPresetHelper.setNumericPropertyWithAttributes( “Smooth Angle”, true, 0, 180, [ 89.9 ] );
break;
default:
break;
}
}
/*********************************************************************/
DsActions.prototype.setProperties = function( oSkeleton, oNode, bRecurse ){
var sSkeleton = “”;
if( oSkeleton ){
this.m_oSkeleton = oSkeleton;
sSkeleton = this.m_oSkeleton.name;
}
this.m_oElement = oNode;
this.m_oObject = ( this.m_oElement ? this.m_oElement.getObject() : undefined );
g_oPresetHelper.setTargetElement( this.m_oElement );
switch( this.m_oElement.name ){
case “door”:
g_oPresetHelper.setTransformProperty( “ZTranslate”, [ -3.5 ] );
g_oPresetHelper.setTransformProperty( “YRotate”, [ 0 ] );
this.m_oElement.getOriginXControl().setValue( 47.25 );
this.m_oElement.getOriginYControl().setValue( 0 );
this.m_oElement.getOriginZControl().setValue( -2.26 );
break;
default:
break;
}
if( bRecurse ){
var aStack = [ oNode ];
while(aStack.length>0){
var oParent = aStack.pop();
var nNodes = oParent.getNumNodeChildren();
var oChild;
for( var n = 0; n < nNodes; n++ ){
oChild = oParent.getNodeChild( n );
if( oChild.inherits( “DzBone” ) ){
if(oChild.getNumNodeChildren()>0){
aStack.push( oChild );
}
this.setProperties( oSkeleton, oChild, false );
}
}
}
}
}
g_bCONTROL_PRESSED ? g_oGui.doDialog() : g_oGui.doNoDialog();
|