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

How to exit script debugger?

$
0
0

Dumb question probably, but how the heck do you get out of the script debugger?  I just want to get back to the script IDE as it was before I started the debugger, but nothing I have found will do that.  Tried the 'Interrupt script', tried running to the end of the script, tried sacrificing a virtual goat inside a circle of point lights - nothing.


Changing Base Color with ERC/Proxy script?

$
0
0

After several hours with this one, I can't quite nail it, and I'm not sure if it's even possible. Basically, I'd like to be able to change an object's Base Color with a single control slider.

Using Rob's 'Post_Load_Material_Proxy_Create' and 'Post_Load_Material_Proxy_Link_Properties' scripts, I've added a new Surface group to Parameters for a material's Base Color. (Which, btw, in the script must be named as 'Diffuse Color', NOT 'Base Color').

Then I did a 10-stage timelined color change for Base Color. At first, I tried using a morph to trigger it. DId an ERC Freeze, but couldn't extract from the timeline. Tried New Property and that was no good. Tried creating all the above in the Surfaces group, No go. I've been in and out the Prop Hierarchy, dragging channels onto controllers, and can't get a thing to work. Maybe, I could set up my own keyed ERC in the hierarchy, but this is just an initial test, and the real thing would probably be fairly complex, so I'd rather avoid manual calculations.

I just need a way to extract the timeline info and link it to a control channel, but I'm just not getting there. Any thoughts?

PS I can get a basic color change by dragging the material into the Hierarchy, but not the full timelined one of 10 changes. So it des work, but not how I want it.

 

Distinguishing G3/G8

$
0
0

Is it possible to distuinguish whether a selected figure is G3 vs G8? For G1/G2/G3, I'm assuming you could do it via differences in the skeleton, but not sure how you'd distuinguish G3 from G8.

Adding scripts to DS Scripts Menu

$
0
0

I'd like to write an install script that copies files from an unzipped file collection into a DS Content Library location.

Once the files have been copied, I'd like to add them to the DS Scripts Menu. That would involve adding a new Submenu to the Scripts Root Menu, and programatically invoking 'Create Custom Action'.

Is there a way to do this with DS Scripts? 

Convert to SubD script

$
0
0

I`d like to include a script to convert the selected item to SubD.

Actually, the idea is to create presets so the user can toggle between 0 and 1 subdivisions for the selected item.

I don`t know where to look at, so I would appreciate a help with this, please.

Adding Image in a dialog

$
0
0

So what I did is I used Dialog Design to create a dialog and added a label as a placeholder for the image. So apparently with the Piximage, I get a error that says "QFileInfo::absolutePath: Constructed with empty filename". 

here's the code

var label = new DzLabel( Dialog );
label.setGeometry( 200, 60, 46, 13 );
var sPath = new DzFileInfo(getScriptFileName()).path();
var filepath = sPath + "\\aero_header.png";
var pixImage = new Pixmap(filepath);
label.pixmap = pixImage;

What did I do wrong??

Creating Custom action script in folder

$
0
0

I used one of the examples "http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/actions/action_custom_create/start" and I tried switching from using the DAZ application path to use the DAZ libairy folder, and for no reason, it's not adding the script to the menu. I'm trying to add another script in a subfolder. Are subfolders not supported?

Here's the code.

//Set what folder this particular script is coming from	
var sPath = DzFileInfo(getScriptFileName()).path();	
	
// Define the custom action components
var sActionMenu = "Fa&vorites";
var sActionToolbar = "Fa&vorites";
var sActionText = "Lock Feet (G1)";
var sActionDesc = "Lock Feet (G1)";
var sActionFilePath = sPath + String( "//Actions/Lock Feet G1.dse" );
var sActionIconPath = sPath + String( "//Actions/Lock Feet G1.png" );
var sActionName = createCustomAction( sActionText, sActionDesc, sActionFilePath, sActionIconPath, true );
addActionToMenu( sActionMenu, sActionName, true, -1 );

 

Passing Parameters out by Reference?

$
0
0

Surely it's possible to pass parameters out of a function by reference, isn't it?

Example:  If select an item in my scene and run this:

(function() {
	var oPrimarySel = null;
	
	function doStuff(oNode) {
		oNode = Scene.getPrimarySelection();
	}

	doStuff(oPrimarySel);
	print('oPrimarySel = '+oPrimarySel);
})()

I get "oPrimarySel = null"


3d Rotation Daz Studio 3ds Max

$
0
0

Does anyone know the math or the method to conver Daz Quaternion rotation to 3ds Max and vice versa ?

The axis swap is doing my head in. 

12 months ago I could have worked it out, but I don't want to have to learn all 3d rotational algebra again. 

