Is Camera Group a Bug?

functionfunction Posts: 283
edited February 2022 in The Commons

Found this camera problem when I investgated an old thread 'World Recenter script', say if you have few cameras in a scene, set them to a camera group, after run this world recenter script, all cameras in the group are weird, can not rotate around the aimed object as normal, the orbit track is weird and difficult to control.

It cost me 2 hours to find out what is the problem, finally I found it is because the camera group has its own none zero coordinate. Even not use that script, as long as you set all cameras as a new group, the orbit problem happened.

Here I made a script to fix it, which is to put all camera group's coordinate to 000 world center.

// DAZ Studio version 4.16.0.3 filetype DAZ Script/* This script is to reset all Camera Groups' coordinate to world center 0,0,0 in a scene, to avoid camera orbit problem. */// get all scene nodes listvar aAllNodes = Scene.getNodeList();var nAllNodes = aAllNodes.length;beginUndo();// Iterate over all scene nodesfor (var i1 = 0; i1 < nAllNodes; i1 += 1) {    // Get the 'current' node    var oNode = aAllNodes[i1];    // set its parent node    var oParent = oNode.getNodeParent();    // check if current node is a Camera    if (oNode.isViewCamera) {        // check if node has parent        if (oParent) {            // Get all of the child nodes of the camera parent            var aNodes = oParent.getNodeChildren(true);            // Get the number of nodes            var nNodes = aNodes.length;            // Iterate over all cameras            for (var i = 0; i < nNodes; i += 1) {                // Get the 'current' camera                var oCamera = aNodes[i];    /* get each Camera's World position & rotation, clear its Local position & rotation,	delete all its keyframes, and set its Local p & r to its World p & r. */                var p = oCamera.getWSPos();                var r = oCamera.getWSRot();                oCamera.getXRotControl().deleteAllKeys();                oCamera.getYRotControl().deleteAllKeys();                oCamera.getZRotControl().deleteAllKeys();                oCamera.getXPosControl().deleteAllKeys();                oCamera.getYPosControl().deleteAllKeys();                oCamera.getZPosControl().deleteAllKeys();                oCamera.setLocalPos(p);                 oCamera.setLocalRot(r);            }     // finally clear Camera Group's world position and rotation and delete keyframes.            oParent.getXRotControl().deleteAllKeys();            oParent.getYRotControl().deleteAllKeys();            oParent.getZRotControl().deleteAllKeys();            oParent.getXPosControl().deleteAllKeys();            oParent.getYPosControl().deleteAllKeys();            oParent.getZPosControl().deleteAllKeys();        }    }}acceptUndo("CameraGroup_to_WorldCenter");

/////////////// (don't know why above code just show in one line)

// DAZ Studio version 4.16.0.3 filetype DAZ Script

/* This script is to reset all Camera Groups' coordinate to

world center 0,0,0 in a scene, to avoid camera orbit problem. */

 

// get all scene nodes list

var aAllNodes = Scene.getNodeList();

var nAllNodes = aAllNodes.length;

beginUndo();

// Iterate over all scene nodes

for (var i1 = 0; i1 < nAllNodes; i1 += 1) {

// Get the 'current' node

var oNode = aAllNodes[i1];

// set its parent node

var oParent = oNode.getNodeParent();

// check if current node is a Camera

if (oNode.isViewCamera) {

// check if node has parent

if (oParent) {

// Get all of the child nodes of the camera parent

var aNodes = oParent.getNodeChildren(true);

// Get the number of nodes

var nNodes = aNodes.length;

// Iterate over all cameras

for (var i = 0; i < nNodes; i += 1) {

// Get the 'current' camera

var oCamera = aNodes[i];

/* get each Camera's World position & rotation, clear its Local position & rotation,

delete all its keyframes, and set its Local p & r to its World p & r. */

var p = oCamera.getWSPos();

var r = oCamera.getWSRot();

oCamera.getXRotControl().deleteAllKeys();

oCamera.getYRotControl().deleteAllKeys();

oCamera.getZRotControl().deleteAllKeys();

oCamera.getXPosControl().deleteAllKeys();

oCamera.getYPosControl().deleteAllKeys();

oCamera.getZPosControl().deleteAllKeys();

oCamera.setLocalPos(p);

oCamera.setLocalRot(r);

}

// finally clear Camera Group's world position and rotation and delete keyframes.

oParent.getXRotControl().deleteAllKeys();

oParent.getYRotControl().deleteAllKeys();

oParent.getZRotControl().deleteAllKeys();

oParent.getXPosControl().deleteAllKeys();

oParent.getYPosControl().deleteAllKeys();

oParent.getZPosControl().deleteAllKeys();

}

}

}

acceptUndo("CameraGroup_to_WorldCenter");

///////////////

 

But still, I wonder why setting a new camera Group will has a none zero coordinate, and why this none zero group coordinate will affect all its cameras' orbit rotation track, is this a Bug?

Post edited by function on

Comments

  • NorthOf45NorthOf45 Posts: 5,546

    It seems to take the centroid of all camera locations as the center of the group. (Either the midpoint of the extreme E-W and N-S positions, or some weighted average. No, I did not do the math). Kind of how framing multiple items looks at the midpoint of all of them.

  • functionfunction Posts: 283
    edited February 2022

    NorthOf45 said:

    It seems to take the centroid of all camera locations as the center of the group. (Either the midpoint of the extreme E-W and N-S positions, or some weighted average. No, I did not do the math). Kind of how framing multiple items looks at the midpoint of all of them.

    Agree, I also think group coordinate is somekind midpoint of its child, convenience for transfer probably. But why a camera group's none zero coordinate will affect all its child cameras' rotation is the problem out of my knowledge. 

    Post edited by function on
Sign In or Register to comment.