Group Bounding Box Questions

I wonder if someone could help me a little conceptually.

In a script I am adding instances of an object to a group. Each instance ends up being selectable in the scene tree, and having its own bounding box in the viewport at the centre of the instance, as I want to be the case. What isn't present is the group's bounding box, and the group centre is at the origin, regardless of where the group actually is.

First off, is this expected behaviour? I was rather expecting adding the instances to the group to automatically update the group Bounding Box and centre (all part of the adding method). If it is expected behaviour, is this the sort of thing where the new origin is found by simply adding up all the instances' origins and dividing by number of instances would do it? And then going through the bounding boxes and finding max/min values for in all contributing instances would be enough to calculate its position?

Finally, is there something similar to these I have not mentioned that I need to consider? I can't give a suggestion because I don't know what I am ignorant of..! I have been trying to follow the DAZ sample script on adding like instances to a group, but there are a few occasions where methods are called that end up in errors because the methods don't seem to be part of the current version of the objects (DzInstanceNode::getPreviewControl() and DzInstanceNode::getCopyModeControl() are two such such examples) or in the documentation. It does make things somewhat more difficult to work through when such things happen, so I do apologize if I am asking questions that should be obvious.

Regards,

Richard

Comments

  • OmnifluxOmniflux Posts: 362

    I am assuming you are asking about DzGroupNode and not DzInstanceGroupNode

    I do not think the bounding box issue is intended as the documentation for DzGroupNode discuses how the bounding box is calculated.

    Not sure about the position of the group.

     

    HOWEVER

    The way group nodes work when creating them with the UI is (through observation)

    • If no nodes are selected when a group is created
      • Group is created at (0,0,0)
      • No bounding box (or 0x0x0 bounding box?) defined
    • If nodes are selected when a group is created
      • Group is created positioned at the center of the selected nodes
      • Bounding box is defined to enclose selected nodes (+ some margin?)
      • Selected nodes are reparented to the group

    Adding nodes to the group does not update the bounding box or position of the group.

    Translating the group or any child nodes causes the bounding box to be recalculated as documented. I suspect this is a bug where the bounding box is not being updated during reparenting.

    Translating any child nodes does NOT change the position (center) of the group. Not sure if this is intended.

    Your method of finding the new center of the group sounds correct.

     

    Are you looking at this sample script? Create Instance Group

  • Omniflux, thanks for your reply.

    I started off largely using the script you referred to as a guide, and the lines :'var oModeProperty = oSelectedNode.getCopyModeControl();' and  'var oPreviewProperty = oSelectedNode.getPreviewControl();' are the ones that cause errors. So, I pretty much ended up ditching the code and trying to work out my own thing.

    I am actually using the DzInstanceGroupNode for this, as there is documentation, and is the one called up in the script you referred to. The DzGroupNode documentation is somewhat missing, and I fear I'm not proficient enough to be able to infer what might be available :  http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/groupnode_dz#a_1add0fdcee1aeb11f4682d8ea43d13a1eb

    Anyway, thanks, I'll try to create the origin in the new place and get a sensible bounding box too. Many thanks.

    Regards,

    Richard

     

Sign In or Register to comment.