Just for reference: daz Studio axis  +Y up,  +X to the right, +Z towards the viewer
3ds Max +Z is up +X to the right, +Y is away from the viewer 

my intuition tells me to rotate the normalized quaternion in max by euler -90°

but I tried that and it was clearly wrong. 

 

Need some help with LineRender9000, and some modifications...

$
0
0

TL;DR: I'm using Daz Studio to create 2D assets that make use of normal, diffuse and specular maps.  In my current piepline, I have to perform seven different renders on every frame of animation.  I think there may be a way to do pull this off with just 3 renders per frame, saving a considerable amount of time and effort.  I could use some help from someone who is savvy with Daz Studio's scripting language, and knowledgeable about shaders, and maybe familiar with the inner-workings of LineRender9000.

The Long Version:

Using 3D artwork to generate pre-rendered game art has been my obsession this year.  Currently, I'm using a program that generates a normal map based on how said object would appear when lit from the front, top, bottom, left and right sides.  It was made for pixel artists, but it works remarkably well when you have five separate renders with light coming from a single direction in each.  The one problem being, there are a lot of images to keep track of.  A typical frame from an animated object might look something like: "SprName_Direction_FrameN_front.png" - with four more for the cardinal directions, one for diffuse, and one for specular.  Basically, I have a handful of different "sets" that I load an object into and render from, and there's a lot of rigorous work involving material setting, and adhering to naming convention.  I'd love to automate as much of this as I can.

Looking through the LineRender9000 documentation, I was saddened to see there were no scripted cameras that would produce a pure light-render (I'm not sure what you'd even call it. Illumination-render? Something where the texture does not appear, only how the light bounces off it).  I did notice something interesting when reading up on the Fresnel Reflection v camera. 

Ignores surface materials and renders the scene geometry using a Fresnel algorithm,
outputting the reflected vector as color information, converted to greyscale. That’s a
long-winded way of saying “the camera you should use for normal-like detail lines that
looks better than a straight output of normals would”.

Minus the greyscale part, that might be exactly what I'm trying to get! If there were a way to get a straight output of normals...well, that would be a normal map, no?  If I could simply use a modified Fresnel Reflection v script to create a colored normal map, I wouldn't have to bother with the five directional lighting renders (nor creating seprate textureless material presets for different circumstances).  I've attached a few images that sort of illustrate the process, and my desire to shorten it as much as possible.

