Solution for restoring "point at" target for node on scene load

This is really my first post, but I got tired of having to re-orinent any node that had a "point at" target. So here's a simple script I wrote up to help out all the batch-render people out there so you can start using the "point at" paramenter again. 

The operation is simple; select anything in your scene (or everything) that's pointing at anything (lights, camera, eyes, etc.) and then just run the script. It takes the current transforms that are applied with the "point at", stores them, removes the target, reapplies the transforms, and finally restores the "point at" target. That way, you don't lose anything and the scene loads without having to "jiggle" anything to get the "point at" to work.

// gather selected nodesvar a_sel = Scene.getSelectedNodeList();var n_sel = Scene.getNumSelectedNodes();if (n_sel > 0){	for(var i = 0; i<n_sel; i++){		var selnode = Scene.getSelectedNode(i);				//store the "point at" target		var selnodePT = selnode.getPointAtTarget();		if (selnodePT!=null){			var current_location = selnode.getLocalPos();			var current_rotation = selnode.getLocalRot();						//unpoint the node			selnode.setPointAtTarget(null);						//re-apply transforms			selnode.setLocalPos(current_location);			selnode.setLocalRot(current_rotation);						//restore node "point at" target			selnode.setPointAtTarget(selnodePT);		}	}}

I have a lot of experience with DAZ, but I just recently started dabbling in the scripting side of things to make my life easier. I don't 100% agree with any coding naming convention in this day and age, but I tried "somewhat" so lay off on the criticism; the code works.

I'd like this to ultimately run in the background and just have some flags going for when a position changes, but I'm not that far along enough to achieve real-time. I also hear having a script running in the background constantly checking would slow the env down a lot soooo..... ya. Other thought was to have it run anytime a scene is saved; but I'm not sure how to make multiple scripts run (in sequence) for that to happen.

Anyways, Hope this helps!

Comments

  • PerttiAPerttiA Posts: 9,298

    I just parent my characters to a group and when I open the scene, I rotate the group 1deg on the Y-axis and undo the rotation and the eyes behave again.

  • Right, this is so you don't have to do that anymore. The point to position is committed, so when you load scene during a batch render nothing needs to be moved.
Sign In or Register to comment.