I haven't done any scripting in Daz, but I've done enough in the past where I can have a pretty good idea of what's going on when looking through a script, provided the code is documented and clean.  Unfortunately, none of the support scripts I found for LR9K address the shaders (or shader cameras) by name.  I'm also pretty in the dark when it comes to shaders in general.  A beginner's guide to scripting in Daz Studio probably wouldn't be helpful in a situation like this one; I can see how learning it could help streamline a lot of processes, but I kind of need to migrate from being stuck on the graphics to being stuck on the game coding. (I know, I'm doing this all in a very nonsensical order).

So my question is, is there a way I could figure out which part of the script applies the Fresnel Reflection algorithm, and more specifically, which part deals with greyscaling the output? I may not be able to write my own script, but I know how to comment things out!  But...if it's clearly not that straightforward of a process, then I may have to outsource this part of the project to someone who knows what they're doing.  There's another version of this thread, somewhere down the road, that involves: Clicking on a single script from Daz Studio -> Renders N times under every necessary circumstance, and saves each image name appropriately.

Setting focus to a DzTextEdit control

$
0
0

I'l love to be able to set the focus to a DzTextEdit control within a dialog window, but apparently Daz Script offers no such way. I'm a bit surprised since most implementations of the control provide a focus property or method.

Does anyone know if the SDK provides this feature?

 

 

Set Resolution Level to Base

$
0
0

Anyone know how a script can set Resolution Level to 'Base' on a figure?

getCachedGeom() question

$
0
0

What is the correct way to get UVs, when the surface might have say, 5 uvsets, and the user has selected something other than the default uvset?

Given this:

var obj = node.getObject();
var uvset = obj.getCachedGeom().getUVs();


What uvset is returned from getCachedGeom() ?  
Is this the currently selected uvset, or does it always return uvset 0 ?

Another question.  How do I know if the currently selected uvset is compatible with my mesh?  Let me give an example of what I mean.  Let's say I load the Genesis 2 Male.  Under surfaces, I select Pupils.  I see that there are 5 UVsets loaded for this surface.

Ok, so let's say I want to load G2F eye textures for this G2M, so I load them.  I now see that there are 6 uvsets loaded for G2M's pupil surface.  The extra uvset that was loaded is called "Base Female".

Now, I'm sure this "Base Female" uvset is not compatible with G2M's mesh.  So, what's happening here?  Is it really using the "Base Female" uvset, or is it bugging out?

Writing a little script to open a PDF file?

$
0
0

Hey guys,

I am looking for a little script that will open up a PDF user-guide when clicked on. The purpose is simple: Rather than having the user search the support folder for my PDF manuals, I would like to include a "link" to them directly in my product folders. I saw some other PA's have done this with their products, but I do not quite understand the code for the script. 

Any help in this regard would be appreciated,

-P

Help fetching Iray render property and adding step value

$
0
0

First off, I'm a complete beginner at this, for as long as I've been around this forum best I can do is follow and combine existing examples, so beginner-level explanation would be appreciated.

Let's say I want to fetch the DzIrayRenderer property like Environment Intensity, but I want to add step value via script, for an example increase value by 0.5 to existing one every time script is innitiated. From my understanding I would use Render Settings - Find Property to locate Environment Intensity property but anything I do afterwards to set value doesn't function and I would appreciate some guildelines.

Beginning so far is consistent:

/==============================================================================
//
//==============================================================================
function getEnvironmentIntensity()
{
	var renderMgr = App.getRenderMgr();
	var renderer = renderMgr.getRenderer( "DzIrayRenderer" );
	if( !renderer )
	{
		return( 0 );
	}
	var renderElements = renderMgr.getRenderElementObjects();
	var element = renderElements[1]; // NVIDIA Iray
	var propGroups = element.getPropertyGroups();
	var prop = propGroups.findProperty( "Environment Intensity" );

 

but here on I don't know how to manipulate further to get to getValue or setValue within the property that would match with the first part let alone step values like increasing by a number (I tried similar examples per nodes and objects but they must've led me rather wrong cause I can't make them work), so I'll just spare you all the fails I had and appreciate it if anyone would be willing to help :) Thanks.


PowerPose Templates generator script

$
0
0

Hi, once again I started a script project to solve a specific issue I had. Read How to Get PowerPose to Work with Genesis 3?

I want to create a simple PowerPose template but I'm too lazy to write all the boring stuff myself even with copy-paste this takes some time and is prone to typos. So yesterday I started to write this script that generates all these lines for me that look like HTML tags based on the selected figure to have at least something to work with while creating the actual tamplate.

For me it is meant to be used to create a face rig template for genesis 3 figures and there are 64 control points in the template that need to get defined for PowerPose with a bone label and a position on the pane.

Here is my first version that does at least something usable. I can imagine this script could also serve others that want to create PowerPose templates for their custom figures. Maybe I should add some kind exclude bones check so you can run it from the root node of the figure without having everything included.

It generated 640 lines of PowerPose template code in a few milliseconds and includes all control points that I wanted for my PowerPose template.

It is far from beeing perfect and I need to find some other way to positioning the control points currently that isn't working at all. I post this script anyway even if I dircracing myself for not getting such a simple thing like one dimensinal offsets to work. I will have a look at it again after some sleep.

But that's why I post this becasue I need some help getting it right. So please can someone have a look and find out why I have commas in a few lines of the string / array output in the console. Must be some issue with the array index or the line break "\n" I've added everywhere. I wonder why I can print out the aTemplate array without joining it. Also I need to test if I have to choose inverted control settings depending on if its a left or right side bone.

I hope you don't mind that I borrowed the upper part of the script from the script example "Adjust Rigging to Shape"

Source: http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/nodes/adjust_rigging_to_shape/start

That example just got the right checks and error messages for working with figure bones. I've included the Creative Commons Attribution 3.0 information in the header comment and included infromation that this is a modification of the original script example.

Update info:


GeneratePowerPoseTemplate_v09.dsa

I was bussy programming again and the code went over many iterations but now I can release an updated Script version that is working.

It is still in beta so to say because it only prints out the results into the console my final goal is to directly write the printed string arrays to DSX or TXT files.

I haven't got into writeFile ( String filename ) yet. Was reading some script examples but they extremly long. There is so much to declare and collecting paths and such, maybe I will add this later.

While the script iterates over the child bones you get the Script IDE console text blocks printed out, formatted in three different flavours: The default node listing now also includes node names.

I've fixed the issues with commas, empty first array indexes, extended the bone label search with the function setXYOffsetsByBoneLabel(sBoneLabel) and if((sBoneLabel.startsWith("Left")) bit this is still case sensitive.

I made experiments with trying to use Regular Expressions but that didn't went far. While I've cleaned up some issues new issues arised and still the offsets get completly messed up. As I tested the control point placements on the PoewerPose pane (by copy pasting console output to a template file) I had some kind of pyramide patterns and thats all this script can do for you I had to invert the left and right offsets because the face image is mirrored. In this release the offsets are completly messed up again with negative or high values exceeding the image boundaries. I made it too complicated and now I don't understand what it does with the offsets anymore. Anyway if you like to see the "debuging" of the "Bone Label Detection" in the console you need to hold down the Alt key while executing.

But just read the script comments its well documented with more details on the updates.


GeneratePowerPoseTemplate_v1.07a.dsa

Whith this version I was testing a way to detect and process children of child bones.


GeneratePowerPoseTemplate_v1.08a.dsa

Still testing but getting closer the main function now is only called once with generateTemplate("Head")the head bone got 7 children but I wanted it to work with all children of children. The script will now do the rest by its own to iterate over all child bones. Unfortunatly not in the right order as I thought I've added a loopCount print out to better see how the generateTemplate() function will process the child bones.


GeneratePowerPoseTemplate_v1.09b.dsa

OK now I figured out why generateTemplate("Head") was only finding the immediately children nodes because I was using getNodeChildren(false)all the time. This is the "Recurse" search switch parameter I was using for a flat hierarchy chain like with the Upper/Lower Face Rig bones but this was not what I wanted if I like to start with the "Head" bone. Now I have implemented both search methods to iterate over all children bones. By default the Recursive search method is used but you can also hold down the Shift key to use the other search method that I was using in v1.07a and v1.08a.


Download links:

Screenshots of the console output:

GeneratePowerPoseTemplate_v1.09b_DefaultExecution.png GeneratePowerPoseTemplate_v1.09b_ShiftKeyExecution.png GeneratePowerPoseTemplate_v1.09b_ProcessFlow-LoopCountConfusion 

Updated Script code:

Sorry with 685 lines of source code I can no longer add it to a code snipped. The forum page says Body is 3719 characters too long. I can only show the bottom part of the script here.

//This is only the bottom part of my script starting at line# 397

	/*********************************************************************
	boolean : generateTemplate () constructs a string based on the bone label you give and the child bones on the selected figure
	*********************************************************************/
	function generateTemplate( sStartWithBoneLabel ) {
		var aChildBones = [];			//array of Child-Nodes of the given bone label - if any otherwise the single bone at index 0
		print('\n\nSearch for a bone with the label: "' + sStartWithBoneLabel + '"');
		var oBone = oFigure.findBoneByLabel( sStartWithBoneLabel );
		if( !oBone ){
			print('> Did not found a bone with the label: "' + sStartWithBoneLabel + '"' + sLine );
			return false; //finished with error
		}else{
			//========================================
			//detect if the given bone got no children
			if ( bFindChildrenOfChildBonesRecursively ){
				print('> found "' + sStartWithBoneLabel + '" the bone includes [' + oBone.getNodeChildren(true).length + '] recursively counted child nodes.' + sLine);
				if(oBone.getNodeChildren(true).length == 0){		//recursively count all this node's children
					aChildBones [0] = oBone;		//also process single bones that don't have children by filling the first array index
				}else aChildBones = oBone.getNodeChildren(true);		//recursively collect all this node's children
			}
			if ( !bFindChildrenOfChildBonesRecursively ){
				print('> found "' + sStartWithBoneLabel + '" the bone includes [' + oBone.getNumNodeChildren() + '] immediate child nodes.' + sLine);		//getNumNodeChildren() does not have a boolean parameter to count recursively
				if(oBone.getNumNodeChildren() == 0){		//count only this node's immediate children
					aChildBones [0] = oBone;		//also process single bones that don't have children by filling the first array index
				} else aChildBones = oBone.getNodeChildren(false);		//collect only this node's immediate children
			}
			/*
			Array : getNodeChildren( Boolean recurse=false )
			Parameter(s):
			    recurse - If true, recursively collect all this node's children, scanning the hierarchy from this node down. If false (default), collect only this node's immediate children.
			Note: can also include other nodes parented to the figure bone hierarchy
			*/
			//========================================
			//main loop
			for ( var n = 0; n < aChildBones.length; n++ ) {
				sLabel = aChildBones[n].getLabel();
				sName = aChildBones[n].getName();
				//========================================
				//if we don't have a bone in the array filled by getNodeChildren that can also include parented items that are not part of the figure skeleton
				if(!aChildBones[n].inherits( "DzBone" )){
					aChildBones.slice(n, n+1);		//remove this node from the array
					debugPrint('\n\n> Skipping the Node with the Label: "' + sLabel + '" ' + 'Name: "' + sName + '"');
					debugPrint("\n\tthis is not a bone of the figure!" + sLine);
					continue;	//skip this for loop, start next loop
				}
				//========================================
				if( ( sLabel == "Upper Face Rig" )
					|| ( sLabel == "Lower Face Rig" ) 
					&& ( bFindChildrenOfChildBonesRecursively ) ){
					aChildBones.slice(n, n+1);		//remove this node from the array
					debugPrint('\n\n> Skipping the Node with the Name: "' + sName + '" ' + 'Label: "' + sLabel + '"');
					debugPrint("\n\tWe do not need to create a control point!");
					continue;	//skip this for loop, start next loop
				}
				//========================================
				//print the current node number, the LoopCount of this name and label to the console
				print("Bone: %1 | LoopCount: %2 | Name: %3 | Label: %4"	
					.arg(aTemplate.length+1, 3)	//fieldWidth=3 stands for a margin spaces of three digits eg. __5, __7, _15, 156
					.arg(n+1, 3)		//fieldWidth=3 print out for loop count
					.arg(sName, 20)	//fieldWidth=20 for names - somehow right alignment?
					.arg(sLabel) );
				debugPrint(sLine);		//add a line if debugging for better readability
				//========================================
				//set node attibutes if not already Selectable On, Hide in Scene View: Off see Joint Editor
				if(bManipChildBones){
					if( !aChildBones[n].isSelectable () ){		//if the node is not selectable
						aChildBones[n].setSelectable(true);
						debugPrint("> Changed Node Attibute: Selectable: On");
					}
					if( aChildBones[n].isHidden() ){			//if the node is set to Hide in Scene View
						aChildBones[n].setHidden(false);
						debugPrint("> Changed Node Attibute: Hide in Scene View: Off");
					}
				}
				//========================================
				//try to detemin the position of the control points by the bone label to get them rougthly positioned in the PowerPose pane
				if( !setXYOffsetsByBoneLabel(sLabel) ){
					debugPrint("> the bone dosn't match any searched pattern." + sLine);
					resetOffsets();
					debugPrint( getOffsets() );
				}
				//========================================
				// construct the PowerPose Template string array
				aTemplate[ aTemplate.length ] = 	//one dimensional array with one string for a bone : index == NodeNr + 1
					   "<node_data>\n"
					+ "\t<x>" + nXoffset + "</x>\n"
				 	+ "\t<y>" + nYoffset + "</y>\n"
				 	+ "\t<node_label>" + sLabel + "</node_label>\n"
				 	+ sControlSet01
				 	+ "</node_data>\n";
				//========================================
				//create another formated child bone list convertable to an Excel table
				if(bCreateChildBoneTable){	
					aChildBoneTable[ aChildBoneTable.length ] =
						   (aChildBoneTable.length + 1)
						+ sTableSeperator
						+ sLabel;
				}
///*
				/*========================================
				Detect if the current child bone got children of its own - obsolete if we search recursively getNumNodeChildren(true).
				This was my workaround becasue oBone.getNodeChildren(fasle) was giving me only the immediate children nodes.
				Was working fine in a flat rigging bone hierarchy with Upper/Lower Face the I forgot what was written about in the API documentation.
				Parameter(s): recurse - If true, recursively collect all this node's children, scanning the hierarchy from this node down. If false (default), collect only this node's immediate children.
				========================================*/
				if ( (aChildBones[n].getNumNodeChildren() != 0)
					&& !bFindChildrenOfChildBonesRecursively ){
//					var sChildrenLabelToStartWith = aChildBones[n].getNodeChild(0).getLabel();	//get the first child of the child bone at current index
					sChildrenLabelToStartWith = aChildBones[n].getLabel();
					debugPrint('\n> Found a child bone with the Name: "' + sName + '"' + ' Label: "' + sLabel + '"'
						+ '\n\tthat looks like it also got [' + aChildBones[n].getNumNodeChildren() + '] child bones!'
						+ '\n\tNow the script will also search for: "' + sChildrenLabelToStartWith + '"'
						+ sLine );
					//fill the function call array with another instance of this function with giving the label of the child bone as argument
					aCallGenerateTemplate [aCallGenerateTemplate.length] = new generateTemplate( sChildrenLabelToStartWith );
				}
//*/
			}	//End of: for loop
		}	//End of: if (!oBone){}else{}
		return true; //finished with success
	};
	
	/*********************************************************************
	[Declaration#1] declaring working variables
	*********************************************************************/
	var sScriptName = "GeneratePowerPoseTemplate";
	var sLine = "\n--------------------------------------------------------------------------------\n";
	var aErrorMsg = [];			//instead of debugPrint() I could fill the error message array and show it at the end
	var aBones  = oFigure.getAllBones ();	//array of all figure bone objects	
	var sLabel = oFigure.getLabel();		//first figure label - later bone label
	var sName = oFigure.getName();		//first figure name - later bone name
	//I try to construct a regular expression here to search anywhere for "left" and ignore case - I'm not shure if I understand the implementation of regular expressions in Daz Scripts yet
//	var reg_expLeft = /("left","i")/;
//	var reg_expLeft = /("[Ll]*eft*")/;
//	var reg_expRight = new RegExp( "^.*?\b(right)\b.*$","i" );	//another regular expression search, I think it says search "right" ignore case
	//offsets are related to the x/y pixel coordinates on the backround image
	//I just gave some values here so the points don't end up all on the same spot
	var nBkrndResX	= 480;	//horizontal resolution of the PowerPose backround images
	var nBkrndResY	= 720;	//vertical resolution of the PowerPose backround images
	var nXoffset	= 0;	//final x offset in relation to the center of the given backroud resolution
	var nXoffsetLeft = 0;	//positive left offset in relation to the center
	var nXoffsetRight = 0;	//negative right offset in relation to the center
	var nYoffset	= 265;		//the pixel height in which the points start to appear
	var bJumpedOnceVert = false;	//apply the Yoffset jump once
	var nXspacing	= 20;	//how far the points get spaced horizontal
	var nYspacing	= 20;	//how far the points get spaced vertical

	var bFindChildrenOfChildBonesRecursively = true;	//set this to false if this script should not detect and process children of child bones
	var bManipChildBones = true;	//in order to edit the PowerPose template in the panes right-click menu "Edit Point" the properties of the processed bones gets changed
	var aCallGenerateTemplate = [];		//this array will store additional generateTemplate() function calls with the bone label as argument that was detected as having child bones of its own
	var sChildrenLabelToStartWith = "";	//this is the bone label that was detected to have children of its own
	var bCreateChildBoneTable = false;	//set this to false to skip creating a Child Bonde table for MS-Excel
	//this array can be written into a ascii text file that is convertable into a useful MS-Excel table
	var aChildBoneTable = [];	//holds an arry of just bone number and bone label with no spaces, seperated by sTableSeperator eg. 1,Right Brow Inner,2,Right Brow Middle,3,Right Brow Outer,...
	var sTableSeperator = ",";	//MS-Excel is importing text files with spaces or commas as seperators by default, semicolons work also
	var aTemplate = [];		//the PoserPose  template string array holds the output strings for all processed bones - can later get written to a DSX file
	//currently you need to manualy select & right-click copy the output from the ScriptIDE console and paste it to a template DSX file
	//========================================
	var s_tpl_bg_file = "G3F-FC-Face.png";	//backround image
	var s_tpl_label_1 = "Body";	//first template selection point
	var s_tpl_label_2 = "Head";	//second template selection point
	var s_tpl_label_3 = "";			//n-i-u
	var s_tpl_label_4 = "";
	var nl = "\n";	//insert new-line
	var sTemplateFileBOF = 	//Beginning Of File
				"<template_file>"
		+nl+	" <version>3</version>"
		+nl+	" <bg_file>" + s_tpl_bg_file + "</bg_file>"
		+nl+	" <width>" + nBkrndResX + "</width>"
		+nl+	" <height>" + nBkrndResY + "</height>"
		+nl+	" <template_points>"
		+nl+	"  <tpl_data>"
		+nl+	"   <x>84</x>"
		+nl+	"   <y>56</y>"
		+nl+	"   <label>" + s_tpl_label_1 + " Template</label>"
		+nl+	"   <tpl_label>" + s_tpl_label_1 + "</tpl_label>"
		+nl+	"  </tpl_data>"
		+nl+	"  <tpl_data>"
		+nl+	"   <x>362</x>"
		+nl+	"   <y>56</y>"
		+nl+	"   <label>" + s_tpl_label_2 + " Template</label>"
		+nl+	"   <tpl_label>" + s_tpl_label_2 + "</tpl_label>"
		+nl+	"  </tpl_data>"
		+nl+	" </template_points>";
	var sTemplateFileEOF =	//End Of File
		nl+	"</template_file>";
	//you can choose which controls you want to have in the lower PowerPose pane - currently only sControlSet01 is used
	var sControlSet01 =
		   "\t<lmb_horiz_prop>ytran</lmb_horiz_prop>\n"
		+ "\t<lmb_vert_prop>xtran</lmb_vert_prop>\n"
		+ "\t<rmb_horiz_prop>zrot</rmb_horiz_prop>\n"
		+ "\t<rmb_horiz_sign>neg</rmb_horiz_sign>\n"
		+ "\t<rmb_vert_prop>xrot</rmb_vert_prop>\n";
	var sControlSet02 =
		   "\t<lmb_horiz_prop>ytran</lmb_horiz_prop>\n"
		+ "\t<lmb_vert_prop>xtran</lmb_vert_prop>\n"
		+ "\t<rmb_horiz_prop>zrot</rmb_horiz_prop>\n"
		+ "\t<rmb_horiz_sign>pos</rmb_horiz_sign>\n"		//I guess if there is a 'neg' there must also be a 'pos'
		+ "\t<rmb_vert_prop>xrot</rmb_vert_prop>\n";

	/*********************************************************************
	[Start#] Main Script process
	*********************************************************************/
//	g_oScriptVersion.setVersionNumber ( 1,08,0,0 );		//void : setVersionNumber ( Number major, Number minor, Number revision, Number build )
//	print( sLine + g_sScriptFileName, "Version:", g_oScriptVersion.getVersionString (),  "running." + sLine); //	not working
	/*********************************************************************/
	//print information about the running script
	if( g_sScriptPathFileName == "" ) {
		print( sLine + sScriptName, "running." + sLine);
	}else{
		print( sLine + g_sScriptFileName, "running." + sLine);
	}

	//print information about the current modifier key state
	if( s_bAltPressed ){	//Alt key was pressed while executing the script
		print("> Alt Key was pressed while executing!\n"
			+ "The script operates in debug mode now and will show additional inforamtions.\n\n");
	}else print("> Alt Key was not pressed while executing!\n"
		+ "The script operates in default mode now and will not show additional inforamtions.\n\n");

	if( s_bShiftPressed ){	//Shift key was pressed while executing the script
		bFindChildrenOfChildBonesRecursively = false;		//the script should not process all children of child bones at once but one after another
		print("> Shift Key was pressed while executing!\n"
			+ "The script will now only find the immediate children of the searched bone\n"
			+ "and will then jump to the next level down the figure bone hierarchy.\n\n");
	}else print('> Shift Key was not pressed while executing!\n'
		+ 'The script will "Recursively Find Children of Children"\n'
		+ 'scanning the current figure rigging down to the last bone in the bone hierarchy chain.\n\n');

	//print information about the current figure selection 
	print( sLine + "The selected figure with label: ["+sLabel+"] name: ["+sName+"] got ["+aBones.length+"] bones." + sLine );

/*// add two slashes at the beginning to execute that:
	//this was for testing and was printing out all bones at once
	for ( var n = 0 ; n < aBones.length ; n++ ) {
		sLabel = aBones[n].getLabel();
		sName  = aBones[n].getName();
		print("Node: %1 | Name: %2 | Label: %3"
			.arg(n+1, 3)
			.arg(sName, 20)
			.arg(sLabel));
	}
//*/// remove two slashes at the beginning

	/*********************************************************************
	generateTemplate() function calls
	*********************************************************************/
///*// remove two slashes at the beginning to skip that:
	if( generateTemplate("Head")){		// try to start from the head bone
		resetOffsets();
	}else{ return "Error! Something went wrong with finding: Head"; }
//*/// remove two slashes at the beginning
/*// add two slashes at the beginning to execute that:
	if( generateTemplate("Upper Face Rig") ){
		nYoffset -= nYspacing;				//the next row of control points will get shifted up
	}else return "Error! Something went wrong with finding: Upper Face Rig";

	if( generateTemplate("Lower Face Rig") ){
	}else return "Error! Something went wrong with finding: Lower Face Rig";
	
	if( generateTemplate("Left Ear") ){
	}else return "Error! Something went wrong with finding: Left Ear";

	if( generateTemplate("Right Ear") ){
	}else return "Error! Something went wrong with finding: Right Ear";
*/// add two slashes at the beginning

	//========================================
	// also process children of child bones if the function call array is not empty and we don't search recursively
	if ( !bFindChildrenOfChildBonesRecursively ){
		for ( var m = 0; m < aCallGenerateTemplate.length; m++ ) {
			if( aCallGenerateTemplate[m] ) {
			}else{ return ("Error! Something went wrong with finding:", sChildrenLabelToStartWith ); }	//something went wrong
		}
	}

	//========================================
	// print the result(s)
	if(bCreateChildBoneTable){					//you can use this ascii text string to convert it into a MS-Excel table
		print("\n\nThe generated Excel table:" + sLine);
		print( aChildBoneTable.join( "\n" ) );		//New-Line seperator for getting a vertical row
	}
	print("\n\nThe generated PowerPose template:" + sLine);
	for( var i = 0; i < aTemplate.length; i++ ) {
		print( aTemplate[ i ] );	//well the print function can be quiet simple if you dont use .arg everywhere and the content is already a string :)
	}
	saveTemplateFile();
	return "Finished. Everything went fine =)";
// Finalize the function and invoke
})( Scene.getPrimarySelection() );

Automating multiple renders

$
0
0

I'm just getting started with daz scripting; as in, looking at the available documentation and wishing there were more resources out there that could help.  I may be able to develop this myself, if I dedicate a lot of time learning the ins and outs, but that would be quite the deviation for me.  I'm willing to pay for assistance with this aspect of the project, but be warned, I'm pretty poor.

What I'm ultimately trying to accomplish, is a script that will render a scene with a single animated character into a series of images, but multiple times under different lighting setups and material properties.  Here's a condensed description of the procedure:

This process uses Scripted 3Delight, LineRender9000, and AgeOfArmour Directional and Ambient Lights, and Visual Style Shaders

  • Every frame of animation needs to be rendered seven times. 
    • The first five renders use a single, unique AoA directional light for Right, Top, Left, Bottom, and Front.
    • The final two renders use an AoA ambient light; one with Diffuse Only set in Illumination, one with Specular Only.
      • As an aside, it would save more time if I could render these directly to greyscale images, or run a post-processing script that does that.
  • When performing the renders for directional lighting, the main model uses what materials are loaded into the scene.
  • The ambient lighting render should use a set of Visual Style Shaders in place of the original materials.  These will be stored on a duplicate, hidden version of the figure.

There may be methods of condensing this process. If there is a way to perform Normal and Depth renders using Scripted 3Delight, that would eliminate the need for the first five directional lighting renders (would potentially add more materials to swap through).

I know it's possible to create different scenes for each lighting/material condition, and then render them separately.  I'm inclined to avoid doing this as a long-term solution due to the additional time, effort, and potential for minor inconsistencies that could arise from maintaining seven separate scenes.  Some have recomended products for rendering queues or batch rendering.  Of the two I looked at in the Daz store, one said it did not support animation/series renders, the other said it only worked for Iray.

I'll have a more detailed view of the project in the next post.

getAnimRange vs getPlayRange

$
0
0

In the "Scene" object (DzScene), what is the difference between "getAnimRange" and "getPlayRange".

Yes, I know, they get "The current animation range" vs "The current play range".  But under what circumstances would the two differ, and how would that occur?

Working with maps

$
0
0

With the function getAllMaps() and by iterating through them allMaps[i].name I am able to output all map names, but how do I know for what these maps are used? 

Or seen differently: getColorMap() seems to return the diffuse color map, but how can I get the maps for glossiness, normals, bump maps, etc.?

Thank you!

My first script - feedback sought

$
0
0

I've finally dipped my toe into the world of Daz scripting and written my first one. Here's what it does...

There are rendering errors that can occur in Iray if a character is too far away from the world origin. Eyes can turn black. Strange marks show on scalps. Maybe other stuff too. So what I've written is a script to move the selected object to (0,0,0) and everything else in the scene stays in the same place relative to it. The only thing that doesn't move is the Perspective View position (is it possible to move that via scripting?).

I've tested it, and it seems to work, but I'd appreciate a once-over from more experienced eyes. Is there anything that I've missed?

// DAZ Studio version 4.10.0.123 filetype DAZ Script
// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables

(function(){

   /*********************************************************************/
   // String : A function for retrieving a translation if one exists

   function text( sText )
   {
      // If the version of the application supports qsTr()
      if( typeof( qsTr ) != "undefined" ){
         // Return the translated (if any) text
         return qsTr( sText );
      }
      // Return the original text
      return sText;
   };

   // Define common message variables
   var sButton = text( "&OK" );

   // Get the selected nodes
   var aNodes = Scene.getSelectedNodeList();
   // Get the number of nodes
   var nNodes = aNodes.length;

   if( nNodes != 1 ){
      // We're done...
      MessageBox.warning( "Please select a single item in the scene before invoking this script", "Selection Error", sButton, "" );
      return;
   }

   var oNode = aNodes[0];

    //Offset is the selected object's position, less any origin positioning
    //This should give the same figures that show in the X/Y/Z Translate properties
    // (for unparented items)

    var vOffset = oNode.getWSPos().subtract(oNode.getOrigin());

    var aAllNodes = Scene.getNodeList();
    var nAllNodes = aAllNodes.length;

    // Iterate over the nodes
    for( var i = 0; i < nAllNodes; i += 1 ){

       // Get the 'current' node
       oNode = aAllNodes[ i ];

       // If the node is a root node, move it by the offset amount
       // if it isn't, there's no need as it'll move with its parent

       if (oNode.isRootNode()) {
          var vNewPos = oNode.getWSPos().subtract(vOffset);
          oNode.setWSPos(vNewPos);
       }
   }

   // Finalize the function and invoke
})();

 

Viewing all 1025 articles
Browse latest View live


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